Files
externals/linux/include/ActivBoost/parameter/parameters.hpp
T
2023-12-15 13:15:08 -05:00

601 lines
22 KiB
C++

// Copyright David Abrahams, Daniel Wallin 2003.
// 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_PARAMETERS_031014_HPP
#define ACTIV_BOOST_PARAMETERS_031014_HPP
#include <ActivBoost/parameter/config.hpp>
#if defined(ACTIV_BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
namespace Boost { namespace parameter { namespace aux {
// The make_arg_list<> metafunction produces a reversed arg_list,
// so pass the arguments to the arg_list constructor reversed in turn.
template <typename ArgList, typename ...Args>
struct arg_list_factory;
}}} // namespace Boost::parameter::aux
#include <ActivBoost/parameter/aux_/arg_list.hpp>
#include <utility>
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
#include <ActivBoost/mp11/utility.hpp>
#include <type_traits>
#else
#include <ActivBoost/mpl/if.hpp>
#include <ActivBoost/type_traits/is_same.hpp>
#endif
namespace Boost { namespace parameter { namespace aux {
// TODO: Reduce template code bloat. -- Cromwell D. Enage
template <typename ArgList>
struct arg_list_factory<ArgList>
{
template <typename ...ReversedArgs>
static inline ACTIV_BOOST_CONSTEXPR ArgList
reverse(ReversedArgs&&... reversed_args)
{
return ArgList(
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
::Boost::mp11::mp_if<
::std::is_same<
#else
typename ::Boost::mpl::if_<
::Boost::is_same<
#endif
typename ArgList::tagged_arg::value_type
, ::Boost::parameter::void_
>
, ::Boost::parameter::aux::value_type_is_void
, ::Boost::parameter::aux::value_type_is_not_void
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
>()
#else
>::type()
#endif
, ::std::forward<ReversedArgs>(reversed_args)...
);
}
};
template <typename ArgList, typename A0, typename ...Args>
struct arg_list_factory<ArgList,A0,Args...>
{
template <typename ...ReversedArgs>
static inline ACTIV_BOOST_CONSTEXPR ArgList
reverse(A0&& a0, Args&&... args, ReversedArgs&&... reversed_args)
{
return ::Boost::parameter::aux
::arg_list_factory<ArgList,Args...>::reverse(
::std::forward<Args>(args)...
, ::std::forward<A0>(a0)
, ::std::forward<ReversedArgs>(reversed_args)...
);
}
};
}}} // namespace Boost::parameter::aux
#include <ActivBoost/parameter/aux_/void.hpp>
#include <ActivBoost/parameter/aux_/pack/make_arg_list.hpp>
#include <ActivBoost/parameter/aux_/pack/make_parameter_spec_items.hpp>
#include <ActivBoost/parameter/aux_/pack/tag_keyword_arg.hpp>
#include <ActivBoost/parameter/aux_/pack/tag_template_keyword_arg.hpp>
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
#include <ActivBoost/mp11/integral.hpp>
#include <ActivBoost/mp11/list.hpp>
#else
#include <ActivBoost/mpl/bool.hpp>
#include <ActivBoost/mpl/pair.hpp>
#include <ActivBoost/mpl/identity.hpp>
#endif
#if !defined(ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE)
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
//#include <ActivBoost/mp11/mpl.hpp>
#define ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE ::Boost::mp11::mp_list
#else
#include <ActivBoost/fusion/container/list/list_fwd.hpp>
// Newer versions of MSVC fail on the evaluate_category and
// preprocessor_eval_category test programs when parameters uses
// Boost::fusion::list.
// -- Cromwell D. Enage
#if defined(ACTIV_BOOST_FUSION_HAS_VARIADIC_LIST) && ( \
!defined(ACTIV_BOOST_MSVC) || (ACTIV_BOOST_MSVC < 1800) \
)
#include <ActivBoost/fusion/container/list.hpp>
#include <ActivBoost/fusion/mpl.hpp>
#define ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE ::Boost::fusion::list
#else
#include <ActivBoost/fusion/container/deque/deque_fwd.hpp>
#if defined(ACTIV_BOOST_FUSION_HAS_VARIADIC_DEQUE)
#include <ActivBoost/fusion/container/deque.hpp>
#include <ActivBoost/fusion/mpl.hpp>
#define ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE ::Boost::fusion::deque
#else
#include <ActivBoost/mpl/vector.hpp>
#define ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE ::Boost::mpl::vector
#endif // ACTIV_BOOST_FUSION_HAS_VARIADIC_DEQUE
#endif // ACTIV_BOOST_FUSION_HAS_VARIADIC_LIST
#endif // ACTIV_BOOST_PARAMETER_CAN_USE_MP11
#endif // ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE
namespace Boost { namespace parameter {
template <typename ...Spec>
struct parameters
{
typedef ACTIV_BOOST_PARAMETER_VARIADIC_MPL_SEQUENCE<Spec...> parameter_spec;
typedef typename ::Boost::parameter::aux
::make_deduced_list<parameter_spec>::type deduced_list;
// If the elements of NamedList match the criteria of overload
// resolution, returns a type which can be constructed from
// parameters. Otherwise, this is not a valid metafunction
// (no nested ::type).
template <typename ArgumentPackAndError>
struct match_base
#if !defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
: ::Boost::mpl::if_<
typename ::Boost::parameter::aux::match_parameters_base_cond<
ArgumentPackAndError
, parameter_spec
>::type
, ::Boost::mpl::identity<
::Boost::parameter::parameters<Spec...>
>
, ::Boost::parameter::void_
>
#endif
{
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
using type = ::Boost::mp11::mp_if<
typename ::Boost::parameter::aux::match_parameters_base_cond<
ArgumentPackAndError
, parameter_spec
>::type
, ::Boost::mp11::mp_identity<
::Boost::parameter::parameters<Spec...>
>
, ::Boost::parameter::void_
>;
#endif
};
// Specializations are to be used as an optional argument
// to eliminate overloads via SFINAE.
template <typename ...Args>
struct match
: ::Boost::parameter::parameters<Spec...>
::ACTIV_BOOST_NESTED_TEMPLATE match_base<
typename ::Boost::parameter::aux::make_arg_list<
typename ::Boost::parameter::aux
::make_parameter_spec_items<parameter_spec,Args...>::type
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg
// Don't emit errors when doing SFINAE.
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
, ::Boost::mp11::mp_false
#else
, ::Boost::mpl::false_
#endif
>::type
>::type
{
};
// Metafunction that returns an ArgumentPack.
template <typename ...Args>
struct bind
#if !defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
: ::Boost::mpl::first<
typename ::Boost::parameter::aux::make_arg_list<
typename ::Boost::parameter::aux
::make_parameter_spec_items<parameter_spec,Args...>::type
, deduced_list
, ::Boost::parameter::aux::tag_template_keyword_arg
>::type
>
#endif
{
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
using type = ::Boost::mp11::mp_at_c<
typename ::Boost::parameter::aux::make_arg_list<
typename ::Boost::parameter::aux
::make_parameter_spec_items<parameter_spec,Args...>::type
, deduced_list
, ::Boost::parameter::aux::tag_template_keyword_arg
>::type
, 0
>;
#endif
};
// The function call operator is used to build an arg_list that
// labels the positional parameters and maintains whatever other
// tags may have been specified by the caller.
inline ::Boost::parameter::aux::empty_arg_list operator()() const
{
return ::Boost::parameter::aux::empty_arg_list();
}
template <typename A0, typename ...Args>
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
inline ::Boost::mp11::mp_at_c<
#else
inline typename ::Boost::mpl::first<
#endif
typename ::Boost::parameter::aux::make_arg_list<
typename ::Boost::parameter::aux
::make_parameter_spec_items<parameter_spec,A0,Args...>::type
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg
>::type
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
, 0
>
#else
>::type
#endif
operator()(A0&& a0, Args&& ...args) const
{
typedef typename ::Boost::parameter::aux::make_arg_list<
typename ::Boost::parameter::aux
::make_parameter_spec_items<parameter_spec,A0,Args...>::type
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg
>::type list_error_pair;
#if defined(ACTIV_BOOST_PARAMETER_CAN_USE_MP11)
using result_type = ::Boost::mp11::mp_at_c<list_error_pair,0>;
using error = ::Boost::mp11::mp_at_c<list_error_pair,1>;
#else
typedef typename ::Boost::mpl
::first<list_error_pair>::type result_type;
typedef typename ::Boost::mpl
::second<list_error_pair>::type error;
#endif
error();
return ::Boost::parameter::aux
::arg_list_factory<result_type,A0,Args...>::reverse(
::std::forward<A0>(a0)
, ::std::forward<Args>(args)...
);
}
};
}} // namespace Boost::parameter
#else // !defined(ACTIV_BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
#include <ActivBoost/parameter/aux_/void.hpp>
#include <ActivBoost/parameter/aux_/arg_list.hpp>
#include <ActivBoost/parameter/aux_/pack/make_arg_list.hpp>
#include <ActivBoost/parameter/aux_/pack/make_items.hpp>
#include <ActivBoost/parameter/aux_/pack/make_deduced_items.hpp>
#include <ActivBoost/parameter/aux_/pack/tag_template_keyword_arg.hpp>
#include <ActivBoost/parameter/aux_/preprocessor/binary_seq_for_each.hpp>
#include <ActivBoost/preprocessor/arithmetic/inc.hpp>
#include <ActivBoost/preprocessor/repetition/enum_shifted.hpp>
#include <ActivBoost/preprocessor/repetition/repeat.hpp>
#include <ActivBoost/preprocessor/selection/min.hpp>
#if ( \
ACTIV_BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < \
ACTIV_BOOST_PARAMETER_MAX_ARITY \
)
#include <ActivBoost/parameter/aux_/pack/tag_keyword_arg_ref.hpp>
#include <ActivBoost/mpl/pair.hpp>
#include <ActivBoost/preprocessor/arithmetic/dec.hpp>
#include <ActivBoost/preprocessor/arithmetic/sub.hpp>
#include <ActivBoost/preprocessor/facilities/intercept.hpp>
#include <ActivBoost/preprocessor/iteration/iterate.hpp>
#include <ActivBoost/preprocessor/repetition/enum.hpp>
#include <ActivBoost/preprocessor/repetition/enum_trailing_params.hpp>
#endif
#if !defined(ACTIV_BOOST_NO_SFINAE) && \
!ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x592))
#include <ActivBoost/parameter/aux_/pack/tag_keyword_arg.hpp>
#include <ActivBoost/mpl/bool.hpp>
#include <ActivBoost/mpl/if.hpp>
#include <ActivBoost/mpl/identity.hpp>
#include <ActivBoost/type_traits/is_same.hpp>
#endif
#if ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564))
#include <ActivBoost/preprocessor/repetition/enum_params.hpp>
#else
#include <ActivBoost/preprocessor/repetition/enum_binary_params.hpp>
#endif
#include <ActivBoost/parameter/aux_/preprocessor/no_perfect_forwarding_begin.hpp>
namespace Boost { namespace parameter {
template <
typename PS0
, ACTIV_BOOST_PP_ENUM_SHIFTED(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ACTIV_BOOST_PARAMETER_template_args
, PS
)
>
struct parameters
{
typedef typename ACTIV_BOOST_PARAMETER_build_deduced_list(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ::Boost::parameter::aux::make_deduced_items
, PS
)::type deduced_list;
// If the elements of NamedList match the criteria of overload
// resolution, returns a type which can be constructed from
// parameters. Otherwise, this is not a valid metafunction
// (no nested ::type).
#if !defined(ACTIV_BOOST_NO_SFINAE) && \
!ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x592))
// If NamedList satisfies the PS0, PS1, ..., this is a metafunction
// returning parameters. Otherwise it has no nested ::type.
template <typename ArgumentPackAndError>
struct match_base
: ::Boost::mpl::if_<
// ::Boost::mpl::and_<
// aux::satisfies_requirements_of<NamedList,PS0>
// , ::Boost::mpl::and_<
// aux::satisfies_requirements_of<NamedList,PS1>...
// ..., ::Boost::mpl::true_
// ...> >
typename ACTIV_BOOST_PP_REPEAT(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ACTIV_BOOST_PARAMETER_satisfies_begin
, PS
)
::Boost::is_same<
typename ::Boost::mpl
::second<ArgumentPackAndError>::type
, ::Boost::parameter::void_
>
ACTIV_BOOST_PP_REPEAT(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ACTIV_BOOST_PARAMETER_satisfies_end
, ::Boost::mpl::false_
)::type
, ::Boost::mpl::identity<
::Boost::parameter::parameters<
ACTIV_BOOST_PP_ENUM_PARAMS(ACTIV_BOOST_PARAMETER_MAX_ARITY, PS)
>
>
, ::Boost::parameter::void_
>
{
};
#endif // SFINAE enabled, not Borland
// Specializations are to be used as an optional argument
// to eliminate overloads via SFINAE.
template <
#if ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564))
// Borland simply can't handle default arguments in member
// class templates. People wishing to write portable code can
// explicitly specify ACTIV_BOOST_PARAMETER_MAX_ARITY arguments.
ACTIV_BOOST_PP_ENUM_PARAMS(ACTIV_BOOST_PARAMETER_MAX_ARITY, typename A)
#else
ACTIV_BOOST_PP_ENUM_BINARY_PARAMS(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, typename A
, = ::Boost::parameter::void_ ACTIV_BOOST_PP_INTERCEPT
)
#endif
>
struct match
#if !defined(ACTIV_BOOST_NO_SFINAE) && \
!ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x592))
: ::Boost::parameter::parameters<
ACTIV_BOOST_PP_ENUM_PARAMS(ACTIV_BOOST_PARAMETER_MAX_ARITY, PS)
>::ACTIV_BOOST_NESTED_TEMPLATE match_base<
typename ::Boost::parameter::aux::make_arg_list<
typename ACTIV_BOOST_PARAMETER_build_arg_list(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ::Boost::parameter::aux::make_items
, PS
, A
)::type
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg
// Don't emit errors when doing SFINAE.
, ::Boost::mpl::false_
>::type
>::type
{
};
#else
{
typedef ::Boost::parameter::parameters<
ACTIV_BOOST_PP_ENUM_PARAMS(ACTIV_BOOST_PARAMETER_MAX_ARITY, PS)
> type;
};
#endif // SFINAE enabled, not Borland
// Metafunction that returns an ArgumentPack.
// TODO, bind has to instantiate the error type in the result
// of make_arg_list.
template <
#if ACTIV_BOOST_WORKAROUND(ACTIV_BOOST_BORLANDC, ACTIV_BOOST_TESTED_AT(0x564))
// Borland simply can't handle default arguments in member
// class templates. People wishing to write portable code can
// explicitly specify ACTIV_BOOST_PARAMETER_MAX_ARITY arguments.
ACTIV_BOOST_PP_ENUM_PARAMS(ACTIV_BOOST_PARAMETER_MAX_ARITY, typename A)
#else
ACTIV_BOOST_PP_ENUM_BINARY_PARAMS(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, typename A
, = ::Boost::parameter::void_ ACTIV_BOOST_PP_INTERCEPT
)
#endif
>
struct bind
{
typedef typename ::Boost::parameter::aux::make_arg_list<
typename ACTIV_BOOST_PARAMETER_build_arg_list(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ::Boost::parameter::aux::make_items
, PS
, A
)::type
, deduced_list
, ::Boost::parameter::aux::tag_template_keyword_arg
>::type result;
typedef typename ::Boost::mpl::first<result>::type type;
};
ACTIV_BOOST_PP_REPEAT(
ACTIV_BOOST_PARAMETER_MAX_ARITY
, ACTIV_BOOST_PARAMETER_forward_typedef
, (PS)(parameter_spec)
)
// The function call operator is used to build an arg_list that
// labels the positional parameters and maintains whatever other
// tags may have been specified by the caller.
//
// !!!NOTE!!!
//
// The make_arg_list<> metafunction produces a reversed arg_list,
// so pass the arguments to the arg_list constructor reversed in turn.
inline ::Boost::parameter::aux::empty_arg_list operator()() const
{
return ::Boost::parameter::aux::empty_arg_list();
}
#if (0 < ACTIV_BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY)
ACTIV_BOOST_PP_REPEAT(
ACTIV_BOOST_PP_MIN(
ACTIV_BOOST_PP_INC(ACTIV_BOOST_PARAMETER_MAX_ARITY)
, ACTIV_BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY
)
, ACTIV_BOOST_PARAMETER_AUX_PP_BINARY_SEQ_FOR_EACH_Z
, (ACTIV_BOOST_PARAMETER_function_call_op_overload_R)(_)
)
#if ( \
ACTIV_BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < \
ACTIV_BOOST_PARAMETER_MAX_ARITY \
)
#define ACTIV_BOOST_PP_ITERATION_PARAMS_1 \
(3,( \
ACTIV_BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \
, ACTIV_BOOST_PARAMETER_MAX_ARITY \
, <ActivBoost/parameter/aux_/preprocessor/overloads.hpp> \
))
#include ACTIV_BOOST_PP_ITERATE()
#endif
#else // (0 == ACTIV_BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY)
template <typename A0>
inline typename ::Boost::mpl::first<
typename ::Boost::parameter::aux::make_arg_list<
::Boost::parameter::aux::item<
PS0,A0
>
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg_ref
>::type
>::type
operator()(A0& a0) const
{
typedef typename ::Boost::parameter::aux::make_arg_list<
::Boost::parameter::aux::item<
PS0,A0
>
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg_ref
>::type result;
typedef typename ::Boost::mpl::first<result>::type result_type;
typedef typename ::Boost::mpl::second<result>::type error;
error();
return result_type(
a0
// , void_(), void_(), void_() ...
ACTIV_BOOST_PP_ENUM_TRAILING_PARAMS(
ACTIV_BOOST_PP_SUB(ACTIV_BOOST_PARAMETER_COMPOSE_MAX_ARITY, 1)
, ::Boost::parameter::aux::void_reference() ACTIV_BOOST_PP_INTERCEPT
)
);
}
template <typename A0, typename A1>
inline typename ::Boost::mpl::first<
typename ::Boost::parameter::aux::make_arg_list<
::Boost::parameter::aux::item<
PS0,A0
, ::Boost::parameter::aux::item<
PS1,A1
>
>
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg_ref
>::type
>::type
operator()(A0& a0, A1& a1) const
{
typedef typename ::Boost::parameter::aux::make_arg_list<
::Boost::parameter::aux::item<
PS0,A0
, ::Boost::parameter::aux::item<
PS1,A1
>
>
, deduced_list
, ::Boost::parameter::aux::tag_keyword_arg
>::type result;
typedef typename ::Boost::mpl::first<result>::type result_type;
typedef typename ::Boost::mpl::second<result>::type error;
error();
return result_type(
a1
, a0
// , void_(), void_() ...
ACTIV_BOOST_PP_ENUM_TRAILING_PARAMS(
ACTIV_BOOST_PP_SUB(ACTIV_BOOST_PARAMETER_COMPOSE_MAX_ARITY, 2)
, ::Boost::parameter::aux::void_reference() ACTIV_BOOST_PP_INTERCEPT
)
);
}
#if (2 < ACTIV_BOOST_PARAMETER_MAX_ARITY)
// Higher arities are handled by the preprocessor
#define ACTIV_BOOST_PP_ITERATION_PARAMS_1 \
(3,( \
3 \
, ACTIV_BOOST_PARAMETER_MAX_ARITY \
, <ActivBoost/parameter/aux_/preprocessor/overloads.hpp> \
))
#include ACTIV_BOOST_PP_ITERATE()
#endif
#endif // exponential overloads
};
}} // namespace Boost::parameter
#include <ActivBoost/parameter/aux_/preprocessor/no_perfect_forwarding_end.hpp>
#endif // ACTIV_BOOST_PARAMETER_HAS_PERFECT_FORWARDING
#endif // include guard