aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-10-19 10:47:40 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-10-21 19:02:33 +0200
commit8976a0a11befafb8bed0105dc29ac5c183745e7a (patch)
tree0cb191948015dc00c07dc2808e50e6f572bb250c
parent71f9c8f2ac48283f3f70a8f1257e6faafee9c74a (diff)
Add support for const data members
Const data members are automatically treated as readonly. New test: const-member.
-rw-r--r--odb/boost/optional/wrapper-traits.hxx12
-rw-r--r--odb/boost/smart-ptr/wrapper-traits.hxx12
2 files changed, 18 insertions, 6 deletions
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<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 = 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<unrestricted_wrapped_type&> (*o);
}
};
}
diff --git a/odb/boost/smart-ptr/wrapper-traits.hxx b/odb/boost/smart-ptr/wrapper-traits.hxx
index 5389eca..de7ec9e 100644
--- a/odb/boost/smart-ptr/wrapper-traits.hxx
+++ b/odb/boost/smart-ptr/wrapper-traits.hxx
@@ -23,6 +23,12 @@ namespace odb
typedef T wrapped_type;
typedef ::boost::shared_ptr<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;
@@ -44,13 +50,13 @@ namespace odb
return *p;
}
- static wrapped_type&
+ static unrestricted_wrapped_type&
set_ref (wrapper_type& p)
{
if (!p)
- p.reset (new wrapped_type);
+ p.reset (new unrestricted_wrapped_type);
- return *p;
+ return const_cast<unrestricted_wrapped_type&> (*p);
}
};
}