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