diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2024-01-15 16:51:39 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2024-01-15 17:18:53 +0000 |
commit | 1e88a151f878e0a139bf55eb0cee2506fb903274 (patch) | |
tree | a258e02df3f15562d187c018373499a1e944e585 | |
parent | 6c703b4eb68cbc32de1d62e5b573cb1b9857af29 (diff) | |
download | gcc-1e88a151f878e0a139bf55eb0cee2506fb903274.zip gcc-1e88a151f878e0a139bf55eb0cee2506fb903274.tar.gz gcc-1e88a151f878e0a139bf55eb0cee2506fb903274.tar.bz2 |
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.
-rw-r--r-- | libstdc++-v3/include/std/tuple | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 5f4a393..2f6e419 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<typename... _UElements> - static constexpr - __enable_if_t<sizeof...(_UElements) == sizeof...(_Elements), bool> - __assignable() - { return __and_<is_assignable<_Elements&, _UElements>...>::value; } - - // Condition for noexcept-specifier of an assignment operator. - template<typename... _UElements> - static constexpr bool __nothrow_assignable() - { - return - __and_<is_nothrow_assignable<_Elements&, _UElements>...>::value; - } - // Condition for noexcept-specifier of a constructor. template<typename... _UElements> 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<typename... _UElements> + static constexpr + __enable_if_t<sizeof...(_UElements) == sizeof...(_Elements), bool> + __assignable() + { return __and_<is_assignable<_Elements&, _UElements>...>::value; } + + // Condition for noexcept-specifier of an assignment operator. + template<typename... _UElements> + static constexpr bool __nothrow_assignable() + { + return + __and_<is_nothrow_assignable<_Elements&, _UElements>...>::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 |