Skip to content

Commit

Permalink
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>
Browse files Browse the repository at this point in the history
	* include/bits/stl_deque.h (deque<>::insert(iterator,
	const value_type&), deque<>::insert(iterator, value_type&&),
	deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
	take a const_iterator.
	(deque<>::erase): Simplify.
	* include/bits/stl_list.h: Likewise.
	(_List_iterator<>::_M_const_cast): Add.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/stl_bvector.h: Likewise.
	(_Bit_iterator::_M_const_cast): Add.
	* include/bits/deque.tcc: Adjust definitions.
	* include/bits/list.tcc: Likewise.
	* include/bits/vector.tcc: Likewise.
	* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
	Define trivial version in C++98 mode.
	* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
	__versa_string<>::replace(iterator, iterator, const __versa_string&),
	__versa_string<>::replace(iterator, iterator, const _CharT*,
	size_type), __versa_string<>::replace(iterator, iterator,
	const _CharT*), __versa_string<>::replace(iterator, iterator,
	size_type, _CharT)): Adjust C++11 signatures to take a pair of
	const_iterators.
	* include/debug/deque: Adjust.
	* include/debug/list: Likewise.
	* include/debug/vector: Likewise.
	* include/profile/deque: Likewise.
	* include/profile/list: Likewise.
	* include/profile/vector: Likewise.
	(vector<>::emplace): Add.
	* testsuite/util/exception/safety.h: Update.
	* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
	New.
	* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
	Likewise.
	* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
	Likewise.
	* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
	Likewise.
	* testsuite/23_containers/vector/bool/modifiers/insert/
	const_iterator.cc: Likewise.
	* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
	Likewise.
	* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
	Likewise.
	* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
	Likewise.
	* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
	Likewise.
	* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
	Likewise.
	* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
	Likewise.

	* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
	ext/vstring/modifiers/erase/char/.
	* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
	ext/vstring/modifiers/wchar_t/.
	* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
	ext/vstring/modifiers/pop_back/char/.
	* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
	testsuite/ext/vstring/modifiers/pop_back/wchar_t/.

	* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
	Adjust dg-error line number.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
	Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_1_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/
	constructor_2_neg.cc: Likewise.
	* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
	Likewise.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@200458 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
paolo committed Jun 27, 2013
1 parent 5ada7a1 commit 3d2b2f4
Show file tree
Hide file tree
Showing 44 changed files with 623 additions and 171 deletions.
89 changes: 89 additions & 0 deletions libstdc++-v3/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,92 @@
2013-06-27 Paolo Carlini <paolo.carlini@oracle.com>

* include/bits/stl_deque.h (deque<>::insert(iterator,
const value_type&), deque<>::insert(iterator, value_type&&),
deque<>::emplace(iterator, _Args&&...)): Adjust C++11 signatures to
take a const_iterator.
(deque<>::erase): Simplify.
* include/bits/stl_list.h: Likewise.
(_List_iterator<>::_M_const_cast): Add.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
(_Bit_iterator::_M_const_cast): Add.
* include/bits/deque.tcc: Adjust definitions.
* include/bits/list.tcc: Likewise.
* include/bits/vector.tcc: Likewise.
* include/bits/stl_iterator.h (__normal_iterator<>::_M_const_cast):
Define trivial version in C++98 mode.
* include/ext/vstring.h (__versa_string<>::insert(iterator, _CharT),
__versa_string<>::replace(iterator, iterator, const __versa_string&),
__versa_string<>::replace(iterator, iterator, const _CharT*,
size_type), __versa_string<>::replace(iterator, iterator,
const _CharT*), __versa_string<>::replace(iterator, iterator,
size_type, _CharT)): Adjust C++11 signatures to take a pair of
const_iterators.
* include/debug/deque: Adjust.
* include/debug/list: Likewise.
* include/debug/vector: Likewise.
* include/profile/deque: Likewise.
* include/profile/list: Likewise.
* include/profile/vector: Likewise.
(vector<>::emplace): Add.
* testsuite/util/exception/safety.h: Update.
* testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc:
New.
* testsuite/23_containers/deque/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/list/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/bool/modifiers/insert/
const_iterator.cc: Likewise.
* testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc:
Likewise.
* testsuite/23_containers/vector/modifiers/insert/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc:
Likewise.
* testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc:
Likewise.

