summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp
parentInitial commit. (diff)
downloadceph-upstream/16.2.11+ds.tar.xz
ceph-upstream/16.2.11+ds.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp')
-rw-r--r--src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp61
1 files changed, 61 insertions, 0 deletions
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 <boost/parameter.hpp>
+#include <iostream>
+
+BOOST_PARAMETER_NAME(index)
+
+template <typename ArgumentPack>
+int print_index(ArgumentPack const& args)
+{
+ std::cout << "index = " << args[_index] << std::endl;
+ return 0;
+}
+
+BOOST_PARAMETER_NAME(name)
+
+template <typename ArgumentPack>
+int print_name_and_index(ArgumentPack const& args)
+{
+ std::cout << "name = " << args[_name] << "; ";
+ return print_index(args);
+}
+
+#include <boost/core/lightweight_test.hpp>
+#include <boost/mpl/bool.hpp>
+#include <boost/mpl/placeholders.hpp>
+#include <boost/mpl/if.hpp>
+#include <boost/type_traits/is_convertible.hpp>
+
+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::_,char const*>
+ , boost::mpl::true_
+ , boost::mpl::false_
+ >
+ >
+ , boost::parameter::optional<
+ tag::index
+ , boost::mpl::if_<
+ boost::is_convertible<boost::mpl::_,int>
+ , 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();
+}
+