aboutsummaryrefslogtreecommitdiff
path: root/odb/details/shared-ptr/base.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-08-14 09:37:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-11-11 10:27:11 +0200
commitded152cfb675537ab4ce24f50d0e95cec5b83b18 (patch)
treec5571f283fa6c0a5735ea4716b0592d9d3b8169d /odb/details/shared-ptr/base.txx
parent6375147d5ae76a84dd64f1996cb0d9d501839db6 (diff)
Draft implementation for INSERT
Diffstat (limited to 'odb/details/shared-ptr/base.txx')
-rw-r--r--odb/details/shared-ptr/base.txx26
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));
}
};