1 // Copyright (C) 2013-2023 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
20 static int counter
= 0;
24 mixin_counter() { ++counter
; }
25 mixin_counter(mixin_counter
const&) { ++counter
; }
26 ~mixin_counter() { --counter
; }
29 struct value_type
: private mixin_counter
31 value_type() = default;
32 value_type(int) : state(1) { }
33 value_type(std::initializer_list
<char>, const char*) : state(2) { }
40 using O
= gdb::optional
<value_type
>;
47 VERIFY( o
&& o
->state
== 0 );
50 O o
{ gdb::in_place
, 0 };
52 VERIFY( o
&& o
->state
== 0 );
58 VERIFY( o
&& o
->state
== 1 );
61 O o
{ gdb::in_place
};
63 VERIFY( o
&& o
->state
== 1 );
69 o
.emplace({ 'a' }, "");
70 VERIFY( o
&& o
->state
== 2 );
73 O o
{ gdb::in_place
};
74 o
.emplace({ 'a' }, "");
75 VERIFY( o
&& o
->state
== 2 );
80 VERIFY(&o
.emplace(0) == &*o
);
82 VERIFY(&o
.emplace({ 'a' }, "") == &*o
);
86 static_assert( !std::is_constructible
<O
, std::initializer_list
<int>, int>(), "" );
88 VERIFY( counter
== 0 );
91 } // namespace assign_6