Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:43:30

0001 // Copyright Daniel Wallin, David Abrahams 2005.
0002 // Copyright Cromwell D. Enage 2017.
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #ifndef BOOST_PARAMETER_AUX_UNWRAP_CV_REFERENCE_HPP
0008 #define BOOST_PARAMETER_AUX_UNWRAP_CV_REFERENCE_HPP
0009 
0010 namespace boost {
0011 
0012     template <typename T>
0013     class reference_wrapper;
0014 } // namespace boost
0015 
0016 #include <boost/parameter/aux_/yesno.hpp>
0017 
0018 namespace boost { namespace parameter { namespace aux {
0019 
0020     //
0021     // reference_wrapper support -- if perfect forwarding is unsupported,
0022     // then when passing arguments positionally by non-const reference,
0023     // we ask users of named parameter interfaces to use ref(x) to wrap them.
0024     //
0025 
0026     template <typename U>
0027     ::boost::parameter::aux::yes_tag
0028         is_cv_reference_wrapper_check(
0029             ::boost::reference_wrapper<U> const volatile*
0030         );
0031 
0032     ::boost::parameter::aux::no_tag is_cv_reference_wrapper_check(...);
0033 }}} // namespace boost::parameter::aux
0034 
0035 #include <boost/parameter/config.hpp>
0036 
0037 #if !defined(BOOST_NO_CXX11_HDR_FUNCTIONAL)
0038 #include <functional>
0039 
0040 namespace boost { namespace parameter { namespace aux {
0041 
0042     // Support for std::ref(x) -- Cromwell D. Enage
0043     template <typename U>
0044     ::boost::parameter::aux::yes_tag
0045         is_cv_reference_wrapper_check(
0046             ::std::reference_wrapper<U> const volatile*
0047         );
0048 }}} // namespace boost::parameter::aux
0049 #endif
0050 
0051 #include <boost/parameter/aux_/preprocessor/nullptr.hpp>
0052 
0053 #if defined(BOOST_PARAMETER_CAN_USE_MP11) && !( \
0054         BOOST_WORKAROUND(BOOST_MSVC, >= 1900) && \
0055         BOOST_WORKAROUND(BOOST_MSVC, < 1910) \
0056     )
0057 #include <boost/mp11/integral.hpp>
0058 #include <boost/mp11/utility.hpp>
0059 #include <type_traits>
0060 #else   // !defined(BOOST_PARAMETER_CAN_USE_MP11) || MSVC-14.0
0061 #include <boost/mpl/bool.hpp>
0062 #include <boost/type_traits/remove_reference.hpp>
0063 #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) && \
0064     !BOOST_WORKAROUND(BOOST_GCC, < 40000)
0065 #include <boost/mpl/eval_if.hpp>
0066 #endif
0067 #endif  // BOOST_PARAMETER_CAN_USE_MP11 && not MSVC-14.0
0068 
0069 namespace boost { namespace parameter { namespace aux {
0070 
0071 #if defined(BOOST_PARAMETER_CAN_USE_MP11) && !( \
0072         BOOST_WORKAROUND(BOOST_MSVC, >= 1900) && \
0073         BOOST_WORKAROUND(BOOST_MSVC, < 1910) \
0074     )
0075     // This metafunction returns mp11::mp_true if T is of type
0076     // reference_wrapper<U> cv.
0077     template <typename T>
0078     using is_cv_reference_wrapper = ::boost::mp11::mp_bool<
0079         sizeof(
0080             ::boost::parameter::aux::is_cv_reference_wrapper_check(
0081                 static_cast<
0082                     typename ::std::remove_reference<T>::type*
0083                 >(BOOST_PARAMETER_AUX_PP_NULLPTR)
0084             )
0085         ) == sizeof(::boost::parameter::aux::yes_tag)
0086     >;
0087 
0088     // Needed for unwrap_cv_reference below. T might be const, so
0089     // mp_eval_if<> might fail because of deriving from T const on EDG.
0090     template <typename T>
0091     using unwrap_cv_reference_impl = typename ::std::remove_reference<T>::type;
0092 
0093     // Produces the unwrapped type to hold a reference to in
0094     // tagged_argument<>.  Can't use boost::unwrap_reference<> here
0095     // because it doesn't handle the case where T = reference_wrapper<U> cv.
0096     template <typename T>
0097     using unwrap_cv_reference = ::boost::mp11::mp_eval_if<
0098         ::boost::parameter::aux::is_cv_reference_wrapper<T>
0099       , ::boost::parameter::aux::unwrap_cv_reference_impl<T>
0100       , ::std::remove_reference
0101       , T
0102     >;
0103 #else  // !defined(BOOST_PARAMETER_CAN_USE_MP11) || MSVC-14.0
0104     // This metafunction returns mpl::true_ if T is of type
0105     // reference_wrapper<U> cv.
0106     template <typename T>
0107     struct is_cv_reference_wrapper
0108     {
0109         BOOST_STATIC_CONSTANT(
0110             bool, value = (
0111                 sizeof(
0112                     ::boost::parameter::aux::is_cv_reference_wrapper_check(
0113                         static_cast<
0114                             typename ::boost::remove_reference<T>::type*
0115                         >(BOOST_PARAMETER_AUX_PP_NULLPTR)
0116                     )
0117                 ) == sizeof(::boost::parameter::aux::yes_tag)
0118             )
0119         );
0120 
0121         typedef boost::mpl::bool_<
0122 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564))
0123             is_cv_reference_wrapper::
0124 #endif
0125         value> type;
0126     };
0127 
0128 #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) || \
0129     BOOST_WORKAROUND(BOOST_GCC, < 40000)
0130     template <
0131         typename T
0132       , typename = typename ::boost::parameter::aux
0133         ::is_cv_reference_wrapper<T>::type
0134     >
0135     struct unwrap_cv_reference : ::boost::remove_reference<T>
0136     {
0137     };
0138 
0139     template <typename T>
0140     struct unwrap_cv_reference<T const,::boost::mpl::false_>
0141     {
0142         typedef T const type;
0143     };
0144 
0145     template <typename T>
0146     struct unwrap_cv_reference<T,::boost::mpl::true_> : T
0147     {
0148     };
0149 #else   // no Borland or GCC 3- workarounds needed
0150     // Needed for unwrap_cv_reference below. T might be const, so
0151     // eval_if<> might fail because of deriving from T const on EDG.
0152     template <typename T>
0153     struct unwrap_cv_reference_impl : ::boost::remove_reference<T>::type
0154     {
0155     };
0156 
0157     // Produces the unwrapped type to hold a reference to in
0158     // tagged_argument<>.  Can't use boost::unwrap_reference<> here
0159     // because it doesn't handle the case where T = reference_wrapper<U> cv.
0160     template <typename T>
0161     struct unwrap_cv_reference
0162       : ::boost::mpl::eval_if<
0163             ::boost::parameter::aux::is_cv_reference_wrapper<T>
0164           , ::boost::parameter::aux::unwrap_cv_reference_impl<T>
0165           , ::boost::remove_reference<T>
0166         >
0167     {
0168     };
0169 #endif  // Borland or GCC 3- workarounds needed
0170 #endif  // BOOST_PARAMETER_CAN_USE_MP11 && not MSVC-14.0
0171 }}} // namespace boost::parameter::aux
0172 
0173 #endif  // include guard
0174