From a482f1c4dd4efab83d3b19309900f1cbf54383a5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 15 Oct 2013 07:01:17 +0200 Subject: Automatically map C++11 enum classes (strong enums) --- odb/context.cxx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'odb/context.cxx') diff --git a/odb/context.cxx b/odb/context.cxx index 4db15a0..352cb51 100644 --- a/odb/context.cxx +++ b/odb/context.cxx @@ -1926,16 +1926,25 @@ database_type_impl (semantics::type& t, bool id, bool* null) { - type_map_type::const_iterator i (data_->type_map_.find (t, hint)); + using semantics::enum_; + + // By default map an enum as its underlying type. + // + if (enum_* e = dynamic_cast (&t)) + return database_type_impl ( + e->underlying_type (), e->underlying_type_hint (), id, null); + // Built-in type mapping. + // + type_map_type::const_iterator i (data_->type_map_.find (t, hint)); if (i != data_->type_map_.end ()) { if (null != 0) *null = i->second.null; return id ? i->second.id_type : i->second.type; } - else - return string (); + + return string (); } static string -- cgit v1.1