]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/optional/test/optional_test_convert_from_T.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / optional / test / optional_test_convert_from_T.cpp
CommitLineData
7c673cae
FG
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// akrzemi1@gmail.com
11
12#include "boost/optional/optional.hpp"
13
14#ifdef __BORLANDC__
15#pragma hdrstop
16#endif
17
18#include "boost/core/lightweight_test.hpp"
19#include "boost/none.hpp"
20
21//#ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR
22
23using boost::optional;
24using boost::none;
25
b32b8144
FG
26template <typename U>
27struct superconv
28{
29 #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
30 template <typename T>
31 superconv(T&&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
32 #else
33 template <typename T>
34 superconv(const T&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
35 template <typename T>
36 superconv( T&) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
37 #endif
38
39 superconv() {}
40};
41
42void test_optional_of_superconverting_T() // compile-time test
43{
44#ifndef BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT
45 superconv<optional<int> > s;
46 superconv<optional<int> > & rs = s;
47 optional<superconv<optional<int> > > os = rs;
48#endif
49}
50
7c673cae
FG
51void test_optional_optional_T()
52{
53 optional<int> oi1 (1), oiN;
54 optional< optional<int> > ooi1 (oi1), ooiN(oiN);
55
56 BOOST_TEST(ooi1);
57 BOOST_TEST(*ooi1);
58 BOOST_TEST_EQ(**ooi1, 1);
59
60 BOOST_TEST(ooiN);
61 BOOST_TEST(!*ooiN);
62}
63
64int main()
65{
66 test_optional_optional_T();
b32b8144
FG
67 test_optional_of_superconverting_T();
68
7c673cae
FG
69 return boost::report_errors();
70}