public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r12-5311] libstdc++: Use hidden friends for vector<bool>::reference swap overloads Date: Tue, 16 Nov 2021 16:43:26 +0000 (GMT) [thread overview] Message-ID: <20211116164326.E50733858401@sourceware.org> (raw) https://gcc.gnu.org/g:59434931fb658f0a180ce3f3305cb3987ed2b56d commit r12-5311-g59434931fb658f0a180ce3f3305cb3987ed2b56d Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Nov 11 20:51:15 2021 +0000 libstdc++: Use hidden friends for vector<bool>::reference swap overloads These swap overloads are non-standard, but are needed to make swap work for vector<bool>::reference rvalues. They don't need to be called explicitly, only via ADL, so hide them from normal lookup. This is what I've proposed as the resolution to LWG 3638. libstdc++-v3/ChangeLog: * include/bits/stl_bvector.h (swap(_Bit_reference, _Bit_reference)) (swap(_Bit_reference, bool&), swap(bool&, _Bit_reference)): Define as hidden friends of _Bit_reference. Diff: --- libstdc++-v3/include/bits/stl_bvector.h | 50 ++++++++++++++++----------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 381c47b6132..68070685baf 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -125,36 +125,36 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void flip() _GLIBCXX_NOEXCEPT { *_M_p ^= _M_mask; } - }; #if __cplusplus >= 201103L - _GLIBCXX20_CONSTEXPR - inline void - swap(_Bit_reference __x, _Bit_reference __y) noexcept - { - bool __tmp = __x; - __x = __y; - __y = __tmp; - } + _GLIBCXX20_CONSTEXPR + friend void + swap(_Bit_reference __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } - _GLIBCXX20_CONSTEXPR - inline void - swap(_Bit_reference __x, bool& __y) noexcept - { - bool __tmp = __x; - __x = __y; - __y = __tmp; - } + _GLIBCXX20_CONSTEXPR + friend void + swap(_Bit_reference __x, bool& __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } - _GLIBCXX20_CONSTEXPR - inline void - swap(bool& __x, _Bit_reference __y) noexcept - { - bool __tmp = __x; - __x = __y; - __y = __tmp; - } + _GLIBCXX20_CONSTEXPR + friend void + swap(bool& __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } #endif + }; struct _Bit_iterator_base : public std::iterator<std::random_access_iterator_tag, bool>
reply other threads:[~2021-11-16 16:43 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=20211116164326.E50733858401@sourceware.org \ --to=redi@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).