[libcxx] r178016 - Need one more swap overload for swapping two lvalue vector<bool>::reference's.
Howard Hinnant
hhinnant at apple.com
Tue Mar 26 06:48:58 PDT 2013
Author: hhinnant
Date: Tue Mar 26 08:48:57 2013
New Revision: 178016
URL: http://llvm.org/viewvc/llvm-project?rev=178016&view=rev
Log:
Need one more swap overload for swapping two lvalue vector<bool>::reference's.
Modified:
libcxx/trunk/include/__bit_reference
libcxx/trunk/test/containers/sequences/vector.bool/swap.pass.cpp
Modified: libcxx/trunk/include/__bit_reference
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__bit_reference?rev=178016&r1=178015&r2=178016&view=diff
==============================================================================
--- libcxx/trunk/include/__bit_reference (original)
+++ libcxx/trunk/include/__bit_reference Tue Mar 26 08:48:57 2013
@@ -81,6 +81,16 @@ class __bit_reference<_Cp, false>
{
};
+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
Modified: libcxx/trunk/test/containers/sequences/vector.bool/swap.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector.bool/swap.pass.cpp?rev=178016&r1=178015&r2=178016&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector.bool/swap.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/vector.bool/swap.pass.cpp Tue Mar 26 08:48:57 2013
@@ -51,4 +51,14 @@ int main()
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);
+ }
}
More information about the cfe-commits
mailing list