]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/sequence/define_struct_inline_move.cpp
1 /*=============================================================================
2 Copyright (c) 2016 Kohei Takahashi
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
8 #include <boost/config.hpp>
9 #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
11 #include <boost/detail/lightweight_test.hpp>
12 #include <boost/fusion/adapted/struct/define_struct_inline.hpp>
19 wrapper() : value(42) {}
20 wrapper(wrapper
&& other
) : value(other
.value
) { other
.value
= 0; }
21 wrapper(wrapper
const& other
) : value(other
.value
) {}
23 wrapper
& operator=(wrapper
&& other
) { value
= other
.value
; other
.value
= 0; return *this; }
24 wrapper
& operator=(wrapper
const& other
) { value
= other
.value
; return *this; }
29 BOOST_FUSION_DEFINE_STRUCT_INLINE(value
, (wrapper
, w
))
34 using namespace boost::fusion
;
38 ns::value
y(x
); // copy
40 BOOST_TEST(x
.w
.value
== 42);
41 BOOST_TEST(y
.w
.value
== 42);
45 BOOST_TEST(x
.w
.value
== 42);
46 BOOST_TEST(y
.w
.value
== 43);
50 BOOST_TEST(x
.w
.value
== 42);
51 BOOST_TEST(y
.w
.value
== 42);
56 ns::value
y(std::move(x
)); // move
58 BOOST_TEST(x
.w
.value
== 0);
59 BOOST_TEST(y
.w
.value
== 42);
63 BOOST_TEST(x
.w
.value
== 0);
64 BOOST_TEST(y
.w
.value
== 43);
66 y
= std::move(x
); // move assign
68 BOOST_TEST(x
.w
.value
== 0);
69 BOOST_TEST(y
.w
.value
== 0);
72 return boost::report_errors();