]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / parameter / test / literate / building-argumentpacks0.cpp
index 71e419ee810b54cec02fb7e8da13a5e546397551..d80f2f9f084eb99f75ecb85de4a1f1bc66aeb052 100644 (file)
@@ -1,47 +1,61 @@
 
 #include <boost/parameter.hpp>
 #include <iostream>
+
 BOOST_PARAMETER_NAME(index)
 
-template <class ArgumentPack>
+template <typename ArgumentPack>
 int print_index(ArgumentPack const& args)
 {
     std::cout << "index = " << args[_index] << std::endl;
     return 0;
 }
 
-int x = print_index(_index = 3);  // prints "index = 3"
-
 BOOST_PARAMETER_NAME(name)
 
-template <class ArgumentPack>
+template <typename ArgumentPack>
 int print_name_and_index(ArgumentPack const& args)
 {
     std::cout << "name = " << args[_name] << "; ";
     return print_index(args);
 }
 
-int y = print_name_and_index((_index = 3, _name = "jones"));
-
-
-namespace parameter = boost::parameter;
-using parameter::required;
-using parameter::optional;
-using boost::is_convertible;
-using boost::mpl::_;
-parameter::parameters<
-    required<tag::name, is_convertible<_,char const*> >
-  , optional<tag::index, is_convertible<_,int> >
-> spec;
+#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>
 
-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")
-);
 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();
+}