Reinstate MP11 support for ArgumentPacks

Argument packs qualify as Boost.MP11-style maps as well as MPL sequences.  These maps store the keyword tag types as their keys.
This commit is contained in:
CromwellEnage
2019-01-21 01:14:59 -05:00
parent 2b796a8746
commit 7b2d3f6e41
12 changed files with 330 additions and 55 deletions

View File

@@ -400,7 +400,13 @@ href="../../../mpl/doc/refmanual/associative-sequence.html"><span
class="concept">MPL Associative Sequence</span></a> consisting of the <a
class="reference internal" href="#keyword-tag-type">keyword tag type</a>s in
its <a class="reference internal" href="#tagged-reference">tagged
reference</a>s. The <a
reference</a>s. If <a class="reference internal"
href="#boost-parameter-can-use-mp11"><tt class="docutils literal"
>BOOST_PARAMETER_CAN_USE_MP11</tt></a> is defined, then every <span
class="concept">ArgumentPack</span> is also a valid <a
class="reference external" href="../../../mp11/doc/html/mp11.html"
>Boost.MP11</a> map whose keys are <a class="reference internal"
href="#keyword-tag-type">keyword tag type</a>s. The <a
class="reference external" href="../../test/singular.cpp"
>test/singular.cpp</a>, <a class="reference external"
href="../../test/compose.cpp">test/compose.cpp</a>, and <a

View File

@@ -175,8 +175,10 @@ library.
An |ArgumentPack| is a collection of |tagged reference|\ s to the actual
arguments passed to a function. Every |ArgumentPack| is also a valid `MPL
Forward Sequence`_ and `MPL Associative Sequence`_ consisting of the |keyword
tag type|\ s in its |tagged reference|\ s. The |singular_cpp|_,
|compose_cpp|_, and |mpl_cpp|_ test programs demonstrate this functionality.
tag type|\ s in its |tagged reference|\ s. If |BOOST_PARAMETER_CAN_USE_MP11|
is defined, then every |ArgumentPack| is also a valid `Boost.MP11`_ map whose
keys are |keyword tag type|\ s. The |singular_cpp|_, |compose_cpp|_, and
|mpl_cpp|_ test programs demonstrate this functionality.
.. _`MPL Forward Sequence`: ../../../mpl/doc/refmanual/forward-sequence.html
.. _`MPL Associative Sequence`: ../../../mpl/doc/refmanual/associative-sequence.html

View File

