Need one more swap overload for swapping two lvalue vector<bool>::reference's.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@178016 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/__bit_reference b/include/__bit_reference
index 8180295..1621deb 100644
--- a/include/__bit_reference
+++ b/include/__bit_reference
@@ -81,6 +81,16 @@
{
};
+template <class _Cp>
+_LIBCPP_INLINE_VISIBILITY inline
+void
+swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT
+{
+ bool __t = __x;
+ __x = __y;
+ __y = __t;
+}
+
template <class _Cp, class _Dp>
_LIBCPP_INLINE_VISIBILITY inline
void
diff --git a/test/containers/sequences/vector.bool/swap.pass.cpp b/test/containers/sequences/vector.bool/swap.pass.cpp
index 642641e..5d0f0af 100644
--- a/test/containers/sequences/vector.bool/swap.pass.cpp
+++ b/test/containers/sequences/vector.bool/swap.pass.cpp
@@ -51,4 +51,14 @@
assert(v1.get_allocator() == A(2));
assert(v2.get_allocator() == A(1));
}
+ {
+ std::vector<bool> v(2);
+ std::vector<bool>::reference r1 = v[0];
+ std::vector<bool>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
}