Chris@16: // Copyright Daniel Wallin, David Abrahams 2005. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version 1.0. (See Chris@16: // accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef UNWRAP_CV_REFERENCE_050328_HPP Chris@16: #define UNWRAP_CV_REFERENCE_050328_HPP Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { template class reference_wrapper; } Chris@16: Chris@16: namespace boost { namespace parameter { namespace aux { Chris@16: Chris@16: // Chris@16: // reference_wrapper support -- because of the forwarding problem, Chris@16: // when passing arguments positionally by non-const reference, we Chris@16: // ask users of named parameter interfaces to use ref(x) to wrap Chris@16: // them. Chris@16: // Chris@16: Chris@16: // is_cv_reference_wrapper returns mpl::true_ if T is of type Chris@16: // reference_wrapper cv Chris@16: template Chris@16: yes_tag is_cv_reference_wrapper_check(reference_wrapper const volatile*); Chris@16: no_tag is_cv_reference_wrapper_check(...); Chris@16: Chris@16: template Chris@16: struct is_cv_reference_wrapper Chris@16: { Chris@16: BOOST_STATIC_CONSTANT( Chris@16: bool, value = ( Chris@16: sizeof(is_cv_reference_wrapper_check((T*)0)) == sizeof(yes_tag) Chris@16: ) Chris@16: ); Chris@16: Chris@16: typedef mpl::bool_< Chris@16: #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: is_cv_reference_wrapper:: Chris@16: #endif Chris@16: value> type; Chris@16: }; Chris@16: Chris@16: #if BOOST_WORKAROUND(MSVC, == 1200) Chris@16: template <> Chris@16: struct is_cv_reference_wrapper Chris@16: : mpl::false_ {}; Chris@16: #endif Chris@16: Chris@16: // Needed for unwrap_cv_reference below. T might be const, so Chris@16: // eval_if might fail because of deriving from T const on EDG. Chris@16: template Chris@16: struct get_type Chris@16: { Chris@16: typedef typename T::type type; Chris@16: }; Chris@16: Chris@16: #if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) Chris@16: template ::type> Chris@16: struct unwrap_cv_reference Chris@16: { Chris@16: typedef T type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct unwrap_cv_reference Chris@16: { Chris@16: typedef T const type; Chris@16: }; Chris@16: Chris@16: template Chris@16: struct unwrap_cv_reference Chris@16: : T Chris@16: {}; Chris@16: Chris@16: #else Chris@16: // Produces the unwrapped type to hold a reference to in named<> Chris@16: // Can't use boost::unwrap_reference<> here because it Chris@16: // doesn't handle the case where T = reference_wrapper cv Chris@16: template Chris@16: struct unwrap_cv_reference Chris@16: { Chris@16: typedef typename mpl::eval_if< Chris@16: is_cv_reference_wrapper Chris@16: , get_type Chris@16: , mpl::identity Chris@16: >::type type; Chris@16: }; Chris@16: #endif Chris@16: Chris@16: }}} // namespace boost::parameter::aux Chris@16: Chris@16: #endif // UNWRAP_CV_REFERENCE_050328_HPP Chris@16: