// (C) Copyright Tobias Schwinger // // Use modification and distribution are subject to the boost Software License, // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). //------------------------------------------------------------------------------ #ifndef BOOST_FT_DETAIL_CV_TRAITS_HPP_INCLUDED #define BOOST_FT_DETAIL_CV_TRAITS_HPP_INCLUDED #include #include #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ || BOOST_WORKAROUND(__BORLANDC__, <= 0x582) # include # include # include #endif #include namespace boost { namespace function_types { namespace detail { #if ! (defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \ || BOOST_WORKAROUND(__BORLANDC__, <= 0x582)) template struct cv_traits { typedef non_cv tag; typedef T type; }; template struct cv_traits { typedef non_cv tag; typedef T type; }; template struct cv_traits { typedef non_cv tag; typedef T type; }; template struct cv_traits { typedef non_cv tag; typedef T type; }; template struct cv_traits { typedef non_cv tag; typedef T type; }; template struct cv_traits { typedef non_cv tag; typedef T type; }; template struct cv_traits { typedef const_non_volatile tag; typedef T type; }; template struct cv_traits { typedef const_non_volatile tag; typedef T type; }; template struct cv_traits { typedef const_non_volatile tag; typedef T type; }; template struct cv_traits { typedef const_non_volatile tag; typedef T type; }; template struct cv_traits { typedef const_non_volatile tag; typedef T type; }; template struct cv_traits { typedef const_non_volatile tag; typedef T type; }; template struct cv_traits { typedef volatile_non_const tag; typedef T type; }; template struct cv_traits { typedef volatile_non_const tag; typedef T type; }; template struct cv_traits { typedef volatile_non_const tag; typedef T type; }; template struct cv_traits { typedef volatile_non_const tag; typedef T type; }; template struct cv_traits { typedef volatile_non_const tag; typedef T type; }; template struct cv_traits { typedef volatile_non_const tag; typedef T type; }; template struct cv_traits { typedef cv_qualified tag; typedef T type; }; template struct cv_traits { typedef cv_qualified tag; typedef T type; }; template struct cv_traits { typedef cv_qualified tag; typedef T type; }; template struct cv_traits { typedef cv_qualified tag; typedef T type; }; template struct cv_traits { typedef cv_qualified tag; typedef T type; }; template struct cv_traits { typedef cv_qualified tag; typedef T type; }; #else template struct cv_tag_impl; template<> struct cv_tag_impl<1> { typedef non_cv type;}; template<> struct cv_tag_impl<2> { typedef const_non_volatile type; }; template<> struct cv_tag_impl<3> { typedef volatile_non_const type; }; template<> struct cv_tag_impl<4> { typedef cv_qualified type; }; typedef char (& case_1)[1]; typedef char (& case_2)[2]; typedef char (& case_3)[3]; typedef char (& case_4)[4]; template case_1 switch_cv(T *); template case_2 switch_cv(T const *); template case_3 switch_cv(T volatile *); template case_4 switch_cv(T const volatile *); template T * ref_to_ptr(T &); template T const * ref_to_ptr(T const &); template T volatile * ref_to_ptr(T volatile &); template T const volatile * ref_to_ptr(T const volatile &); template T * ref_to_ptr(T * const volatile &); template struct cv_code { static T _t; BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(::boost::function_types::detail::switch_cv( ::boost::function_types::detail::ref_to_ptr(_t) ) )); }; template struct cv_traits { typedef typename boost::function_types::detail::cv_tag_impl< ::boost::function_types::detail::cv_code::value >::type tag; // may require Boost.TypeTraits broken compiler specializations // to work typedef typename boost::remove_cv< typename boost::remove_pointer< typename boost::remove_reference::type >::type >::type type; }; #endif } } } // namespace boost::function_types::detail #endif