Commit 232c4925 by Paolo Carlini Committed by Paolo Carlini

stl_bvector.h (_M_fill_insert(iterator, size_type, bool), [...]): Move out of line...

2007-03-31  Paolo Carlini  <pcarlini@suse.de>

	* 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
parent 29e86cb0
2007-03-31 Paolo Carlini <pcarlini@suse.de>
* 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 <pcarlini@suse.de> 2007-03-30 Paolo Carlini <pcarlini@suse.de>
PR c++/26099 PR c++/26099
......
...@@ -373,7 +373,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) ...@@ -373,7 +373,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
__fill_bvector(__first, __last, __x); __fill_bvector(__first, __last, __x);
} }
template<class _Alloc> template<typename _Alloc>
struct _Bvector_base struct _Bvector_base
{ {
typedef typename _Alloc::template rebind<_Bit_type>::other typedef typename _Alloc::template rebind<_Bit_type>::other
...@@ -501,7 +501,7 @@ template<typename _Alloc> ...@@ -501,7 +501,7 @@ template<typename _Alloc>
_M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start); _M_copy_aligned(__x.begin(), __x.end(), this->_M_impl._M_start);
} }
template<class _InputIterator> template<typename _InputIterator>
vector(_InputIterator __first, _InputIterator __last, vector(_InputIterator __first, _InputIterator __last,
const allocator_type& __a = allocator_type()) const allocator_type& __a = allocator_type())
: _Base(__a) : _Base(__a)
...@@ -535,7 +535,7 @@ template<typename _Alloc> ...@@ -535,7 +535,7 @@ template<typename _Alloc>
assign(size_type __n, const bool& __x) assign(size_type __n, const bool& __x)
{ _M_fill_assign(__n, __x); } { _M_fill_assign(__n, __x); }
template<class _InputIterator> template<typename _InputIterator>
void void
assign(_InputIterator __first, _InputIterator __last) assign(_InputIterator __first, _InputIterator __last)
{ {
...@@ -712,7 +712,7 @@ template<typename _Alloc> ...@@ -712,7 +712,7 @@ template<typename _Alloc>
return begin() + __n; return begin() + __n;
} }
template<class _InputIterator> template<typename _InputIterator>
void void
insert(iterator __position, insert(iterator __position,
_InputIterator __first, _InputIterator __last) _InputIterator __first, _InputIterator __last)
...@@ -790,7 +790,7 @@ template<typename _Alloc> ...@@ -790,7 +790,7 @@ template<typename _Alloc>
} }
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
template<class _Integer> template<typename _Integer>
void void
_M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
{ {
...@@ -799,14 +799,14 @@ template<typename _Alloc> ...@@ -799,14 +799,14 @@ template<typename _Alloc>
this->_M_impl._M_end_of_storage, __x ? ~0 : 0); this->_M_impl._M_end_of_storage, __x ? ~0 : 0);
} }
template<class _InputIterator> template<typename _InputIterator>
void void
_M_initialize_dispatch(_InputIterator __first, _InputIterator __last, _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
__false_type) __false_type)
{ _M_initialize_range(__first, __last, { _M_initialize_range(__first, __last,
std::__iterator_category(__first)); } std::__iterator_category(__first)); }
template<class _InputIterator> template<typename _InputIterator>
void void
_M_initialize_range(_InputIterator __first, _InputIterator __last, _M_initialize_range(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag) std::input_iterator_tag)
...@@ -815,7 +815,7 @@ template<typename _Alloc> ...@@ -815,7 +815,7 @@ template<typename _Alloc>
push_back(*__first); push_back(*__first);
} }
template<class _ForwardIterator> template<typename _ForwardIterator>
void void
_M_initialize_range(_ForwardIterator __first, _ForwardIterator __last, _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag) std::forward_iterator_tag)
...@@ -825,7 +825,7 @@ template<typename _Alloc> ...@@ -825,7 +825,7 @@ template<typename _Alloc>
std::copy(__first, __last, this->_M_impl._M_start); std::copy(__first, __last, this->_M_impl._M_start);
} }
template<class _Integer> template<typename _Integer>
void void
_M_assign_dispatch(_Integer __n, _Integer __val, __true_type) _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
{ _M_fill_assign((size_t) __n, (bool) __val); } { _M_fill_assign((size_t) __n, (bool) __val); }
...@@ -853,7 +853,7 @@ template<typename _Alloc> ...@@ -853,7 +853,7 @@ template<typename _Alloc>
} }
} }
template<class _InputIterator> template<typename _InputIterator>
void void
_M_assign_aux(_InputIterator __first, _InputIterator __last, _M_assign_aux(_InputIterator __first, _InputIterator __last,
std::input_iterator_tag) std::input_iterator_tag)
...@@ -867,7 +867,7 @@ template<typename _Alloc> ...@@ -867,7 +867,7 @@ template<typename _Alloc>
insert(end(), __first, __last); insert(end(), __first, __last);
} }
template<class _ForwardIterator> template<typename _ForwardIterator>
void void
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
std::forward_iterator_tag) std::forward_iterator_tag)
...@@ -885,13 +885,13 @@ template<typename _Alloc> ...@@ -885,13 +885,13 @@ template<typename _Alloc>
} }
// Check whether it's an integral type. If so, it's not an iterator. // Check whether it's an integral type. If so, it's not an iterator.
template<class _Integer> template<typename _Integer>
void void
_M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x, _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
__true_type) __true_type)
{ _M_fill_insert(__pos, __n, __x); } { _M_fill_insert(__pos, __n, __x); }
template<class _InputIterator> template<typename _InputIterator>
void void
_M_insert_dispatch(iterator __pos, _M_insert_dispatch(iterator __pos,
_InputIterator __first, _InputIterator __last, _InputIterator __first, _InputIterator __last,
...@@ -900,35 +900,9 @@ template<typename _Alloc> ...@@ -900,35 +900,9 @@ template<typename _Alloc>
std::__iterator_category(__first)); } std::__iterator_category(__first)); }
void void
_M_fill_insert(iterator __position, size_type __n, bool __x) _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<class _InputIterator> template<typename _InputIterator>
void void
_M_insert_range(iterator __pos, _InputIterator __first, _M_insert_range(iterator __pos, _InputIterator __first,
_InputIterator __last, std::input_iterator_tag) _InputIterator __last, std::input_iterator_tag)
...@@ -940,66 +914,13 @@ template<typename _Alloc> ...@@ -940,66 +914,13 @@ template<typename _Alloc>
} }
} }
template<class _ForwardIterator> template<typename _ForwardIterator>
void void
_M_insert_range(iterator __position, _ForwardIterator __first, _M_insert_range(iterator __position, _ForwardIterator __first,
_ForwardIterator __last, std::forward_iterator_tag) _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);
}
}
}
void void
_M_insert_aux(iterator __position, bool __x) _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<size_type>(_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);
}
}
void void
_M_erase_at_end(iterator __pos) _M_erase_at_end(iterator __pos)
......
// Vector implementation (out of line) -*- C++ -*- // 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 // 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 // software; you can redistribute it and/or modify it under the
...@@ -388,7 +389,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) ...@@ -388,7 +389,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
} }
} }
template<typename _Tp, typename _Alloc> template<typename _InputIterator> template<typename _Tp, typename _Alloc>
template<typename _InputIterator>
void void
vector<_Tp, _Alloc>:: vector<_Tp, _Alloc>::
_M_range_insert(iterator __pos, _InputIterator __first, _M_range_insert(iterator __pos, _InputIterator __first,
...@@ -491,6 +493,105 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD) ...@@ -491,6 +493,105 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD)
} }
} }
// vector<bool>
template<typename _Alloc>
void
vector<bool, _Alloc>::
_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<typename _Alloc>
template<typename _ForwardIterator>
void
vector<bool, _Alloc>::
_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<typename _Alloc>
void
vector<bool, _Alloc>::
_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<size_type>(_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 _GLIBCXX_END_NESTED_NAMESPACE
#endif /* _VECTOR_TCC */ #endif /* _VECTOR_TCC */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment