From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [committed] libstdc++: Explicitly default some copy ctors and assignments
Date: Wed, 9 Aug 2023 15:21:47 +0100 [thread overview]
Message-ID: <20230809142156.1014897-1-jwakely@redhat.com> (raw)
Tested x86_64-linux. Pushed to trunk.
-- >8 --
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 | 4 ++++
libstdc++-v3/include/std/complex | 13 +++++++++++++
2 files changed, 17 insertions(+)
diff --git a/libstdc++-v3/include/bits/new_allocator.h b/libstdc++-v3/include/bits/new_allocator.h
index 0a0b12eb504..357700292ed 100644
--- a/libstdc++-v3/include/bits/new_allocator.h
+++ b/libstdc++-v3/include/bits/new_allocator.h
@@ -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 { }
diff --git a/libstdc++-v3/include/std/complex b/libstdc++-v3/include/std/complex
index f01a3af4371..0ba2167bf02 100644
--- a/libstdc++-v3/include/std/complex
+++ b/libstdc++-v3/include/std/complex
@@ -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>
--
2.41.0
reply other threads:[~2023-08-09 14:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230809142156.1014897-1-jwakely@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).