aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-10-19 10:47:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-10-21 19:06:27 +0200
commitf2625ff388a037ce0d65fcc14f76586614936d78 (patch)
tree1a10996dd2270433f13c12ce2341e178694f840c
parentf1393c250da7e932b76843cfa38781fd439003a5 (diff)
Add support for const data members
Const data members are automatically treated as readonly. New test: const-member.
-rw-r--r--odb/qt/smart-ptr/wrapper-traits.hxx10
1 files 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<T> wrapper_type;
+ // T can be const.
+ //
+ typedef
+ typename details::meta::remove_const<T>::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<unrestricted_wrapped_type&> (*p);
}
};
}