From: Paolo Carlini Date: Sat, 31 Mar 2007 19:48:41 +0000 (+0000) Subject: stl_bvector.h (_M_fill_insert(iterator, size_type, bool), [...]): Move out of line... X-Git-Tag: releases/gcc-4.3.0~5938 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=232c49252634e798efd4e9e84c2c9e4013e10f1e;p=thirdparty%2Fgcc.git stl_bvector.h (_M_fill_insert(iterator, size_type, bool), [...]): Move out of line... 2007-03-31 Paolo Carlini * include/bits/stl_bvector.h (_M_fill_insert(iterator, size_type, bool), _M_insert_range(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag), _M_insert_aux(iterator, bool)): Move out of line... * include/bits/vector.tcc: ... here. From-SVN: r123389 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index a6ab09b72fe0..d05f5b5bc1b5 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2007-03-31 Paolo Carlini + + * include/bits/stl_bvector.h (_M_fill_insert(iterator, size_type, + bool), _M_insert_range(iterator, _ForwardIterator, _ForwardIterator, + std::forward_iterator_tag), _M_insert_aux(iterator, bool)): Move + out of line... + * include/bits/vector.tcc: ... here. + 2007-03-30 Paolo Carlini PR c++/26099 diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index de72dac353c4..6f24154d2f97 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -373,7 +373,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) __fill_bvector(__first, __last, __x); } - template + template struct _Bvector_base { typedef typename _Alloc::template rebind<_Bit_type>::other @@ -501,7 +501,7 @@ template _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); } - template + template vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a = allocator_type()) : _Base(__a) @@ -535,7 +535,7 @@ template assign(size_type __n, const bool& __x) { _M_fill_assign(__n, __x); } - template + template void assign(_InputIterator __first, _InputIterator __last) { @@ -712,7 +712,7 @@ template return begin() + __n; } - template + template void insert(iterator __position, _InputIterator __first, _InputIterator __last) @@ -790,7 +790,7 @@ template } // Check whether it's an integral type. If so, it's not an iterator. - template + template void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) { @@ -799,14 +799,14 @@ template this->_M_impl._M_end_of_storage, __x ? ~0 : 0); } - template + template void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last, __false_type) { _M_initialize_range(__first, __last, std::__iterator_category(__first)); } - template + template void _M_initialize_range(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -815,7 +815,7 @@ template push_back(*__first); } - template + template void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) @@ -825,7 +825,7 @@ template std::copy(__first, __last, this->_M_impl._M_start); } - template + template void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type) { _M_fill_assign((size_t) __n, (bool) __val); } @@ -853,7 +853,7 @@ template } } - template + template void _M_assign_aux(_InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -867,7 +867,7 @@ template insert(end(), __first, __last); } - template + template void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, std::forward_iterator_tag) @@ -885,13 +885,13 @@ template } // Check whether it's an integral type. If so, it's not an iterator. - template + template void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, __true_type) { _M_fill_insert(__pos, __n, __x); } - template + template void _M_insert_dispatch(iterator __pos, _InputIterator __first, _InputIterator __last, @@ -900,35 +900,9 @@ template std::__iterator_category(__first)); } void - _M_fill_insert(iterator __position, size_type __n, bool __x) - { - if (__n == 0) - return; - if (capacity() - size() >= __n) - { - std::copy_backward(__position, end(), - this->_M_impl._M_finish + difference_type(__n)); - 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 = _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(); - this->_M_impl._M_end_of_storage = (__q + ((__len - + int(_S_word_bit) - 1) - / int(_S_word_bit))); - this->_M_impl._M_start = iterator(__q, 0); - } - } + _M_fill_insert(iterator __position, size_type __n, bool __x); - template + template void _M_insert_range(iterator __pos, _InputIterator __first, _InputIterator __last, std::input_iterator_tag) @@ -940,66 +914,13 @@ template } } - template + template void _M_insert_range(iterator __position, _ForwardIterator __first, - _ForwardIterator __last, std::forward_iterator_tag) - { - if (__first != __last) - { - size_type __n = std::distance(__first, __last); - if (capacity() - size() >= __n) - { - std::copy_backward(__position, end(), - this->_M_impl._M_finish - + difference_type(__n)); - std::copy(__first, __last, __position); - 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 = _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(); - this->_M_impl._M_end_of_storage = (__q - + ((__len - + int(_S_word_bit) - 1) - / int(_S_word_bit))); - this->_M_impl._M_start = iterator(__q, 0); - } - } - } + _ForwardIterator __last, std::forward_iterator_tag); void - _M_insert_aux(iterator __position, bool __x) - { - if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) - { - std::copy_backward(__position, this->_M_impl._M_finish, - this->_M_impl._M_finish + 1); - *__position = __x; - ++this->_M_impl._M_finish; - } - else - { - const size_type __len = size() ? 2 * size() - : static_cast(_S_word_bit); - _Bit_type * __q = this->_M_allocate(__len); - 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(); - this->_M_impl._M_end_of_storage = (__q + ((__len - + int(_S_word_bit) - 1) - / int(_S_word_bit))); - this->_M_impl._M_start = iterator(__q, 0); - } - } + _M_insert_aux(iterator __position, bool __x); void _M_erase_at_end(iterator __pos) diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index f476c460d33e..9b416be158d5 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -1,6 +1,7 @@ // Vector implementation (out of line) -*- C++ -*- -// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 +// 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 @@ -388,18 +389,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) } } - template template - void - vector<_Tp, _Alloc>:: - _M_range_insert(iterator __pos, _InputIterator __first, - _InputIterator __last, std::input_iterator_tag) - { - for (; __first != __last; ++__first) - { - __pos = insert(__pos, *__first); - ++__pos; - } - } + template + template + void + vector<_Tp, _Alloc>:: + _M_range_insert(iterator __pos, _InputIterator __first, + _InputIterator __last, std::input_iterator_tag) + { + for (; __first != __last; ++__first) + { + __pos = insert(__pos, *__first); + ++__pos; + } + } template template @@ -491,6 +493,105 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) } } + + // vector + + template + void + vector:: + _M_fill_insert(iterator __position, size_type __n, bool __x) + { + if (__n == 0) + return; + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + difference_type(__n)); + 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 = _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(); + this->_M_impl._M_end_of_storage = (__q + ((__len + + int(_S_word_bit) - 1) + / int(_S_word_bit))); + this->_M_impl._M_start = iterator(__q, 0); + } + } + + template + template + void + vector:: + _M_insert_range(iterator __position, _ForwardIterator __first, + _ForwardIterator __last, std::forward_iterator_tag) + { + if (__first != __last) + { + size_type __n = std::distance(__first, __last); + if (capacity() - size() >= __n) + { + std::copy_backward(__position, end(), + this->_M_impl._M_finish + + difference_type(__n)); + std::copy(__first, __last, __position); + 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 = _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(); + this->_M_impl._M_end_of_storage = (__q + + ((__len + + int(_S_word_bit) - 1) + / int(_S_word_bit))); + this->_M_impl._M_start = iterator(__q, 0); + } + } + } + + template + void + vector:: + _M_insert_aux(iterator __position, bool __x) + { + if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage) + { + std::copy_backward(__position, this->_M_impl._M_finish, + this->_M_impl._M_finish + 1); + *__position = __x; + ++this->_M_impl._M_finish; + } + else + { + const size_type __len = size() ? 2 * size() + : static_cast(_S_word_bit); + _Bit_type * __q = this->_M_allocate(__len); + 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(); + this->_M_impl._M_end_of_storage = (__q + ((__len + + int(_S_word_bit) - 1) + / int(_S_word_bit))); + this->_M_impl._M_start = iterator(__q, 0); + } + } + _GLIBCXX_END_NESTED_NAMESPACE #endif /* _VECTOR_TCC */