@@ -197,11 +197,8 @@ namespace boost { namespace parameter { namespace aux {
, ::boost::parameter::aux::get_reference<TaggedArg>
>::type;
using value_type = ::boost::mp11::mp_if<
_holds_maybe
, reference
, typename TaggedArg::value_type
>;
using value_type = ::boost::mp11
::mp_if<_holds_maybe,reference,typename TaggedArg::value_type>;
#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
typedef typename ::boost::mpl::eval_if<
_holds_maybe
@@ -418,8 +415,8 @@ namespace boost { namespace parameter { namespace aux {
inline BOOST_CONSTEXPR reference
operator[](::boost::parameter::keyword<key_type> const&) const
{
#if defined(BOOST_PARAMETER_CAN_USE_MP11) && \
!defined(BOOST_NO_CXX14_CONSTEXPR)
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(!_holds_maybe::value, "must not hold maybe");
#elif !( \
BOOST_WORKAROUND(BOOST_GCC, >= 40700) && \
@@ -427,6 +424,7 @@ namespace boost { namespace parameter { namespace aux {
) && !BOOST_WORKAROUND(BOOST_GCC, >= 50000) && \
!BOOST_WORKAROUND(BOOST_MSVC, < 1910)
BOOST_MPL_ASSERT_NOT((_holds_maybe));
#endif
#endif
return this->arg.get_value();
}
@@ -455,8 +453,8 @@ namespace boost { namespace parameter { namespace aux {
BOOST_PARAMETER_lazy_default_fallback<key_type,Default> const&
) const
{
#if defined(BOOST_PARAMETER_CAN_USE_MP11) && \
!defined(BOOST_NO_CXX14_CONSTEXPR)
#if !defined(BOOST_NO_CXX14_CONSTEXPR)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(!_holds_maybe::value, "must not hold maybe");
#elif !( \
BOOST_WORKAROUND(BOOST_GCC, >= 40700) && \
@@ -464,6 +462,7 @@ namespace boost { namespace parameter { namespace aux {
) && !BOOST_WORKAROUND(BOOST_GCC, >= 50000) && \
!BOOST_WORKAROUND(BOOST_MSVC, < 1910)
BOOST_MPL_ASSERT_NOT((_holds_maybe));
#endif
#endif
return this->arg.get_value();
}
@@ -1028,6 +1027,131 @@ namespace boost { namespace parameter { namespace aux {
#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
namespace boost { namespace parameter { namespace aux {
template <typename ...ArgTuples>
struct arg_list_cons;
template <>
struct arg_list_cons<>
{
using type = ::boost::parameter::aux::empty_arg_list;
};
template <typename ArgTuple0, typename ...Tuples>
struct arg_list_cons<ArgTuple0,Tuples...>
{
using type = ::boost::parameter::aux::arg_list<
typename ArgTuple0::tagged_arg
, typename ::boost::parameter::aux::arg_list_cons<Tuples...>::type
, typename ArgTuple0::emits_errors
>;
};
template <
typename Keyword
, typename TaggedArg
, typename EmitsErrors = ::boost::mp11::mp_true
>
struct flat_like_arg_tuple
{
using tagged_arg = TaggedArg;
using emits_errors = EmitsErrors;
};
template <typename ...ArgTuples>
class flat_like_arg_list
: public ::boost::parameter::aux::arg_list_cons<ArgTuples...>::type
{
using _base_type = typename ::boost::parameter::aux
::arg_list_cons<ArgTuples...>::type;
public:
inline BOOST_CONSTEXPR flat_like_arg_list(
typename _base_type::tagged_arg const& head
, typename _base_type::tail_type const& tail
) : _base_type(head, tail)
{
}
template <typename ...Args>
inline BOOST_CONSTEXPR flat_like_arg_list(Args&&... args)
: _base_type(::std::forward<Args>(args)...)
{
}
using _base_type::operator[];
using _base_type::satisfies;
// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
template <typename TaggedArg>
inline BOOST_CONSTEXPR ::boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux::flat_like_arg_tuple<
typename TaggedArg::base_type::key_type
, typename TaggedArg::base_type
>
, ArgTuples...
>
operator,(TaggedArg const& x) const
{
return ::boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux::flat_like_arg_tuple<
typename TaggedArg::base_type::key_type
, typename TaggedArg::base_type
>
, ArgTuples...
>(
static_cast<typename TaggedArg::base_type const&>(x)
, static_cast<_base_type const&>(*this)
);
}
};
template <>
class flat_like_arg_list<>
: public ::boost::parameter::aux::empty_arg_list
{
using _base_type = ::boost::parameter::aux::empty_arg_list;
public:
template <typename ...Args>
inline BOOST_CONSTEXPR flat_like_arg_list(Args&&... args)
: _base_type(::std::forward<Args>(args)...)
{
}
using _base_type::operator[];
using _base_type::satisfies;
// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
template <typename TaggedArg>
inline BOOST_CONSTEXPR ::boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux::flat_like_arg_tuple<
typename TaggedArg::base_type::key_type
, typename TaggedArg::base_type
>
>
operator,(TaggedArg const& x) const
{
return ::boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux::flat_like_arg_tuple<
typename TaggedArg::base_type::key_type
, typename TaggedArg::base_type
>
>(
static_cast<typename TaggedArg::base_type const&>(x)
, static_cast<_base_type const&>(*this)
);
}
};
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_CAN_USE_MP11
#include <boost/mpl/iterator_tags.hpp>
namespace boost { namespace parameter { namespace aux {

View File

@@ -1,4 +1,5 @@
// Copyright David Abrahams, Daniel Wallin 2003.
// Copyright Cromwell D. Enage 2018.
// 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)
@@ -50,6 +51,21 @@ namespace boost { namespace parameter { namespace aux {
namespace boost { namespace parameter { namespace aux {
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
template <typename ArgumentPack, typename TaggedArg, typename EmitsErrors>
struct append_to_make_arg_list
{
using type = ::boost::mp11::mp_push_front<
ArgumentPack
, ::boost::parameter::aux::flat_like_arg_tuple<
typename TaggedArg::key_type
, TaggedArg
, EmitsErrors
>
>;
};
#endif
// Borland needs the insane extra-indirection workaround below so that
// it doesn't magically drop the const qualifier from the argument type.
template <
@@ -238,12 +254,12 @@ namespace boost { namespace parameter { namespace aux {
#endif
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
using _argument_pack = ::boost::mp11::mp_if<
using _argument_pack = typename ::boost::mp11::mp_if<
::std::is_same<_tagged,::boost::parameter::void_>
, ArgumentPack
, ::boost::mp11::mp_identity<ArgumentPack>
, ::boost::parameter::aux
::arg_list<_tagged,ArgumentPack,EmitsErrors>
>;
::append_to_make_arg_list<ArgumentPack,_tagged,EmitsErrors>
>::type;
#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
typedef typename ::boost::mpl::if_<
::boost::is_same<_tagged,::boost::parameter::void_>
@@ -402,7 +418,11 @@ namespace boost { namespace parameter { namespace aux {
, ::boost::mpl::true_
#endif
, ::boost::parameter::aux::set0
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
, ::boost::parameter::aux::flat_like_arg_list<>
#else
, ::boost::parameter::aux::empty_arg_list
#endif
, ::boost::parameter::void_
, EmitsErrors
#if defined(BOOST_PARAMETER_CAN_USE_MP11)

View File

@@ -24,17 +24,22 @@ namespace boost { namespace parameter { namespace aux {
template <typename Keyword, typename Arg>
struct tag_if_lvalue_reference
{
typedef ::boost::parameter::aux::tagged_argument<
Keyword
, typename ::boost::parameter::aux::unwrap_cv_reference<Arg>::type
> type;
using type = ::boost::parameter::aux::tagged_argument_list_of_1<
::boost::parameter::aux::tagged_argument<
Keyword
, typename ::boost::parameter::aux
::unwrap_cv_reference<Arg>::type
>
>;
};
template <typename Keyword, typename Arg>
struct tag_if_scalar
{
typedef ::boost::parameter::aux
::tagged_argument<Keyword,typename ::std::add_const<Arg>::type> type;
using type = ::boost::parameter::aux::tagged_argument_list_of_1<
::boost::parameter::aux
::tagged_argument<Keyword,typename ::std::add_const<Arg>::type>
>;
};
template <typename Keyword, typename Arg>
@@ -42,7 +47,9 @@ namespace boost { namespace parameter { namespace aux {
::std::is_scalar<typename ::std::remove_const<Arg>::type>
, ::boost::parameter::aux::tag_if_scalar<Keyword,Arg>
, ::boost::mp11::mp_identity<
::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
::boost::parameter::aux::tagged_argument_list_of_1<
::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
>
>
>;
@@ -84,12 +91,27 @@ namespace boost { namespace parameter { namespace aux {
, ::boost::parameter::aux::is_cv_reference_wrapper<ActualArg>
>::type
, ::boost::mpl::identity<
::boost::parameter::aux::tagged_argument<Keyword,Arg>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
::boost::parameter::aux::tagged_argument_list_of_1<
#endif
::boost::parameter::aux::tagged_argument<Keyword,Arg>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
>
#endif
>
, ::boost::mpl::if_<
::boost::is_scalar<MutArg>
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
, ::boost::parameter::aux::tagged_argument_list_of_1<
::boost::parameter::aux::tagged_argument<Keyword,ConstArg>
>
, ::boost::parameter::aux::tagged_argument_list_of_1<
::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
>
#else
, ::boost::parameter::aux::tagged_argument<Keyword,ConstArg>
, ::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
#endif
>
>::type type;
};

View File

@@ -219,6 +219,7 @@ namespace boost { namespace parameter { namespace aux {
#endif
};
#if !defined(BOOST_PARAMETER_CAN_USE_MP11)
// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
template <typename Keyword2, typename Arg2>
@@ -226,7 +227,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument<Keyword,Arg>
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux::tagged_argument<Keyword2,Arg2>
>
>
>
operator,(
::boost::parameter::aux
@@ -237,7 +238,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument<Keyword,Arg>
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux::tagged_argument<Keyword2,Arg2>
>
>
>(
*this
, ::boost::parameter::aux::arg_list<
@@ -251,7 +252,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument<Keyword,Arg>
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux::tagged_argument_rref<Keyword2,Arg2>
>
>
>
operator,(
::boost::parameter::aux
@@ -262,7 +263,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument<Keyword,Arg>
, boost::parameter::aux::arg_list<
boost::parameter::aux::tagged_argument_rref<Keyword2,Arg2>
>
>
>(
*this
, ::boost::parameter::aux::arg_list<
@@ -271,6 +272,7 @@ namespace boost { namespace parameter { namespace aux {
>(x, ::boost::parameter::aux::empty_arg_list())
);
}
#endif // BOOST_PARAMETER_CAN_USE_MP11
// Accessor interface.
inline BOOST_CONSTEXPR reference get_value() const
@@ -428,6 +430,7 @@ namespace boost { namespace parameter { namespace aux {
#endif
};
#if !defined(BOOST_PARAMETER_CAN_USE_MP11)
// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
template <typename Keyword2, typename Arg2>
@@ -435,7 +438,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux::tagged_argument<Keyword2,Arg2>
>
>
>
operator,(
::boost::parameter::aux
@@ -446,7 +449,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux::tagged_argument<Keyword2,Arg2>
>
>
>(
*this
, ::boost::parameter::aux::arg_list<
@@ -460,7 +463,7 @@ namespace boost { namespace parameter { namespace aux {
::boost::parameter::aux::tagged_argument_rref<Keyword,Arg>
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux::tagged_argument_rref<Keyword2,Arg2>
>
>
>
operator,(
::boost::parameter::aux
@@ -472,7 +475,7 @@ namespace boost { namespace parameter { namespace aux {
, ::boost::parameter::aux::arg_list<
::boost::parameter::aux
::tagged_argument_rref<Keyword2,Arg2>
>
>
>(
*this
, ::boost::parameter::aux::arg_list<
@@ -483,6 +486,7 @@ namespace boost { namespace parameter { namespace aux {
>(x, ::boost::parameter::aux::empty_arg_list())
);
}
#endif // BOOST_PARAMETER_CAN_USE_MP11
// Accessor interface.
inline BOOST_CONSTEXPR reference get_value() const
@@ -568,10 +572,8 @@ namespace boost { namespace parameter { namespace aux {
// MPL sequence support
// Convenience for users
typedef ::boost::parameter::aux::tagged_argument_rref<
Keyword
, Arg
> type;
typedef ::boost::parameter::aux
::tagged_argument_rref<Keyword,Arg> type;
// For the benefit of iterators
typedef ::boost::parameter::aux::empty_arg_list tail_type;
// For dispatching to sequence intrinsics
@@ -833,5 +835,60 @@ namespace boost { namespace parameter { namespace aux {
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
namespace boost { namespace parameter { namespace aux {
template <typename TaggedArg>
struct tagged_argument_list_of_1 : public TaggedArg
{
using base_type = TaggedArg;
inline explicit BOOST_CONSTEXPR tagged_argument_list_of_1(
typename base_type::reference x
) : base_type(static_cast<typename base_type::reference>(x))
{
}
inline BOOST_CONSTEXPR tagged_argument_list_of_1(
tagged_argument_list_of_1 const& copy
) : base_type(static_cast<base_type const&>(copy))
{
}
using base_type::operator[];
using base_type::satisfies;
template <typename TA2>
inline BOOST_CONSTEXPR ::boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux
::flat_like_arg_tuple<typename TaggedArg::key_type,TaggedArg>
, ::boost::parameter::aux::flat_like_arg_tuple<
typename TA2::base_type::key_type
, typename TA2::base_type
>
>
operator,(TA2 const& x) const
{
return boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux
::flat_like_arg_tuple<typename TaggedArg::key_type,TaggedArg>
, ::boost::parameter::aux::flat_like_arg_tuple<
typename TA2::base_type::key_type
, typename TA2::base_type
>
>(
static_cast<base_type const&>(*this)
, ::boost::parameter::aux::arg_list<typename TA2::base_type>(
static_cast<typename TA2::base_type const&>(x)
, ::boost::parameter::aux::empty_arg_list()
)
);
}
};
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_CAN_USE_MP11
#endif // include guard

View File

@@ -23,6 +23,16 @@ namespace boost { namespace parameter { namespace aux {
struct tagged_argument_rref;
}}} // namespace boost::parameter::aux
#endif
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
namespace boost { namespace parameter { namespace aux {
template <typename TaggedArg>
struct tagged_argument_list_of_1;
}}} // namespace boost::parameter::aux
#endif
#endif // include guard

View File

@@ -22,6 +22,18 @@ namespace boost { namespace parameter {
namespace boost { namespace parameter { namespace aux {
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
template <typename ...TaggedArgs>
struct compose_arg_list
{
using type = ::boost::parameter::aux::flat_like_arg_list<
::boost::parameter::aux::flat_like_arg_tuple<
typename TaggedArgs::base_type::key_type
, typename TaggedArgs::base_type
>...
>;
};
#else // !defined(BOOST_PARAMETER_CAN_USE_MP11)
template <typename TaggedArg0, typename ...TaggedArgs>
struct compose_arg_list;
@@ -40,6 +52,7 @@ namespace boost { namespace parameter { namespace aux {
::compose_arg_list<TaggedArgs...>::type
> type;
};
#endif // BOOST_PARAMETER_CAN_USE_MP11
}}} // namespace boost::parameter::aux
#include <boost/parameter/are_tagged_arguments.hpp>

View File

@@ -36,7 +36,7 @@ namespace param {
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/list.hpp>
#include <boost/mp11/map.hpp>
#include <type_traits>
@@ -58,7 +58,7 @@ namespace test {
template <typename ArgPack>
A(ArgPack const& args) : i(args[param::a0]), j(args[param::a1])
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
boost::mp11::mp_map_contains<ArgPack,param::tag::a0>::value
, "param::tag::a0 must be in ArgPack"
@@ -248,7 +248,7 @@ namespace test {
, j(args[param::_lr])
, k(args[param::_lrc])
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value
, "param::tag::lrc must be in ArgPack"
@@ -453,7 +453,7 @@ namespace test {
, j(args[param::_lr])
, k(args[param::_lrc])
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
boost::mp11::mp_map_contains<ArgPack,param::tag::lrc>::value
, "param::tag::lrc must be in ArgPack"
@@ -470,7 +470,7 @@ namespace test {
, "param::tag::lrc must be found in ArgPack"
);
static_assert(
std::is_same<
!std::is_same<
boost::mp11::mp_map_find<ArgPack,param::tag::lr>
, void
>::value

View File

@@ -10,7 +10,8 @@
#include <boost/parameter/config.hpp>
#include "basics.hpp"
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/map.hpp>
#include <boost/mp11/algorithm.hpp>
#else
#include <boost/mpl/bool.hpp>
@@ -43,7 +44,7 @@ namespace test {
template <typename T>
static bool check_not_present(T const&)
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
std::is_same<T,test::not_present_tag>::value
, "T == test::not_present_tag"
@@ -75,7 +76,7 @@ namespace test {
}
template <typename K>
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
void operator()(K&&) const
#else
void operator()(K) const
@@ -90,8 +91,10 @@ namespace test {
template <typename E, typename A>
void check0(E const& e, A const& args)
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
boost::mp11::mp_for_each<E>(test::assert_expected<E,A>(e, args));
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
boost::mp11::mp_for_each<boost::mp11::mp_map_keys<E> >(
test::assert_expected<E,A>(e, args)
);
#else
boost::mpl::for_each<E>(test::assert_expected<E,A>(e, args));
#endif

View File

@@ -1,4 +1,5 @@
// Copyright David Abrahams 2006.
// Copyright Cromwell D. Enage 2019.
// 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)
@@ -13,15 +14,29 @@
#include <boost/type_traits/add_pointer.hpp>
#include "basics.hpp"
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/list.hpp>
#include <boost/mp11/map.hpp>
#include <boost/mp11/algorithm.hpp>
#include <boost/mp11/mpl.hpp>
#endif
namespace test {
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
template <typename Map>
struct assert_in_map
{
template <typename T>
void operator()(T&&)
{
static_assert(
boost::mp11::mp_map_contains<Map,T>::value
, "T must be in Map"
);
}
};
template <typename Set>
struct assert_in_set_0
{
@@ -49,7 +64,7 @@ namespace test {
template <typename Expected, typename Args>
void f_impl(Args const& p BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
boost::mp11::mp_size<Expected>::value == boost::mp11::mp_size<
Args
@@ -57,8 +72,10 @@ namespace test {
, "mp_size<Expected>::value == mp_size<Args>::value"
);
boost::mp11::mp_for_each<Args>(test::assert_in_set_0<Expected>());
boost::mp11::mp_for_each<Expected>(test::assert_in_set_0<Args>());
boost::mp11::mp_for_each<boost::mp11::mp_map_keys<Args> >(
test::assert_in_set_0<Expected>()
);
boost::mp11::mp_for_each<Expected>(test::assert_in_map<Args>());
#endif
BOOST_MPL_ASSERT_RELATION(
@@ -128,7 +145,7 @@ namespace test {
typedef test::tag::value value_;
typedef test::tag::index index_;
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
test::f<
boost::mp11::mp_list<tester_,name_,value_,index_>
>(1, 2, 3, 4);

View File

@@ -1,4 +1,5 @@
// Copyright Daniel Wallin 2005.
// Copyright Cromwell D. Enage 2019.
// 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)
@@ -31,7 +32,7 @@ namespace test {
#include <boost/mpl/assert.hpp>
#include <boost/core/lightweight_test.hpp>
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
#include <boost/mp11/map.hpp>
#include <type_traits>
#endif
@@ -41,7 +42,7 @@ namespace test {
template <typename ArgumentPack, typename K, typename T>
void check0(ArgumentPack const& p, K const& kw, T const& value)
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
!boost::mp11::mp_map_contains<ArgumentPack,test::tag::z>::value
, "test::tag::z must not be in ArgumentPack"
@@ -77,7 +78,7 @@ namespace test {
template <typename ArgumentPack, typename K, typename T>
void check1(ArgumentPack const& p, K const& kw, T const& value)
{
#if 0//defined(BOOST_PARAMETER_CAN_USE_MP11)
#if defined(BOOST_PARAMETER_CAN_USE_MP11)
static_assert(
boost::mp11::mp_map_contains<ArgumentPack,typename K::tag>::value
, "typename K::tag must be in ArgumentPack"