]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/optional/assignment/9.cc
1 // { dg-do compile { target c++17 } }
3 // Copyright (C) 2018-2022 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
24 std::optional
<int> o1
{42};
25 std::optional
<int> o2
;
32 std::optional
<int> o1
{42};
33 std::optional
<int> o2
;
34 std::optional
<int> o3
;
42 constexpr bool b
= f();
44 constexpr bool b2
= f2();
48 struct NonTrivialButConstexpr
51 NonTrivialButConstexpr() = default;
52 constexpr NonTrivialButConstexpr(int val
) : dummy(val
) {}
53 NonTrivialButConstexpr(const NonTrivialButConstexpr
&) = default;
54 NonTrivialButConstexpr(NonTrivialButConstexpr
&&) = default;
55 constexpr NonTrivialButConstexpr
&
56 operator=(const NonTrivialButConstexpr
& other
)
61 constexpr NonTrivialButConstexpr
&
62 operator=(NonTrivialButConstexpr
&& other
)
71 std::optional
<NonTrivialButConstexpr
> d1
, d2
;
73 std::optional
<NonTrivialButConstexpr
> o1
{42};
74 std::optional
<NonTrivialButConstexpr
> o2
{22};
76 return ((*o1
).dummy
== (*o2
).dummy
&& o1
->dummy
== o2
->dummy
);
81 std::optional
<NonTrivialButConstexpr
> d1
, d2
;
83 std::optional
<NonTrivialButConstexpr
> o1
{42};
84 std::optional
<NonTrivialButConstexpr
> o2
{22};
85 std::optional
<NonTrivialButConstexpr
> o3
{33};
88 return ((*o1
).dummy
== (*o3
).dummy
&& o1
->dummy
== o3
->dummy
);
93 constexpr bool b
= f3();
95 constexpr bool b2
= f4();