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/deduced.cpp | 182 ++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 src/boost/libs/parameter/test/deduced.cpp (limited to 'src/boost/libs/parameter/test/deduced.cpp') diff --git a/src/boost/libs/parameter/test/deduced.cpp b/src/boost/libs/parameter/test/deduced.cpp new file mode 100644 index 00000000..359685fd --- /dev/null +++ b/src/boost/libs/parameter/test/deduced.cpp @@ -0,0 +1,182 @@ +// Copyright Daniel Wallin 2006. +// 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 "deduced.hpp" + +#if defined(BOOST_PARAMETER_CAN_USE_MP11) +#include +#else +#include +#include +#include +#endif + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) +#include +#endif + +namespace test { + + BOOST_PARAMETER_NAME(x) + BOOST_PARAMETER_NAME(y) + BOOST_PARAMETER_NAME(z) + + template + struct predicate + { + template +#if defined(BOOST_PARAMETER_CAN_USE_MP11) + using fn = std::is_convertible; +#else + struct apply + : boost::mpl::if_< + boost::is_convertible + , boost::mpl::true_ + , boost::mpl::false_ + > + { + }; +#endif + }; +} // namespace test + +#include +#include + +int main() +{ + test::check< + boost::parameter::parameters + >((test::_x = 0, test::_y = 1), 0, 1); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced + , test::predicate + > + , boost::parameter::optional< + boost::parameter::deduced + , test::predicate + > + > + >( + ( + test::_x = 0 + , test::_y = test::not_present + , test::_z = std::string("foo") + ) + , test::_x = 0 + , std::string("foo") + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced + , test::predicate + > + , boost::parameter::optional< + boost::parameter::deduced + , test::predicate + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , 0 + , std::string("foo") + , 1 + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced + , test::predicate + > + , boost::parameter::optional< + boost::parameter::deduced + , test::predicate + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , 0 + , 1 + , std::string("foo") + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced + , test::predicate + > + , boost::parameter::optional< + boost::parameter::deduced + , test::predicate + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , 0 + , test::_y = 1 + , std::string("foo") + ); + + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced + , test::predicate + > + , boost::parameter::optional< + boost::parameter::deduced + , test::predicate + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , test::_z = std::string("foo") + , test::_x = 0 + , 1 + ); + +#if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) + // Fails because boost::parameter::aux::make_arg_list<> evaluates + // boost::parameter::aux::is_named_argument<> to boost::mpl::false_ + // for static_cast(BOOST_PARAMETER_AUX_PP_NULLPTR). + test::check< + boost::parameter::parameters< + test::tag::x + , boost::parameter::required< + boost::parameter::deduced + , test::predicate + > + , boost::parameter::optional< + boost::parameter::deduced + , test::predicate + > + > + >( + (test::_x = 0, test::_y = 1, test::_z = std::string("foo")) + , test::_x = 0 + , static_cast(BOOST_PARAMETER_AUX_PP_NULLPTR) + , 1 + ); +#endif + + return boost::report_errors(); +} + -- cgit v1.2.3