gcc/libstdc++-v3/testsuite/experimental/optional/requirements.cc

260 lines
9.3 KiB
C++
Raw Normal View History

limits: Remove stray semicolon. 2014-10-15 Paolo Carlini <paolo.carlini@oracle.com> * include/std/limits: Remove stray semicolon. 2014-10-15 Paolo Carlini <paolo.carlini@oracle.com> * testsuite/20_util/add_const/requirements/alias_decl.cc: Prefer -std=gnu++14. * testsuite/20_util/add_cv/requirements/alias_decl.cc: Likewise. * testsuite/20_util/add_lvalue_reference/requirements/alias_decl.cc: Likewise. * testsuite/20_util/add_pointer/requirements/alias_decl.cc: Likewise. * testsuite/20_util/add_rvalue_reference/requirements/alias_decl.cc: Likewise. * testsuite/20_util/add_volatile/requirements/alias_decl.cc: Likewise. * testsuite/20_util/aligned_storage/requirements/alias_decl.cc: Likewise. * testsuite/20_util/aligned_union/requirements/alias_decl.cc: Likewise. * testsuite/20_util/common_type/requirements/alias_decl.cc: Likewise. * testsuite/20_util/conditional/requirements/alias_decl.cc: Likewise. * testsuite/20_util/decay/requirements/alias_decl.cc: Likewise. * testsuite/20_util/duration/literals/61166.cc: Likewise. * testsuite/20_util/duration/literals/ns_detail.cc: Likewise. * testsuite/20_util/duration/literals/range.cc: Likewise. * testsuite/20_util/duration/literals/types.cc: Likewise. * testsuite/20_util/duration/literals/values.cc: Likewise. * testsuite/20_util/enable_if/requirements/alias_decl.cc: Likewise. * testsuite/20_util/exchange/1.cc: Likewise. * testsuite/20_util/function_objects/comparisons_void.cc: Likewise. * testsuite/20_util/integer_sequence/intseq.cc: Likewise. * testsuite/20_util/integer_sequence/requirements/typedefs.cc: Likewise. * testsuite/20_util/integral_constant/call_operator.cc: Likewise. * testsuite/20_util/make_signed/requirements/alias_decl.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/alias_decl.cc: Likewise. * testsuite/20_util/pair/astuple/constexpr_get_by_type.cc: Likewise. * testsuite/20_util/pair/astuple/get_by_type.cc: Likewise. * testsuite/20_util/pair/astuple/get_by_type_neg.cc: Likewise. * testsuite/20_util/pair/astuple/get_neg.cc: Likewise. * testsuite/20_util/remove_all_extents/requirements/alias_decl.cc: Likewise. * testsuite/20_util/remove_const/requirements/alias_decl.cc: Likewise. * testsuite/20_util/remove_cv/requirements/alias_decl.cc: Likewise. * testsuite/20_util/remove_extent/requirements/alias_decl.cc: Likewise. * testsuite/20_util/remove_pointer/requirements/alias_decl.cc: Likewise. * testsuite/20_util/remove_reference/requirements/alias_decl.cc: Likewise. * testsuite/20_util/remove_volatile/requirements/alias_decl.cc: Likewise. * testsuite/20_util/result_of/requirements/alias_decl.cc: Likewise. * testsuite/20_util/tuple/element_access/constexpr_get_by_type.cc: Likewise. * testsuite/20_util/tuple/element_access/get2_by_type.cc: Likewise. * testsuite/20_util/tuple/element_access/get_by_type.cc: Likewise. * testsuite/20_util/underlying_type/requirements/alias_decl.cc: Likewise. * testsuite/20_util/unique_ptr/creation/array.cc: Likewise. * testsuite/20_util/unique_ptr/creation/array_neg.cc: Likewise. * testsuite/20_util/unique_ptr/creation/single.cc: Likewise. * testsuite/21_strings/basic_string/literals/types.cc: Likewise. * testsuite/21_strings/basic_string/literals/values.cc: Likewise. * testsuite/25_algorithms/equal/2.cc: Likewise. * testsuite/25_algorithms/equal/check_type2.cc: Likewise. * testsuite/25_algorithms/is_permutation/2.cc: Likewise. * testsuite/25_algorithms/is_permutation/check_type2.cc: Likewise. * testsuite/25_algorithms/is_permutation/vectorbool.cc: Likewise. * testsuite/25_algorithms/mismatch/2.cc: Likewise. * testsuite/25_algorithms/mismatch/check_type2.cc: Likewise. * testsuite/26_numerics/complex/literals/values.cc: Likewise. * testsuite/27_io/manipulators/standard/char/quoted.cc: Likewise. * testsuite/27_io/manipulators/standard/wchar_t/quoted.cc: Likewise. * testsuite/30_threads/shared_lock/cons/1.cc: Likewise. * testsuite/30_threads/shared_lock/cons/2.cc: Likewise. * testsuite/30_threads/shared_lock/cons/3.cc: Likewise. * testsuite/30_threads/shared_lock/cons/4.cc: Likewise. * testsuite/30_threads/shared_lock/cons/5.cc: Likewise. * testsuite/30_threads/shared_lock/cons/6.cc: Likewise. * testsuite/30_threads/shared_lock/locking/1.cc: Likewise. * testsuite/30_threads/shared_lock/locking/2.cc: Likewise. * testsuite/30_threads/shared_lock/locking/3.cc: Likewise. * testsuite/30_threads/shared_lock/locking/4.cc: Likewise. * testsuite/30_threads/shared_lock/modifiers/1.cc: Likewise. * testsuite/30_threads/shared_lock/modifiers/2.cc: Likewise. * testsuite/30_threads/shared_lock/requirements/ explicit_instantiation.cc: Likewise. * testsuite/30_threads/shared_lock/requirements/typedefs.cc: Likewise. * testsuite/30_threads/shared_timed_mutex/cons/1.cc: Likewise. * testsuite/30_threads/shared_timed_mutex/cons/assign_neg.cc: Likewise. * testsuite/30_threads/shared_timed_mutex/cons/copy_neg.cc: Likewise. * testsuite/30_threads/shared_timed_mutex/requirements/ standard_layout.cc: Likewise. * testsuite/30_threads/shared_timed_mutex/try_lock/1.cc: Likewise. * testsuite/30_threads/shared_timed_mutex/try_lock/2.cc: Likewise. * testsuite/experimental/optional/assignment/1.cc: Likewise. * testsuite/experimental/optional/assignment/2.cc: Likewise. * testsuite/experimental/optional/assignment/3.cc: Likewise. * testsuite/experimental/optional/assignment/4.cc: Likewise. * testsuite/experimental/optional/assignment/5.cc: Likewise. * testsuite/experimental/optional/assignment/6.cc: Likewise. * testsuite/experimental/optional/cons/copy.cc: Likewise. * testsuite/experimental/optional/cons/default.cc: Likewise. * testsuite/experimental/optional/cons/move.cc: Likewise. * testsuite/experimental/optional/cons/value.cc: Likewise. * testsuite/experimental/optional/constexpr/cons/default.cc: Likewise. * testsuite/experimental/optional/constexpr/cons/value.cc: Likewise. * testsuite/experimental/optional/constexpr/in_place.cc: Likewise. * testsuite/experimental/optional/constexpr/make_optional.cc: Likewise. * testsuite/experimental/optional/constexpr/nullopt.cc: Likewise. * testsuite/experimental/optional/constexpr/observers/1.cc: Likewise. * testsuite/experimental/optional/constexpr/observers/2.cc: Likewise. * testsuite/experimental/optional/constexpr/observers/3.cc: Likewise. * testsuite/experimental/optional/constexpr/observers/4.cc: Likewise. * testsuite/experimental/optional/constexpr/observers/5.cc: Likewise. * testsuite/experimental/optional/constexpr/relops/1.cc: Likewise. * testsuite/experimental/optional/constexpr/relops/2.cc: Likewise. * testsuite/experimental/optional/constexpr/relops/3.cc: Likewise. * testsuite/experimental/optional/constexpr/relops/4.cc: Likewise. * testsuite/experimental/optional/constexpr/relops/5.cc: Likewise. * testsuite/experimental/optional/constexpr/relops/6.cc: Likewise. * testsuite/experimental/optional/in_place.cc: Likewise. * testsuite/experimental/optional/make_optional.cc: Likewise. * testsuite/experimental/optional/nullopt.cc: Likewise. * testsuite/experimental/optional/observers/1.cc: Likewise. * testsuite/experimental/optional/observers/2.cc: Likewise. * testsuite/experimental/optional/observers/3.cc: Likewise. * testsuite/experimental/optional/observers/4.cc: Likewise. * testsuite/experimental/optional/observers/5.cc: Likewise. * testsuite/experimental/optional/relops/1.cc: Likewise. * testsuite/experimental/optional/relops/2.cc: Likewise. * testsuite/experimental/optional/relops/3.cc: Likewise. * testsuite/experimental/optional/relops/4.cc: Likewise. * testsuite/experimental/optional/relops/5.cc: Likewise. * testsuite/experimental/optional/relops/6.cc: Likewise. * testsuite/experimental/optional/requirements.cc: Likewise. * testsuite/experimental/optional/swap/1.cc: Likewise. * testsuite/experimental/string_view/capacity/1.cc: Likewise. * testsuite/experimental/string_view/cons/char/1.cc: Likewise. * testsuite/experimental/string_view/cons/char/2.cc: Likewise. * testsuite/experimental/string_view/cons/char/3.cc: Likewise. * testsuite/experimental/string_view/cons/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/cons/wchar_t/2.cc: Likewise. * testsuite/experimental/string_view/cons/wchar_t/3.cc: Likewise. * testsuite/experimental/string_view/element_access/char/1.cc: Likewise. * testsuite/experimental/string_view/element_access/char/2.cc: Likewise. * testsuite/experimental/string_view/element_access/char/empty.cc: Likewise. * testsuite/experimental/string_view/element_access/char/ front_back.cc: Likewise. * testsuite/experimental/string_view/element_access/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/element_access/wchar_t/2.cc: Likewise. * testsuite/experimental/string_view/element_access/wchar_t/empty.cc: Likewise. * testsuite/experimental/string_view/element_access/wchar_t/ front_back.cc: Likewise. * testsuite/experimental/string_view/include.cc: Likewise. * testsuite/experimental/string_view/inserters/char/1.cc: Likewise. * testsuite/experimental/string_view/inserters/char/2.cc: Likewise. * testsuite/experimental/string_view/inserters/char/3.cc: Likewise. * testsuite/experimental/string_view/inserters/pod/10081-out.cc: Likewise. * testsuite/experimental/string_view/inserters/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/inserters/wchar_t/2.cc: Likewise. * testsuite/experimental/string_view/inserters/wchar_t/3.cc: Likewise. * testsuite/experimental/string_view/literals/types.cc: Likewise. * testsuite/experimental/string_view/literals/values.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_prefix/char/ 1.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_prefix/ wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_suffix/ char/1.cc: Likewise. * testsuite/experimental/string_view/modifiers/remove_suffix/ wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/compare/char/1.cc: Likewise. * testsuite/experimental/string_view/operations/compare/char/13650.cc: Likewise. * testsuite/experimental/string_view/operations/compare/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/compare/wchar_t/ 13650.cc: Likewise. * testsuite/experimental/string_view/operations/copy/char/1.cc: Likewise. * testsuite/experimental/string_view/operations/copy/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/data/char/1.cc: Likewise. * testsuite/experimental/string_view/operations/data/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/find/char/1.cc: Likewise. * testsuite/experimental/string_view/operations/find/char/2.cc: Likewise. * testsuite/experimental/string_view/operations/find/char/3.cc: Likewise. * testsuite/experimental/string_view/operations/find/char/4.cc: Likewise. * testsuite/experimental/string_view/operations/find/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/find/wchar_t/2.cc: Likewise. * testsuite/experimental/string_view/operations/find/wchar_t/3.cc: Likewise. * testsuite/experimental/string_view/operations/find/wchar_t/4.cc: Likewise. * testsuite/experimental/string_view/operations/rfind/char/1.cc: Likewise. * testsuite/experimental/string_view/operations/rfind/char/2.cc: Likewise. * testsuite/experimental/string_view/operations/rfind/char/3.cc: Likewise. * testsuite/experimental/string_view/operations/rfind/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/rfind/wchar_t/2.cc: Likewise. * testsuite/experimental/string_view/operations/rfind/wchar_t/3.cc: Likewise. * testsuite/experimental/string_view/operations/substr/char/1.cc: Likewise. * testsuite/experimental/string_view/operations/substr/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/operations/to_string/1.cc: Likewise. * testsuite/experimental/string_view/operators/char/2.cc: Likewise. * testsuite/experimental/string_view/operators/wchar_t/2.cc: Likewise. * testsuite/experimental/string_view/range_access/char/1.cc: Likewise. * testsuite/experimental/string_view/range_access/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/1.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char/1.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char16_t/1.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/char32_t/1.cc: Likewise. * testsuite/experimental/string_view/requirements/ explicit_instantiation/wchar_t/1.cc: Likewise. * testsuite/experimental/string_view/requirements/typedefs.cc: Likewise. * testsuite/experimental/string_view/types/1.cc: Likewise. From-SVN: r216257
2014-10-15 14:03:20 +02:00
// { dg-options "-std=gnu++14" }
enable_special_members.h: New. 2013-10-31 Michael Brune <lucdanton@free.fr> * include/bits/enable_special_members.h: New. * include/experimental/optional: New. * include/Makefile.am: Handle include/experimental. * include/Makefile.in: Regenerate. * testsuite/libstdc++-dg/conformance.exp: Run tests from testsuite/experimental sub-directory. * testsuite/experimental/optional/assignment/1.cc: New. * testsuite/experimental/optional/assignment/2.cc: New. * testsuite/experimental/optional/assignment/3.cc: New. * testsuite/experimental/optional/assignment/4.cc: New. * testsuite/experimental/optional/assignment/5.cc: New. * testsuite/experimental/optional/assignment/6.cc: New. * testsuite/experimental/optional/cons/copy.cc: New. * testsuite/experimental/optional/cons/default.cc: New. * testsuite/experimental/optional/cons/move.cc: New. * testsuite/experimental/optional/cons/value.cc: New. * testsuite/experimental/optional/constexpr/cons/default.cc: New. * testsuite/experimental/optional/constexpr/cons/value.cc: New. * testsuite/experimental/optional/constexpr/in_place.cc: New. * testsuite/experimental/optional/constexpr/make_optional.cc: New. * testsuite/experimental/optional/constexpr/nullopt.cc: New. * testsuite/experimental/optional/constexpr/observers/1.cc: New. * testsuite/experimental/optional/constexpr/observers/2.cc: New. * testsuite/experimental/optional/constexpr/observers/3.cc: New. * testsuite/experimental/optional/constexpr/observers/4.cc: New. * testsuite/experimental/optional/constexpr/observers/5.cc: New. * testsuite/experimental/optional/constexpr/relops/1.cc: New. * testsuite/experimental/optional/constexpr/relops/2.cc: New. * testsuite/experimental/optional/constexpr/relops/3.cc: New. * testsuite/experimental/optional/constexpr/relops/4.cc: New. * testsuite/experimental/optional/constexpr/relops/5.cc: New. * testsuite/experimental/optional/constexpr/relops/6.cc: New. * testsuite/experimental/optional/in_place.cc: New. * testsuite/experimental/optional/make_optional.cc: New. * testsuite/experimental/optional/nullopt.cc: New. * testsuite/experimental/optional/observers/1.cc: New. * testsuite/experimental/optional/observers/2.cc: New. * testsuite/experimental/optional/observers/3.cc: New. * testsuite/experimental/optional/observers/4.cc: New. * testsuite/experimental/optional/observers/5.cc: New. * testsuite/experimental/optional/relops/1.cc: New. * testsuite/experimental/optional/relops/2.cc: New. * testsuite/experimental/optional/relops/3.cc: New. * testsuite/experimental/optional/relops/4.cc: New. * testsuite/experimental/optional/relops/5.cc: New. * testsuite/experimental/optional/relops/6.cc: New. * testsuite/experimental/optional/requirements.cc: New. * testsuite/experimental/optional/swap/1.cc: New. From-SVN: r204299
2013-11-01 21:08:39 +01:00
// { dg-do run }
// Copyright (C) 2013-2015 Free Software Foundation, Inc.
enable_special_members.h: New. 2013-10-31 Michael Brune <lucdanton@free.fr> * include/bits/enable_special_members.h: New. * include/experimental/optional: New. * include/Makefile.am: Handle include/experimental. * include/Makefile.in: Regenerate. * testsuite/libstdc++-dg/conformance.exp: Run tests from testsuite/experimental sub-directory. * testsuite/experimental/optional/assignment/1.cc: New. * testsuite/experimental/optional/assignment/2.cc: New. * testsuite/experimental/optional/assignment/3.cc: New. * testsuite/experimental/optional/assignment/4.cc: New. * testsuite/experimental/optional/assignment/5.cc: New. * testsuite/experimental/optional/assignment/6.cc: New. * testsuite/experimental/optional/cons/copy.cc: New. * testsuite/experimental/optional/cons/default.cc: New. * testsuite/experimental/optional/cons/move.cc: New. * testsuite/experimental/optional/cons/value.cc: New. * testsuite/experimental/optional/constexpr/cons/default.cc: New. * testsuite/experimental/optional/constexpr/cons/value.cc: New. * testsuite/experimental/optional/constexpr/in_place.cc: New. * testsuite/experimental/optional/constexpr/make_optional.cc: New. * testsuite/experimental/optional/constexpr/nullopt.cc: New. * testsuite/experimental/optional/constexpr/observers/1.cc: New. * testsuite/experimental/optional/constexpr/observers/2.cc: New. * testsuite/experimental/optional/constexpr/observers/3.cc: New. * testsuite/experimental/optional/constexpr/observers/4.cc: New. * testsuite/experimental/optional/constexpr/observers/5.cc: New. * testsuite/experimental/optional/constexpr/relops/1.cc: New. * testsuite/experimental/optional/constexpr/relops/2.cc: New. * testsuite/experimental/optional/constexpr/relops/3.cc: New. * testsuite/experimental/optional/constexpr/relops/4.cc: New. * testsuite/experimental/optional/constexpr/relops/5.cc: New. * testsuite/experimental/optional/constexpr/relops/6.cc: New. * testsuite/experimental/optional/in_place.cc: New. * testsuite/experimental/optional/make_optional.cc: New. * testsuite/experimental/optional/nullopt.cc: New. * testsuite/experimental/optional/observers/1.cc: New. * testsuite/experimental/optional/observers/2.cc: New. * testsuite/experimental/optional/observers/3.cc: New. * testsuite/experimental/optional/observers/4.cc: New. * testsuite/experimental/optional/observers/5.cc: New. * testsuite/experimental/optional/relops/1.cc: New. * testsuite/experimental/optional/relops/2.cc: New. * testsuite/experimental/optional/relops/3.cc: New. * testsuite/experimental/optional/relops/4.cc: New. * testsuite/experimental/optional/relops/5.cc: New. * testsuite/experimental/optional/relops/6.cc: New. * testsuite/experimental/optional/requirements.cc: New. * testsuite/experimental/optional/swap/1.cc: New. From-SVN: r204299
2013-11-01 21:08:39 +01:00
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a moved_to of the GNU General Public License along
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <experimental/optional>
#include <testsuite_hooks.h>
#include <tuple>
using std::experimental::bad_optional_access;
static_assert( std::is_default_constructible<bad_optional_access>::value, "" );
enable_special_members.h: New. 2013-10-31 Michael Brune <lucdanton@free.fr> * include/bits/enable_special_members.h: New. * include/experimental/optional: New. * include/Makefile.am: Handle include/experimental. * include/Makefile.in: Regenerate. * testsuite/libstdc++-dg/conformance.exp: Run tests from testsuite/experimental sub-directory. * testsuite/experimental/optional/assignment/1.cc: New. * testsuite/experimental/optional/assignment/2.cc: New. * testsuite/experimental/optional/assignment/3.cc: New. * testsuite/experimental/optional/assignment/4.cc: New. * testsuite/experimental/optional/assignment/5.cc: New. * testsuite/experimental/optional/assignment/6.cc: New. * testsuite/experimental/optional/cons/copy.cc: New. * testsuite/experimental/optional/cons/default.cc: New. * testsuite/experimental/optional/cons/move.cc: New. * testsuite/experimental/optional/cons/value.cc: New. * testsuite/experimental/optional/constexpr/cons/default.cc: New. * testsuite/experimental/optional/constexpr/cons/value.cc: New. * testsuite/experimental/optional/constexpr/in_place.cc: New. * testsuite/experimental/optional/constexpr/make_optional.cc: New. * testsuite/experimental/optional/constexpr/nullopt.cc: New. * testsuite/experimental/optional/constexpr/observers/1.cc: New. * testsuite/experimental/optional/constexpr/observers/2.cc: New. * testsuite/experimental/optional/constexpr/observers/3.cc: New. * testsuite/experimental/optional/constexpr/observers/4.cc: New. * testsuite/experimental/optional/constexpr/observers/5.cc: New. * testsuite/experimental/optional/constexpr/relops/1.cc: New. * testsuite/experimental/optional/constexpr/relops/2.cc: New. * testsuite/experimental/optional/constexpr/relops/3.cc: New. * testsuite/experimental/optional/constexpr/relops/4.cc: New. * testsuite/experimental/optional/constexpr/relops/5.cc: New. * testsuite/experimental/optional/constexpr/relops/6.cc: New. * testsuite/experimental/optional/in_place.cc: New. * testsuite/experimental/optional/make_optional.cc: New. * testsuite/experimental/optional/nullopt.cc: New. * testsuite/experimental/optional/observers/1.cc: New. * testsuite/experimental/optional/observers/2.cc: New. * testsuite/experimental/optional/observers/3.cc: New. * testsuite/experimental/optional/observers/4.cc: New. * testsuite/experimental/optional/observers/5.cc: New. * testsuite/experimental/optional/relops/1.cc: New. * testsuite/experimental/optional/relops/2.cc: New. * testsuite/experimental/optional/relops/3.cc: New. * testsuite/experimental/optional/relops/4.cc: New. * testsuite/experimental/optional/relops/5.cc: New. * testsuite/experimental/optional/relops/6.cc: New. * testsuite/experimental/optional/requirements.cc: New. * testsuite/experimental/optional/swap/1.cc: New. From-SVN: r204299
2013-11-01 21:08:39 +01:00
struct trivially_destructible
{
trivially_destructible() = delete;
trivially_destructible(trivially_destructible const&) = delete;
trivially_destructible& operator=(trivially_destructible const&) = delete;
trivially_destructible(trivially_destructible&&) = delete;
trivially_destructible& operator=(trivially_destructible&&) = delete;
~trivially_destructible() noexcept = default;
};
static_assert( std::is_trivially_destructible<trivially_destructible>(), "" );
struct no_default_constructor
{
no_default_constructor() = delete;
};
struct no_copy_constructor
{
no_copy_constructor() = default;
no_copy_constructor(no_copy_constructor const&) = delete;
no_copy_constructor& operator=(no_copy_constructor const&) = default;
no_copy_constructor(no_copy_constructor&&) = default;
no_copy_constructor& operator=(no_copy_constructor&&) = default;
};
struct no_copy_assignment
{
no_copy_assignment() = default;
no_copy_assignment(no_copy_assignment const&) = default;
no_copy_assignment(no_copy_assignment&&) = default;
no_copy_assignment& operator=(no_copy_assignment&&) = default;
};
struct no_move_constructor
{
no_move_constructor() = default;
no_move_constructor(no_move_constructor const&) = default;
no_move_constructor& operator=(no_move_constructor const&) = default;
no_move_constructor(no_move_constructor&&) = delete;
no_move_constructor& operator=(no_move_constructor&&) = default;
};
struct no_move_assignment
{
no_move_assignment() = default;
no_move_assignment(no_move_assignment const&) = default;
no_move_assignment& operator=(no_move_assignment const&) = default;
no_move_assignment(no_move_assignment&&) = default;
no_move_assignment& operator=(no_move_assignment&&) = delete;
};
struct no_copy : no_copy_constructor, no_copy_assignment { };
struct no_move : no_move_constructor, no_move_assignment { };
// Laxest possible model of a value type for optional
struct only_destructible
{
only_destructible(only_destructible&&) = delete;
};
int main()
{
{
static_assert( std::is_trivially_destructible<std::experimental::optional<trivially_destructible>>(), "" );
}
{
using T = no_default_constructor;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( std::is_copy_constructible<O>(), "" );
{ O o; auto copy = o; }
static_assert( std::is_copy_assignable<O>(), "" );
{ O o, p; p = o; }
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = no_copy_constructor;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( !std::is_copy_constructible<O>(), "" );
static_assert( !std::is_copy_assignable<O>(), "" );
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = no_copy_assignment;
using O = std::experimental::optional<T>;
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( std::is_copy_constructible<O>(), "" );
{ O o; auto copy = o; }
static_assert( !std::is_copy_assignable<O>(), "" );
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = no_copy;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( !std::is_copy_constructible<O>(), "" );
static_assert( !std::is_copy_assignable<O>(), "" );
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = no_move_constructor;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( std::is_copy_constructible<O>(), "" );
{ O o; auto copy = o; }
static_assert( std::is_copy_assignable<O>(), "" );
/*
* T should be move constructible due to [12.8/11], which is a new rule in C++1y
* not yet implemented by GCC. Because there is already a special exception in C++11
* for the generation of the special members that GCC implements (at least some of the
* time), this does not affect the std::experimental::optional implementation however. So the assertion
* for T should be changed (or removed altogether) when the time comes, but the rest
* should however remain correct and unchanged.
*/
static_assert( !std::is_move_constructible<T>(), "" );
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = no_move_assignment;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( std::is_copy_constructible<O>(), "" );
{ O o; auto copy = o; }
static_assert( std::is_copy_assignable<O>(), "" );
{ O o, p; p = o; }
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
/*
* Paragraph 23 of same leads to a similar situation but with respect to move
* assignment.
*/
static_assert( !std::is_move_assignable<T>(), "" );
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = no_move;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( std::is_copy_constructible<O>(), "" );
{ O o; auto copy = o; }
static_assert( std::is_copy_assignable<O>(), "" );
{ O o, p; p = o; }
static_assert( std::is_move_constructible<O>(), "" );
{ O o; auto moved_to = std::move(o); }
static_assert( std::is_move_assignable<O>(), "" );
{ O o, p; p = std::move(o); }
}
{
using T = only_destructible;
using O = std::experimental::optional<T>;
static_assert( std::is_same<O::value_type, T>(), "" );
static_assert( std::is_default_constructible<O>(), "" );
{ O o; }
static_assert( !std::is_copy_constructible<O>(), "" );
static_assert( !std::is_copy_assignable<O>(), "" );
static_assert( !std::is_move_constructible<O>(), "" );
static_assert( !std::is_move_assignable<O>(), "" );
}
{
/*
* Should not complain about 'invalid' specializations as long as
* they're not instantiated.
*/
using A = std::experimental::optional<int&>;
using B = std::experimental::optional<int&&>;
using C1 = std::experimental::optional<std::experimental::in_place_t>;
using C2 = std::experimental::optional<std::experimental::in_place_t const>;
using C3 = std::experimental::optional<std::experimental::in_place_t volatile>;
using C4 = std::experimental::optional<std::experimental::in_place_t const volatile>;
using D1 = std::experimental::optional<std::experimental::nullopt_t>;
using D2 = std::experimental::optional<std::experimental::nullopt_t const>;
using D3 = std::experimental::optional<std::experimental::nullopt_t volatile>;
using D4 = std::experimental::optional<std::experimental::nullopt_t const volatile>;
using X = std::tuple<A, B, C1, C2, C3, C4, D1, D2, D3, D4>;
}
{
std::experimental::optional<const int> o { 42 };
static_assert( std::is_same<decltype(o)::value_type, const int>(), "" );
VERIFY( o );
VERIFY( *o == 42 );
}
{
constexpr std::experimental::optional<const int> o { 33 };
static_assert( std::is_same<decltype(o)::value_type, const int>(), "" );
static_assert( o, "" );
static_assert( *o == 33, "" );
}
}