]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/literate/building-argumentpacks0.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / parameter / test / literate / building-argumentpacks0.cpp
1
2 #include <boost/parameter.hpp>
3 #include <iostream>
4 BOOST_PARAMETER_NAME(index)
5
6 template <class ArgumentPack>
7 int print_index(ArgumentPack const& args)
8 {
9 std::cout << "index = " << args[_index] << std::endl;
10 return 0;
11 }
12
13 int x = print_index(_index = 3); // prints "index = 3"
14
15 BOOST_PARAMETER_NAME(name)
16
17 template <class ArgumentPack>
18 int print_name_and_index(ArgumentPack const& args)
19 {
20 std::cout << "name = " << args[_name] << "; ";
21 return print_index(args);
22 }
23
24 int y = print_name_and_index((_index = 3, _name = "jones"));
25
26
27 namespace parameter = boost::parameter;
28 using parameter::required;
29 using parameter::optional;
30 using boost::is_convertible;
31 using boost::mpl::_;
32 parameter::parameters<
33 required<tag::name, is_convertible<_,char const*> >
34 , optional<tag::index, is_convertible<_,int> >
35 > spec;
36
37 char const sam[] = "sam";
38 int twelve = 12;
39
40 int z0 = print_name_and_index( spec(sam, twelve) );
41
42 int z1 = print_name_and_index(
43 spec(_index=12, _name="sam")
44 );
45 int main()
46 {}
47