]> 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>
Wed, 9 Aug 2023 14:19:15 +0000 (15:19 +0100)
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.

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

index 0a0b12eb504180aa627dd7b43338f90006fed265..357700292edcc9e5619550ba5ca5755dbe712038 100644 (file)
@@ -96,6 +96,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 f01a3af43718bf35bb2fadad87adbef206175181..0ba2167bf0222923ffe7cad0c83763955992c7cb 100644 (file)
@@ -1359,6 +1359,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 #endif
 
+#if __cplusplus >= 201103L
+      _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
 #if __cplusplus > 202002L
       template<typename _Up>
        explicit(!requires(_Up __u) { value_type{__u}; })
@@ -1512,6 +1516,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 #endif
 
+#if __cplusplus >= 201103L
+      _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
 #if __cplusplus > 202002L
       template<typename _Up>
        explicit(!requires(_Up __u) { value_type{__u}; })
@@ -1666,6 +1674,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       }
 #endif
 
+#if __cplusplus >= 201103L
+      _GLIBCXX14_CONSTEXPR complex(const complex&) = default;
+#endif
+
 #if __cplusplus > 202002L
       template<typename _Up>
        explicit(!requires(_Up __u) { value_type{__u}; })
@@ -1901,6 +1913,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       // Let the compiler synthesize the copy and assignment
       // operator.  It always does a pretty good job.
+      constexpr complex(const complex&) = default;
       constexpr complex& operator=(const complex&) = default;
 
       template<typename _Up>