From ec087ba34e3e4f8ce60c83d5ca754c15a9bdf785 Mon Sep 17 00:00:00 2001 From: Nina Dinka Ranns Date: Sun, 28 Apr 2019 21:17:50 +0000 Subject: [PATCH] Adding noexcept-specification on tuple constructors (LWG 2899) 2019-04-28 Nina Dinka Ranns * libstdc++-v3/include/std/tuple: (tuple()): Add noexcept-specification. (tuple(const _Elements&...)): Likewise (tuple(_UElements&&...)): Likewise (tuple(const tuple<_UElements...>&)): Likewise (tuple(tuple<_UElements...>&&)): Likewise (tuple(const _T1&, const _T2&)): Likewise (tuple(_U1&&, _U2&&)): Likewise (tuple(const tuple<_U1, _U2>&): Likewise (tuple(tuple<_U1, _U2>&&): Likewise (tuple(const pair<_U1, _U2>&): Likewise (tuple(pair<_U1, _U2>&&): Likewise * libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc: New From-SVN: r270632 --- libstdc++-v3/ChangeLog | 17 + libstdc++-v3/include/std/tuple | 39 + .../20_util/tuple/cons/noexcept_specs.cc | 943 ++++++++++++++++++ 3 files changed, 999 insertions(+) create mode 100644 libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 606244f331c..15020ee6664 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,20 @@ +2019-04-28 Nina Dinka Ranns + + Adding noexcept-specification on tuple constructors (LWG 2899) + * libstdc++-v3/include/std/tuple: + (tuple()): Add noexcept-specification. + (tuple(const _Elements&...)): Likewise + (tuple(_UElements&&...)): Likewise + (tuple(const tuple<_UElements...>&)): Likewise + (tuple(tuple<_UElements...>&&)): Likewise + (tuple(const _T1&, const _T2&)): Likewise + (tuple(_U1&&, _U2&&)): Likewise + (tuple(const tuple<_U1, _U2>&): Likewise + (tuple(tuple<_U1, _U2>&&): Likewise + (tuple(const pair<_U1, _U2>&): Likewise + (tuple(pair<_U1, _U2>&&): Likewise + * libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc: New + 2019-04-27 Marc Glisse PR libstdc++/87106 diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 6c7d91b7987..fba28f963cd 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -552,6 +552,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __and_...>::value; } + template + static constexpr bool __nothrow_constructible() + { + return + __and_...>::value; + } public: template::type = true> constexpr tuple() + noexcept(__and_...>::value) : _Inherited() { } template::type = false> explicit constexpr tuple() + noexcept(__and_...>::value) : _Inherited() { } // Shortcut for the cases where constructors taking _Elements... @@ -586,6 +594,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && (sizeof...(_Elements) >= 1), bool>::type=true> constexpr tuple(const _Elements&... __elements) + noexcept(__nothrow_constructible()) : _Inherited(__elements...) { } template= 1), bool>::type=false> explicit constexpr tuple(const _Elements&... __elements) + noexcept(__nothrow_constructible()) : _Inherited(__elements...) { } // Shortcut for the cases where constructors taking _UElements... @@ -624,6 +634,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && (sizeof...(_Elements) >= 1), bool>::type=true> constexpr tuple(_UElements&&... __elements) + noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(std::forward<_UElements>(__elements)...) { } template= 1), bool>::type=false> explicit constexpr tuple(_UElements&&... __elements) + noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(std::forward<_UElements>(__elements)...) { } constexpr tuple(const tuple&) = default; @@ -656,6 +668,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _NonNestedTuple&>(), bool>::type=true> constexpr tuple(const tuple<_UElements...>& __in) + noexcept(__nothrow_constructible()) : _Inherited(static_cast&>(__in)) { } @@ -668,6 +681,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _NonNestedTuple&>(), bool>::type=false> explicit constexpr tuple(const tuple<_UElements...>& __in) + noexcept(__nothrow_constructible()) : _Inherited(static_cast&>(__in)) { } @@ -680,6 +694,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _NonNestedTuple&&>(), bool>::type=true> constexpr tuple(tuple<_UElements...>&& __in) + noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } template&&>(), bool>::type=false> explicit constexpr tuple(tuple<_UElements...>&& __in) + noexcept(__nothrow_constructible<_UElements...>()) : _Inherited(static_cast<_Tuple_impl<0, _UElements...>&&>(__in)) { } // Allocator-extended constructors. @@ -908,6 +924,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION is_nothrow_assignable<_T2&, _U2>>::value; } + template + static constexpr bool __nothrow_constructible() + { + return __and_, + is_nothrow_constructible<_T2, _U2>>::value; + } + public: template > ::value, bool>::type = true> constexpr tuple() + noexcept(__and_, + is_nothrow_default_constructible<_T2>>::value) : _Inherited() { } template >>> ::value, bool>::type = false> explicit constexpr tuple() + noexcept(__and_, + is_nothrow_default_constructible<_T2>>::value) : _Inherited() { } // Shortcut for the cases where constructors taking _T1, _T2 @@ -943,6 +970,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ImplicitlyConvertibleTuple<_T1, _T2>(), bool>::type = true> constexpr tuple(const _T1& __a1, const _T2& __a2) + noexcept(__nothrow_constructible()) : _Inherited(__a1, __a2) { } template(), bool>::type = false> explicit constexpr tuple(const _T1& __a1, const _T2& __a2) + noexcept(__nothrow_constructible()) : _Inherited(__a1, __a2) { } // Shortcut for the cases where constructors taking _U1, _U2 @@ -966,6 +995,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION && !is_same<__remove_cvref_t<_U1>, allocator_arg_t>::value, bool>::type = true> constexpr tuple(_U1&& __a1, _U2&& __a2) + noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } template, allocator_arg_t>::value, bool>::type = false> explicit constexpr tuple(_U1&& __a1, _U2&& __a2) + noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__a1), std::forward<_U2>(__a2)) { } constexpr tuple(const tuple&) = default; @@ -989,6 +1020,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ImplicitlyConvertibleTuple<_U1, _U2>(), bool>::type = true> constexpr tuple(const tuple<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) : _Inherited(static_cast&>(__in)) { } template(), bool>::type = false> explicit constexpr tuple(const tuple<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) : _Inherited(static_cast&>(__in)) { } template(), bool>::type = true> constexpr tuple(tuple<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template(), bool>::type = false> explicit constexpr tuple(tuple<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(static_cast<_Tuple_impl<0, _U1, _U2>&&>(__in)) { } template(), bool>::type = true> constexpr tuple(const pair<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) : _Inherited(__in.first, __in.second) { } template(), bool>::type = false> explicit constexpr tuple(const pair<_U1, _U2>& __in) + noexcept(__nothrow_constructible()) : _Inherited(__in.first, __in.second) { } template(), bool>::type = true> constexpr tuple(pair<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } @@ -1053,6 +1091,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _ImplicitlyMoveConvertibleTuple<_U1, _U2>(), bool>::type = false> explicit constexpr tuple(pair<_U1, _U2>&& __in) + noexcept(__nothrow_constructible<_U1, _U2>()) : _Inherited(std::forward<_U1>(__in.first), std::forward<_U2>(__in.second)) { } diff --git a/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc b/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc new file mode 100644 index 00000000000..da9ef1c26b2 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/tuple/cons/noexcept_specs.cc @@ -0,0 +1,943 @@ +//{ dg-do run { target c++11 } } + +// 2019-04-10 Nina Dinka Ranns +// +// Copyright (C) 2019 Free Software Foundation, Inc. +// +// 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 copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include +#include + +using namespace __gnu_test; + +bool throwing_ctor_called = false; + +namespace test_trait{ + template + using bool_constant = std::integral_constant; + + template, std::is_function, + std::is_array>::value> + struct is_nt_convertible_helper + : std::is_void + { }; + + template + class is_nt_convertible_helper + { + template + static void test_aux(To1) noexcept; + + template + static bool_constant({std::declval()}))> + test(int); + + template + static std::false_type + test(...); + + public: + using type = decltype(test(0)); + }; + + /// is_nothrow_convertible + template + struct is_nothrow_convertible + : public is_nt_convertible_helper::type + { }; +} + +template +bool checkDefaultThrowConstruct() +{ + throwing_ctor_called = false; + bool deduced_nothrow = std::is_nothrow_constructible::value; + T t{}; + return throwing_ctor_called != deduced_nothrow; +} +template +bool checkCopyThrowConstruct() +{ + throwing_ctor_called = false; + bool deduced_nothrow = std::is_nothrow_constructible::value; + U u; + T t{u}; + return throwing_ctor_called != deduced_nothrow; +} +template +bool checkMoveThrowConstruct() +{ + throwing_ctor_called = false; + bool deduced_nothrow = std::is_nothrow_constructible::value; + U u; + T t{std::move(u)}; + return throwing_ctor_called != deduced_nothrow; +} + +typedef std::tuple IT; +typedef std::tuple CIT; +typedef std::tuple RVIT; +typedef std::tuple IIT; +typedef std::pair IIP; +typedef std::tuple IIIT; + +namespace DefaultConstructionTests +{ + struct NoexceptDC + { + NoexceptDC() noexcept(true){} + }; + + struct ExceptDC + { + ExceptDC() noexcept(false) + { throwing_ctor_called = true; } + }; + + struct ExplicitNoexceptDC + { + explicit ExplicitNoexceptDC() noexcept(true) + {} + }; + + struct ExplicitExceptDC + { + explicit ExplicitExceptDC() noexcept(false) + { throwing_ctor_called = true; } + }; + + typedef std::tuple NDT; + typedef std::tuple EDT; + typedef std::tuple X_NDT; + typedef std::tuple X_EDT; + + typedef std::tuple NNDT; + typedef std::tuple EEDT; + typedef std::tuple ENDT; + typedef std::tuple X_NNDT; + typedef std::tuple X_EEDT; + typedef std::tuple X_ENDT; + + typedef std::tuple LNDNDT; + typedef std::tuple LNDEDT; + typedef std::tuple X_LNEDNDT; + typedef std::tuple X_LNEDEDT; + typedef std::tuple X_LEEDEDT; + + + /* if it has E in the name, it contains a type that throws when default constructed */ + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + + void Run() + { + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + VERIFY( checkDefaultThrowConstruct() ); + } +} +namespace AllNoThrow +{ + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + static_assert(test_trait::is_nothrow_convertible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); +} +namespace ThrowCopyNothrowConversion +{ + struct A + { + A() noexcept(true) + {} + + A(const int&) noexcept(true) + {} + + A(const A&) noexcept(false) + { throwing_ctor_called = true; } + + }; + + typedef std::tuple AT; + typedef std::tuple AAT; + typedef std::pair AAP; + typedef std::tuple IAT; + typedef std::pair IAP; + typedef std::tuple AAAT; + typedef std::tuple IIAT; + +/* one element tests */ + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible,AT>::value,""); + static_assert(test_trait::is_nothrow_convertible,AT>::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible,AT>::value,""); + static_assert(!test_trait::is_nothrow_convertible,AT>::value,""); + +/* two element tests */ + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible,AAT>::value,""); + + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible,AAT>::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible,AAT>::value,""); + + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + +/* three element tests */ + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + + void Run() + { + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + + VERIFY( (checkCopyThrowConstruct>()) ); + VERIFY( (checkMoveThrowConstruct>()) ); + VERIFY( (checkCopyThrowConstruct>()) ); + VERIFY( (checkMoveThrowConstruct>()) ); + + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + } +} +namespace NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion +{ + struct B + { + B() noexcept(true) + {} + + B(const int&) noexcept(false) + { throwing_ctor_called = true; } + + B(int&&) noexcept(true) + {} + + B(const B&) noexcept(true) + {} + + B(B&&) noexcept(false) + { throwing_ctor_called = true; } + }; + + + struct D + { + D() noexcept(true) + {} + + explicit + D(const int&) noexcept(false) + { throwing_ctor_called = true; } + + explicit + D(int&&) noexcept(true) + {} + + explicit + D(const D&) noexcept(true) + {} + + explicit + D(D&&) noexcept(false) + { throwing_ctor_called = true; } + + }; + + typedef std::tuple BT; + typedef std::tuple BBT; + typedef std::pair BBP; + typedef std::tuple DT; + typedef std::tuple DDT; + typedef std::pair DDP; + typedef std::tuple IDT; + typedef std::pair IDP; + typedef std::tuple IBT; + typedef std::pair IBP; + typedef std::tuple DBT; + typedef std::pair DBP; + typedef std::tuple BBBT; + typedef std::tuple DDDT; + typedef std::tuple IDIT; + typedef std::tuple IBIT; + typedef std::tuple IDBT; + +/* one element tests */ + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible>::value, ""); + static_assert(!std::is_nothrow_constructible>::value, ""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); + static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); + + + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible>::value, ""); + static_assert(std::is_nothrow_constructible>::value, ""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible,BT>::value,""); + static_assert(test_trait::is_nothrow_convertible,BT>::value,""); + +/* explicit */ + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(!std::is_nothrow_constructible>::value, ""); + static_assert(!std::is_nothrow_constructible>::value, ""); + + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible>::value, ""); + static_assert(std::is_nothrow_constructible>::value, ""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + +/* two elements tests */ + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible,BBT>::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible,BBT>::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible,BBT>::value,""); + + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + +/* explicit */ + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + +/* three elements tests */ + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(!test_trait::is_nothrow_convertible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(!std::is_nothrow_constructible>::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + +/* explicit */ + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(!test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(!std::is_nothrow_constructible>::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + + void Run() + { + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct>()) ); + VERIFY( (checkMoveThrowConstruct>()) ); + + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct>()) ); + VERIFY( (checkMoveThrowConstruct>()) ); + + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + + + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + + } +} +namespace ThrowCopy +{ + struct C + { + C() noexcept(true) + {} + + explicit + C(const C&) noexcept(true) {} + + }; + + typedef std::tuple CT; + typedef std::tuple CCT; + typedef std::pair CCP; + typedef std::tuple IICT; + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + +} +namespace ThrowMoveNothrowConversion +{ + struct D + { + D() noexcept(true) + {} + + explicit + D(const int&) noexcept(true) + {} + + explicit + D(int&&) noexcept(false) + { throwing_ctor_called = true; } + + }; + + typedef std::tuple DT; + typedef std::tuple DDT; + typedef std::pair DDP; + typedef std::tuple IDIT; + + + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + + static_assert(!std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible::value, ""); + static_assert(std::is_nothrow_constructible>::value, ""); + static_assert(std::is_nothrow_constructible>::value, ""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + +/* two elements tests */ + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + static_assert(std::is_convertible::value,""); + +/* three elements tests */ + static_assert(!std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + + static_assert(test_trait::is_nothrow_convertible::value,""); + static_assert(test_trait::is_nothrow_convertible::value,""); + + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible::value,""); + static_assert(std::is_nothrow_constructible>::value,""); + static_assert(!std::is_nothrow_constructible>::value,""); + + void Run() + { + VERIFY( (checkCopyThrowConstruct()) ); + VERIFY( (checkMoveThrowConstruct()) ); + VERIFY( (checkCopyThrowConstruct>()) ); + VERIFY( (checkMoveThrowConstruct>()) ); + } +} + +int main() +{ + + DefaultConstructionTests::Run(); + + ThrowCopyNothrowConversion::Run(); + + NothrowCopyThrowMoveThrowCopyConversionNothrowMoveConversion::Run(); + + ThrowMoveNothrowConversion::Run(); + +} + -- 2.30.2