]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant2/test/variant_ostream_insert.cpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / libs / variant2 / test / variant_ostream_insert.cpp
1 // Copyright 2021 Peter Dimov
2 // Distributed under the Boost Software License, Version 1.0.
3 // https://www.boost.org/LICENSE_1_0.txt
4
5 #include <boost/variant2/variant.hpp>
6 #include <boost/core/lightweight_test.hpp>
7 #include <sstream>
8 #include <string>
9
10 using namespace boost::variant2;
11
12 template<class T> std::string to_string( T const& t )
13 {
14 std::ostringstream os;
15
16 os << t;
17
18 return os.str();
19 }
20
21 int main()
22 {
23 {
24 BOOST_TEST_EQ( to_string( monostate() ), "monostate" );
25 }
26
27 {
28 variant<monostate, int, float, std::string> v;
29
30 BOOST_TEST_EQ( to_string( v ), to_string( monostate() ) );
31
32 v = 1;
33 BOOST_TEST_EQ( to_string( v ), to_string( 1 ) );
34
35 v = 3.14f;
36 BOOST_TEST_EQ( to_string( v ), to_string( 3.14f ) );
37
38 v = "test";
39 BOOST_TEST_EQ( to_string( v ), to_string( "test" ) );
40 }
41
42 return boost::report_errors();
43 }