diff options
Diffstat (limited to 'odb/pointer-traits.hxx')
-rw-r--r-- | odb/pointer-traits.hxx | 15 |
1 files changed, 15 insertions, 0 deletions
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 <memory> // std::auto_ptr #include <cstddef> // std::size_t +#include <odb/details/meta/remove-const.hxx> + 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<T>::result* + unrestricted_pointer_type; typedef raw_ptr_guard<pointer_type> 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<unrestricted_pointer_type> (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) |