]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/optional/test/optional_test_ref_move.cpp
1 // Copyright (C) 2014 Andrzej Krzemienski.
3 // Use, modification, and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
7 // See http://www.boost.org/lib/optional for documentation.
9 // You are welcome to contact the author at: akrzemi1@gmail.com
12 #include "boost/optional/optional.hpp"
19 #include "boost/core/addressof.hpp"
20 #include "boost/core/lightweight_test.hpp"
22 using boost::optional
;
24 std::string
global("text");
26 optional
<std::string
&> make_optional_string_ref()
28 return optional
<std::string
&>(global
);
31 std::string
& return_global()
38 optional
<std::string
&> opt
;
39 opt
= make_optional_string_ref();
40 BOOST_TEST(bool(opt
));
41 BOOST_TEST(*opt
== global
);
42 BOOST_TEST(boost::addressof(*opt
) == boost::addressof(global
));
45 std::string
& str
= *make_optional_string_ref();
46 BOOST_TEST(str
== global
);
47 BOOST_TEST(boost::addressof(str
) == boost::addressof(global
));
51 std::string
& str
= make_optional_string_ref().value();
52 BOOST_TEST(str
== global
);
53 BOOST_TEST(boost::addressof(str
) == boost::addressof(global
));
57 std::string
& str
= make_optional_string_ref().value_or(global
);
58 BOOST_TEST(str
== global
);
59 BOOST_TEST(boost::addressof(str
) == boost::addressof(global
));
63 std::string
& str
= make_optional_string_ref().value_or_eval(&return_global
);
64 BOOST_TEST(str
== global
);
65 BOOST_TEST(boost::addressof(str
) == boost::addressof(global
));
68 return boost::report_errors();