From 8976a0a11befafb8bed0105dc29ac5c183745e7a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2011 10:47:40 +0200 Subject: Add support for const data members Const data members are automatically treated as readonly. New test: const-member. --- odb/boost/optional/wrapper-traits.hxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'odb/boost/optional/wrapper-traits.hxx') diff --git a/odb/boost/optional/wrapper-traits.hxx b/odb/boost/optional/wrapper-traits.hxx index 04f4b55..cc2b7a4 100644 --- a/odb/boost/optional/wrapper-traits.hxx +++ b/odb/boost/optional/wrapper-traits.hxx @@ -22,6 +22,12 @@ namespace odb typedef T wrapped_type; typedef ::boost::optional wrapper_type; + // T can be const. + // + typedef + typename details::meta::remove_const::result + unrestricted_wrapped_type; + static const bool null_handler = true; static const bool null_default = true; @@ -43,13 +49,13 @@ namespace odb return *o; } - static wrapped_type& + static unrestricted_wrapped_type& set_ref (wrapper_type& o) { if (!o) - o = T (); + o = unrestricted_wrapped_type (); - return *o; + return const_cast (*o); } }; } -- cgit v1.1