From f2625ff388a037ce0d65fcc14f76586614936d78 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 19 Oct 2011 10:47:41 +0200 Subject: Add support for const data members Const data members are automatically treated as readonly. New test: const-member. --- odb/qt/smart-ptr/wrapper-traits.hxx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/odb/qt/smart-ptr/wrapper-traits.hxx b/odb/qt/smart-ptr/wrapper-traits.hxx index 1f61b5e..6faf34b 100644 --- a/odb/qt/smart-ptr/wrapper-traits.hxx +++ b/odb/qt/smart-ptr/wrapper-traits.hxx @@ -23,6 +23,12 @@ namespace odb typedef T wrapped_type; typedef QSharedPointer 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 = false; @@ -48,9 +54,9 @@ namespace odb set_ref (wrapper_type& p) { if (p.isNull ()) - p = wrapper_type (new wrapped_type); + p = wrapper_type (new unrestricted_wrapped_type); - return *p; + return const_cast (*p); } }; } -- cgit v1.1