* testsuite/ext/vstring/modifiers/char/54577.cc: Move to testsuite/
ext/vstring/modifiers/erase/char/.
* testsuite/ext/vstring/modifiers/wchar_t/54577.cc: Move to testsuite/
ext/vstring/modifiers/wchar_t/.
* testsuite/ext/vstring/modifiers/char/pop_back.cc: Move to testsuite/
ext/vstring/modifiers/pop_back/char/.
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: Move to
testsuite/ext/vstring/modifiers/pop_back/wchar_t/.

* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.

2013-06-25 Ed Smith-Rowland <3dw4rd@verizon.net>

Status page for C++2014 library features
Expand Down
51 changes: 28 additions & 23 deletions libstdc++-v3/include/bits/deque.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -143,33 +143,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
}
#endif

template <typename _Tp, typename _Alloc>
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
insert(iterator __position, const value_type& __x)
{
if (__position._M_cur == this->_M_impl._M_start._M_cur)
{
push_front(__x);
return this->_M_impl._M_start;
}
else if (__position._M_cur == this->_M_impl._M_finish._M_cur)
{
push_back(__x);
iterator __tmp = this->_M_impl._M_finish;
--__tmp;
return __tmp;
}
else
return _M_insert_aux(__position, __x);
}

#if __cplusplus >= 201103L
template<typename _Tp, typename _Alloc>
template<typename... _Args>
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
emplace(iterator __position, _Args&&... __args)
emplace(const_iterator __position, _Args&&... __args)
{
if (__position._M_cur == this->_M_impl._M_start._M_cur)
{
Expand All @@ -184,10 +163,36 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
return __tmp;
}
else
return _M_insert_aux(__position, std::forward<_Args>(__args)...);
return _M_insert_aux(__position._M_const_cast(),
std::forward<_Args>(__args)...);
}
#endif

template <typename _Tp, typename _Alloc>
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
#if __cplusplus >= 201103L
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x)
#endif
{
if (__position._M_cur == this->_M_impl._M_start._M_cur)
{
push_front(__x);
return this->_M_impl._M_start;
}
else if (__position._M_cur == this->_M_impl._M_finish._M_cur)
{
push_back(__x);
iterator __tmp = this->_M_impl._M_finish;
--__tmp;
return __tmp;
}
else
return _M_insert_aux(__position._M_const_cast(), __x);
}

template <typename _Tp, typename _Alloc>
typename deque<_Tp, _Alloc>::iterator
deque<_Tp, _Alloc>::
Expand Down
14 changes: 7 additions & 7 deletions libstdc++-v3/include/bits/list.tcc
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,25 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename... _Args>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
emplace(iterator __position, _Args&&... __args)
emplace(const_iterator __position, _Args&&... __args)
{
_Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
__tmp->_M_hook(__position._M_node);
__tmp->_M_hook(__position._M_const_cast()._M_node);
return iterator(__tmp);
}
#endif

template<typename _Tp, typename _Alloc>
typename list<_Tp, _Alloc>::iterator
list<_Tp, _Alloc>::
#if __cplusplus >= 201103L
insert(const_iterator __position, const value_type& __x)
#else
insert(iterator __position, const value_type& __x)
#endif
{
_Node* __tmp = _M_create_node(__x);
__tmp->_M_hook(__position._M_node);
__tmp->_M_hook(__position._M_const_cast()._M_node);
return iterator(__tmp);
}

Expand All @@ -113,11 +117,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#endif
{
iterator __ret = iterator(__position._M_node->_M_next);
#if __cplusplus >= 201103L
_M_erase(__position._M_const_cast());
#else
_M_erase(__position);
#endif
return __ret;
}

Expand Down
16 changes: 11 additions & 5 deletions libstdc++-v3/include/bits/stl_bvector.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_Bit_iterator(_Bit_type * __x, unsigned int __y)
: _Bit_iterator_base(__x, __y) { }

iterator
_M_const_cast() const
{ return *this; }

reference
operator*() const
{ return reference(_M_p, 1UL << _M_offset); }
Expand Down Expand Up @@ -859,14 +863,18 @@ template<typename _Alloc>
}

