[gcc r14-7256] libstdc++: Fix redefinition error in std::tuple [PR108822]
Jonathan Wakely
redi@gcc.gnu.org
Mon Jan 15 19:02:18 GMT 2024
https://gcc.gnu.org/g:1e88a151f878e0a139bf55eb0cee2506fb903274
commit r14-7256-g1e88a151f878e0a139bf55eb0cee2506fb903274
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Jan 15 16:51:39 2024 +0000
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:
---
libstdc++-v3/include/std/tuple | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 5f4a393b532..2f6e419ea5b 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
More information about the Libstdc++-cvs
mailing list