]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant/test/test5.cpp
1 //-----------------------------------------------------------------------------
2 // boost-libs variant/test/test5.cpp header file
3 // See http://www.boost.org for updates, documentation, and revision history.
4 //-----------------------------------------------------------------------------
7 // Eric Friedman, Itay Maman
9 // Distributed under the Boost Software License, Version 1.0. (See
10 // accompanying file LICENSE_1_0.txt or copy at
11 // http://www.boost.org/LICENSE_1_0.txt)
13 #include "boost/test/minimal.hpp"
14 #include "boost/variant.hpp"
28 using boost::apply_visitor
;
30 typedef variant
<int, float, unsigned short, unsigned char> t_var1
;
31 typedef variant
<int, t_var1
, unsigned short, unsigned char> t_var2
;
32 typedef variant
<string
, int, t_var2
> t_var3
;
42 //v2 and v3 are holding (aka: containing) a variant
46 verify(v1
, spec
<int>());
47 verify(v2
, spec
<t_var1
>());
48 verify(v3
, spec
<t_var2
>());
52 // assignment from const char (Converted to int)
57 verify(v2
, spec
<int>());
58 verify(v3
, spec
<int>());
61 BOOST_CHECK(apply_visitor(sum_int(), v2
) == c0
);
62 BOOST_CHECK(apply_visitor(sum_int(), v3
) == c0
);
65 apply_visitor(adder
, v2
);
66 apply_visitor(adder
, v3
);
68 BOOST_CHECK(adder
.result() == 2*c0
);
71 // A variant holding a variant
73 typedef variant
<unsigned char, float> t_var4
;
74 typedef variant
<string
, t_var4
> t_var5
;
80 verify(v5
, spec
<t_var4
>(), "[V] [V] 22.5");
85 int test_main(int , char* [])