From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- src/boost/libs/parameter/test/mpl.cpp | 185 ++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 src/boost/libs/parameter/test/mpl.cpp (limited to 'src/boost/libs/parameter/test/mpl.cpp') diff --git a/src/boost/libs/parameter/test/mpl.cpp b/src/boost/libs/parameter/test/mpl.cpp new file mode 100644 index 00000000..d03ce4d6 --- /dev/null +++ b/src/boost/libs/parameter/test/mpl.cpp @@ -0,0 +1,185 @@ +// 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) + +#include +#include +#include +#include +#include +#include +#include +#include +#include "basics.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include +#include +#include +#include +#endif + +namespace test { + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + template + struct assert_in_map + { + template + void operator()(T&&) + { + static_assert( + boost::mp11::mp_map_contains::value + , "T must be in Map" + ); + } + }; + + template + struct assert_in_set_0 + { + template + void operator()(T&&) + { + static_assert( + boost::mp11::mp_contains::value + , "T must be in Set" + ); + } + }; +#endif + + template + struct assert_in_set_1 + { + template + void operator()(T*) + { + BOOST_MPL_ASSERT((boost::mpl::contains)); + } + }; + + template + void f_impl(Args const& p BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected)) + { +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + static_assert( + boost::mp11::mp_size::value == boost::mp11::mp_size< + Args + >::value + , "mp_size::value == mp_size::value" + ); + + boost::mp11::mp_for_each >( + test::assert_in_set_0() + ); + boost::mp11::mp_for_each(test::assert_in_map()); +#endif + + BOOST_MPL_ASSERT_RELATION( + boost::mpl::size::value + , == + , boost::mpl::size::value + ); + + boost::mpl::for_each >( + test::assert_in_set_1() + ); + boost::mpl::for_each >( + test::assert_in_set_1() + ); + } + + template < + typename Expected + , typename Tester + , typename Name + , typename Value + , typename Index + > + void f( + Tester const& t + , Name const& name_ + , Value const& value_ + , Index const& index_ + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected) + ) + { + test::f_impl( + test::f_parameters()(t, name_, value_, index_) + ); + } + + template < + typename Expected + , typename Tester + , typename Name + , typename Value + > + void f( + Tester const& t + , Name const& name_ + , Value const& value_ + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected) + ) + { + test::f_impl(test::f_parameters()(t, name_, value_)); + } + + template + void f( + Tester const& t + , Name const& name_ + BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected) + ) + { + test::f_impl(test::f_parameters()(t, name_)); + } + + void run() + { + typedef test::tag::tester tester_; + typedef test::tag::name name_; + typedef test::tag::value value_; + typedef test::tag::index index_; + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + test::f< + boost::mp11::mp_list + >(1, 2, 3, 4); + test::f< + boost::mp11::mp_list + >(1, 2, test::_index = 3); + test::f< + boost::mp11::mp_list + >(1, test::_index = 2, test::_name = 3); + test::f< + boost::mp11::mp_list + >(test::_name = 3, test::_value = 4); + test::f_impl >(test::_value = 4); +#endif + + test::f >(1, 2, 3, 4); + test::f< + boost::mpl::list3 + >(1, 2, test::_index = 3); + test::f< + boost::mpl::list3 + >(1, test::_index = 2, test::_name = 3); + test::f< + boost::mpl::list2 + >(test::_name = 3, test::_value = 4); + test::f_impl >(test::_value = 4); + } +} + +#include + +int main() +{ + test::run(); + return boost::report_errors(); +} + -- cgit v1.2.3