diff options
Diffstat (limited to 'odb/details/shared-ptr/base.txx')
-rw-r--r-- | odb/details/shared-ptr/base.txx | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/odb/details/shared-ptr/base.txx b/odb/details/shared-ptr/base.txx index e00bd5c..7047b7a 100644 --- a/odb/details/shared-ptr/base.txx +++ b/odb/details/shared-ptr/base.txx @@ -13,38 +13,32 @@ namespace odb { // Support for locating the counter in the memory block. // + struct LIBODB_EXPORT locator_common + { + static std::size_t* + counter (void*); + }; + template <typename X, bool poly = meta::polymorphic_p<X>::result> struct locator; template <typename X> - struct locator<X, false> + struct locator<X, false>: locator_common { static std::size_t* counter (X* x) { - std::size_t* p (reinterpret_cast<std::size_t*> (x)); - - if (*(--p) != 0xDEADBEEF) - throw not_shared (); - - return --p; + return locator_common::counter (x); } }; template <typename X> - struct locator<X, true> + struct locator<X, true>: locator_common { static std::size_t* counter (X* x) { - std::size_t* p ( - static_cast<std::size_t*> ( - dynamic_cast<void*> (x))); - - if (*(--p) != 0xDEADBEEF) - throw not_shared (); - - return --p; + return locator_common::counter (dynamic_cast<void*> (x)); } }; |