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.