From: Jonathan Wakely Date: Mon, 15 Jan 2024 16:51:39 +0000 (+0000) Subject: libstdc++: Fix redefinition error in std::tuple [PR108822] X-Git-Tag: basepoints/gcc-15~2883 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1e88a151f878e0a139bf55eb0cee2506fb903274;p=thirdparty%2Fgcc.git libstdc++: Fix redefinition error in std::tuple [PR108822] When using a compiler that doesn't define __cpp_conditional_explicit there's a redefinition error for tuple::__nothrow_assignable. This is because it's defined in different places for the pre-C++20 and C++20 implementations, which are controled by different preprocessor conditions. For certain combinations of C++20 feature test macros it's possible for both __nothrow_assignable definitions to be in scope. Move the pre-C++20 __assignable and __nothrow_assignable definitions adjacent to their use, so that only one set of definitions is visible for any given set of feature test macros. libstdc++-v3/ChangeLog: PR libstdc++/108822 * include/std/tuple (__assignable, __is_nothrow_assignable): Move pre-C++20 definitions adjacent to their use. --- diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 5f4a393b532c..2f6e419ea5bf 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -1237,20 +1237,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _TCC<_Cond>::template __is_explicitly_constructible<_Args...>(), bool>; - template - static constexpr - __enable_if_t - __assignable() - { return __and_...>::value; } - - // Condition for noexcept-specifier of an assignment operator. - template - static constexpr bool __nothrow_assignable() - { - return - __and_...>::value; - } - // Condition for noexcept-specifier of a constructor. template static constexpr bool __nothrow_constructible() @@ -1685,7 +1671,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION operator=(_UTuple&& __u) const; #endif // C++23 -#else // ! concepts +#else // ! (concepts && consteval) + + private: + template + static constexpr + __enable_if_t + __assignable() + { return __and_...>::value; } + + // Condition for noexcept-specifier of an assignment operator. + template + static constexpr bool __nothrow_assignable() + { + return + __and_...>::value; + } + + public: _GLIBCXX20_CONSTEXPR tuple& @@ -1728,7 +1731,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION this->_M_assign(std::move(__in)); return *this; } -#endif // concepts +#endif // concepts && consteval // tuple swap _GLIBCXX20_CONSTEXPR