//{ dg-do run { target c++11 } } // 2019-04-10 Nina Dinka Ranns // // Copyright (C) 2019-2025 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)); }; // Similar to std::is_nothrow_convertible, but only considers whether the // actual conversion can throw (and not any potential copies of From). // This means the result is not affected by copy elision of From in C++17. 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, ""); #if __cplusplus > 202002L // C++23 extended tuple's constructor overload set as part of P2321R2, after // which its converting constructors more accurately forward the elements // from a non-const tuple lvalue and from a const tuple rvalue. In particular // for the below test we now forward int&& as an rvalue reference instead of // as an lvalue reference, which means we now select the noexcept B(int&&) // ctor instead of the non-noexcept B(const int&) ctor. static_assert(std::is_nothrow_constructible>::value, ""); #else static_assert(!std::is_nothrow_constructible>::value, ""); #endif 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,""); #if __cplusplus > 202002L // See the note about P2321R2 above. static_assert(test_trait::is_nothrow_convertible,BT>::value,""); #else static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); #endif 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, ""); #if __cplusplus > 202002L // See the note about P2321R2 above. static_assert(!std::is_nothrow_constructible>::value, ""); #else static_assert(std::is_nothrow_constructible>::value, ""); #endif 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,""); #if __cplusplus > 202002L // See the note about P2321R2 above. static_assert(!test_trait::is_nothrow_convertible,BT>::value,""); #else static_assert(test_trait::is_nothrow_convertible,BT>::value,""); #endif /* 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, ""); #if __cplusplus > 202002L // See the note about P2321R2 above. static_assert(std::is_nothrow_constructible>::value, ""); #else static_assert(!std::is_nothrow_constructible>::value, ""); #endif 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, ""); #if __cplusplus > 202002L // See note about P2321R2 above. static_assert(!std::is_nothrow_constructible>::value, ""); #else static_assert(std::is_nothrow_constructible>::value, ""); #endif 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, ""); #if __cplusplus > 202002L // See the note about P2321R2 above. static_assert(!std::is_nothrow_constructible>::value, ""); #else static_assert(std::is_nothrow_constructible>::value, ""); #endif 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(); }