blob: c1df59442ac296234595c63270e09dc8fe52ec37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#if defined(_MSC_VER)
# pragma warning( disable: 4702 ) // unreachable code
#endif
#include <boost/variant2/variant.hpp>
#include <boost/core/lightweight_test.hpp>
#include <stdexcept>
using namespace boost::variant2;
struct Y1
{
Y1() noexcept {} // =default fails on msvc-14.0
Y1(Y1&&)
{
throw std::runtime_error( "Y1(Y1&&)" );
}
Y1& operator=(Y1&&) = default;
};
struct Y2
{
Y2() noexcept {}
Y2(Y2&&)
{
throw std::runtime_error( "Y2(Y2&&)" );
}
Y2& operator=(Y2&&) = default;
};
void test()
{
variant<Y1, Y2> v1( in_place_type_t<Y1>{} );
variant<Y1, Y2> v2( in_place_type_t<Y2>{} );
BOOST_TEST_THROWS( v1 = std::move( v2 ), std::runtime_error )
}
int main()
{
test();
return boost::report_errors();
}
|