From a28444da4ca6adb016f719e032174ccb54e1692e Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 21 Sep 2011 13:00:33 +0200 Subject: Rework const object handling Now objects are always loaded as non-const and the object cache in session treats all objects as non-const. --- odb/pointer-traits.hxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'odb/pointer-traits.hxx') diff --git a/odb/pointer-traits.hxx b/odb/pointer-traits.hxx index 8882309..f8eed3a 100644 --- a/odb/pointer-traits.hxx +++ b/odb/pointer-traits.hxx @@ -12,6 +12,8 @@ #include // std::auto_ptr #include // std::size_t +#include + namespace odb { enum pointer_kind @@ -81,6 +83,8 @@ namespace odb typedef T element_type; typedef T* pointer_type; typedef const T* const_pointer_type; + typedef typename details::meta::remove_const::result* + unrestricted_pointer_type; typedef raw_ptr_guard guard; // Return raw pointer to the pointed-to element, including NULL. @@ -107,6 +111,14 @@ namespace odb return p == 0; } + // Cast away constness. + // + static unrestricted_pointer_type + cast (pointer_type p) + { + return const_cast (p); + } + public: // Allocate memory for an element that will be managed by this // pointer. @@ -162,6 +174,9 @@ namespace odb return p.get () == 0; } + // cast() is not provided since it transfers the ownership. + // + public: static void* allocate (std::size_t n) -- cgit v1.1