]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/experimental/optional/constexpr/cons/value.cc
Update copyright years.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / experimental / optional / constexpr / cons / value.cc
CommitLineData
15d9538c 1// { dg-options "-std=gnu++14" }
e3f166cf 2// { dg-do compile }
3
f1717362 4// Copyright (C) 2013-2016 Free Software Foundation, Inc.
e3f166cf 5//
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)
10// any later version.
11
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.
16
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/>.
20
21#include <experimental/optional>
22#include <testsuite_hooks.h>
23
24int main()
25{
26 // [20.5.4.1] Constructors
27
28 {
d75579d0 29 constexpr long i = 0x1234ABCD;
e3f166cf 30 constexpr std::experimental::optional<long> o { i };
31 static_assert( o, "" );
d75579d0 32 static_assert( *o == 0x1234ABCD, "" );
e3f166cf 33 }
34
35 {
d75579d0 36 constexpr long i = 0x1234ABCD;
e3f166cf 37 constexpr std::experimental::optional<long> o = i;
38 static_assert( o, "" );
d75579d0 39 static_assert( *o == 0x1234ABCD, "" );
e3f166cf 40 }
41
42 {
d75579d0 43 constexpr long i = 0x1234ABCD;
e3f166cf 44 constexpr std::experimental::optional<long> o = { i };
45 static_assert( o, "" );
d75579d0 46 static_assert( *o == 0x1234ABCD, "" );
e3f166cf 47 }
48
49 {
d75579d0 50 constexpr long i = 0x1234ABCD;
e3f166cf 51 constexpr std::experimental::optional<long> o { std::move(i) };
52 static_assert( o, "" );
d75579d0 53 static_assert( *o == 0x1234ABCD, "" );
e3f166cf 54 }
55
56 {
d75579d0 57 constexpr long i = 0x1234ABCD;
e3f166cf 58 constexpr std::experimental::optional<long> o = std::move(i);
59 static_assert( o, "" );
d75579d0 60 static_assert( *o == 0x1234ABCD, "" );
e3f166cf 61 }
62
63 {
d75579d0 64 constexpr long i = 0x1234ABCD;
e3f166cf 65 constexpr std::experimental::optional<long> o = { std::move(i) };
66 static_assert( o, "" );
d75579d0 67 static_assert( *o == 0x1234ABCD, "" );
e3f166cf 68 }
69}