1*1424dfb3Schristos // Copyright (C) 2013-2020 Free Software Foundation, Inc.
207163879Schristos //
307163879Schristos // This file is part of the GNU ISO C++ Library.  This library is free
407163879Schristos // software; you can redistribute it and/or modify it under the
507163879Schristos // terms of the GNU General Public License as published by the
607163879Schristos // Free Software Foundation; either version 3, or (at your option)
707163879Schristos // any later version.
807163879Schristos 
907163879Schristos // This library is distributed in the hope that it will be useful,
1007163879Schristos // but WITHOUT ANY WARRANTY; without even the implied warranty of
1107163879Schristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1207163879Schristos // GNU General Public License for more details.
1307163879Schristos 
1407163879Schristos // You should have received a copy of the GNU General Public License along
1507163879Schristos // with this library; see the file COPYING3.  If not see
1607163879Schristos // <http://www.gnu.org/licenses/>.
1707163879Schristos 
1807163879Schristos namespace in_place {
1907163879Schristos 
20*1424dfb3Schristos static void
test()21*1424dfb3Schristos test ()
2207163879Schristos {
2307163879Schristos   // [20.5.5] In-place construction
2407163879Schristos   {
2507163879Schristos     gdb::optional<int> o { gdb::in_place };
2607163879Schristos     VERIFY( o );
2707163879Schristos     VERIFY( *o == int() );
2807163879Schristos 
2907163879Schristos #ifndef GDB_OPTIONAL
3007163879Schristos     static_assert( !std::is_convertible<gdb::in_place_t, gdb::optional<int>>(), "" );
3107163879Schristos #endif
3207163879Schristos   }
3307163879Schristos 
3407163879Schristos   {
3507163879Schristos     gdb::optional<int> o { gdb::in_place, 42 };
3607163879Schristos     VERIFY( o );
3707163879Schristos     VERIFY( *o == 42 );
3807163879Schristos   }
3907163879Schristos 
4007163879Schristos   {
4107163879Schristos     gdb::optional<std::vector<int>> o { gdb::in_place, 18, 4 };
4207163879Schristos     VERIFY( o );
4307163879Schristos     VERIFY( o->size() == 18 );
4407163879Schristos     VERIFY( (*o)[17] == 4 );
4507163879Schristos   }
4607163879Schristos 
4707163879Schristos #ifndef GDB_OPTIONAL
4807163879Schristos   {
4907163879Schristos     gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 } };
5007163879Schristos     VERIFY( o );
5107163879Schristos     VERIFY( o->size() == 2 );
5207163879Schristos     VERIFY( (*o)[0] == 18 );
5307163879Schristos   }
5407163879Schristos #endif
5507163879Schristos 
5607163879Schristos #ifndef GDB_OPTIONAL
5707163879Schristos   {
5807163879Schristos     gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 }, std::allocator<int> {} };
5907163879Schristos     VERIFY( o );
6007163879Schristos     VERIFY( o->size() == 2 );
6107163879Schristos     VERIFY( (*o)[0] == 18 );
6207163879Schristos   }
6307163879Schristos #endif
6407163879Schristos }
6507163879Schristos 
6607163879Schristos } // namespace in_place
67