diff options
Diffstat (limited to 'boost/type_traits/detail')
27 files changed, 833 insertions, 770 deletions
diff --git a/boost/type_traits/detail/bool_trait_def.hpp b/boost/type_traits/detail/bool_trait_def.hpp index 69e4f1ca62..b6b0677d68 100644 --- a/boost/type_traits/detail/bool_trait_def.hpp +++ b/boost/type_traits/detail/bool_trait_def.hpp @@ -11,10 +11,15 @@ // $Date$ // $Revision$ +// +// This header is deprecated and no longer used by type_traits: +// +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (bool_trait_def.hpp) is deprecated") +#endif + #include <boost/type_traits/detail/template_arity_spec.hpp> #include <boost/type_traits/integral_constant.hpp> -#include <boost/mpl/bool.hpp> -#include <boost/mpl/aux_/lambda_support.hpp> #include <boost/config.hpp> // @@ -39,14 +44,6 @@ #undef BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1 #endif -#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x570) -# define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - typedef ::boost::integral_constant<bool,C> type; \ - enum { value = type::value }; \ - /**/ -# define BOOST_TT_AUX_BOOL_C_BASE(C) -#endif - #ifndef BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL # define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) /**/ #endif @@ -62,7 +59,6 @@ template< typename T > struct trait \ { \ public:\ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \ }; \ \ BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \ @@ -75,7 +71,6 @@ template< typename T1, typename T2 > struct trait \ { \ public:\ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT(2,trait,(T1,T2)) \ }; \ \ BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(2,trait) \ @@ -87,7 +82,6 @@ template< typename T1, typename T2, typename T3 > struct trait \ { \ public:\ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT(3,trait,(T1,T2,T3)) \ }; \ \ BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(3,trait) \ @@ -99,7 +93,6 @@ template<> struct trait< sp > \ { \ public:\ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(sp)) \ }; \ /**/ @@ -109,7 +102,6 @@ template<> struct trait< sp1,sp2 > \ { \ public:\ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \ }; \ /**/ @@ -153,7 +145,6 @@ template< param > struct trait< sp1,sp2 > \ { \ public:\ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(2,trait,(sp1,sp2)) \ }; \ /**/ diff --git a/boost/type_traits/detail/common_arithmetic_type.hpp b/boost/type_traits/detail/common_arithmetic_type.hpp new file mode 100644 index 0000000000..7211002218 --- /dev/null +++ b/boost/type_traits/detail/common_arithmetic_type.hpp @@ -0,0 +1,212 @@ +#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_ARITHMETIC_TYPE_HPP_INCLUDED +#define BOOST_TYPE_TRAITS_DETAIL_COMMON_ARITHMETIC_TYPE_HPP_INCLUDED + +// +// Copyright 2015 Peter Dimov +// +// 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 +// + +#include <boost/config.hpp> + +namespace boost +{ + +namespace type_traits_detail +{ + +template<int I> struct arithmetic_type; + +// Types bool, char, char16_t, char32_t, wchar_t, +// and the signed and unsigned integer types are +// collectively called integral types + +template<> struct arithmetic_type<1> +{ + typedef bool type; + typedef char (&result_type) [1]; +}; + +template<> struct arithmetic_type<2> +{ + typedef char type; + typedef char (&result_type) [2]; +}; + +template<> struct arithmetic_type<3> +{ + typedef wchar_t type; + typedef char (&result_type) [3]; +}; + +// There are five standard signed integer types: +// “signed char”, “short int”, “int”, “long int”, and “long long int”. + +template<> struct arithmetic_type<4> +{ + typedef signed char type; + typedef char (&result_type) [4]; +}; + +template<> struct arithmetic_type<5> +{ + typedef short type; + typedef char (&result_type) [5]; +}; + +template<> struct arithmetic_type<6> +{ + typedef int type; + typedef char (&result_type) [6]; +}; + +template<> struct arithmetic_type<7> +{ + typedef long type; + typedef char (&result_type) [7]; +}; + +template<> struct arithmetic_type<8> +{ + typedef boost::long_long_type type; + typedef char (&result_type) [8]; +}; + +// For each of the standard signed integer types, there exists a corresponding +// (but different) standard unsigned integer type: “unsigned char”, “unsigned short int”, +// “unsigned int”, “unsigned long int”, and “unsigned long long int” + +template<> struct arithmetic_type<9> +{ + typedef unsigned char type; + typedef char (&result_type) [9]; +}; + +template<> struct arithmetic_type<10> +{ + typedef unsigned short type; + typedef char (&result_type) [10]; +}; + +template<> struct arithmetic_type<11> +{ + typedef unsigned int type; + typedef char (&result_type) [11]; +}; + +template<> struct arithmetic_type<12> +{ + typedef unsigned long type; + typedef char (&result_type) [12]; +}; + +template<> struct arithmetic_type<13> +{ + typedef boost::ulong_long_type type; + typedef char (&result_type) [13]; +}; + +// There are three floating point types: float, double, and long double. + +template<> struct arithmetic_type<14> +{ + typedef float type; + typedef char (&result_type) [14]; +}; + +template<> struct arithmetic_type<15> +{ + typedef double type; + typedef char (&result_type) [15]; +}; + +template<> struct arithmetic_type<16> +{ + typedef long double type; + typedef char (&result_type) [16]; +}; + +#if !defined( BOOST_NO_CXX11_CHAR16_T ) + +template<> struct arithmetic_type<17> +{ + typedef char16_t type; + typedef char (&result_type) [17]; +}; + +#endif + +#if !defined( BOOST_NO_CXX11_CHAR32_T ) + +template<> struct arithmetic_type<18> +{ + typedef char32_t type; + typedef char (&result_type) [18]; +}; + +#endif + +#if defined( BOOST_HAS_INT128 ) + +template<> struct arithmetic_type<19> +{ + typedef boost::int128_type type; + typedef char (&result_type) [19]; +}; + +template<> struct arithmetic_type<20> +{ + typedef boost::uint128_type type; + typedef char (&result_type) [20]; +}; + +#endif + +template<class T, class U> class common_arithmetic_type +{ +private: + + static arithmetic_type<1>::result_type select( arithmetic_type<1>::type ); + static arithmetic_type<2>::result_type select( arithmetic_type<2>::type ); + static arithmetic_type<3>::result_type select( arithmetic_type<3>::type ); + static arithmetic_type<4>::result_type select( arithmetic_type<4>::type ); + static arithmetic_type<5>::result_type select( arithmetic_type<5>::type ); + static arithmetic_type<6>::result_type select( arithmetic_type<6>::type ); + static arithmetic_type<7>::result_type select( arithmetic_type<7>::type ); + static arithmetic_type<8>::result_type select( arithmetic_type<8>::type ); + static arithmetic_type<9>::result_type select( arithmetic_type<9>::type ); + static arithmetic_type<10>::result_type select( arithmetic_type<10>::type ); + static arithmetic_type<11>::result_type select( arithmetic_type<11>::type ); + static arithmetic_type<12>::result_type select( arithmetic_type<12>::type ); + static arithmetic_type<13>::result_type select( arithmetic_type<13>::type ); + static arithmetic_type<14>::result_type select( arithmetic_type<14>::type ); + static arithmetic_type<15>::result_type select( arithmetic_type<15>::type ); + static arithmetic_type<16>::result_type select( arithmetic_type<16>::type ); + +#if !defined( BOOST_NO_CXX11_CHAR16_T ) + static arithmetic_type<17>::result_type select( arithmetic_type<17>::type ); +#endif + +#if !defined( BOOST_NO_CXX11_CHAR32_T ) + static arithmetic_type<18>::result_type select( arithmetic_type<18>::type ); +#endif + +#if defined( BOOST_HAS_INT128 ) + static arithmetic_type<19>::result_type select( arithmetic_type<19>::type ); + static arithmetic_type<20>::result_type select( arithmetic_type<20>::type ); +#endif + + static bool cond(); + +public: + + typedef typename arithmetic_type< sizeof(select( cond()? T(): U() )) >::type type; +}; + +} // namespace type_traits_detail + +} // namespace boost + +#endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_ARITHMETIC_TYPE_HPP_INCLUDED diff --git a/boost/type_traits/detail/common_type_imp.hpp b/boost/type_traits/detail/common_type_imp.hpp deleted file mode 100644 index 84de8b4125..0000000000 --- a/boost/type_traits/detail/common_type_imp.hpp +++ /dev/null @@ -1,333 +0,0 @@ -/******************************************************************************* - * boost/type_traits/detail/common_type_imp.hpp - * - * Copyright 2010, Jeffrey Hellrung. - * 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) - * - * struct boost::common_type<T,U> - * - * common_type<T,U>::type is the type of the expression - * b() ? x() : y() - * where b() returns a bool, x() has return type T, and y() has return type U. - * See - * http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2661.htm#common_type - * - * Note that this evaluates to void if one or both of T and U is void. - ******************************************************************************/ - -#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP -#define BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMP_HPP - -#include <cstddef> - -#include <boost/mpl/assert.hpp> -#include <boost/mpl/at.hpp> -#include <boost/mpl/begin_end.hpp> -#include <boost/mpl/contains.hpp> -#include <boost/mpl/copy.hpp> -#include <boost/mpl/deref.hpp> -#include <boost/mpl/eval_if.hpp> -#include <boost/mpl/if.hpp> -#include <boost/mpl/inserter.hpp> -#include <boost/mpl/next.hpp> -#include <boost/mpl/or.hpp> -#include <boost/mpl/placeholders.hpp> -#include <boost/mpl/push_back.hpp> -#include <boost/mpl/size.hpp> -#include <boost/mpl/vector/vector0.hpp> -#include <boost/mpl/vector/vector10.hpp> -#include <boost/type_traits/integral_constant.hpp> -#include <boost/type_traits/is_enum.hpp> -#include <boost/type_traits/is_integral.hpp> -#include <boost/type_traits/make_signed.hpp> -#include <boost/type_traits/make_unsigned.hpp> -#include <boost/type_traits/remove_cv.hpp> -#include <boost/type_traits/remove_reference.hpp> -#include <boost/utility/declval.hpp> - -namespace boost -{ - -namespace detail_type_traits_common_type -{ - -/******************************************************************************* - * struct propagate_cv< From, To > - * - * This metafunction propagates cv-qualifiers on type From to type To. - ******************************************************************************/ - -template< class From, class To > -struct propagate_cv -{ typedef To type; }; -template< class From, class To > -struct propagate_cv< const From, To > -{ typedef To const type; }; -template< class From, class To > -struct propagate_cv< volatile From, To > -{ typedef To volatile type; }; -template< class From, class To > -struct propagate_cv< const volatile From, To > -{ typedef To const volatile type; }; - -/******************************************************************************* - * struct is_integral_or_enum<T> - * - * This metafunction determines if T is an integral type which can be made - * signed or unsigned. - ******************************************************************************/ - -template< class T > -struct is_integral_or_enum - : public mpl::or_< is_integral<T>, is_enum<T> > -{ }; -template<> -struct is_integral_or_enum< bool > - : public false_type -{ }; - -/******************************************************************************* - * struct make_unsigned_soft<T> - * struct make_signed_soft<T> - * - * These metafunction are identical to make_unsigned and make_signed, - * respectively, except for special-casing bool. - ******************************************************************************/ - -template< class T > -struct make_unsigned_soft - : public make_unsigned<T> -{ }; -template<> -struct make_unsigned_soft< bool > -{ typedef bool type; }; - -template< class T > -struct make_signed_soft - : public make_signed<T> -{ }; -template<> -struct make_signed_soft< bool > -{ typedef bool type; }; - -/******************************************************************************* - * struct sizeof_t<N> - * typedef ... yes_type - * typedef ... no_type - * - * These types are integral players in the use of the "sizeof trick", i.e., we - * can distinguish overload selection by inspecting the size of the return type - * of the overload. - ******************************************************************************/ - -template< std::size_t N > struct sizeof_t { char _dummy[N]; }; -typedef sizeof_t<1> yes_type; -typedef sizeof_t<2> no_type; -BOOST_MPL_ASSERT_RELATION( sizeof( yes_type ), ==, 1 ); -BOOST_MPL_ASSERT_RELATION( sizeof( no_type ), ==, 2 ); - -/******************************************************************************* - * rvalue_test(T&) -> no_type - * rvalue_test(...) -> yes_type - * - * These overloads are used to determine the rvalue-ness of an expression. - ******************************************************************************/ - -template< class T > no_type rvalue_test(T&); -yes_type rvalue_test(...); - -/******************************************************************************* - * struct conversion_test_overloads< Sequence > - * - * This struct has multiple overloads of the static member function apply, each - * one taking a single parameter of a type within the Boost.MPL sequence - * Sequence. Each such apply overload has a return type with sizeof equal to - * one plus the index of the parameter type within Sequence. Thus, we can - * deduce the type T of an expression as long as we can generate a finite set of - * candidate types containing T via these apply overloads and the "sizeof - * trick". - ******************************************************************************/ - -template< class First, class Last, std::size_t Index > -struct conversion_test_overloads_iterate - : public conversion_test_overloads_iterate< - typename mpl::next< First >::type, Last, Index + 1 - > -{ - using conversion_test_overloads_iterate< - typename mpl::next< First >::type, Last, Index + 1 - >::apply; - static sizeof_t< Index + 1 > - apply(typename mpl::deref< First >::type); -}; - -template< class Last, std::size_t Index > -struct conversion_test_overloads_iterate< Last, Last, Index > -{ static sizeof_t< Index + 1 > apply(...); }; - -template< class Sequence > -struct conversion_test_overloads - : public conversion_test_overloads_iterate< - typename mpl::begin< Sequence >::type, - typename mpl::end< Sequence >::type, - 0 - > -{ }; - -/******************************************************************************* - * struct select< Sequence, Index > - * - * select is synonymous with mpl::at_c unless Index equals the size of the - * Boost.MPL Sequence, in which case this evaluates to void. - ******************************************************************************/ - -template< - class Sequence, int Index, - int N = mpl::size< Sequence >::value -> -struct select - : public mpl::at_c< Sequence, Index > -{ }; -template< class Sequence, int N > -struct select< Sequence, N, N > -{ typedef void type; }; - -/******************************************************************************* - * class deduce_common_type< T, U, NominalCandidates > - * struct nominal_candidates<T,U> - * struct common_type_dispatch_on_rvalueness<T,U> - * struct common_type_impl<T,U> - * - * These classes and structs implement the logic behind common_type, which goes - * roughly as follows. Let C be the type of the conditional expression - * declval< bool >() ? declval<T>() : declval<U>() - * if C is an rvalue, then: - * let T' and U' be T and U stripped of reference- and cv-qualifiers - * if T' and U' are pointer types, say, T' = V* and U' = W*, then: - * define the set of NominalCandidates to be - * { V*, W*, V'*, W'* } - * where V' is V with whatever cv-qualifiers are on W, and W' is W - * with whatever cv-qualifiers are on V - * else if T' and U' are both integral or enum types, then: - * define the set of NominalCandidates to be - * { - * unsigned_soft(T'), - * unsigned_soft(U'), - * signed_soft(T'), - * signed_soft(U'), - * T', - * U', - * unsigned int, - * int - * } - * where unsigned_soft(X) is make_unsigned_soft<X>::type and - * signed_soft(X) is make_signed_soft<X>::type (these are all - * generally necessary to cover the various integral promotion cases) - * else - * define the set of NominalCandidates to be - * { T', U' } - * else - * let V and W be T and U stripped of reference-qualifiers - * define the set of NominalCandidates to be - * { V&, W&, V'&, W'& } - * where V' is V with whatever cv-qualifiers are on W, and W' is W with - * whatever cv-qualifiers are on V - * define the set of Candidates to be equal to the set of NominalCandidates with - * duplicates removed, and use this set of Candidates to determine C using the - * conversion_test_overloads struct - ******************************************************************************/ - -template< class T, class U, class NominalCandidates > -class deduce_common_type -{ - typedef typename mpl::copy< - NominalCandidates, - mpl::inserter< - mpl::vector0<>, - mpl::if_< - mpl::contains< mpl::_1, mpl::_2 >, - mpl::_1, - mpl::push_back< mpl::_1, mpl::_2 > - > - > - >::type candidate_types; - static const int best_candidate_index = - sizeof( conversion_test_overloads< candidate_types >::apply( - declval< bool >() ? declval<T>() : declval<U>() - ) ) - 1; -public: - typedef typename select< candidate_types, best_candidate_index >::type type; -}; - -template< - class T, class U, - class V = typename remove_cv< typename remove_reference<T>::type >::type, - class W = typename remove_cv< typename remove_reference<U>::type >::type, - bool = is_integral_or_enum<V>::value && is_integral_or_enum<W>::value -> -struct nominal_candidates -{ typedef mpl::vector2<V,W> type; }; - -template< class T, class U, class V, class W > -struct nominal_candidates< T, U, V, W, true > -{ - typedef boost::mpl::vector8< - typename make_unsigned_soft<V>::type, - typename make_unsigned_soft<W>::type, - typename make_signed_soft<V>::type, - typename make_signed_soft<W>::type, - V, W, unsigned int, int - > type; -}; - -template< class T, class U, class V, class W > -struct nominal_candidates< T, U, V*, W*, false > -{ - typedef mpl::vector4< - V*, W*, - typename propagate_cv<W,V>::type *, - typename propagate_cv<V,W>::type * - > type; -}; - -template<class T, class U, bool b> -struct common_type_dispatch_on_rvalueness - : public deduce_common_type< T, U, typename nominal_candidates<T,U>::type > -{ }; - -template< class T, class U > -struct common_type_dispatch_on_rvalueness< T, U, false > -{ -private: - typedef typename remove_reference<T>::type unrefed_T_type; - typedef typename remove_reference<U>::type unrefed_U_type; -public: - typedef typename deduce_common_type< - T, U, - mpl::vector4< - unrefed_T_type &, - unrefed_U_type &, - typename propagate_cv< unrefed_U_type, unrefed_T_type >::type &, - typename propagate_cv< unrefed_T_type, unrefed_U_type >::type & - > - >::type type; -}; - -template< class T, class U > -struct common_type_impl - : public common_type_dispatch_on_rvalueness<T,U, sizeof( ::boost::detail_type_traits_common_type::rvalue_test( - declval< bool >() ? declval<T>() : declval<U>() ) ) == sizeof( yes_type ) > -{ }; - -template< class T > struct common_type_impl< T, void > { typedef void type; }; -template< class T > struct common_type_impl< void, T > { typedef void type; }; -template<> struct common_type_impl< void, void > { typedef void type; }; - -} // namespace detail_type_traits_common_type - - -} // namespace boost - -#endif // BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_HPP - diff --git a/boost/type_traits/detail/common_type_impl.hpp b/boost/type_traits/detail/common_type_impl.hpp new file mode 100644 index 0000000000..53a634d4df --- /dev/null +++ b/boost/type_traits/detail/common_type_impl.hpp @@ -0,0 +1,107 @@ +#ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMPL_HPP_INCLUDED +#define BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMPL_HPP_INCLUDED + +// +// Copyright 2015 Peter Dimov +// +// 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 +// + +#include <boost/type_traits/detail/common_arithmetic_type.hpp> +#include <boost/type_traits/detail/composite_pointer_type.hpp> +#include <boost/type_traits/detail/composite_member_pointer_type.hpp> +#include <boost/type_traits/type_identity.hpp> +#include <boost/type_traits/is_class.hpp> +#include <boost/type_traits/is_union.hpp> +#include <boost/type_traits/is_convertible.hpp> +#include <boost/type_traits/is_pointer.hpp> +#include <boost/type_traits/is_member_pointer.hpp> +#include <boost/type_traits/conditional.hpp> + +namespace boost +{ + +namespace type_traits_detail +{ + +// the arguments to common_type_impl have already been passed through decay<> + +template<class T, class U> struct common_type_impl; + +// same type + +template<class T> struct common_type_impl<T, T> +{ + typedef T type; +}; + +// one of the operands is a class type, try conversions in both directions + +template<class T, class U> struct ct_class +{ + BOOST_STATIC_CONSTANT( bool, ct = boost::is_class<T>::value || boost::is_union<T>::value ); + BOOST_STATIC_CONSTANT( bool, cu = boost::is_class<U>::value || boost::is_union<U>::value ); + + BOOST_STATIC_CONSTANT( bool, value = ct || cu ); +}; + +template<class T, class U> struct common_type_impl3; + +template<class T, class U> struct common_type_class: public boost::conditional< + + boost::is_convertible<T, U>::value && !boost::is_convertible<U, T>::value, + boost::type_identity<U>, + + typename boost::conditional< + + boost::is_convertible<U, T>::value && !boost::is_convertible<T, U>::value, + boost::type_identity<T>, + + common_type_impl3<T, U> + >::type +>::type +{ +}; + +template<class T, class U> struct common_type_impl: public boost::conditional< + ct_class<T, U>::value, + common_type_class<T, U>, + common_type_impl3<T, U> >::type +{ +}; + +// pointers + +template<class T, class U> struct common_type_impl4; + +template<class T, class U> struct common_type_impl3: public boost::conditional< + boost::is_pointer<T>::value || boost::is_pointer<U>::value, + composite_pointer_type<T, U>, + common_type_impl4<T, U> >::type +{ +}; + +// pointers to members + +template<class T, class U> struct common_type_impl5; + +template<class T, class U> struct common_type_impl4: public boost::conditional< + boost::is_member_pointer<T>::value || boost::is_member_pointer<U>::value, + composite_member_pointer_type<T, U>, + common_type_impl5<T, U> >::type +{ +}; + +// arithmetic types (including class types w/ conversions to arithmetic and enums) + +template<class T, class U> struct common_type_impl5: public common_arithmetic_type<T, U> +{ +}; + +} // namespace type_traits_detail + +} // namespace boost + +#endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_COMMON_TYPE_IMPL_HPP_INCLUDED diff --git a/boost/type_traits/detail/composite_member_pointer_type.hpp b/boost/type_traits/detail/composite_member_pointer_type.hpp new file mode 100644 index 0000000000..a747ee4db6 --- /dev/null +++ b/boost/type_traits/detail/composite_member_pointer_type.hpp @@ -0,0 +1,113 @@ +#ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_MEMBER_POINTER_TYPE_HPP_INCLUDED +#define BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_MEMBER_POINTER_TYPE_HPP_INCLUDED + +// +// Copyright 2015 Peter Dimov +// +// 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 +// + +#include <boost/type_traits/detail/composite_pointer_type.hpp> +#include <boost/type_traits/remove_pointer.hpp> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/conditional.hpp> +#include <boost/config.hpp> +#include <cstddef> + +namespace boost +{ + +namespace type_traits_detail +{ + +template<class T, class U> struct composite_member_pointer_type; + +// nullptr_t + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +#if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) ) + +template<class C, class T> struct composite_member_pointer_type<T C::*, decltype(nullptr)> +{ + typedef T C::* type; +}; + +template<class C, class T> struct composite_member_pointer_type<decltype(nullptr), T C::*> +{ + typedef T C::* type; +}; + +template<> struct composite_member_pointer_type<decltype(nullptr), decltype(nullptr)> +{ + typedef decltype(nullptr) type; +}; + +#else + +template<class C, class T> struct composite_member_pointer_type<T C::*, std::nullptr_t> +{ + typedef T C::* type; +}; + +template<class C, class T> struct composite_member_pointer_type<std::nullptr_t, T C::*> +{ + typedef T C::* type; +}; + +template<> struct composite_member_pointer_type<std::nullptr_t, std::nullptr_t> +{ + typedef std::nullptr_t type; +}; + +#endif + +#endif // !defined( BOOST_NO_CXX11_NULLPTR ) + +template<class C1, class C2> struct common_member_class; + +template<class C> struct common_member_class<C, C> +{ + typedef C type; +}; + +template<class C1, class C2> struct common_member_class +{ + typedef typename boost::conditional< + + boost::is_base_of<C1, C2>::value, + C2, + typename boost::conditional<boost::is_base_of<C2, C1>::value, C1, void>::type + + >::type type; +}; + +//This indirection avoids compilation errors on some older +//compilers like MSVC 7.1 +template<class CT, class CB> +struct common_member_class_pointer_to_member +{ + typedef CT CB::* type; +}; + +template<class C1, class T1, class C2, class T2> struct composite_member_pointer_type<T1 C1::*, T2 C2::*> +{ +private: + + typedef typename composite_pointer_type<T1*, T2*>::type CPT; + typedef typename boost::remove_pointer<CPT>::type CT; + + typedef typename common_member_class<C1, C2>::type CB; + +public: + + typedef typename common_member_class_pointer_to_member<CT, CB>::type type; +}; + +} // namespace type_traits_detail + +} // namespace boost + +#endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_MEMBER_POINTER_TYPE_HPP_INCLUDED diff --git a/boost/type_traits/detail/composite_pointer_type.hpp b/boost/type_traits/detail/composite_pointer_type.hpp new file mode 100644 index 0000000000..ae21e18ade --- /dev/null +++ b/boost/type_traits/detail/composite_pointer_type.hpp @@ -0,0 +1,153 @@ +#ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_POINTER_TYPE_HPP_INCLUDED +#define BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_POINTER_TYPE_HPP_INCLUDED + +// +// Copyright 2015 Peter Dimov +// +// 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 +// + +#include <boost/type_traits/copy_cv.hpp> +#include <boost/type_traits/remove_cv.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/is_void.hpp> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/config.hpp> +#include <cstddef> + +namespace boost +{ + +namespace type_traits_detail +{ + +template<class T, class U> struct composite_pointer_type; + +// same type + +template<class T> struct composite_pointer_type<T*, T*> +{ + typedef T* type; +}; + +// nullptr_t + +#if !defined( BOOST_NO_CXX11_NULLPTR ) + +#if !defined( BOOST_NO_CXX11_DECLTYPE ) && ( ( defined( __clang__ ) && !defined( _LIBCPP_VERSION ) ) || defined( __INTEL_COMPILER ) ) + +template<class T> struct composite_pointer_type<T*, decltype(nullptr)> +{ + typedef T* type; +}; + +template<class T> struct composite_pointer_type<decltype(nullptr), T*> +{ + typedef T* type; +}; + +template<> struct composite_pointer_type<decltype(nullptr), decltype(nullptr)> +{ + typedef decltype(nullptr) type; +}; + +#else + +template<class T> struct composite_pointer_type<T*, std::nullptr_t> +{ + typedef T* type; +}; + +template<class T> struct composite_pointer_type<std::nullptr_t, T*> +{ + typedef T* type; +}; + +template<> struct composite_pointer_type<std::nullptr_t, std::nullptr_t> +{ + typedef std::nullptr_t type; +}; + +#endif + +#endif // !defined( BOOST_NO_CXX11_NULLPTR ) + +namespace detail +{ + +template<class T, class U> struct has_common_pointee +{ +private: + + typedef typename boost::remove_cv<T>::type T2; + typedef typename boost::remove_cv<U>::type U2; + +public: + + BOOST_STATIC_CONSTANT( bool, value = + (boost::is_same<T2, U2>::value) + || boost::is_void<T2>::value + || boost::is_void<U2>::value + || (boost::is_base_of<T2, U2>::value) + || (boost::is_base_of<U2, T2>::value) ); +}; + +template<class T, class U> struct common_pointee +{ +private: + + typedef typename boost::remove_cv<T>::type T2; + typedef typename boost::remove_cv<U>::type U2; + +public: + + typedef typename boost::conditional< + + boost::is_same<T2, U2>::value || boost::is_void<T2>::value || boost::is_base_of<T2, U2>::value, + typename boost::copy_cv<T, U>::type, + typename boost::copy_cv<U, T>::type + + >::type type; +}; + +template<class T, class U> struct composite_pointer_impl +{ +private: + + typedef typename boost::remove_cv<T>::type T2; + typedef typename boost::remove_cv<U>::type U2; + +public: + + typedef typename boost::copy_cv<typename boost::copy_cv<typename composite_pointer_type<T2, U2>::type const, T>::type, U>::type type; +}; + +//Old compilers like MSVC-7.1 have problems using boost::conditional in +//composite_pointer_type. Partially specializing on has_common_pointee<T, U>::value +//seems to make their life easier +template<class T, class U, bool = has_common_pointee<T, U>::value > +struct composite_pointer_type_dispatch + : common_pointee<T, U> +{}; + +template<class T, class U> +struct composite_pointer_type_dispatch<T, U, false> + : composite_pointer_impl<T, U> +{}; + + +} // detail + + +template<class T, class U> struct composite_pointer_type<T*, U*> +{ + typedef typename detail::composite_pointer_type_dispatch<T, U>::type* type; +}; + +} // namespace type_traits_detail + +} // namespace boost + +#endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_COMPOSITE_POINTER_TYPE_HPP_INCLUDED diff --git a/boost/type_traits/detail/config.hpp b/boost/type_traits/detail/config.hpp new file mode 100644 index 0000000000..ebb1dd65f0 --- /dev/null +++ b/boost/type_traits/detail/config.hpp @@ -0,0 +1,72 @@ + +// (C) Copyright Steve Cleary, Beman Dawes, Howard Hinnant & John Maddock 2000. +// Use, modification and distribution are subject to 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/type_traits for most recent version including documentation. + +#ifndef BOOST_TT_CONFIG_HPP_INCLUDED +#define BOOST_TT_CONFIG_HPP_INCLUDED + +#ifndef BOOST_CONFIG_HPP +#include <boost/config.hpp> +#endif +#include <boost/version.hpp> +#include <boost/detail/workaround.hpp> + +// +// whenever we have a conversion function with ellipses +// it needs to be declared __cdecl to suppress compiler +// warnings from MS and Borland compilers (this *must* +// appear before we include is_same.hpp below): +#if defined(BOOST_MSVC) || (defined(__BORLANDC__) && !defined(BOOST_DISABLE_WIN32)) +# define BOOST_TT_DECL __cdecl +#else +# define BOOST_TT_DECL /**/ +#endif + +# if (BOOST_WORKAROUND(__MWERKS__, < 0x3000) \ + || BOOST_WORKAROUND(__IBMCPP__, < 600 ) \ + || BOOST_WORKAROUND(__BORLANDC__, < 0x5A0) \ + || defined(__ghs) \ + || BOOST_WORKAROUND(__HP_aCC, < 60700) \ + || BOOST_WORKAROUND(MPW_CPLUS, BOOST_TESTED_AT(0x890)) \ + || BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))) \ + && defined(BOOST_NO_IS_ABSTRACT) + +# define BOOST_TT_NO_CONFORMING_IS_CLASS_IMPLEMENTATION 1 + +#endif + +#ifndef BOOST_TT_NO_CONFORMING_IS_CLASS_IMPLEMENTATION +# define BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION 1 +#endif + +// +// define BOOST_TT_TEST_MS_FUNC_SIGS +// when we want to test __stdcall etc function types with is_function etc +// (Note, does not work with Borland, even though it does support __stdcall etc): +// +#if defined(_MSC_EXTENSIONS) && !defined(__BORLANDC__) +# define BOOST_TT_TEST_MS_FUNC_SIGS +#endif + +// +// define BOOST_TT_NO_CV_FUNC_TEST +// if tests for cv-qualified member functions don't +// work in is_member_function_pointer +// +#if BOOST_WORKAROUND(__MWERKS__, < 0x3000) || BOOST_WORKAROUND(__IBMCPP__, <= 600) +# define BOOST_TT_NO_CV_FUNC_TEST +#endif + +// +// Macros that have been deprecated, defined here for backwards compatibility: +// +#define BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(x) +#define BOOST_TT_BROKEN_COMPILER_SPEC(x) + +#endif // BOOST_TT_CONFIG_HPP_INCLUDED + + diff --git a/boost/type_traits/detail/cv_traits_impl.hpp b/boost/type_traits/detail/cv_traits_impl.hpp deleted file mode 100644 index 8e995bb064..0000000000 --- a/boost/type_traits/detail/cv_traits_impl.hpp +++ /dev/null @@ -1,140 +0,0 @@ - -// (C) Copyright Dave Abrahams, Steve Cleary, Beman Dawes, Howard -// Hinnant & John Maddock 2000. -// Use, modification and distribution are subject to 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/type_traits for most recent version including documentation. - - -#ifndef BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED -#define BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED - -#include <cstddef> -#include <boost/config.hpp> -#include <boost/detail/workaround.hpp> - - -// implementation helper: - - -namespace boost { -namespace detail { - -#if BOOST_WORKAROUND(BOOST_MSVC, == 1700) -#define BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(X) X - template <typename T> - struct cv_traits_imp - { - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type; - }; - - template <typename T> - struct cv_traits_imp<T[]> - { - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type[]; - }; - - template <typename T> - struct cv_traits_imp<const T[]> - { - BOOST_STATIC_CONSTANT(bool, is_const = true); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type[]; - }; - - template <typename T> - struct cv_traits_imp<volatile T[]> - { - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = true); - typedef T unqualified_type[]; - }; - - template <typename T> - struct cv_traits_imp<const volatile T[]> - { - BOOST_STATIC_CONSTANT(bool, is_const = true); - BOOST_STATIC_CONSTANT(bool, is_volatile = true); - typedef T unqualified_type[]; - }; - - template <typename T, std::size_t N> - struct cv_traits_imp<T[N]> - { - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type[N]; - }; - - template <typename T, std::size_t N> - struct cv_traits_imp<const T[N]> - { - BOOST_STATIC_CONSTANT(bool, is_const = true); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type[N]; - }; - - template <typename T, std::size_t N> - struct cv_traits_imp<volatile T[N]> - { - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = true); - typedef T unqualified_type[N]; - }; - - template <typename T, std::size_t N> - struct cv_traits_imp<const volatile T[N]> - { - BOOST_STATIC_CONSTANT(bool, is_const = true); - BOOST_STATIC_CONSTANT(bool, is_volatile = true); - typedef T unqualified_type[N]; - }; - -#else -#define BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(X) X * -template <typename T> struct cv_traits_imp {}; - -template <typename T> -struct cv_traits_imp<T*> -{ - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type; -}; -#endif - -template <typename T> -struct cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(const T)> -{ - BOOST_STATIC_CONSTANT(bool, is_const = true); - BOOST_STATIC_CONSTANT(bool, is_volatile = false); - typedef T unqualified_type; -}; - -template <typename T> -struct cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(volatile T)> -{ - BOOST_STATIC_CONSTANT(bool, is_const = false); - BOOST_STATIC_CONSTANT(bool, is_volatile = true); - typedef T unqualified_type; -}; - -template <typename T> -struct cv_traits_imp<BOOST_TT_AUX_CV_TRAITS_IMPL_PARAM(const volatile T)> -{ - BOOST_STATIC_CONSTANT(bool, is_const = true); - BOOST_STATIC_CONSTANT(bool, is_volatile = true); - typedef T unqualified_type; -}; - -} // namespace detail -} // namespace boost - - -#endif // BOOST_TT_DETAIL_CV_TRAITS_IMPL_HPP_INCLUDED diff --git a/boost/type_traits/detail/false_result.hpp b/boost/type_traits/detail/false_result.hpp deleted file mode 100644 index e65e8bc257..0000000000 --- a/boost/type_traits/detail/false_result.hpp +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright David Abrahams 2002. -// Use, modification and distribution are subject to 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/type_traits for most recent version including documentation. - - -#ifndef BOOST_TT_DETAIL_FALSE_RESULT_HPP_INCLUDED -#define BOOST_TT_DETAIL_FALSE_RESULT_HPP_INCLUDED - -#include <boost/config.hpp> - -namespace boost { -namespace type_traits { - -// Utility class which always "returns" false -struct false_result -{ - template <typename T> struct result_ - { - BOOST_STATIC_CONSTANT(bool, value = false); - }; -}; - -}} // namespace boost::type_traits - -#endif // BOOST_TT_DETAIL_FALSE_RESULT_HPP_INCLUDED diff --git a/boost/type_traits/detail/has_binary_operator.hpp b/boost/type_traits/detail/has_binary_operator.hpp index d82a5cefdb..039a6bb778 100644 --- a/boost/type_traits/detail/has_binary_operator.hpp +++ b/boost/type_traits/detail/has_binary_operator.hpp @@ -7,7 +7,7 @@ // See http://www.boost.org/libs/type_traits for most recent version including documentation. #include <boost/config.hpp> -#include <boost/type_traits/ice.hpp> +#include <boost/type_traits/detail/yes_no_type.hpp> #include <boost/type_traits/integral_constant.hpp> #include <boost/type_traits/is_base_of.hpp> #include <boost/type_traits/is_const.hpp> @@ -21,9 +21,6 @@ #include <boost/type_traits/remove_pointer.hpp> #include <boost/type_traits/remove_reference.hpp> -// should be the last #include -#include <boost/type_traits/detail/bool_trait_def.hpp> - // cannot include this header without getting warnings of the kind: // gcc: // warning: value computed is not used @@ -40,7 +37,10 @@ # pragma GCC system_header #elif defined(BOOST_MSVC) # pragma warning ( push ) -# pragma warning ( disable : 4018 4244 4547 4800 4804 4805 4913 ) +# pragma warning ( disable : 4018 4244 4547 4800 4804 4805 4913) +# if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) +# pragma warning ( disable : 6334) +# endif #endif namespace boost { @@ -177,13 +177,7 @@ struct trait_impl1 < Lhs, Rhs, Ret, true > { template < typename Lhs, typename Rhs, typename Ret > struct trait_impl1 < Lhs, Rhs, Ret, false > { BOOST_STATIC_CONSTANT(bool, - value = ( - ::boost::type_traits::ice_and< - operator_exists < Lhs, Rhs >::value, - operator_returns_Ret < Lhs, Rhs, Ret, operator_returns_void < Lhs, Rhs >::value >::value - >::value - ) - ); + value = (operator_exists < Lhs, Rhs >::value && operator_returns_Ret < Lhs, Rhs, Ret, operator_returns_void < Lhs, Rhs >::value >::value)); }; // some specializations needs to be declared for the special void case @@ -218,12 +212,11 @@ struct trait_impl { } // namespace detail // this is the accessible definition of the trait to end user -BOOST_TT_AUX_BOOL_TRAIT_DEF3(BOOST_TT_TRAIT_NAME, Lhs, Rhs=Lhs, Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::trait_impl < Lhs, Rhs, Ret >::value)) +template <class Lhs, class Rhs=Lhs, class Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care> +struct BOOST_TT_TRAIT_NAME : public integral_constant<bool, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME, _impl)::trait_impl < Lhs, Rhs, Ret >::value)>{}; } // namespace boost #if defined(BOOST_MSVC) # pragma warning ( pop ) #endif - -#include <boost/type_traits/detail/bool_trait_undef.hpp> diff --git a/boost/type_traits/detail/has_postfix_operator.hpp b/boost/type_traits/detail/has_postfix_operator.hpp index e9048e1214..3e686f12b5 100644 --- a/boost/type_traits/detail/has_postfix_operator.hpp +++ b/boost/type_traits/detail/has_postfix_operator.hpp @@ -7,7 +7,7 @@ // See http://www.boost.org/libs/type_traits for most recent version including documentation. #include <boost/config.hpp> -#include <boost/type_traits/ice.hpp> +#include <boost/type_traits/detail/yes_no_type.hpp> #include <boost/type_traits/integral_constant.hpp> #include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_fundamental.hpp> @@ -18,15 +18,15 @@ #include <boost/type_traits/remove_pointer.hpp> #include <boost/type_traits/remove_reference.hpp> -// should be the last #include -#include <boost/type_traits/detail/bool_trait_def.hpp> - // avoid warnings #if defined(__GNUC__) # pragma GCC system_header #elif defined(BOOST_MSVC) # pragma warning ( push ) -# pragma warning ( disable : 4244 4913 ) +# pragma warning ( disable : 4244 4913) +# if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) +# pragma warning ( disable : 6334) +# endif #endif namespace boost { @@ -163,13 +163,7 @@ struct trait_impl1 < Lhs, Ret, true > { template < typename Lhs, typename Ret > struct trait_impl1 < Lhs, Ret, false > { BOOST_STATIC_CONSTANT(bool, - value = ( - ::boost::type_traits::ice_and< - operator_exists < Lhs >::value, - operator_returns_Ret < Lhs, Ret, operator_returns_void < Lhs >::value >::value - >::value - ) - ); + value = (operator_exists < Lhs >::value && operator_returns_Ret < Lhs, Ret, operator_returns_void < Lhs >::value >::value)); }; // specialization needs to be declared for the special void case @@ -191,12 +185,11 @@ struct trait_impl { } // namespace detail // this is the accessible definition of the trait to end user -BOOST_TT_AUX_BOOL_TRAIT_DEF2(BOOST_TT_TRAIT_NAME, Lhs, Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::trait_impl< Lhs, Ret >::value)) +template <class Lhs, class Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care> +struct BOOST_TT_TRAIT_NAME : public integral_constant<bool, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME, _impl)::trait_impl< Lhs, Ret >::value)>{}; } // namespace boost #if defined(BOOST_MSVC) # pragma warning ( pop ) #endif - -#include <boost/type_traits/detail/bool_trait_undef.hpp> diff --git a/boost/type_traits/detail/has_prefix_operator.hpp b/boost/type_traits/detail/has_prefix_operator.hpp index e1cf8d054f..d4574fc60d 100644 --- a/boost/type_traits/detail/has_prefix_operator.hpp +++ b/boost/type_traits/detail/has_prefix_operator.hpp @@ -7,7 +7,7 @@ // See http://www.boost.org/libs/type_traits for most recent version including documentation. #include <boost/config.hpp> -#include <boost/type_traits/ice.hpp> +#include <boost/type_traits/detail/yes_no_type.hpp> #include <boost/type_traits/integral_constant.hpp> #include <boost/type_traits/is_const.hpp> #include <boost/type_traits/is_fundamental.hpp> @@ -19,9 +19,6 @@ #include <boost/type_traits/remove_pointer.hpp> #include <boost/type_traits/remove_reference.hpp> -// should be the last #include -#include <boost/type_traits/detail/bool_trait_def.hpp> - // cannot include this header without getting warnings of the kind: // gcc: // warning: value computed is not used @@ -34,9 +31,14 @@ # pragma GCC system_header #elif defined(BOOST_MSVC) # pragma warning ( push ) -# pragma warning ( disable : 4146 4804 4913 4244 ) +# pragma warning ( disable : 4146 4804 4913 4244) +# if BOOST_WORKAROUND(BOOST_MSVC_FULL_VER, >= 140050000) +# pragma warning ( disable : 6334) +# endif #endif + + namespace boost { namespace detail { @@ -171,13 +173,7 @@ struct trait_impl1 < Rhs, Ret, true > { template < typename Rhs, typename Ret > struct trait_impl1 < Rhs, Ret, false > { BOOST_STATIC_CONSTANT(bool, - value = ( - ::boost::type_traits::ice_and< - operator_exists < Rhs >::value, - operator_returns_Ret < Rhs, Ret, operator_returns_void < Rhs >::value >::value - >::value - ) - ); + value = (operator_exists < Rhs >::value && operator_returns_Ret < Rhs, Ret, operator_returns_void < Rhs >::value >::value)); }; // specialization needs to be declared for the special void case @@ -199,12 +195,11 @@ struct trait_impl { } // namespace detail // this is the accessible definition of the trait to end user -BOOST_TT_AUX_BOOL_TRAIT_DEF2(BOOST_TT_TRAIT_NAME, Rhs, Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::trait_impl < Rhs, Ret >::value)) +template <class Rhs, class Ret=::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME,_impl)::dont_care> +struct BOOST_TT_TRAIT_NAME : public integral_constant<bool, (::boost::detail::BOOST_JOIN(BOOST_TT_TRAIT_NAME, _impl)::trait_impl < Rhs, Ret >::value)>{}; } // namespace boost #if defined(BOOST_MSVC) # pragma warning ( pop ) #endif - -#include <boost/type_traits/detail/bool_trait_undef.hpp> diff --git a/boost/type_traits/detail/ice_and.hpp b/boost/type_traits/detail/ice_and.hpp index 8b461b9fff..3ccb03e850 100644 --- a/boost/type_traits/detail/ice_and.hpp +++ b/boost/type_traits/detail/ice_and.hpp @@ -11,6 +11,13 @@ #include <boost/config.hpp> +// +// This header is deprecated and no longer used by type_traits: +// +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (ice_and.hpp) is deprecated") +#endif + namespace boost { namespace type_traits { diff --git a/boost/type_traits/detail/ice_eq.hpp b/boost/type_traits/detail/ice_eq.hpp index ea42a60b66..5908f81512 100644 --- a/boost/type_traits/detail/ice_eq.hpp +++ b/boost/type_traits/detail/ice_eq.hpp @@ -10,6 +10,13 @@ #include <boost/config.hpp> +// +// This header is deprecated and no longer used by type_traits: +// +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (ice_eq.hpp) is deprecated") +#endif + namespace boost { namespace type_traits { diff --git a/boost/type_traits/detail/ice_not.hpp b/boost/type_traits/detail/ice_not.hpp index ee1dca0ecd..e095be9cc1 100644 --- a/boost/type_traits/detail/ice_not.hpp +++ b/boost/type_traits/detail/ice_not.hpp @@ -10,6 +10,13 @@ #include <boost/config.hpp> +// +// This header is deprecated and no longer used by type_traits: +// +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (ice_not.hpp) is deprecated") +#endif + namespace boost { namespace type_traits { diff --git a/boost/type_traits/detail/ice_or.hpp b/boost/type_traits/detail/ice_or.hpp index f88d9f6aec..ea523c808a 100644 --- a/boost/type_traits/detail/ice_or.hpp +++ b/boost/type_traits/detail/ice_or.hpp @@ -10,6 +10,13 @@ #include <boost/config.hpp> +// +// This header is deprecated and no longer used by type_traits: +// +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (ice_or.hpp) is deprecated") +#endif + namespace boost { namespace type_traits { diff --git a/boost/type_traits/detail/is_function_ptr_helper.hpp b/boost/type_traits/detail/is_function_ptr_helper.hpp index 1c3b17f6d2..3538e402da 100644 --- a/boost/type_traits/detail/is_function_ptr_helper.hpp +++ b/boost/type_traits/detail/is_function_ptr_helper.hpp @@ -15,12 +15,20 @@ #ifndef BOOST_TT_DETAIL_IS_FUNCTION_PTR_HELPER_HPP_INCLUDED #define BOOST_TT_DETAIL_IS_FUNCTION_PTR_HELPER_HPP_INCLUDED -#include <boost/type_traits/config.hpp> - #if defined(BOOST_TT_PREPROCESSING_MODE) -# include <boost/preprocessor/iterate.hpp> -# include <boost/preprocessor/enum_params.hpp> -# include <boost/preprocessor/comma_if.hpp> +// +// Hide these #include from dependency analysers as +// these are required in maintenance mode only: +// +#define PP1 <boost/preprocessor/iterate.hpp> +#include PP1 +#undef PP1 +#define PP1 <boost/preprocessor/enum_params.hpp> +#include PP1 +#undef PP1 +#define PP1 <boost/preprocessor/comma_if.hpp> +#include PP1 +#undef PP1 #endif namespace boost { diff --git a/boost/type_traits/detail/is_function_ptr_tester.hpp b/boost/type_traits/detail/is_function_ptr_tester.hpp index 2eb8a6f47f..4fe88e81b2 100644 --- a/boost/type_traits/detail/is_function_ptr_tester.hpp +++ b/boost/type_traits/detail/is_function_ptr_tester.hpp @@ -15,12 +15,21 @@ #define BOOST_TT_DETAIL_IS_FUNCTION_PTR_TESTER_HPP_INCLUDED #include <boost/type_traits/detail/yes_no_type.hpp> -#include <boost/type_traits/config.hpp> #if defined(BOOST_TT_PREPROCESSING_MODE) -# include <boost/preprocessor/iterate.hpp> -# include <boost/preprocessor/enum_params.hpp> -# include <boost/preprocessor/comma_if.hpp> +// +// Hide include dependencies from analysers since they're +// only require in maintenance mode: +// +#define PP1 <boost/preprocessor/iterate.hpp> +#define PP2 <boost/preprocessor/enum_params.hpp> +#define PP3 <boost/preprocessor/comma_if.hpp> +#include PP1 +#include PP2 +#include PP3 +#undef PP1 +#undef PP2 +#undef PP3 #endif namespace boost { diff --git a/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp b/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp index bd5c591b20..5698a74897 100644 --- a/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp +++ b/boost/type_traits/detail/is_mem_fun_pointer_impl.hpp @@ -17,9 +17,19 @@ #include <boost/config.hpp> #if defined(BOOST_TT_PREPROCESSING_MODE) -# include <boost/preprocessor/iterate.hpp> -# include <boost/preprocessor/enum_params.hpp> -# include <boost/preprocessor/comma_if.hpp> +// +// Maintenance mode, hide include dependencies +// from trackers: +// +#define PPI <boost/preprocessor/iterate.hpp> +#include PPI +#undef PPI +#define PPI <boost/preprocessor/enum_params.hpp> +#include PPI +#undef PPI +#define PPI <boost/preprocessor/comma_if.hpp> +#include PPI +#undef PPI #endif namespace boost { diff --git a/boost/type_traits/detail/is_mem_fun_pointer_tester.hpp b/boost/type_traits/detail/is_mem_fun_pointer_tester.hpp index 334a843450..5e31693111 100644 --- a/boost/type_traits/detail/is_mem_fun_pointer_tester.hpp +++ b/boost/type_traits/detail/is_mem_fun_pointer_tester.hpp @@ -15,12 +15,22 @@ #define BOOST_TT_DETAIL_IS_MEM_FUN_POINTER_TESTER_HPP_INCLUDED #include <boost/type_traits/detail/yes_no_type.hpp> -#include <boost/type_traits/config.hpp> +#include <boost/type_traits/detail/config.hpp> #if defined(BOOST_TT_PREPROCESSING_MODE) -# include <boost/preprocessor/iterate.hpp> -# include <boost/preprocessor/enum_params.hpp> -# include <boost/preprocessor/comma_if.hpp> +// +// Maintentance mode, hide include dependencies +// from dependency trackers: +// +#define PPI <boost/preprocessor/iterate.hpp> +#include PPI +#undef PPI +#define PPI <boost/preprocessor/enum_params.hpp> +#include PPI +#undef PPI +#define <boost/preprocessor/comma_if.hpp> +#include PPI +#undef #endif namespace boost { diff --git a/boost/type_traits/detail/mp_defer.hpp b/boost/type_traits/detail/mp_defer.hpp new file mode 100644 index 0000000000..7910e545e1 --- /dev/null +++ b/boost/type_traits/detail/mp_defer.hpp @@ -0,0 +1,56 @@ +#ifndef BOOST_TYPE_TRAITS_DETAIL_MP_DEFER_HPP_INCLUDED +#define BOOST_TYPE_TRAITS_DETAIL_MP_DEFER_HPP_INCLUDED + +// +// Copyright 2015 Peter Dimov +// +// 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 +// + +#include <boost/type_traits/integral_constant.hpp> +#include <boost/type_traits/conditional.hpp> + +namespace boost +{ + +namespace type_traits_detail +{ + +// mp_valid +// implementation by Bruno Dutra (by the name is_evaluable) + +template<template<class...> class F, class... T> +struct mp_valid_impl +{ + template<template<class...> class G, class = G<T...>> + static boost::true_type check(int); + + template<template<class...> class> + static boost::false_type check(...); + + using type = decltype(check<F>(0)); +}; + +template<template<class...> class F, class... T> +using mp_valid = typename mp_valid_impl<F, T...>::type; + +// mp_defer + +struct mp_empty +{ +}; + +template<template<class...> class F, class... T> struct mp_defer_impl +{ + using type = F<T...>; +}; + +template<template<class...> class F, class... T> using mp_defer = typename boost::conditional<mp_valid<F, T...>::value, mp_defer_impl<F, T...>, mp_empty>::type; + +} // namespace type_traits_detail + +} // namespace boost + +#endif // #ifndef BOOST_TYPE_TRAITS_DETAIL_MP_DEFER_HPP_INCLUDED diff --git a/boost/type_traits/detail/size_t_trait_def.hpp b/boost/type_traits/detail/size_t_trait_def.hpp deleted file mode 100644 index 8cea9b4522..0000000000 --- a/boost/type_traits/detail/size_t_trait_def.hpp +++ /dev/null @@ -1,51 +0,0 @@ - -// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION - -// Copyright Aleksey Gurtovoy 2002-2004 -// -// 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) - -// $Source$ -// $Date$ -// $Revision$ - -#include <boost/type_traits/detail/template_arity_spec.hpp> -#include <boost/type_traits/integral_constant.hpp> -#include <boost/mpl/aux_/lambda_support.hpp> -#include <boost/mpl/size_t.hpp> - -#include <cstddef> - -// Obsolete. Remove. -#define BOOST_TT_AUX_SIZE_T_BASE(C) public ::boost::integral_constant<std::size_t,C> -#define BOOST_TT_AUX_SIZE_T_TRAIT_VALUE_DECL(C) /**/ - - -#define BOOST_TT_AUX_SIZE_T_TRAIT_DEF1(trait,T,C) \ -template< typename T > struct trait \ - : public ::boost::integral_constant<std::size_t,C> \ -{ \ -public:\ - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \ -}; \ -\ -BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \ -/**/ - -#define BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(trait,spec,C) \ -template<> struct trait<spec> \ - : public ::boost::integral_constant<std::size_t,C> \ -{ \ -public:\ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(spec)) \ -}; \ -/**/ - -#define BOOST_TT_AUX_SIZE_T_TRAIT_PARTIAL_SPEC1_1(param,trait,spec,C) \ -template< param > struct trait<spec> \ - : public ::boost::integral_constant<std::size_t,C> \ -{ \ -}; \ -/**/ diff --git a/boost/type_traits/detail/size_t_trait_undef.hpp b/boost/type_traits/detail/size_t_trait_undef.hpp deleted file mode 100644 index 1694fac772..0000000000 --- a/boost/type_traits/detail/size_t_trait_undef.hpp +++ /dev/null @@ -1,16 +0,0 @@ - -// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION - -// Copyright Aleksey Gurtovoy 2002-2004 -// -// 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) - -// $Source$ -// $Date$ -// $Revision$ - -#undef BOOST_TT_AUX_SIZE_T_TRAIT_DEF1 -#undef BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1 -#undef BOOST_TT_AUX_SIZE_T_TRAIT_PARTIAL_SPEC1_1 diff --git a/boost/type_traits/detail/template_arity_spec.hpp b/boost/type_traits/detail/template_arity_spec.hpp index fe9b422e83..36ea96d6d5 100644 --- a/boost/type_traits/detail/template_arity_spec.hpp +++ b/boost/type_traits/detail/template_arity_spec.hpp @@ -1,4 +1,3 @@ - // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION // Copyright Aleksey Gurtovoy 2002-2004 @@ -7,25 +6,11 @@ // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#include <boost/mpl/int.hpp> -#include <boost/mpl/aux_/template_arity_fwd.hpp> -#include <boost/mpl/aux_/preprocessor/params.hpp> -#include <boost/mpl/aux_/config/lambda.hpp> -#include <boost/mpl/aux_/config/overload_resolution.hpp> +// +// This header is deprecated and no longer used by type_traits: +// +#if defined(__GNUC__) || defined(_MSC_VER) +# pragma message("NOTE: Use of this header (template_arity_spec.hpp) is deprecated") +#endif -#if defined(BOOST_MPL_CFG_NO_FULL_LAMBDA_SUPPORT) \ - && defined(BOOST_MPL_CFG_BROKEN_OVERLOAD_RESOLUTION) -# define BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(i, name) \ -namespace mpl { namespace aux { \ -template< BOOST_MPL_PP_PARAMS(i, typename T) > \ -struct template_arity< \ - name< BOOST_MPL_PP_PARAMS(i, T) > \ - > \ - : int_<i> \ -{ \ -}; \ -}} \ -/**/ -#else # define BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(i, name) /**/ -#endif diff --git a/boost/type_traits/detail/type_trait_def.hpp b/boost/type_traits/detail/type_trait_def.hpp deleted file mode 100644 index bc54696b55..0000000000 --- a/boost/type_traits/detail/type_trait_def.hpp +++ /dev/null @@ -1,67 +0,0 @@ - -// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION - -// Copyright Aleksey Gurtovoy 2002-2004 -// -// 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) - -// $Source$ -// $Date$ -// $Revision$ - -#include <boost/type_traits/detail/template_arity_spec.hpp> -#include <boost/mpl/aux_/lambda_support.hpp> - -#define BOOST_TT_AUX_TYPE_TRAIT_DEF1(trait,T,result) \ -template< typename T > struct trait \ -{ \ -public:\ - typedef result type; \ - BOOST_MPL_AUX_LAMBDA_SUPPORT(1,trait,(T)) \ -}; \ -\ -BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,trait) \ -/**/ - -#define BOOST_TT_AUX_TYPE_TRAIT_SPEC1(trait,spec,result) \ -template<> struct trait<spec> \ -{ \ -public:\ - typedef result type; \ - BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,trait,(spec)) \ -}; \ -/**/ - -#define BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1(trait,spec,result) \ -template<> struct trait##_impl<spec> \ -{ \ -public:\ - typedef result type; \ -}; \ -/**/ - -#define BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1(param,trait,spec,result) \ -template< param > struct trait<spec> \ -{ \ -public:\ - typedef result type; \ -}; \ -/**/ - -#define BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,spec,result) \ -template< param1, param2 > struct trait<spec> \ -{ \ -public:\ - typedef result; \ -}; \ -/**/ - -#define BOOST_TT_AUX_TYPE_TRAIT_IMPL_PARTIAL_SPEC1_1(param,trait,spec,result) \ -template< param > struct trait##_impl<spec> \ -{ \ -public:\ - typedef result type; \ -}; \ -/**/ diff --git a/boost/type_traits/detail/type_trait_undef.hpp b/boost/type_traits/detail/type_trait_undef.hpp deleted file mode 100644 index d8edf66275..0000000000 --- a/boost/type_traits/detail/type_trait_undef.hpp +++ /dev/null @@ -1,19 +0,0 @@ - -// NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION - -// Copyright Aleksey Gurtovoy 2002-2004 -// -// 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) - -// $Source$ -// $Date$ -// $Revision$ - -#undef BOOST_TT_AUX_TYPE_TRAIT_DEF1 -#undef BOOST_TT_AUX_TYPE_TRAIT_SPEC1 -#undef BOOST_TT_AUX_TYPE_TRAIT_IMPL_SPEC1 -#undef BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_1 -#undef BOOST_TT_AUX_TYPE_TRAIT_PARTIAL_SPEC1_2 -#undef BOOST_TT_AUX_TYPE_TRAIT_IMPL_PARTIAL_SPEC1_1 diff --git a/boost/type_traits/detail/wrap.hpp b/boost/type_traits/detail/wrap.hpp deleted file mode 100644 index d0a75d06cb..0000000000 --- a/boost/type_traits/detail/wrap.hpp +++ /dev/null @@ -1,18 +0,0 @@ -// (C) Copyright David Abrahams 2002. -// Use, modification and distribution are subject to 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/type_traits for most recent version including documentation. - -#ifndef BOOST_TT_DETAIL_WRAP_HPP_INCLUDED -#define BOOST_TT_DETAIL_WRAP_HPP_INCLUDED - -namespace boost { -namespace type_traits { - -template <class T> struct wrap {}; - -}} // namespace boost::type_traits - -#endif // BOOST_TT_DETAIL_WRAP_HPP_INCLUDED |