1 // { dg-options "-std=gnu++14" }
4 // Copyright (C) 2013-2014 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a moved_to of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <experimental/optional>
22 #include <testsuite_hooks.h>
26 // [20.5.4.1] Constructors
29 constexpr long i
= 0x1234ABCD;
30 constexpr std::experimental::optional
<long> o
{ i
};
31 static_assert( o
, "" );
32 static_assert( *o
== 0x1234ABCD, "" );
36 constexpr long i
= 0x1234ABCD;
37 constexpr std::experimental::optional
<long> o
= i
;
38 static_assert( o
, "" );
39 static_assert( *o
== 0x1234ABCD, "" );
43 constexpr long i
= 0x1234ABCD;
44 constexpr std::experimental::optional
<long> o
= { i
};
45 static_assert( o
, "" );
46 static_assert( *o
== 0x1234ABCD, "" );
50 constexpr long i
= 0x1234ABCD;
51 constexpr std::experimental::optional
<long> o
{ std::move(i
) };
52 static_assert( o
, "" );
53 static_assert( *o
== 0x1234ABCD, "" );
57 constexpr long i
= 0x1234ABCD;
58 constexpr std::experimental::optional
<long> o
= std::move(i
);
59 static_assert( o
, "" );
60 static_assert( *o
== 0x1234ABCD, "" );
64 constexpr long i
= 0x1234ABCD;
65 constexpr std::experimental::optional
<long> o
= { std::move(i
) };
66 static_assert( o
, "" );
67 static_assert( *o
== 0x1234ABCD, "" );