iterator
#if __cplusplus >= 201103L
insert(const_iterator __position, const bool& __x = bool())
#else
insert(iterator __position, const bool& __x = bool())
#endif
{
const difference_type __n = __position - begin();
if (this->_M_impl._M_finish._M_p != this->_M_impl._M_end_of_storage
&& __position == end())
*this->_M_impl._M_finish++ = __x;
else
_M_insert_aux(__position, __x);
_M_insert_aux(__position._M_const_cast(), __x);
return begin() + __n;
}

Expand Down Expand Up @@ -904,20 +912,18 @@ template<typename _Alloc>
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
{ return _M_erase(__position._M_const_cast()); }
#else
erase(iterator __position)
{ return _M_erase(__position); }
#endif
{ return _M_erase(__position._M_const_cast()); }

iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
#else
erase(iterator __first, iterator __last)
{ return _M_erase(__first, __last); }
#endif
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }

void
resize(size_type __new_size, bool __x = bool())
Expand Down
28 changes: 19 additions & 9 deletions libstdc++-v3/include/bits/stl_deque.h
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
#if __cplusplus >= 201103L
/**
* @brief Inserts an object in %deque before specified iterator.
* @param __position An iterator into the %deque.
* @param __position A const_iterator into the %deque.
* @param __args Arguments.
* @return An iterator that points to the inserted data.
*
Expand All @@ -1467,9 +1467,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
template<typename... _Args>
iterator
emplace(iterator __position, _Args&&... __args);
#endif
emplace(const_iterator __position, _Args&&... __args);

/**
* @brief Inserts given value into %deque before specified iterator.
* @param __position A const_iterator into the %deque.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given value before the
* specified location.
*/
iterator
insert(const_iterator __position, const value_type& __x);
#else
/**
* @brief Inserts given value into %deque before specified iterator.
* @param __position An iterator into the %deque.
Expand All @@ -1481,19 +1492,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
*/
iterator
insert(iterator __position, const value_type& __x);
#endif

#if __cplusplus >= 201103L
/**
* @brief Inserts given rvalue into %deque before specified iterator.
* @param __position An iterator into the %deque.
* @param __position A const_iterator into the %deque.
* @param __x Data to be inserted.
* @return An iterator that points to the inserted data.
*
* This function will insert a copy of the given rvalue before the
* specified location.
*/
iterator
insert(iterator __position, value_type&& __x)
insert(const_iterator __position, value_type&& __x)
{ return emplace(__position, std::move(__x)); }

/**
Expand Down Expand Up @@ -1568,11 +1580,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
#if __cplusplus >= 201103L
erase(const_iterator __position)
{ return _M_erase(__position._M_const_cast()); }
#else
erase(iterator __position)
{ return _M_erase(__position); }
#endif
{ return _M_erase(__position._M_const_cast()); }

/**
* @brief Remove a range of elements.
Expand All @@ -1593,11 +1604,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
iterator
#if __cplusplus >= 201103L
erase(const_iterator __first, const_iterator __last)
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
#else
erase(iterator __first, iterator __last)
{ return _M_erase(__first, __last); }
#endif
{ return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }

/**
* @brief Swaps data with another %deque.
Expand Down
9 changes: 5 additions & 4 deletions libstdc++-v3/include/bits/stl_iterator.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,19 +734,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_Container>::__type>& __i)
: _M_current(__i.base()) { }

#if __cplusplus >= 201103L
__normal_iterator<typename _Container::pointer, _Container>
_M_const_cast() const
{
#if __cplusplus >= 201103L
using _PTraits = std::pointer_traits<typename _Container::pointer>;
return __normal_iterator<typename _Container::pointer, _Container>
(_PTraits::pointer_to(const_cast<typename _PTraits::element_type&>
(*_M_current)));
}
#else
return __normal_iterator<typename _Container::pointer, _Container>
(const_cast<typename _Container::pointer>(_M_current));
__normal_iterator
_M_const_cast() const
{ return *this; }
#endif
}

// Forward iterator requirements
reference
Expand Down
Loading

0 comments on commit 3d2b2f4

Please sign in to comment.