Index: include/bits/stl_algobase.h =================================================================== --- include/bits/stl_algobase.h (revision 184911) +++ include/bits/stl_algobase.h (working copy) @@ -1,7 +1,7 @@ // Core algorithmic facilities -*- C++ -*- // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, -// 2011 Free Software Foundation, Inc. +// 2011, 2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -74,6 +74,7 @@ { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#ifndef __GXX_EXPERIMENTAL_CXX0X__ // See http://gcc.gnu.org/ml/libstdc++/2004-08/msg00167.html: in a // nutshell, we are partially implementing the resolution of DR 187, // when it's safe, i.e., the value_types are equal. @@ -102,6 +103,7 @@ swap(*__a, *__b); } }; +#endif /** * @brief Swaps the contents of two iterators. @@ -117,16 +119,18 @@ inline void iter_swap(_ForwardIterator1 __a, _ForwardIterator2 __b) { + // concept requirements + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator1>) + __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< + _ForwardIterator2>) + +#ifndef __GXX_EXPERIMENTAL_CXX0X__ typedef typename iterator_traits<_ForwardIterator1>::value_type _ValueType1; typedef typename iterator_traits<_ForwardIterator2>::value_type _ValueType2; - // concept requirements - __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< - _ForwardIterator1>) - __glibcxx_function_requires(_Mutable_ForwardIteratorConcept< - _ForwardIterator2>) __glibcxx_function_requires(_ConvertibleConcept<_ValueType1, _ValueType2>) __glibcxx_function_requires(_ConvertibleConcept<_ValueType2, @@ -140,6 +144,9 @@ && __are_same<_ValueType1&, _ReferenceType1>::__value && __are_same<_ValueType2&, _ReferenceType2>::__value>:: iter_swap(__a, __b); +#else + swap(*__a, *__b); +#endif } /** Index: include/bits/stl_bvector.h =================================================================== --- include/bits/stl_bvector.h (revision 184911) +++ include/bits/stl_bvector.h (working copy) @@ -108,6 +108,32 @@ { *_M_p ^= _M_mask; } }; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + inline void + swap(_Bit_reference __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + inline void + swap(_Bit_reference __x, bool& __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } + + inline void + swap(bool& __x, _Bit_reference __y) noexcept + { + bool __tmp = __x; + __x = __y; + __y = __tmp; + } +#endif + struct _Bit_iterator_base : public std::iterator { Index: testsuite/23_containers/vector/bool/swap.cc =================================================================== --- testsuite/23_containers/vector/bool/swap.cc (revision 0) +++ testsuite/23_containers/vector/bool/swap.cc (revision 0) @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++11" } + +// Copyright (C) 2012 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include +#include + +template + void + my_reverse(Cont& c) + { + for (std::size_t i = 0, j = c.size(); i < j; ++i) + { + --j; + using std::swap; + swap(c[i], c[j]); + } + } + +template + void + my_compare(const Cont& c1, const Cont& c2) + { + bool test __attribute__((unused)) = true; + + VERIFY( c1.size() == c2.size() ); + + for (std::size_t i = 0; i < c1.size(); ++i) + VERIFY( c1[i] == c2[c1.size() - i - 1] ); + } + +void test01() +{ + const std::vector vb_ref{0, 1, 1, 0, 1}; + std::vector vb(vb_ref); + my_reverse(vb); + my_compare(vb_ref, vb); +} + +int main() +{ + test01(); + return 0; +}