1 // Copyright Daniel Wallin, David Abrahams 2005. Use, modification and
2 // distribution is subject to the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef UNWRAP_CV_REFERENCE_050328_HPP
7 #define UNWRAP_CV_REFERENCE_050328_HPP
9 #include <boost/parameter/aux_/yesno.hpp>
10 #include <boost/mpl/bool.hpp>
11 #include <boost/mpl/identity.hpp>
12 #include <boost/mpl/eval_if.hpp>
14 namespace boost { template<class T> class reference_wrapper; }
16 namespace boost { namespace parameter { namespace aux {
19 // reference_wrapper support -- because of the forwarding problem,
20 // when passing arguments positionally by non-const reference, we
21 // ask users of named parameter interfaces to use ref(x) to wrap
25 // is_cv_reference_wrapper returns mpl::true_ if T is of type
26 // reference_wrapper<U> cv
28 yes_tag is_cv_reference_wrapper_check(reference_wrapper<U> const volatile*);
29 no_tag is_cv_reference_wrapper_check(...);
32 struct is_cv_reference_wrapper
34 BOOST_STATIC_CONSTANT(
36 sizeof(is_cv_reference_wrapper_check((T*)0)) == sizeof(yes_tag)
41 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
42 is_cv_reference_wrapper::
47 #if BOOST_WORKAROUND(MSVC, == 1200)
49 struct is_cv_reference_wrapper<int>
53 // Needed for unwrap_cv_reference below. T might be const, so
54 // eval_if might fail because of deriving from T const on EDG.
58 typedef typename T::type type;
61 #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
62 template <class T, class is_reference_wrapper = typename is_cv_reference_wrapper<T>::type>
63 struct unwrap_cv_reference
69 struct unwrap_cv_reference<T const, mpl::false_>
75 struct unwrap_cv_reference<T, mpl::true_>
80 // Produces the unwrapped type to hold a reference to in named<>
81 // Can't use boost::unwrap_reference<> here because it
82 // doesn't handle the case where T = reference_wrapper<U> cv
84 struct unwrap_cv_reference
86 typedef typename mpl::eval_if<
87 is_cv_reference_wrapper<T>
94 }}} // namespace boost::parameter::aux
96 #endif // UNWRAP_CV_REFERENCE_050328_HPP