From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- .../test/literate/building-argumentpacks0.cpp | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp (limited to 'src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp') diff --git a/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp b/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp new file mode 100644 index 000000000..d80f2f9f0 --- /dev/null +++ b/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp @@ -0,0 +1,61 @@ + +#include +#include + +BOOST_PARAMETER_NAME(index) + +template +int print_index(ArgumentPack const& args) +{ + std::cout << "index = " << args[_index] << std::endl; + return 0; +} + +BOOST_PARAMETER_NAME(name) + +template +int print_name_and_index(ArgumentPack const& args) +{ + std::cout << "name = " << args[_name] << "; "; + return print_index(args); +} + +#include +#include +#include +#include +#include + +int main() +{ + int x = print_index(_index = 3); // prints "index = 3" + int y = print_name_and_index((_index = 3, _name = "jones")); + boost::parameter::parameters< + boost::parameter::required< + tag::name + , boost::mpl::if_< + boost::is_convertible + , boost::mpl::true_ + , boost::mpl::false_ + > + > + , boost::parameter::optional< + tag::index + , boost::mpl::if_< + boost::is_convertible + , boost::mpl::true_ + , boost::mpl::false_ + > + > + > spec; + char const sam[] = "sam"; + int twelve = 12; + int z0 = print_name_and_index(spec(sam, twelve)); + int z1 = print_name_and_index(spec(_index=12, _name="sam")); + BOOST_TEST(!x); + BOOST_TEST(!y); + BOOST_TEST(!z0); + BOOST_TEST(!z1); + return boost::report_errors(); +} + -- cgit v1.2.3