From 976e25f422573c2c1b3c76329ccf06b8bbc553ba Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 9 Aug 2006 23:39:16 +0000 Subject: [PATCH] stl_bvector.h (vector::_M_copy_aligned): New. 2006-08-09 Paolo Carlini * include/bits/stl_bvector.h (vector::_M_copy_aligned): New. (vector::vector(const vector&), operator=(const vector&), reserve(size_type), _M_fill_insert(iterator, size_type, bool), _M_insert_range(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag), _M_insert_aux(iterator, bool)): Use it. * testsuite/performance/23_containers/copy_construct/ vector_bool.cc: New. * testsuite/23_containers/vector/bool/cons/1.cc: New. * testsuite/23_containers/vector/bool/cons/2.cc: Likewise. * include/bits/stl_bvector.h (vector::_M_fill): Remove. (fill(_Bit_iterator, _Bit_iterator, const bool&)): New. (vector::_M_fill_insert(iterator, size_type, bool)): Adjust. * include/bits/stl_bvector.h (_M_initialize_range(_InputIterator, _InputIterator, std::input_iterator_tag)): Remove redundant assignments. * include/bits/stl_algo.h (find(istreambuf_iterator<>, istreambuf_iterator<>, _CharT)): Adjust signature. * include/bits/streambuf_iterator.h: Likewise. * include/std/std_streambuf.h: Likewise. From-SVN: r116049 --- libstdc++-v3/ChangeLog | 26 +++ libstdc++-v3/include/bits/stl_algo.h | 3 +- libstdc++-v3/include/bits/stl_bvector.h | 59 ++++--- libstdc++-v3/include/bits/streambuf_iterator.h | 4 +- libstdc++-v3/include/std/std_streambuf.h | 5 +- .../testsuite/23_containers/vector/bool/cons/1.cc | 179 ++++++++++++++++++++ .../testsuite/23_containers/vector/bool/cons/2.cc | 181 +++++++++++++++++++++ .../23_containers/copy_construct/vector_bool.cc | 47 ++++++ 8 files changed, 474 insertions(+), 30 deletions(-) create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc create mode 100644 libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index efb06c9..6fc3dba 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,31 @@ 2006-08-09 Paolo Carlini + * include/bits/stl_bvector.h (vector::_M_copy_aligned): New. + (vector::vector(const vector&), operator=(const vector&), + reserve(size_type), _M_fill_insert(iterator, size_type, bool), + _M_insert_range(iterator, _ForwardIterator, _ForwardIterator, + std::forward_iterator_tag), _M_insert_aux(iterator, bool)): Use it. + * testsuite/performance/23_containers/copy_construct/ + vector_bool.cc: New. + + * testsuite/23_containers/vector/bool/cons/1.cc: New. + * testsuite/23_containers/vector/bool/cons/2.cc: Likewise. + + * include/bits/stl_bvector.h (vector::_M_fill): Remove. + (fill(_Bit_iterator, _Bit_iterator, const bool&)): New. + (vector::_M_fill_insert(iterator, size_type, bool)): Adjust. + + * include/bits/stl_bvector.h (_M_initialize_range(_InputIterator, + _InputIterator, std::input_iterator_tag)): Remove redundant + assignments. + + * include/bits/stl_algo.h (find(istreambuf_iterator<>, + istreambuf_iterator<>, _CharT)): Adjust signature. + * include/bits/streambuf_iterator.h: Likewise. + * include/std/std_streambuf.h: Likewise. + +2006-08-09 Paolo Carlini + * include/bits/stl_algobase.h (fill(const _Deque_iterator<>&, const _Deque_iterator<>&, const _Tp&)): Move... * include/bits/deque.tcc: ... here. diff --git a/libstdc++-v3/include/bits/stl_algo.h b/libstdc++-v3/include/bits/stl_algo.h index cbdcd98..582b272 100644 --- a/libstdc++-v3/include/bits/stl_algo.h +++ b/libstdc++-v3/include/bits/stl_algo.h @@ -302,7 +302,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template typename __enable_if, __is_char<_CharT>::__value>::__type - find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT); + find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, + const _CharT&); /** * @brief Find the first occurrence of a value in a sequence. diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 72982a8..d728ce5 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -354,6 +354,20 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) operator+(ptrdiff_t __n, const _Bit_const_iterator& __x) { return __x + __n; } + inline void + fill(_Bit_iterator __first, _Bit_iterator __last, const bool& __x) + { + if (__first._M_p != __last._M_p) + { + std::__fill::fill(__first._M_p + 1, __last._M_p, __x ? ~0 : 0); + std::__fill::fill(__first, _Bit_iterator(__first._M_p + 1, 0), + __x); + std::__fill::fill(_Bit_iterator(__last._M_p, 0), __last, __x); + } + else + std::__fill::fill(__first, __last, __x); + } + template struct _Bvector_base { @@ -479,7 +493,7 @@ template : _Base(__x._M_get_Bit_allocator()) { _M_initialize(__x.size()); - std::copy(__x.begin(), __x.end(), this->_M_impl._M_start); + _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); } template @@ -503,8 +517,8 @@ template this->_M_deallocate(); _M_initialize(__x.size()); } - std::copy(__x.begin(), __x.end(), begin()); - this->_M_impl._M_finish = begin() + difference_type(__x.size()); + this->_M_impl._M_finish = _M_copy_aligned(__x.begin(), __x.end(), + begin()); return *this; } @@ -612,8 +626,8 @@ template if (this->capacity() < __n) { _Bit_type* __q = this->_M_allocate(__n); - this->_M_impl._M_finish = std::copy(begin(), end(), - iterator(__q, 0)); + this->_M_impl._M_finish = _M_copy_aligned(begin(), end(), + iterator(__q, 0)); this->_M_deallocate(); this->_M_impl._M_start = iterator(__q, 0); this->_M_impl._M_end_of_storage = (__q + (__n + int(_S_word_bit) - 1) @@ -745,18 +759,14 @@ template protected: - - void - _M_fill(iterator __first, iterator __last, bool __x) + // Precondition: __first._M_offset == 0 && __result._M_offset == 0. + iterator + _M_copy_aligned(const_iterator __first, const_iterator __last, + iterator __result) { - if (__first._M_p != __last._M_p) - { - std::fill(__first._M_p + 1, __last._M_p, __x ? ~0 : 0); - std::fill(__first, iterator(__first._M_p + 1, 0), __x); - std::fill(iterator(__last._M_p, 0), __last, __x); - } - else - std::fill(__first, __last, __x); + _Bit_type* __q = std::copy(__first._M_p, __last._M_p, __result._M_p); + return std::copy(const_iterator(__last._M_p, 0), __last, + iterator(__q, 0)); } void @@ -792,9 +802,6 @@ template _M_initialize_range(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) { - this->_M_impl._M_start = iterator(); - this->_M_impl._M_finish = iterator(); - this->_M_impl._M_end_of_storage = 0; for (; __first != __last; ++__first) push_back(*__first); } @@ -892,15 +899,16 @@ template { std::copy_backward(__position, end(), this->_M_impl._M_finish + difference_type(__n)); - _M_fill(__position, __position + difference_type(__n), __x); + std::fill(__position, __position + difference_type(__n), __x); this->_M_impl._M_finish += difference_type(__n); } else { const size_type __len = size() + std::max(size(), __n); _Bit_type * __q = this->_M_allocate(__len); - iterator __i = std::copy(begin(), __position, iterator(__q, 0)); - _M_fill(__i, __i + difference_type(__n), __x); + iterator __i = _M_copy_aligned(begin(), __position, + iterator(__q, 0)); + std::fill(__i, __i + difference_type(__n), __x); this->_M_impl._M_finish = std::copy(__position, end(), __i + difference_type(__n)); this->_M_deallocate(); @@ -943,8 +951,8 @@ template { const size_type __len = size() + std::max(size(), __n); _Bit_type * __q = this->_M_allocate(__len); - iterator __i = std::copy(begin(), __position, - iterator(__q, 0)); + iterator __i = _M_copy_aligned(begin(), __position, + iterator(__q, 0)); __i = std::copy(__first, __last, __i); this->_M_impl._M_finish = std::copy(__position, end(), __i); this->_M_deallocate(); @@ -972,7 +980,8 @@ template const size_type __len = size() ? 2 * size() : static_cast(_S_word_bit); _Bit_type * __q = this->_M_allocate(__len); - iterator __i = std::copy(begin(), __position, iterator(__q, 0)); + iterator __i = _M_copy_aligned(begin(), __position, + iterator(__q, 0)); *__i++ = __x; this->_M_impl._M_finish = std::copy(__position, end(), __i); this->_M_deallocate(); diff --git a/libstdc++-v3/include/bits/streambuf_iterator.h b/libstdc++-v3/include/bits/streambuf_iterator.h index 56de85c..4691531 100644 --- a/libstdc++-v3/include/bits/streambuf_iterator.h +++ b/libstdc++-v3/include/bits/streambuf_iterator.h @@ -83,7 +83,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) friend typename __enable_if, __is_char<_CharT2>::__value>::__type find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, - _CharT2); + const _CharT2&); private: // 24.5.3 istreambuf_iterator @@ -363,7 +363,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) typename __enable_if, __is_char<_CharT>::__value>::__type find(istreambuf_iterator<_CharT> __first, - istreambuf_iterator<_CharT> __last, _CharT __val) + istreambuf_iterator<_CharT> __last, const _CharT& __val) { typedef istreambuf_iterator<_CharT> __is_iterator_type; typedef typename __is_iterator_type::traits_type traits_type; diff --git a/libstdc++-v3/include/std/std_streambuf.h b/libstdc++-v3/include/std/std_streambuf.h index 0cc83ce..40ef0d8 100644 --- a/libstdc++-v3/include/std/std_streambuf.h +++ b/libstdc++-v3/include/std/std_streambuf.h @@ -67,7 +67,8 @@ _GLIBCXX_BEGIN_NAMESPACE(std) template typename __enable_if, __is_char<_CharT>::__value>::__type - find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, _CharT); + find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, + const _CharT&); /** * @brief The actual work of input and output (interface). @@ -174,7 +175,7 @@ _GLIBCXX_BEGIN_NAMESPACE(std) friend typename __enable_if, __is_char<_CharT2>::__value>::__type find(istreambuf_iterator<_CharT2>, istreambuf_iterator<_CharT2>, - _CharT2); + const _CharT2&); template friend basic_istream<_CharT2, _Traits2>& diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc new file mode 100644 index 0000000..0eb8da1 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/1.cc @@ -0,0 +1,179 @@ +// 2006-08-09 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.5 vector copy construct + +#include +#include + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0,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1, + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + + const vec_type v1_ref(A1, A1 + N1); + vec_type v1(v1_ref); + VERIFY( v1.size() == v1_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v1_ref.begin()) ); + + const vec_type v2_ref(A2, A2 + N2); + vec_type v2(v2_ref); + VERIFY( v2.size() == v2_ref.size() ); + VERIFY( std::equal(v2.begin(), v2.end(), v2_ref.begin()) ); + + const vec_type v3_ref(A3, A3 + N3); + vec_type v3(v3_ref); + VERIFY( v3.size() == v3_ref.size() ); + VERIFY( std::equal(v3.begin(), v3.end(), v3_ref.begin()) ); + + const vec_type v4_ref(A4, A4 + N4); + vec_type v4(v4_ref); + VERIFY( v4.size() == v4_ref.size() ); + VERIFY( std::equal(v4.begin(), v4.end(), v4_ref.begin()) ); + + const vec_type v5_ref(A5, A5 + N5); + vec_type v5(v5_ref); + VERIFY( v5.size() == v5_ref.size() ); + VERIFY( std::equal(v5.begin(), v5.end(), v5_ref.begin()) ); + + const vec_type v6_ref(A6, A6 + N6); + vec_type v6(v6_ref); + VERIFY( v6.size() == v6_ref.size() ); + VERIFY( std::equal(v6.begin(), v6.end(), v6_ref.begin()) ); + + const vec_type v7_ref(A7, A7 + N7); + vec_type v7(v7_ref); + VERIFY( v7.size() == v7_ref.size() ); + VERIFY( std::equal(v7.begin(), v7.end(), v7_ref.begin()) ); + + const vec_type v8_ref(A8, A8 + N8); + vec_type v8(v8_ref); + VERIFY( v8.size() == v8_ref.size() ); + VERIFY( std::equal(v8.begin(), v8.end(), v8_ref.begin()) ); + + const vec_type v9_ref(A9, A9 + N9); + vec_type v9(v9_ref); + VERIFY( v9.size() == v9_ref.size() ); + VERIFY( std::equal(v9.begin(), v9.end(), v9_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc new file mode 100644 index 0000000..621c7d9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/2.cc @@ -0,0 +1,181 @@ +// 2006-08-09 Paolo Carlini + +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 23.2.5 vector assignment operator + +#include +#include + +const bool A1[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 1, 0}; + +const unsigned N1 = sizeof(A1) / sizeof(bool); +const unsigned N2 = sizeof(A2) / sizeof(bool); +const unsigned N3 = sizeof(A3) / sizeof(bool); +const unsigned N4 = sizeof(A4) / sizeof(bool); +const unsigned N5 = sizeof(A5) / sizeof(bool); +const unsigned N6 = sizeof(A6) / sizeof(bool); +const unsigned N7 = sizeof(A7) / sizeof(bool); +const unsigned N8 = sizeof(A8) / sizeof(bool); +const unsigned N9 = sizeof(A9) / sizeof(bool); + +void +test01() +{ + bool test __attribute__((unused)) = true; + + typedef std::vector vec_type; + + vec_type v1; + + const vec_type v1_ref(A1, A1 + N1); + v1 = v1_ref; + VERIFY( v1.size() == v1_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v1_ref.begin()) ); + + const vec_type v2_ref(A2, A2 + N2); + v1 = v2_ref; + VERIFY( v1.size() == v2_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v2_ref.begin()) ); + + const vec_type v3_ref(A3, A3 + N3); + v1 = v3_ref; + VERIFY( v1.size() == v3_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v3_ref.begin()) ); + + const vec_type v4_ref(A4, A4 + N4); + v1 = v4_ref; + VERIFY( v1.size() == v4_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v4_ref.begin()) ); + + const vec_type v5_ref(A5, A5 + N5); + v1 = v5_ref; + VERIFY( v1.size() == v5_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v5_ref.begin()) ); + + const vec_type v6_ref(A6, A6 + N6); + v1 = v6_ref; + VERIFY( v1.size() == v6_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v6_ref.begin()) ); + + const vec_type v7_ref(A7, A7 + N7); + v1 = v7_ref; + VERIFY( v1.size() == v7_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v7_ref.begin()) ); + + const vec_type v8_ref(A8, A8 + N8); + v1 = v8_ref; + VERIFY( v1.size() == v8_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v8_ref.begin()) ); + + const vec_type v9_ref(A9, A9 + N9); + v1 = v9_ref; + VERIFY( v1.size() == v9_ref.size() ); + VERIFY( std::equal(v1.begin(), v1.end(), v9_ref.begin()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc b/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc new file mode 100644 index 0000000..43f74a5 --- /dev/null +++ b/libstdc++-v3/testsuite/performance/23_containers/copy_construct/vector_bool.cc @@ -0,0 +1,47 @@ +// Copyright (C) 2006 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +#include +#include + +int main() +{ + using namespace __gnu_test; + + time_counter time; + resource_counter resource; + + start_counters(time, resource); + const std::vector ref(100000); + + for (unsigned i = 0; i < 1000000; ++i) + std::vector v(ref); + stop_counters(time, resource); + report_performance(__FILE__, "", time, resource); + + return 0; +} -- 2.7.4