public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Tamar Christina <tnfchris@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc(refs/vendors/ARM/heads/arm-struct-reorg-wip)] libstdc++ Fix compilation of <stop_token> with Clang Date: Fri, 17 Jul 2020 13:44:42 +0000 (GMT) [thread overview] Message-ID: <20200717134442.3CDAA39A0C37@sourceware.org> (raw) https://gcc.gnu.org/g:e5de406f9967ef4b0bbdbcbc0320869d2bf04558 commit e5de406f9967ef4b0bbdbcbc0320869d2bf04558 Author: Jonathan Wakely <jwakely@redhat.com> Date: Wed Mar 18 12:55:29 2020 +0000 libstdc++ Fix compilation of <stop_token> with Clang Clang 9 supports C++20 via -std=c++2a but doesn't support three-way comparisons, so <stop_token> fails to compile. When the compiler doesn't support default comparisons, this patch defines operator== and operator!= for the _Stop_state_ref class. That is enough for the header to be compiled with Clang. It allows operator== for stop_token and stop_source to work, but not operator!= because that isn't explicitly defined. * include/std/stop_token (stop_token::_Stop_state_ref): Define comparison operators explicitly if the compiler won't synthesize them. Diff: --- libstdc++-v3/ChangeLog | 3 +++ libstdc++-v3/include/std/stop_token | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ae5fedbc66b..a9cd2599243 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2020-03-18 Jonathan Wakely <jwakely@redhat.com> + * include/std/stop_token (stop_token::_Stop_state_ref): Define + comparison operators explicitly if the compiler won't synthesize them. + * include/bits/stl_algobase.h (__lexicographical_compare_aux): Check __cpp_lib_concepts before using iter_reference_t. * include/bits/stream_iterator.h (istream_iterator): Check diff --git a/libstdc++-v3/include/std/stop_token b/libstdc++-v3/include/std/stop_token index 6fb8ae05197..87beb08c71d 100644 --- a/libstdc++-v3/include/std/stop_token +++ b/libstdc++-v3/include/std/stop_token @@ -456,8 +456,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Stop_state_t* operator->() const noexcept { return _M_ptr; } +#if __cpp_impl_three_way_comparison >= 201907L friend bool operator==(const _Stop_state_ref&, const _Stop_state_ref&) = default; +#else + friend bool + operator==(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs) + noexcept + { return __lhs._M_ptr == __rhs._M_ptr; } + + friend bool + operator!=(const _Stop_state_ref& __lhs, const _Stop_state_ref& __rhs) + noexcept + { return __lhs._M_ptr != __rhs._M_ptr; } +#endif private: _Stop_state_t* _M_ptr = nullptr;
reply other threads:[~2020-07-17 13:44 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=20200717134442.3CDAA39A0C37@sourceware.org \ --to=tnfchris@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@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: linkBe 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).