]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/literate/extracting-parameter-types0.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / parameter / test / literate / extracting-parameter-types0.cpp
1
2 #include <boost/parameter.hpp>
3
4 BOOST_PARAMETER_NAME(name)
5 BOOST_PARAMETER_NAME(index)
6
7 template <typename T>
8 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
9 void noop(T&&)
10 #else
11 void noop(T&)
12 #endif
13 {
14 }
15
16 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
17 #include <utility>
18 #endif
19
20 template <typename Name, typename Index>
21 #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
22 int deduce_arg_types_impl(Name&& name, Index&& index)
23 {
24 noop(std::forward<Name>(name));
25 noop(std::forward<Index>(index));
26 return index;
27 }
28 #else
29 int deduce_arg_types_impl(Name& name, Index& index)
30 {
31 Name& n2 = name; // we know the types
32 Index& i2 = index;
33 noop(n2);
34 noop(i2);
35 return index;
36 }
37 #endif
38
39 template <typename ArgumentPack>
40 int deduce_arg_types(ArgumentPack const& args)
41 {
42 return deduce_arg_types_impl(args[_name], args[_index|42]);
43 }
44
45 #include <boost/core/lightweight_test.hpp>
46
47 int main()
48 {
49 int a1 = deduce_arg_types((_name = "foo"));
50 int a2 = deduce_arg_types((_name = "foo", _index = 3));
51 BOOST_TEST_EQ(a1, 42);
52 BOOST_TEST_EQ(a2, 3);
53 return boost::report_errors();
54 }
55