public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/105241] New: std::bitset::reference should have an ADL swap
@ 2022-04-12 16:39 arthur.j.odwyer at gmail dot com
  2022-04-12 17:46 ` [Bug libstdc++/105241] " redi at gcc dot gnu.org
  2022-04-12 18:27 ` redi at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: arthur.j.odwyer at gmail dot com @ 2022-04-12 16:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105241

            Bug ID: 105241
           Summary: std::bitset::reference should have an ADL swap
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

(Originally reported by Nicholas Sielicki on the cpplang Slack)

// https://godbolt.org/z/138cPv5cn
#include <bitset>
#include <utility>
std::bitset<1> a = {1};
std::bitset<1> b = {0};
int main() {
    using std::swap;
    swap(a[0], b[0]);
    return a[0] == 0 && b[0] == 1;  // should be TRUE, right?
}

<source>:8:9: error: no matching function for call to
'swap(std::bitset<1>::reference, std::bitset<1>::reference)'
    8 |     swap(a[0], b[0]);
      |     ~~~~^~~~~~~~~~~~

Swapping elements via the std::swap two-step works for `std::vector<bool>`; I
see no reason it shouldn't also work for `std::bitset<N>`.
libc++ and Microsoft STL both support `swap` on `bitset::reference` just fine.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/105241] std::bitset::reference should have an ADL swap
  2022-04-12 16:39 [Bug libstdc++/105241] New: std::bitset::reference should have an ADL swap arthur.j.odwyer at gmail dot com
@ 2022-04-12 17:46 ` redi at gcc dot gnu.org
  2022-04-12 18:27 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-12 17:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105241

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-04-12
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Arthur O'Dwyer from comment #0)
> Swapping elements via the std::swap two-step works for `std::vector<bool>`;

Not according to the C++ standard it doesn't. That's https://wg21.link/lwg3638

> I see no reason it shouldn't also work for `std::bitset<N>`.

I see no requirement in the standard for it to work.

> libc++ and Microsoft STL both support `swap` on `bitset::reference` just
> fine.

That's a non-standard extension.

I think we could add it to libstdc++, but this seems like an LWG issue to me.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug libstdc++/105241] std::bitset::reference should have an ADL swap
  2022-04-12 16:39 [Bug libstdc++/105241] New: std::bitset::reference should have an ADL swap arthur.j.odwyer at gmail dot com
  2022-04-12 17:46 ` [Bug libstdc++/105241] " redi at gcc dot gnu.org
@ 2022-04-12 18:27 ` redi at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2022-04-12 18:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105241

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-04-12 18:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-12 16:39 [Bug libstdc++/105241] New: std::bitset::reference should have an ADL swap arthur.j.odwyer at gmail dot com
2022-04-12 17:46 ` [Bug libstdc++/105241] " redi at gcc dot gnu.org
2022-04-12 18:27 ` redi at gcc dot gnu.org

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).