]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Explicitly default some copy ctors and assignments
authorJonathan Wakely <jwakely@redhat.com>
Tue, 8 Aug 2023 15:24:31 +0000 (16:24 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 18 Mar 2024 13:50:54 +0000 (13:50 +0000)
The standard says that the implicit copy assignment operator is
deprecated for classes that have a user-provided copy constructor, and
vice versa.

libstdc++-v3/ChangeLog:

* include/bits/new_allocator.h (__new_allocator): Define copy
assignment operator as defaulted.
* include/std/complex (complex<float>, complex<double>)
(complex<long double>): Define copy constructor as defaulted.

(cherry picked from commit 008e439f34d4b356825a6c9b70245143f00bd353)

libstdc++-v3/include/bits/new_allocator.h
libstdc++-v3/include/std/complex

index 99f7a2ee51e3a1d54f89904883be7da93690c50b..d066d015a9d0e9eabb323d5907fa6d43c3dce712 100644 (file)
@@ -86,6 +86,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
        _GLIBCXX20_CONSTEXPR
        __new_allocator(const __new_allocator<_Tp1>&) _GLIBCXX_USE_NOEXCEPT { }
 
+#if __cplusplus >= 201103L
+      __new_allocator& operator=(const __new_allocator&) = default;
+#endif
+
 #if __cplusplus <= 201703L
       ~__new_allocator() _GLIBCXX_USE_NOEXCEPT { }
 
index 8f9368fd7d04f25d3313625de70c3fb8b95e63a3..bdc238e73b00ae07858717a3b0647b2b5b97f2ad 100644 (file)
@@ -1098,6 +1098,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 #endif
 
+#if __cplusplus >= 201103L
+      _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
       explicit _GLIBCXX_CONSTEXPR complex(const complex<double>&);
       explicit _GLIBCXX_CONSTEXPR complex(const complex<long double>&);
 
@@ -1244,6 +1248,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 #endif
 
+#if __cplusplus >= 201103L
+      _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
       _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
       : _M_value(__z.__rep()) { }
 
@@ -1391,6 +1399,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 #endif
 
+#if __cplusplus >= 201103L
+      _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
       _GLIBCXX_CONSTEXPR complex(const complex<float>& __z)
       : _M_value(__z.__rep()) { }