Chris@102: ////////////////////////////////////////////////////////////////////////////// Chris@102: // Chris@102: // (C) Copyright Ion Gaztanaga 2014-2014. Distributed under the Boost Chris@102: // Software License, Version 1.0. (See accompanying file Chris@102: // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) Chris@102: // Chris@102: // See http://www.boost.org/libs/intrusive for documentation. Chris@102: // Chris@102: ////////////////////////////////////////////////////////////////////////////// Chris@102: Chris@102: #ifndef BOOST_INTRUSIVE_POINTER_REBIND_HPP Chris@102: #define BOOST_INTRUSIVE_POINTER_REBIND_HPP Chris@102: Chris@102: #ifndef BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP Chris@102: #include Chris@102: #endif //BOOST_INTRUSIVE_DETAIL_WORKAROUND_HPP Chris@102: Chris@102: #ifndef BOOST_CONFIG_HPP Chris@102: # include Chris@102: #endif Chris@102: Chris@102: #if defined(BOOST_HAS_PRAGMA_ONCE) Chris@102: # pragma once Chris@102: #endif Chris@102: Chris@102: namespace boost { Chris@102: namespace intrusive { Chris@102: Chris@102: /////////////////////////// Chris@102: //struct pointer_rebind_mode Chris@102: /////////////////////////// Chris@102: template Chris@102: struct pointer_has_rebind Chris@102: { Chris@102: template struct any Chris@102: { any(const V&) { } }; Chris@102: Chris@102: template Chris@102: static char test(int, typename X::template rebind*); Chris@102: Chris@102: template Chris@102: static int test(any, void*); Chris@102: Chris@102: static const bool value = (1 == sizeof(test(0, 0))); Chris@102: }; Chris@102: Chris@102: template Chris@102: struct pointer_has_rebind_other Chris@102: { Chris@102: template struct any Chris@102: { any(const V&) { } }; Chris@102: Chris@102: template Chris@102: static char test(int, typename X::template rebind::other*); Chris@102: Chris@102: template Chris@102: static int test(any, void*); Chris@102: Chris@102: static const bool value = (1 == sizeof(test(0, 0))); Chris@102: }; Chris@102: Chris@102: template Chris@102: struct pointer_rebind_mode Chris@102: { Chris@102: static const unsigned int rebind = (unsigned int)pointer_has_rebind::value; Chris@102: static const unsigned int rebind_other = (unsigned int)pointer_has_rebind_other::value; Chris@102: static const unsigned int mode = rebind + rebind*rebind_other; Chris@102: }; Chris@102: Chris@102: //////////////////////// Chris@102: //struct pointer_rebinder Chris@102: //////////////////////// Chris@102: template Chris@102: struct pointer_rebinder; Chris@102: Chris@102: // Implementation of pointer_rebinder::type if Ptr has Chris@102: // its own rebind::other type (C++03) Chris@102: template Chris@102: struct pointer_rebinder< Ptr, U, 2u > Chris@102: { Chris@102: typedef typename Ptr::template rebind::other type; Chris@102: }; Chris@102: Chris@102: // Implementation of pointer_rebinder::type if Ptr has Chris@102: // its own rebind template. Chris@102: template Chris@102: struct pointer_rebinder< Ptr, U, 1u > Chris@102: { Chris@102: typedef typename Ptr::template rebind type; Chris@102: }; Chris@102: Chris@102: // Specialization of pointer_rebinder if Ptr does not Chris@102: // have its own rebind template but has a the form Ptr, Chris@102: // where An... comprises zero or more type parameters. Chris@102: // Many types fit this form, hence many pointers will get a Chris@102: // reasonable default for rebind. Chris@102: #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) Chris@102: Chris@102: template