1*56bb7041Schristos // Copyright (C) 2013-2020 Free Software Foundation, Inc.
23aed4a8bSchristos //
33aed4a8bSchristos // This file is part of the GNU ISO C++ Library.  This library is free
43aed4a8bSchristos // software; you can redistribute it and/or modify it under the
53aed4a8bSchristos // terms of the GNU General Public License as published by the
63aed4a8bSchristos // Free Software Foundation; either version 3, or (at your option)
73aed4a8bSchristos // any later version.
83aed4a8bSchristos 
93aed4a8bSchristos // This library is distributed in the hope that it will be useful,
103aed4a8bSchristos // but WITHOUT ANY WARRANTY; without even the implied warranty of
113aed4a8bSchristos // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
123aed4a8bSchristos // GNU General Public License for more details.
133aed4a8bSchristos 
143aed4a8bSchristos // You should have received a copy of the GNU General Public License along
153aed4a8bSchristos // with this library; see the file COPYING3.  If not see
163aed4a8bSchristos // <http://www.gnu.org/licenses/>.
173aed4a8bSchristos 
183aed4a8bSchristos namespace in_place {
193aed4a8bSchristos 
20*56bb7041Schristos static void
test()21*56bb7041Schristos test ()
223aed4a8bSchristos {
233aed4a8bSchristos   // [20.5.5] In-place construction
243aed4a8bSchristos   {
253aed4a8bSchristos     gdb::optional<int> o { gdb::in_place };
263aed4a8bSchristos     VERIFY( o );
273aed4a8bSchristos     VERIFY( *o == int() );
283aed4a8bSchristos 
293aed4a8bSchristos #ifndef GDB_OPTIONAL
303aed4a8bSchristos     static_assert( !std::is_convertible<gdb::in_place_t, gdb::optional<int>>(), "" );
313aed4a8bSchristos #endif
323aed4a8bSchristos   }
333aed4a8bSchristos 
343aed4a8bSchristos   {
353aed4a8bSchristos     gdb::optional<int> o { gdb::in_place, 42 };
363aed4a8bSchristos     VERIFY( o );
373aed4a8bSchristos     VERIFY( *o == 42 );
383aed4a8bSchristos   }
393aed4a8bSchristos 
403aed4a8bSchristos   {
413aed4a8bSchristos     gdb::optional<std::vector<int>> o { gdb::in_place, 18, 4 };
423aed4a8bSchristos     VERIFY( o );
433aed4a8bSchristos     VERIFY( o->size() == 18 );
443aed4a8bSchristos     VERIFY( (*o)[17] == 4 );
453aed4a8bSchristos   }
463aed4a8bSchristos 
473aed4a8bSchristos #ifndef GDB_OPTIONAL
483aed4a8bSchristos   {
493aed4a8bSchristos     gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 } };
503aed4a8bSchristos     VERIFY( o );
513aed4a8bSchristos     VERIFY( o->size() == 2 );
523aed4a8bSchristos     VERIFY( (*o)[0] == 18 );
533aed4a8bSchristos   }
543aed4a8bSchristos #endif
553aed4a8bSchristos 
563aed4a8bSchristos #ifndef GDB_OPTIONAL
573aed4a8bSchristos   {
583aed4a8bSchristos     gdb::optional<std::vector<int>> o { gdb::in_place, { 18, 4 }, std::allocator<int> {} };
593aed4a8bSchristos     VERIFY( o );
603aed4a8bSchristos     VERIFY( o->size() == 2 );
613aed4a8bSchristos     VERIFY( (*o)[0] == 18 );
623aed4a8bSchristos   }
633aed4a8bSchristos #endif
643aed4a8bSchristos }
653aed4a8bSchristos 
663aed4a8bSchristos } // namespace in_place
67