175 lines
6.0 KiB
C++
175 lines
6.0 KiB
C++
// Copyright Daniel Wallin, David Abrahams 2005.
|
|
// Copyright Cromwell D. Enage 2017.
|
|
// 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)
|
|
|
|
#ifndef ACTIV_BOOST_PARAMETER_AUX_UNWRAP_CV_REFERENCE_HPP
|
|
#define ACTIV_BOOST_PARAMETER_AUX_UNWRAP_CV_REFERENCE_HPP
|
|
|
|
namespace Boost {
|
|
|
|
template <typename T>
|
|
class reference_wrapper;
|
|
} // namespace Boost
|
|
|
|
#include <ActivBoost/parameter/aux_/yesno.hpp>
|
|
|
|
namespace Boost { namespace parameter { namespace aux {
|
|
|
|
//
|
|
// reference_wrapper support -- if perfect forwarding is unsupported,
|
|
// then when passing arguments positionally by non-const reference,
|
|
// we ask users of named parameter interfaces to use ref(x) to wrap them.
|
|
//
|
|
|
|
template <typename U>
|
|
::Boost::parameter::aux::yes_tag
|
|
is_cv_reference_wrapper_check(
|
|
::Boost::reference_wrapper<U> const volatile*
|
|
);
|
|
|
|
::Boost::parameter::aux::no_tag is_cv_reference_wrapper_check(...);
|
|
}}} // namespace Boost::parameter::aux
|
|
|
|
#include <ActivBoost/parameter/config.hpp>
|
|
|
|
#if !defined(ACTIV_BOOST_NO_CXX11_HDR_FUNCTIONAL)
|
|
#include <functional>
|
|
|
|
namespace Boost { namespace parameter { namespace aux {
|
|
|
|
// Support for std::ref(x) -- Cromwell D. Enage
|
|
template <typename U>
|
|
::Boost::parameter::aux::yes_tag
|
|
is_cv_reference_wrapper_check(
|
|
::std::reference_wrapper<U> const volatile*
|
|
);
|
|
}}} // namespace Boost::parameter::aux
|
|
#endif
|
|
|
|
#include <ActivBoost/parameter/aux_/preprocessor/nullptr.hpp>
|
|
|
|
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11) && !( \
|
|
ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_MSVC, >= 1900) && \
|
|
ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_MSVC, < 1910) \
|
|
)
|
|
#include <ActivBoost/mp11/integral.hpp>
|
|
#include <ActivBoost/mp11/utility.hpp>
|
|
#include <type_traits>
|
|
#else // !defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11) || MSVC-14.0
|
|
#include <ActivBoost/mpl/bool.hpp>
|
|
#include <ActivBoost/type_traits/remove_reference.hpp>
|
|
#if !ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564)) && \
|
|
!ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_GCC, < 40000)
|
|
#include <ActivBoost/mpl/eval_if.hpp>
|
|
#endif
|
|
#endif // ACTIV_BOOST_PARAMETER_CAN_USE_MP11 && not MSVC-14.0
|
|
|
|
namespace Boost { namespace parameter { namespace aux {
|
|
|
|
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11) && !( \
|
|
ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_MSVC, >= 1900) && \
|
|
ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_MSVC, < 1910) \
|
|
)
|
|
// This metafunction returns mp11::mp_true if T is of type
|
|
// reference_wrapper<U> cv.
|
|
template <typename T>
|
|
using is_cv_reference_wrapper = ::Boost::mp11::mp_bool<
|
|
sizeof(
|
|
::Boost::parameter::aux::is_cv_reference_wrapper_check(
|
|
static_cast<
|
|
typename ::std::remove_reference<T>::type*
|
|
>(ACTIV_BOOST_PARAMETER_AUX_PP_NULLPTR)
|
|
)
|
|
) == sizeof(::Boost::parameter::aux::yes_tag)
|
|
>;
|
|
|
|
// Needed for unwrap_cv_reference below. T might be const, so
|
|
// mp_eval_if<> might fail because of deriving from T const on EDG.
|
|
template <typename T>
|
|
using unwrap_cv_reference_impl = typename ::std::remove_reference<T>::type;
|
|
|
|
// Produces the unwrapped type to hold a reference to in
|
|
// tagged_argument<>. Can't use Boost::unwrap_reference<> here
|
|
// because it doesn't handle the case where T = reference_wrapper<U> cv.
|
|
template <typename T>
|
|
using unwrap_cv_reference = ::Boost::mp11::mp_eval_if<
|
|
::Boost::parameter::aux::is_cv_reference_wrapper<T>
|
|
, ::Boost::parameter::aux::unwrap_cv_reference_impl<T>
|
|
, ::std::remove_reference
|
|
, T
|
|
>;
|
|
#else // !defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11) || MSVC-14.0
|
|
// This metafunction returns mpl::true_ if T is of type
|
|
// reference_wrapper<U> cv.
|
|
template <typename T>
|
|
struct is_cv_reference_wrapper
|
|
{
|
|
ACTIV_BOOST_STATIC_CONSTANT(
|
|
bool, value = (
|
|
sizeof(
|
|
::Boost::parameter::aux::is_cv_reference_wrapper_check(
|
|
static_cast<
|
|
typename ::Boost::remove_reference<T>::type*
|
|
>(ACTIV_BOOST_PARAMETER_AUX_PP_NULLPTR)
|
|
)
|
|
) == sizeof(::Boost::parameter::aux::yes_tag)
|
|
)
|
|
);
|
|
|
|
typedef Boost::mpl::bool_<
|
|
#if ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564))
|
|
is_cv_reference_wrapper::
|
|
#endif
|
|
value> type;
|
|
};
|
|
|
|
#if ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564)) || \
|
|
ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_GCC, < 40000)
|
|
template <
|
|
typename T
|
|
, typename = typename ::Boost::parameter::aux
|
|
::is_cv_reference_wrapper<T>::type
|
|
>
|
|
struct unwrap_cv_reference : ::Boost::remove_reference<T>
|
|
{
|
|
};
|
|
|
|
template <typename T>
|
|
struct unwrap_cv_reference<T const,::Boost::mpl::false_>
|
|
{
|
|
typedef T const type;
|
|
};
|
|
|
|
template <typename T>
|
|
struct unwrap_cv_reference<T,::Boost::mpl::true_> : T
|
|
{
|
|
};
|
|
#else // no Borland or GCC 3- workarounds needed
|
|
// Needed for unwrap_cv_reference below. T might be const, so
|
|
// eval_if<> might fail because of deriving from T const on EDG.
|
|
template <typename T>
|
|
struct unwrap_cv_reference_impl : ::Boost::remove_reference<T>::type
|
|
{
|
|
};
|
|
|
|
// Produces the unwrapped type to hold a reference to in
|
|
// tagged_argument<>. Can't use Boost::unwrap_reference<> here
|
|
// because it doesn't handle the case where T = reference_wrapper<U> cv.
|
|
template <typename T>
|
|
struct unwrap_cv_reference
|
|
: ::Boost::mpl::eval_if<
|
|
::Boost::parameter::aux::is_cv_reference_wrapper<T>
|
|
, ::Boost::parameter::aux::unwrap_cv_reference_impl<T>
|
|
, ::Boost::remove_reference<T>
|
|
>
|
|
{
|
|
};
|
|
#endif // Borland or GCC 3- workarounds needed
|
|
#endif // ACTIV_BOOST_PARAMETER_CAN_USE_MP11 && not MSVC-14.0
|
|
}}} // namespace Boost::parameter::aux
|
|
|
|
#endif // include guard
|
|
|