]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | //----------------------------------------------------------------------------- |
2 | // boost-libs variant/test/variant_get_test.cpp source file | |
3 | // See http://www.boost.org for updates, documentation, and revision history. | |
4 | //----------------------------------------------------------------------------- | |
5 | // | |
6 | // Copyright (c) 2017-2017 Albert Sverdlov | |
7 | // | |
8 | // Distributed under the Boost Software License, Version 1.0. (See | |
9 | // accompanying file LICENSE_1_0.txt or copy at | |
10 | // http://www.boost.org/LICENSE_1_0.txt) | |
11 | ||
12 | #include "boost/variant/get.hpp" | |
13 | #include "boost/variant/variant.hpp" | |
14 | #include "boost/test/minimal.hpp" | |
15 | ||
16 | #include <boost/move/move.hpp> | |
17 | #include <boost/static_assert.hpp> | |
18 | ||
19 | #include <string> | |
20 | ||
21 | #define UNUSED(v) (void)(v) | |
22 | ||
23 | inline void run() | |
24 | { | |
25 | #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES | |
26 | typedef boost::variant<int, std::string> var_t; | |
27 | ||
28 | std::string s = "abacaba"; | |
29 | var_t v = s; | |
30 | ||
31 | // must spit an error at compile-time because of 'std::string&' | |
32 | std::string new_s = boost::strict_get<std::string&>(boost::move(v)); | |
33 | UNUSED(new_s); | |
34 | #else | |
35 | BOOST_STATIC_ASSERT_MSG(false, "Dummy compile-time error to pass the test on C++03"); | |
36 | #endif | |
37 | } | |
38 | ||
39 | int test_main(int /*argc*/, char* /*argv*/ []) | |
40 | { | |
41 | run(); | |
42 | return boost::exit_success; | |
43 | } |