1 // Copyright (C) 2014 Andrzej Krzemienski.
2 //
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)
6 //
7 // See http://www.boost.org/lib/optional for documentation.
8 //
9 // You are welcome to contact the author at:
10 //  [email protected]
11 
12 #include "boost/optional/optional.hpp"
13 
14 #ifdef BOOST_BORLANDC
15 #pragma hdrstop
16 #endif
17 
18 #include "boost/core/lightweight_test.hpp"
19 
20 #if defined(BOOST_NO_CXX11_DELETED_FUNCTIONS)
21 
main()22 int main()
23 {
24 }
25 
26 #else
27 
28 #include <utility>
29 
30 struct NotDefaultConstructible
31 {
32 	NotDefaultConstructible() = delete;
33 };
34 
test_tc_base()35 void test_tc_base()
36 {
37   boost::optional<NotDefaultConstructible> o;
38 
39   BOOST_TEST(boost::none == o);
40 }
41 
42 struct S
43 {
44 
45 };
46 
47 template<class T>
48 struct W
49 {
50 	T& t_;
51 
52 	template<class... Args>
WW53 	W(Args&&... args)
54 		: t_(std::forward<Args>(args)...)
55 	{
56 	}
57 };
58 
test_value_init()59 void test_value_init()
60 {
61 #ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
62 	{
63 		S s;
64 		W<S> w{s};
65 	}
66 #endif
67 	{
68 		S s;
69 		W<S> w(s);
70 	}
71 }
72 
test_optoinal_reference_wrapper()73 void test_optoinal_reference_wrapper()
74 {
75 	boost::optional<W<S&> > o;
76 	BOOST_TEST(boost::none == o);
77 }
78 
main()79 int main()
80 {
81   test_tc_base();
82   test_value_init();
83   test_optoinal_reference_wrapper();
84   return boost::report_errors();
85 }
86 
87 #endif
88