]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/optional/test/optional_test_inplace_fail2.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / optional / test / optional_test_inplace_fail2.cpp
1 // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
2 // Copyright (C) 2015 Andrzej Krzemienski.
3 //
4 // Use, modification, and distribution is subject to the Boost Software
5 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 // See http://www.boost.org/lib/optional for documentation.
9 //
10 // You are welcome to contact the author at:
11 // fernando_cacciola@hotmail.com
12
13 #include<string>
14 #include "boost/optional/optional.hpp"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
21 #include "boost/utility/in_place_factory.hpp"
22 #include "boost/utility/typed_in_place_factory.hpp"
23 #endif
24
25 #include "boost/core/lightweight_test.hpp"
26 #include "boost/none.hpp"
27
28 struct Guard
29 {
30 double num;
31 std::string str;
32 Guard() : num() {}
33 Guard(double num_, std::string str_) : num(num_), str(str_) {}
34
35 friend bool operator==(const Guard& lhs, const Guard& rhs) { return lhs.num == rhs.num && lhs.str == rhs.str; }
36 friend bool operator!=(const Guard& lhs, const Guard& rhs) { return !(lhs == rhs); }
37
38 private:
39 Guard(const Guard&);
40 Guard& operator=(const Guard&);
41 };
42
43
44 int main()
45 {
46 #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
47 typedef int BAD_TARGET_TYPE;
48 boost::optional<Guard> og1 ( boost::in_place<BAD_TARGET_TYPE>(1.0, "one") );
49 #else
50 NOTHING_TO_TEST_SO_JUST_FAIL
51 #endif
52 return 0;
53 }