Mercurial > hg > vamp-build-and-test
diff DEPENDENCIES/generic/include/boost/intrusive/pointer_traits.hpp @ 101:c530137014c0
Update Boost headers (1.58.0)
author | Chris Cannam |
---|---|
date | Mon, 07 Sep 2015 11:12:49 +0100 |
parents | 2665513ce2d3 |
children |
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/intrusive/pointer_traits.hpp Fri Sep 04 12:01:02 2015 +0100 +++ b/DEPENDENCIES/generic/include/boost/intrusive/pointer_traits.hpp Mon Sep 07 11:12:49 2015 +0100 @@ -6,7 +6,7 @@ // ////////////////////////////////////////////////////////////////////////////// // -// (C) Copyright Ion Gaztanaga 2011-2013. Distributed under the Boost +// (C) Copyright Ion Gaztanaga 2011-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) // @@ -17,23 +17,53 @@ #ifndef BOOST_INTRUSIVE_POINTER_TRAITS_HPP #define BOOST_INTRUSIVE_POINTER_TRAITS_HPP -#if (defined _MSC_VER) && (_MSC_VER >= 1200) +#include <boost/intrusive/detail/config_begin.hpp> +#include <boost/intrusive/detail/workaround.hpp> +#include <boost/intrusive/pointer_rebind.hpp> +#include <boost/intrusive/detail/pointer_element.hpp> +#include <boost/intrusive/detail/mpl.hpp> +#include <cstddef> + +#if defined(BOOST_HAS_PRAGMA_ONCE) # pragma once #endif -#include <boost/intrusive/detail/config_begin.hpp> -#include <boost/intrusive/detail/workaround.hpp> -#include <boost/intrusive/detail/memory_util.hpp> -#include <boost/type_traits/integral_constant.hpp> -#include <cstddef> - namespace boost { namespace intrusive { +namespace detail { + +#if !defined(BOOST_MSVC) || (BOOST_MSVC > 1310) +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_member_function_callable_with_pointer_to, pointer_to) +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_member_function_callable_with_dynamic_cast_from, dynamic_cast_from) +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_member_function_callable_with_static_cast_from, static_cast_from) +BOOST_INTRUSIVE_HAS_STATIC_MEMBER_FUNC_SIGNATURE(has_member_function_callable_with_const_cast_from, const_cast_from) +#else +BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(has_member_function_callable_with_pointer_to, pointer_to) +BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(has_member_function_callable_with_dynamic_cast_from, dynamic_cast_from) +BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(has_member_function_callable_with_static_cast_from, static_cast_from) +BOOST_INTRUSIVE_HAS_MEMBER_FUNC_CALLED_IGNORE_SIGNATURE(has_member_function_callable_with_const_cast_from, const_cast_from) +#endif + +BOOST_INTRUSIVE_INSTANTIATE_EVAL_DEFAULT_TYPE_TMPLT(element_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(difference_type) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(reference) +BOOST_INTRUSIVE_INSTANTIATE_DEFAULT_TYPE_TMPLT(value_traits_ptr) + +} //namespace detail { + //! pointer_traits is the implementation of C++11 std::pointer_traits class with some //! extensions like castings. //! //! pointer_traits supplies a uniform interface to certain attributes of pointer-like types. +//! +//! <b>Note</b>: When defining a custom family of pointers or references to be used with BI +//! library, make sure the public static conversion functions accessed through +//! the `pointer_traits` interface (`*_cast_from` and `pointer_to`) can +//! properly convert between const and nonconst referred member types +//! <b>without the use of implicit constructor calls</b>. It is suggested these +//! conversions be implemented as function templates, where the template +//! argument is the type of the object being converted from. template <typename Ptr> struct pointer_traits { @@ -59,11 +89,9 @@ //!shall be used instead of rebind<U> to obtain a pointer to U. template <class U> using rebind = unspecified; - //!Ptr::rebind<U> if such a type exists; otherwise, SomePointer<U, Args> if Ptr is - //!a class template instantiation of the form SomePointer<T, Args>, where Args is zero or - //!more type arguments ; otherwise, the instantiation of rebind is ill-formed. + //!Ptr::reference if such a type exists (non-standard extension); otherwise, element_type & //! - typedef element_type &reference; + typedef unspecified_type reference; #else typedef Ptr pointer; // @@ -73,75 +101,100 @@ // typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT (boost::intrusive::detail::, Ptr, difference_type, std::ptrdiff_t) difference_type; - // - typedef typename boost::intrusive::detail::unvoid_ref<element_type>::type reference; + + typedef BOOST_INTRUSIVE_OBTAIN_TYPE_WITH_DEFAULT + (boost::intrusive::detail::, Ptr, reference, typename boost::intrusive::detail::unvoid_ref<element_type>::type) reference; // template <class U> struct rebind_pointer { - typedef typename boost::intrusive::detail::type_rebinder<Ptr, U>::type type; + typedef typename boost::intrusive::pointer_rebind<Ptr, U>::type type; }; #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) - template <class U> using rebind = typename boost::intrusive::detail::type_rebinder<Ptr, U>::type; + template <class U> using rebind = typename boost::intrusive::pointer_rebind<Ptr, U>::type; #endif #endif //#if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) //! <b>Remark</b>: If element_type is (possibly cv-qualified) void, r type is unspecified; otherwise, //! it is element_type &. //! - //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::pointer_to(r). + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::pointer_to(reference). //! Non-standard extension: If such function does not exist, returns pointer(addressof(r)); + //! + //! <b>Note</b>: For non-conforming compilers only the existence of a member function called + //! <code>pointer_to</code> is checked. static pointer pointer_to(reference r) { //Non-standard extension, it does not require Ptr::pointer_to. If not present //tries to converts &r to pointer. const bool value = boost::intrusive::detail:: has_member_function_callable_with_pointer_to - <Ptr, typename boost::intrusive::detail::unvoid<element_type &>::type>::value; - ::boost::integral_constant<bool, value> flag; + <Ptr, Ptr (*)(reference)>::value; + boost::intrusive::detail::bool_<value> flag; return pointer_traits::priv_pointer_to(flag, r); } //! <b>Remark</b>: Non-standard extension. //! - //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::static_cast_from(r). + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling the static template function + //! Ptr::static_cast_from(UPpr/const UPpr &). //! If such function does not exist, returns pointer_to(static_cast<element_type&>(*uptr)) + //! + //! <b>Note</b>: For non-conforming compilers only the existence of a member function called + //! <code>static_cast_from</code> is checked. template<class UPtr> static pointer static_cast_from(const UPtr &uptr) { + typedef const UPtr &RefArg; const bool value = boost::intrusive::detail:: has_member_function_callable_with_static_cast_from - <Ptr, const UPtr>::value; - ::boost::integral_constant<bool, value> flag; - return pointer_traits::priv_static_cast_from(flag, uptr); + <pointer, pointer(*)(RefArg)>::value + || boost::intrusive::detail:: + has_member_function_callable_with_static_cast_from + <pointer, pointer(*)(UPtr)>::value; + return pointer_traits::priv_static_cast_from(boost::intrusive::detail::bool_<value>(), uptr); } //! <b>Remark</b>: Non-standard extension. //! - //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::const_cast_from(r). + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling the static template function + //! Ptr::const_cast_from<UPtr>(UPpr/const UPpr &). //! If such function does not exist, returns pointer_to(const_cast<element_type&>(*uptr)) + //! + //! <b>Note</b>: For non-conforming compilers only the existence of a member function called + //! <code>const_cast_from</code> is checked. template<class UPtr> static pointer const_cast_from(const UPtr &uptr) { + typedef const UPtr &RefArg; const bool value = boost::intrusive::detail:: has_member_function_callable_with_const_cast_from - <Ptr, const UPtr>::value; - ::boost::integral_constant<bool, value> flag; - return pointer_traits::priv_const_cast_from(flag, uptr); + <pointer, pointer(*)(RefArg)>::value + || boost::intrusive::detail:: + has_member_function_callable_with_const_cast_from + <pointer, pointer(*)(UPtr)>::value; + return pointer_traits::priv_const_cast_from(boost::intrusive::detail::bool_<value>(), uptr); } //! <b>Remark</b>: Non-standard extension. //! - //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling Ptr::dynamic_cast_from(r). + //! <b>Returns</b>: A dereferenceable pointer to r obtained by calling the static template function + //! Ptr::dynamic_cast_from<UPtr>(UPpr/const UPpr &). //! If such function does not exist, returns pointer_to(*dynamic_cast<element_type*>(&*uptr)) + //! + //! <b>Note</b>: For non-conforming compilers only the existence of a member function called + //! <code>dynamic_cast_from</code> is checked. template<class UPtr> static pointer dynamic_cast_from(const UPtr &uptr) { + typedef const UPtr &RefArg; const bool value = boost::intrusive::detail:: has_member_function_callable_with_dynamic_cast_from - <Ptr, const UPtr>::value; - ::boost::integral_constant<bool, value> flag; - return pointer_traits::priv_dynamic_cast_from(flag, uptr); + <pointer, pointer(*)(RefArg)>::value + || boost::intrusive::detail:: + has_member_function_callable_with_dynamic_cast_from + <pointer, pointer(*)(UPtr)>::value; + return pointer_traits::priv_dynamic_cast_from(boost::intrusive::detail::bool_<value>(), uptr); } ///@cond @@ -157,38 +210,46 @@ { return pointer_traits::to_raw_pointer(p.operator->()); } //priv_pointer_to - static pointer priv_pointer_to(boost::true_type, typename boost::intrusive::detail::unvoid<element_type>::type& r) - { return Ptr::pointer_to(r); } + static pointer priv_pointer_to(boost::intrusive::detail::true_, reference r) + { return Ptr::pointer_to(r); } - static pointer priv_pointer_to(boost::false_type, typename boost::intrusive::detail::unvoid<element_type>::type& r) - { return pointer(boost::intrusive::detail::addressof(r)); } + static pointer priv_pointer_to(boost::intrusive::detail::false_, reference r) + { return pointer(boost::intrusive::detail::addressof(r)); } //priv_static_cast_from template<class UPtr> - static pointer priv_static_cast_from(boost::true_type, const UPtr &uptr) + static pointer priv_static_cast_from(boost::intrusive::detail::true_, const UPtr &uptr) { return Ptr::static_cast_from(uptr); } template<class UPtr> - static pointer priv_static_cast_from(boost::false_type, const UPtr &uptr) + static pointer priv_static_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) { return pointer_to(*static_cast<element_type*>(to_raw_pointer(uptr))); } //priv_const_cast_from template<class UPtr> - static pointer priv_const_cast_from(boost::true_type, const UPtr &uptr) + static pointer priv_const_cast_from(boost::intrusive::detail::true_, const UPtr &uptr) { return Ptr::const_cast_from(uptr); } template<class UPtr> - static pointer priv_const_cast_from(boost::false_type, const UPtr &uptr) + static pointer priv_const_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) { return pointer_to(const_cast<element_type&>(*uptr)); } //priv_dynamic_cast_from template<class UPtr> - static pointer priv_dynamic_cast_from(boost::true_type, const UPtr &uptr) + static pointer priv_dynamic_cast_from(boost::intrusive::detail::true_, const UPtr &uptr) { return Ptr::dynamic_cast_from(uptr); } template<class UPtr> - static pointer priv_dynamic_cast_from(boost::false_type, const UPtr &uptr) - { return pointer_to(*dynamic_cast<element_type*>(&*uptr)); } + static pointer priv_dynamic_cast_from(boost::intrusive::detail::false_, const UPtr &uptr) + { + element_type *p = dynamic_cast<element_type*>(&*uptr); + if(!p){ + return pointer(); + } + else{ + return pointer_to(*p); + } + } ///@endcond };