From 4dbba0a5df21e9d70b8c060a71944b5c613322c3 Mon Sep 17 00:00:00 2001 From: bstarynk Date: Thu, 27 Jun 2013 17:08:06 +0000 Subject: 2013-06-27 Basile Starynkevitch MELT branch merged with trunk rev 200479 using svnmerge.py git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/melt-branch@200483 138bc75d-0d04-0410-961f-82ee72b054a4 --- libstdc++-v3/ChangeLog | 113 ++++++++++++ libstdc++-v3/include/bits/deque.tcc | 51 +++--- libstdc++-v3/include/bits/list.tcc | 14 +- libstdc++-v3/include/bits/stl_bvector.h | 16 +- libstdc++-v3/include/bits/stl_deque.h | 28 ++- libstdc++-v3/include/bits/stl_iterator.h | 9 +- libstdc++-v3/include/bits/stl_list.h | 30 +++- libstdc++-v3/include/bits/stl_vector.h | 32 ++-- libstdc++-v3/include/bits/vector.tcc | 13 +- libstdc++-v3/include/debug/deque | 8 +- libstdc++-v3/include/debug/list | 20 ++- libstdc++-v3/include/debug/vector | 8 +- libstdc++-v3/include/ext/vstring.h | 27 ++- libstdc++-v3/include/profile/deque | 8 +- libstdc++-v3/include/profile/list | 17 +- libstdc++-v3/include/profile/vector | 17 +- .../20_util/ratio/operations/ops_overflow_neg.cc | 1 + .../21_strings/basic_string/append/char/1.cc | 158 ----------------- .../21_strings/basic_string/append/char/2.cc | 66 ------- .../21_strings/basic_string/append/char/3.cc | 55 ------ .../21_strings/basic_string/append/wchar_t/1.cc | 158 ----------------- .../21_strings/basic_string/append/wchar_t/2.cc | 66 ------- .../21_strings/basic_string/append/wchar_t/3.cc | 61 ------- .../21_strings/basic_string/assign/char/1.cc | 55 ------ .../21_strings/basic_string/assign/char/2.cc | 58 ------- .../21_strings/basic_string/assign/char/3.cc | 58 ------- .../basic_string/assign/char/move_assign.cc | 43 ----- .../21_strings/basic_string/assign/wchar_t/1.cc | 52 ------ .../21_strings/basic_string/assign/wchar_t/2.cc | 58 ------- .../21_strings/basic_string/assign/wchar_t/3.cc | 58 ------- .../basic_string/assign/wchar_t/move_assign.cc | 43 ----- .../21_strings/basic_string/insert/char/1.cc | 189 --------------------- .../21_strings/basic_string/insert/char/2.cc | 82 --------- .../21_strings/basic_string/insert/wchar_t/1.cc | 189 --------------------- .../21_strings/basic_string/insert/wchar_t/2.cc | 82 --------- .../basic_string/modifiers/append/char/1.cc | 158 +++++++++++++++++ .../basic_string/modifiers/append/char/2.cc | 66 +++++++ .../basic_string/modifiers/append/char/3.cc | 55 ++++++ .../basic_string/modifiers/append/wchar_t/1.cc | 158 +++++++++++++++++ .../basic_string/modifiers/append/wchar_t/2.cc | 66 +++++++ .../basic_string/modifiers/append/wchar_t/3.cc | 61 +++++++ .../basic_string/modifiers/assign/char/1.cc | 55 ++++++ .../basic_string/modifiers/assign/char/2.cc | 58 +++++++ .../basic_string/modifiers/assign/char/3.cc | 58 +++++++ .../modifiers/assign/char/move_assign.cc | 43 +++++ .../basic_string/modifiers/assign/wchar_t/1.cc | 52 ++++++ .../basic_string/modifiers/assign/wchar_t/2.cc | 58 +++++++ .../basic_string/modifiers/assign/wchar_t/3.cc | 58 +++++++ .../modifiers/assign/wchar_t/move_assign.cc | 43 +++++ .../basic_string/modifiers/char/pop_back.cc | 41 ----- .../basic_string/modifiers/insert/char/1.cc | 189 +++++++++++++++++++++ .../basic_string/modifiers/insert/char/2.cc | 82 +++++++++ .../basic_string/modifiers/insert/wchar_t/1.cc | 189 +++++++++++++++++++++ .../basic_string/modifiers/insert/wchar_t/2.cc | 82 +++++++++ .../basic_string/modifiers/pop_back/char/1.cc | 41 +++++ .../basic_string/modifiers/pop_back/wchar_t/1.cc | 41 +++++ .../basic_string/modifiers/replace/char/1.cc | 81 +++++++++ .../basic_string/modifiers/replace/char/2.cc | 45 +++++ .../basic_string/modifiers/replace/char/3.cc | 73 ++++++++ .../basic_string/modifiers/replace/char/4.cc | 66 +++++++ .../basic_string/modifiers/replace/char/5.cc | 42 +++++ .../basic_string/modifiers/replace/char/6.cc | 54 ++++++ .../basic_string/modifiers/replace/wchar_t/1.cc | 81 +++++++++ .../basic_string/modifiers/replace/wchar_t/2.cc | 46 +++++ .../basic_string/modifiers/replace/wchar_t/3.cc | 73 ++++++++ .../basic_string/modifiers/replace/wchar_t/4.cc | 66 +++++++ .../basic_string/modifiers/replace/wchar_t/5.cc | 42 +++++ .../basic_string/modifiers/replace/wchar_t/6.cc | 54 ++++++ .../basic_string/modifiers/wchar_t/pop_back.cc | 41 ----- .../21_strings/basic_string/replace/char/1.cc | 81 --------- .../21_strings/basic_string/replace/char/2.cc | 45 ----- .../21_strings/basic_string/replace/char/3.cc | 73 -------- .../21_strings/basic_string/replace/char/4.cc | 66 ------- .../21_strings/basic_string/replace/char/5.cc | 42 ----- .../21_strings/basic_string/replace/char/6.cc | 54 ------ .../21_strings/basic_string/replace/wchar_t/1.cc | 81 --------- .../21_strings/basic_string/replace/wchar_t/2.cc | 46 ----- .../21_strings/basic_string/replace/wchar_t/3.cc | 73 -------- .../21_strings/basic_string/replace/wchar_t/4.cc | 66 ------- .../21_strings/basic_string/replace/wchar_t/5.cc | 42 ----- .../21_strings/basic_string/replace/wchar_t/6.cc | 54 ------ .../deque/modifiers/emplace/const_iterator.cc | 27 +++ .../deque/modifiers/insert/const_iterator.cc | 29 ++++ .../deque/requirements/dr438/assign_neg.cc | 2 +- .../deque/requirements/dr438/constructor_1_neg.cc | 2 +- .../deque/requirements/dr438/constructor_2_neg.cc | 2 +- .../deque/requirements/dr438/insert_neg.cc | 2 +- .../list/modifiers/emplace/const_iterator.cc | 27 +++ .../list/modifiers/insert/const_iterator.cc | 29 ++++ .../list/requirements/dr438/assign_neg.cc | 2 +- .../list/requirements/dr438/constructor_1_neg.cc | 2 +- .../list/requirements/dr438/constructor_2_neg.cc | 2 +- .../list/requirements/dr438/insert_neg.cc | 2 +- .../vector/bool/modifiers/insert/const_iterator.cc | 27 +++ .../vector/modifiers/emplace/const_iterator.cc | 27 +++ .../vector/modifiers/insert/const_iterator.cc | 29 ++++ .../vector/requirements/dr438/assign_neg.cc | 2 +- .../vector/requirements/dr438/constructor_1_neg.cc | 2 +- .../vector/requirements/dr438/constructor_2_neg.cc | 2 +- .../vector/requirements/dr438/insert_neg.cc | 2 +- .../testsuite/ext/vstring/assign/move_assign.cc | 54 ------ .../ext/vstring/modifiers/assign/move_assign.cc | 54 ++++++ .../testsuite/ext/vstring/modifiers/char/54577.cc | 33 ---- .../ext/vstring/modifiers/char/pop_back.cc | 45 ----- .../ext/vstring/modifiers/erase/char/54577.cc | 33 ++++ .../ext/vstring/modifiers/erase/wchar_t/54577.cc | 33 ++++ .../modifiers/insert/char/const_iterator.cc | 27 +++ .../modifiers/insert/wchar_t/const_iterator.cc | 27 +++ .../ext/vstring/modifiers/pop_back/char/1.cc | 45 +++++ .../ext/vstring/modifiers/pop_back/wchar_t/1.cc | 45 +++++ .../modifiers/replace/char/const_iterator.cc | 30 ++++ .../modifiers/replace/wchar_t/const_iterator.cc | 30 ++++ .../ext/vstring/modifiers/wchar_t/54577.cc | 33 ---- .../ext/vstring/modifiers/wchar_t/pop_back.cc | 45 ----- libstdc++-v3/testsuite/util/exception/safety.h | 74 +------- 115 files changed, 3194 insertions(+), 2717 deletions(-) delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/move_assign.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/move_assign.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/4.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/5.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/6.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/2.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/3.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/4.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/5.cc create mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/6.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc delete mode 100644 libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc delete mode 100644 libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/assign/move_assign.cc delete mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/char/54577.cc delete mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/erase/char/54577.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/erase/wchar_t/54577.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/char/1.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/wchar_t/1.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc create mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc delete mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/54577.cc delete mode 100644 libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 640f00a0be2..347cf3cee8f 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,106 @@ +2013-06-27 Paolo Carlini + + * testsuite/21_strings/basic_string/append/*: Move inside + testsuite/21_strings/basic_string/modifiers/. + * testsuite/21_strings/basic_string/assign/*: Likewise. + * testsuite/21_strings/basic_string/insert/*: Likewise. + * testsuite/21_strings/basic_string/replace/*: Likewise. + * testsuite/21_strings/basic_string/modifiers/pop_back/char/ + pop_back.cc: Rename to 1.cc. + * testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/ + pop_back.cc: Likewise. + * testsuite/ext/vstring/assign/*: Move inside + testsuite/ext/vstring/modifiers/. + +2013-06-27 Paolo Carlini + + * 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 @@ -5,6 +108,16 @@ * doc/xml/manual/intro.xml: Ditto. * doc/xml/manual/status_cxx2014.xml: New. +2013-06-25 Paolo Carlini + + * testsuite/23_containers/map/modifiers/erase/abi_tag.cc: Avoid + spurious fails with check-debug. + * testsuite/23_containers/multimap/modifiers/erase/abi_tag.cc: + Likewise. + * testsuite/23_containers/set/modifiers/erase/abi_tag.cc: Likewise. + * testsuite/23_containers/multiset/modifiers/erase/abi_tag.cc: + Likewise. + 2013-06-25 Paolo Carlini PR libstdc++/57704 diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc index 8da73589869..9c33ad9b0dd 100644 --- a/libstdc++-v3/include/bits/deque.tcc +++ b/libstdc++-v3/include/bits/deque.tcc @@ -143,33 +143,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER } #endif - template - 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 template 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) { @@ -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 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 deque<_Tp, _Alloc>::iterator deque<_Tp, _Alloc>:: diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc index 9fc43cfe68a..4f82e35c921 100644 --- a/libstdc++-v3/include/bits/list.tcc +++ b/libstdc++-v3/include/bits/list.tcc @@ -85,10 +85,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template 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 @@ -96,10 +96,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template 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); } @@ -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; } diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 97424fa7a7d..489d819f06f 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -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); } @@ -859,14 +863,18 @@ template } 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; } @@ -904,20 +912,18 @@ template 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()) diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index 4bea82b1807..a03ba256b53 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -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. * @@ -1467,9 +1467,20 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ template 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. @@ -1481,11 +1492,12 @@ _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. * @@ -1493,7 +1505,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * specified location. */ iterator - insert(iterator __position, value_type&& __x) + insert(const_iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } /** @@ -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. @@ -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. diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 50b55eb57b4..9952c2c92d6 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -734,19 +734,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Container>::__type>& __i) : _M_current(__i.base()) { } +#if __cplusplus >= 201103L __normal_iterator _M_const_cast() const { -#if __cplusplus >= 201103L using _PTraits = std::pointer_traits; return __normal_iterator (_PTraits::pointer_to(const_cast (*_M_current))); + } #else - return __normal_iterator - (const_cast(_M_current)); + __normal_iterator + _M_const_cast() const + { return *this; } #endif - } // Forward iterator requirements reference diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 678947107f3..7c3eb159aba 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -140,6 +140,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _List_iterator(__detail::_List_node_base* __x) : _M_node(__x) { } + _Self + _M_const_cast() const + { return *this; } + // Must downcast from _List_node_base to _List_node to get to _M_data. reference operator*() const @@ -1060,9 +1064,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ template iterator - emplace(iterator __position, _Args&&... __args); -#endif + emplace(const_iterator __position, _Args&&... __args); + /** + * @brief Inserts given value into %list before specified iterator. + * @param __position A const_iterator into the %list. + * @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. Due to the nature of a %list this + * operation can be done in constant time, and does not + * invalidate iterators and references. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else /** * @brief Inserts given value into %list before specified iterator. * @param __position An iterator into the %list. @@ -1076,11 +1093,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ iterator insert(iterator __position, const value_type& __x); +#endif #if __cplusplus >= 201103L /** * @brief Inserts given rvalue into %list before specified iterator. - * @param __position An iterator into the %list. + * @param __position A const_iterator into the %list. * @param __x Data to be inserted. * @return An iterator that points to the inserted data. * @@ -1090,7 +1108,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * invalidate iterators and references. */ iterator - insert(iterator __position, value_type&& __x) + insert(const_iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } /** @@ -1206,11 +1224,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER { while (__first != __last) __first = erase(__first); -#if __cplusplus >= 201103L return __last._M_const_cast(); -#else - return __last; -#endif } /** diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index 5ac575460a0..a403b4f83bb 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -943,7 +943,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER #if __cplusplus >= 201103L /** * @brief Inserts an object in %vector before specified iterator. - * @param __position An iterator into the %vector. + * @param __position A const_iterator into the %vector. * @param __args Arguments. * @return An iterator that points to the inserted data. * @@ -955,9 +955,22 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ template iterator - emplace(iterator __position, _Args&&... __args); -#endif + emplace(const_iterator __position, _Args&&... __args); + /** + * @brief Inserts given value into %vector before specified iterator. + * @param __position A const_iterator into the %vector. + * @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. Note that this kind of operation + * could be expensive for a %vector and if it is frequently + * used the user should consider using std::list. + */ + iterator + insert(const_iterator __position, const value_type& __x); +#else /** * @brief Inserts given value into %vector before specified iterator. * @param __position An iterator into the %vector. @@ -971,11 +984,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER */ iterator insert(iterator __position, const value_type& __x); +#endif #if __cplusplus >= 201103L /** * @brief Inserts given rvalue into %vector before specified iterator. - * @param __position An iterator into the %vector. + * @param __position A const_iterator into the %vector. * @param __x Data to be inserted. * @return An iterator that points to the inserted data. * @@ -985,7 +999,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER * used the user should consider using std::list. */ iterator - insert(iterator __position, value_type&& __x) + insert(const_iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } /** @@ -1074,11 +1088,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. @@ -1101,11 +1114,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 %vector. @@ -1119,7 +1131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER void swap(vector& __x) #if __cplusplus >= 201103L - noexcept(_Alloc_traits::_S_nothrow_swap()) + noexcept(_Alloc_traits::_S_nothrow_swap()) #endif { this->_M_impl._M_swap_data(__x._M_impl); diff --git a/libstdc++-v3/include/bits/vector.tcc b/libstdc++-v3/include/bits/vector.tcc index d26cfafd1fa..8e22d10a26e 100644 --- a/libstdc++-v3/include/bits/vector.tcc +++ b/libstdc++-v3/include/bits/vector.tcc @@ -105,7 +105,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: +#if __cplusplus >= 201103L + insert(const_iterator __position, const value_type& __x) +#else insert(iterator __position, const value_type& __x) +#endif { const size_type __n = __position - begin(); if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage @@ -120,11 +124,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) { _Tp __x_copy = __x; - _M_insert_aux(__position, std::move(__x_copy)); + _M_insert_aux(__position._M_const_cast(), std::move(__x_copy)); } else #endif - _M_insert_aux(__position, __x); + _M_insert_aux(__position._M_const_cast(), __x); } return iterator(this->_M_impl._M_start + __n); } @@ -292,7 +296,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER template typename vector<_Tp, _Alloc>::iterator vector<_Tp, _Alloc>:: - emplace(iterator __position, _Args&&... __args) + emplace(const_iterator __position, _Args&&... __args) { const size_type __n = __position - begin(); if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage @@ -303,7 +307,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER ++this->_M_impl._M_finish; } else - _M_insert_aux(__position, std::forward<_Args>(__args)...); + _M_insert_aux(__position._M_const_cast(), + std::forward<_Args>(__args)...); return iterator(this->_M_impl._M_start + __n); } diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index 2ac6d252e1d..638bf1cd3ca 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -383,7 +383,7 @@ namespace __debug template iterator - emplace(iterator __position, _Args&&... __args) + emplace(const_iterator __position, _Args&&... __args) { __glibcxx_check_insert(__position); _Base_iterator __res = _Base::emplace(__position.base(), @@ -394,7 +394,11 @@ namespace __debug #endif iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else insert(iterator __position, const _Tp& __x) +#endif { __glibcxx_check_insert(__position); _Base_iterator __res = _Base::insert(__position.base(), __x); @@ -404,7 +408,7 @@ namespace __debug #if __cplusplus >= 201103L iterator - insert(iterator __position, _Tp&& __x) + insert(const_iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } void diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 9bc47124f39..c175de01f23 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -379,7 +379,7 @@ namespace __debug #if __cplusplus >= 201103L template iterator - emplace(iterator __position, _Args&&... __args) + emplace(const_iterator __position, _Args&&... __args) { __glibcxx_check_insert(__position); return iterator(_Base::emplace(__position.base(), @@ -387,16 +387,20 @@ namespace __debug } #endif - iterator - insert(iterator __position, const _Tp& __x) - { - __glibcxx_check_insert(__position); - return iterator(_Base::insert(__position.base(), __x), this); - } + iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else + insert(iterator __position, const _Tp& __x) +#endif + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __x), this); + } #if __cplusplus >= 201103L iterator - insert(iterator __position, _Tp&& __x) + insert(const_iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } void diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 4a65518bc82..f55dc67ede0 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -429,7 +429,7 @@ namespace __debug #if __cplusplus >= 201103L template iterator - emplace(iterator __position, _Args&&... __args) + emplace(const_iterator __position, _Args&&... __args) { __glibcxx_check_insert(__position); bool __realloc = _M_requires_reallocation(this->size() + 1); @@ -446,7 +446,11 @@ namespace __debug #endif iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else insert(iterator __position, const _Tp& __x) +#endif { __glibcxx_check_insert(__position); bool __realloc = _M_requires_reallocation(this->size() + 1); @@ -464,7 +468,7 @@ namespace __debug template typename __gnu_cxx::__enable_if::__value, iterator>::__type - insert(iterator __position, _Tp&& __x) + insert(const_iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } void diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 716d145f184..c78f2146a13 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -1087,7 +1087,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * change if an error is thrown. */ iterator - insert(iterator __p, _CharT __c) +#if __cplusplus >= 201103L + insert(const_iterator __p, _CharT __c) +#else + insert(iterator __p, _CharT __c) +#endif { _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); const size_type __pos = __p - _M_ibegin(); @@ -1313,7 +1317,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the string doesn't change if an error is thrown. */ __versa_string& +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, + const __versa_string& __str) +#else replace(iterator __i1, iterator __i2, const __versa_string& __str) +#endif { return this->replace(__i1, __i2, __str._M_data(), __str.size()); } /** @@ -1331,7 +1340,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * value of the string doesn't change if an error is thrown. */ __versa_string& +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, + const _CharT* __s, size_type __n) +#else replace(iterator __i1, iterator __i2, const _CharT* __s, size_type __n) +#endif { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); @@ -1352,7 +1366,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the string doesn't change if an error is thrown. */ __versa_string& - replace(iterator __i1, iterator __i2, const _CharT* __s) +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, const _CharT* __s) +#else + replace(iterator __i1, iterator __i2, const _CharT* __s) +#endif { __glibcxx_requires_string(__s); return this->replace(__i1, __i2, __s, traits_type::length(__s)); @@ -1373,7 +1391,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * the string doesn't change if an error is thrown. */ __versa_string& +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, size_type __n, + _CharT __c) +#else replace(iterator __i1, iterator __i2, size_type __n, _CharT __c) +#endif { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); diff --git a/libstdc++-v3/include/profile/deque b/libstdc++-v3/include/profile/deque index 9943e1e9f02..0ec98386bae 100644 --- a/libstdc++-v3/include/profile/deque +++ b/libstdc++-v3/include/profile/deque @@ -320,7 +320,7 @@ namespace __profile template iterator - emplace(iterator __position, _Args&&... __args) + emplace(const_iterator __position, _Args&&... __args) { typename _Base::iterator __res = _Base::emplace(__position, std::forward<_Args>(__args)...); @@ -329,7 +329,11 @@ namespace __profile #endif iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else insert(iterator __position, const _Tp& __x) +#endif { typename _Base::iterator __res = _Base::insert(__position, __x); return iterator(__res); @@ -337,7 +341,7 @@ namespace __profile #if __cplusplus >= 201103L iterator - insert(iterator __position, _Tp&& __x) + insert(const_iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } void diff --git a/libstdc++-v3/include/profile/list b/libstdc++-v3/include/profile/list index 25ad11248b1..3a68bf7493a 100644 --- a/libstdc++-v3/include/profile/list +++ b/libstdc++-v3/include/profile/list @@ -335,7 +335,7 @@ template > #if __cplusplus >= 201103L template iterator - emplace(iterator __position, _Args&&... __args) + emplace(const_iterator __position, _Args&&... __args) { return iterator(_Base::emplace(__position.base(), std::forward<_Args>(__args)...), @@ -344,7 +344,11 @@ template > #endif iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else insert(iterator __position, const _Tp& __x) +#endif { _M_profile_insert(this, __position, size()); return iterator(_Base::insert(__position.base(), __x), this); @@ -352,8 +356,8 @@ template > #if __cplusplus >= 201103L iterator - insert(iterator __position, _Tp&& __x) - { + insert(const_iterator __position, _Tp&& __x) + { _M_profile_insert(this, __position, size()); return iterator(_Base::emplace(__position.base(), std::move(__x)), this); @@ -606,11 +610,12 @@ template > } private: - size_type _M_profile_insert(void* obj, iterator __pos, size_type __size) + size_type + _M_profile_insert(void* obj, const_iterator __pos, size_type __size) { size_type __shift = 0; - typename _Base::iterator __it = __pos.base(); - for ( ; __it!=_Base::end(); __it++) + typename _Base::const_iterator __it = __pos.base(); + for (; __it != _Base::end(); ++__it) __shift++; __profcxx_list_rewind(this); __profcxx_list_operation(this); diff --git a/libstdc++-v3/include/profile/vector b/libstdc++-v3/include/profile/vector index d9eb15740c6..de058d0d814 100644 --- a/libstdc++-v3/include/profile/vector +++ b/libstdc++-v3/include/profile/vector @@ -352,7 +352,11 @@ namespace __profile #endif iterator +#if __cplusplus >= 201103L + insert(const_iterator __position, const _Tp& __x) +#else insert(iterator __position, const _Tp& __x) +#endif { __profcxx_vector_insert(this, __position.base() - _Base::begin(), this->size()); @@ -364,7 +368,7 @@ namespace __profile #if __cplusplus >= 201103L iterator - insert(iterator __position, _Tp&& __x) + insert(const_iterator __position, _Tp&& __x) { __profcxx_vector_insert(this, __position.base() - _Base::begin(), this->size()); @@ -374,6 +378,16 @@ namespace __profile return iterator(__res, this); } + template + iterator + emplace(const_iterator __position, _Args&&... __args) + { + typename _Base::iterator __res + = _Base::emplace(__position.base(), + std::forward<_Args>(__args)...); + return iterator(__res, this); + } + void insert(iterator __position, initializer_list __l) { this->insert(__position, __l.begin(), __l.end()); } @@ -423,7 +437,6 @@ namespace __profile _M_profile_resize(this, __old_size, this->capacity()); } - iterator #if __cplusplus >= 201103L erase(const_iterator __position) diff --git a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc index f0dcdec080d..f2f2330cea4 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/operations/ops_overflow_neg.cc @@ -46,5 +46,6 @@ test02() // { dg-error "overflow in multiplication" "" { target *-*-* } 97 } // { dg-error "overflow in multiplication" "" { target *-*-* } 99 } // { dg-error "overflow in multiplication" "" { target *-*-* } 101 } +// { dg-error "overflow in constant expression" "" { target *-*-* } 108 } // { dg-prune-output "out of range" } // { dg-prune-output "not usable in a constant expression" } diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc deleted file mode 100644 index 2e9a3cf85f6..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/1.cc +++ /dev/null @@ -1,158 +0,0 @@ -// 1999-07-08 bkoz - -// Copyright (C) 1999-2013 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 -// . - -// 21.3.5.2 basic_string::append - -#include -#include -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - typedef std::string::const_reference cref; - typedef std::string::reference ref; - csize_type csz01; - - const char str_lit01[] = "point bolivar, texas"; - const std::string str01(str_lit01); - const std::string str02("corpus, "); - const std::string str03; - std::string str05; - - - // string& append(const string&) - str05 = str02; - str05.append(str05); - VERIFY( str05 == "corpus, corpus, " ); - str05.append(str01); - VERIFY( str05 == "corpus, corpus, point bolivar, texas" ); - str05.append(str03); - VERIFY( str05 == "corpus, corpus, point bolivar, texas" ); - std::string str06; - str06.append(str05); - VERIFY( str06 == str05 ); - - - // string& append(const string&, size_type pos, size_type n) - str05.erase(); - str06.erase(); - csz01 = str03.size(); - try { - str06.append(str03, csz01 + 1, 0); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - csz01 = str01.size(); - try { - str06.append(str01, csz01 + 1, 0); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - str05 = str02; - str05.append(str01, 0, std::string::npos); - VERIFY( str05 == "corpus, point bolivar, texas" ); - VERIFY( str05 != str02 ); - - str06 = str02; - str06.append(str01, 15, std::string::npos); - VERIFY( str06 == "corpus, texas" ); - VERIFY( str02 != str06 ); - - - // string& append(const char* s) - str05.erase(); - str06.erase(); - str05.append(""); - VERIFY( str05 == str03 ); - - str05.append(str_lit01); - VERIFY( str05 == str01 ); - - str06 = str02; - str06.append("corpus, "); - VERIFY( str06 == "corpus, corpus, " ); - - - // string& append(const char* s, size_type n) - str05.erase(); - str06.erase(); - str05.append("", 0); - VERIFY( str05.size() == 0 ); - VERIFY( str05 == str03 ); - - str05.append(str_lit01, sizeof(str_lit01) - 1); - VERIFY( str05 == str01 ); - - str06 = str02; - str06.append("corpus, ", 6); - VERIFY( str06 == "corpus, corpus" ); - - str06 = str02; - str06.append("corpus, ", 12); - VERIFY( str06 != "corpus, corpus, " ); - - - // string& append(size_type n, char c) - str05.erase(); - str06.erase(); - str05.append(0, 'a'); - VERIFY( str05 == str03 ); - str06.append(8, '.'); - VERIFY( str06 == "........" ); - - - // template - // string& append(InputIter first, InputIter last) - str05.erase(); - str06.erase(); - str05.append(str03.begin(), str03.end()); - VERIFY( str05 == str03 ); - - str06 = str02; - str06.append(str01.begin(), str01.begin() + str01.find('r')); - VERIFY( str06 == "corpus, point boliva" ); - VERIFY( str06 != str01 ); - VERIFY( str06 != str02 ); - - str05 = str01; - str05.append(str05.begin(), str05.begin() + str05.find('r')); - VERIFY( str05 == "point bolivar, texaspoint boliva" ); - VERIFY( str05 != str01 ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc deleted file mode 100644 index 8d12169e389..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/2.cc +++ /dev/null @@ -1,66 +0,0 @@ -// 2004-25-10 Paolo Carlini - -// Copyright (C) 2004-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include - -// append(const _CharT* __s, size_type __n) -// append(const _CharT* __s) -void -test02() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - string one; - string two; - string three; - const char * source = "Written in your eyes"; - - one.append(source); - VERIFY( one == "Written in your eyes" ); - - two.append(source, 20); - VERIFY( two == "Written in your eyes" ); - - three.append(source, 7); - VERIFY( three == "Written" ); - - three.clear(); - three.append(source + 8, 2); - VERIFY( three == "in" ); - - one.append(one.c_str(), 20); - VERIFY( one == "Written in your eyesWritten in your eyes" ); - - two.append(two.c_str() + 16, 4); - VERIFY( two == "Written in your eyeseyes" ); - - two.append(two.c_str(), 3); - VERIFY( two == "Written in your eyeseyesWri" ); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc deleted file mode 100644 index 47699d2396c..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/append/char/3.cc +++ /dev/null @@ -1,55 +0,0 @@ -// 2004-25-10 Paolo Carlini - -// Copyright (C) 2004-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include - -// Upon reallocation (basic_string::reserve) we were copying from -// deallocated memory. -void -test03() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - const char * source = "Kesto"; - - for (unsigned i = 0; i < 10; ++i) - { - string one(source); - string two(source); - for (unsigned j = 0; j < 18; ++j) - { - VERIFY( one == two ); - one.append(one); - one += 'x'; - two.append(two.c_str(), two.size()); - two += 'x'; - } - } -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc deleted file mode 100644 index c2e435fb9d9..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/1.cc +++ /dev/null @@ -1,158 +0,0 @@ -// 1999-07-08 bkoz - -// Copyright (C) 1999-2013 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 -// . - -// 21.3.5.2 basic_string::append - -#include -#include -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - typedef std::wstring::const_reference cref; - typedef std::wstring::reference ref; - csize_type csz01; - - const wchar_t str_lit01[] = L"point bolivar, texas"; - const std::wstring str01(str_lit01); - const std::wstring str02(L"corpus, "); - const std::wstring str03; - std::wstring str05; - - - // wstring& append(const wstring&) - str05 = str02; - str05.append(str05); - VERIFY( str05 == L"corpus, corpus, " ); - str05.append(str01); - VERIFY( str05 == L"corpus, corpus, point bolivar, texas" ); - str05.append(str03); - VERIFY( str05 == L"corpus, corpus, point bolivar, texas" ); - std::wstring str06; - str06.append(str05); - VERIFY( str06 == str05 ); - - - // wstring& append(const wstring&, size_type pos, size_type n) - str05.erase(); - str06.erase(); - csz01 = str03.size(); - try { - str06.append(str03, csz01 + 1, 0); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - csz01 = str01.size(); - try { - str06.append(str01, csz01 + 1, 0); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - str05 = str02; - str05.append(str01, 0, std::wstring::npos); - VERIFY( str05 == L"corpus, point bolivar, texas" ); - VERIFY( str05 != str02 ); - - str06 = str02; - str06.append(str01, 15, std::wstring::npos); - VERIFY( str06 == L"corpus, texas" ); - VERIFY( str02 != str06 ); - - - // wstring& append(const wchar_t* s) - str05.erase(); - str06.erase(); - str05.append(L""); - VERIFY( str05 == str03 ); - - str05.append(str_lit01); - VERIFY( str05 == str01 ); - - str06 = str02; - str06.append(L"corpus, "); - VERIFY( str06 == L"corpus, corpus, " ); - - - // wstring& append(const wchar_t* s, size_type n) - str05.erase(); - str06.erase(); - str05.append(L"", 0); - VERIFY( str05.size() == 0 ); - VERIFY( str05 == str03 ); - - str05.append(str_lit01, sizeof(str_lit01) / sizeof(wchar_t) - 1); - VERIFY( str05 == str01 ); - - str06 = str02; - str06.append(L"corpus, ", 6); - VERIFY( str06 == L"corpus, corpus" ); - - str06 = str02; - str06.append(L"corpus, ", 12); - VERIFY( str06 != L"corpus, corpus, " ); - - - // wstring& append(size_type n, char c) - str05.erase(); - str06.erase(); - str05.append(0, L'a'); - VERIFY( str05 == str03 ); - str06.append(8, L'.'); - VERIFY( str06 == L"........" ); - - - // template - // wstring& append(InputIter first, InputIter last) - str05.erase(); - str06.erase(); - str05.append(str03.begin(), str03.end()); - VERIFY( str05 == str03 ); - - str06 = str02; - str06.append(str01.begin(), str01.begin() + str01.find(L'r')); - VERIFY( str06 == L"corpus, point boliva" ); - VERIFY( str06 != str01 ); - VERIFY( str06 != str02 ); - - str05 = str01; - str05.append(str05.begin(), str05.begin() + str05.find(L'r')); - VERIFY( str05 == L"point bolivar, texaspoint boliva" ); - VERIFY( str05 != str01 ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc deleted file mode 100644 index 6f1875b622d..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/2.cc +++ /dev/null @@ -1,66 +0,0 @@ -// 2004-25-10 Paolo Carlini - -// Copyright (C) 2004-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include - -// append(const _CharT* __s, size_type __n) -// append(const _CharT* __s) -void -test02() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - wstring one; - wstring two; - wstring three; - const wchar_t * source = L"Written in your eyes"; - - one.append(source); - VERIFY( one == L"Written in your eyes" ); - - two.append(source, 20); - VERIFY( two == L"Written in your eyes" ); - - three.append(source, 7); - VERIFY( three == L"Written" ); - - three.clear(); - three.append(source + 8, 2); - VERIFY( three == L"in" ); - - one.append(one.c_str(), 20); - VERIFY( one == L"Written in your eyesWritten in your eyes" ); - - two.append(two.c_str() + 16, 4); - VERIFY( two == L"Written in your eyeseyes" ); - - two.append(two.c_str(), 3); - VERIFY( two == L"Written in your eyeseyesWri" ); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc deleted file mode 100644 index 0867fa47f6b..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/append/wchar_t/3.cc +++ /dev/null @@ -1,61 +0,0 @@ -// 2004-25-10 Paolo Carlini - -// Copyright (C) 2004-2013 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 -// . - -// 21.3.5 string modifiers - -// { dg-options "-DITERATIONS=14" { target simulator } } - -#ifndef ITERATIONS -#define ITERATIONS 18 -#endif - -#include -#include - -// Upon reallocation (basic_string::reserve) we were copying from -// deallocated memory. -void -test03() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - const wchar_t * source = L"Kesto"; - - for (unsigned i = 0; i < 10; ++i) - { - wstring one(source); - wstring two(source); - for (unsigned j = 0; j < ITERATIONS; ++j) - { - VERIFY( one == two ); - one.append(one); - one += L'x'; - two.append(two.c_str(), two.size()); - two += L'x'; - } - } -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc deleted file mode 100644 index d7cf0aa0dac..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/1.cc +++ /dev/null @@ -1,55 +0,0 @@ -// 2001-10-30 Benjamin Kosnik - -// Copyright (C) 2001-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include -#include - -void -test01() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii"; - string aux = strlit; - string::size_type i = aux.rfind("/"); - if (i != string::npos) - aux.assign(aux, i + 1, string::npos); - VERIFY(aux == "Hawaii"); - - aux = strlit; - i = aux.rfind("r/"); - if (i != string::npos) - aux.assign(aux, i + 1, string::npos); - VERIFY(aux.c_str()[9] == 'B'); - VERIFY(aux == "/Hanalei Bay/Kauai/Hawaii"); - - aux.assign(10, 0); - VERIFY(aux.length() == 10); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc deleted file mode 100644 index be14bb64c88..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/2.cc +++ /dev/null @@ -1,58 +0,0 @@ -// 2001-10-30 Benjamin Kosnik - -// Copyright (C) 2001-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include -#include - -// assign(const basic_string& __str, size_type __pos, size_type __n) -void -test02() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - string one = "Selling England by the pound"; - string two = one; - string three = "Brilliant trees"; - - one.assign(one, 8, 100); - VERIFY( one == "England by the pound" ); - - one.assign(one, 8, 0); - VERIFY( one == "" ); - - one.assign(two, 8, 7); - VERIFY( one == "England" ); - - one.assign(three, 10, 100); - VERIFY( one == "trees" ); - - three.assign(one, 0, 3); - VERIFY( three == "tre" ); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc deleted file mode 100644 index b4ab4ace1fd..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/3.cc +++ /dev/null @@ -1,58 +0,0 @@ -// 2001-10-30 Benjamin Kosnik - -// Copyright (C) 2001-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include - -// assign(const _CharT* __s, size_type __n) -// assign(const _CharT* __s) -void -test03() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - string one; - string two; - const char * source = "Selling England by the pound"; - - one.assign(source); - VERIFY( one == "Selling England by the pound" ); - - one.assign(source, 28); - VERIFY( one == "Selling England by the pound" ); - - two.assign(source, 7); - VERIFY( two == "Selling" ); - - one.assign(one.c_str() + 8, 20); - VERIFY( one == "England by the pound" ); - - one.assign(one.c_str() + 8, 6); - VERIFY( one == "by the" ); -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc deleted file mode 100644 index ceb853612c5..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/char/move_assign.cc +++ /dev/null @@ -1,43 +0,0 @@ -// { dg-options "-std=gnu++0x" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2010-2013 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 -// . - -// NOTE: This makes use of the fact that we know how moveable -// is implemented on string (via swap). If the implementation changes -// this test may begin to fail. - -#include -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - std::string a, b; - a.push_back('1'); - b.assign(std::move(a)); - VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc deleted file mode 100644 index f158a5b2a64..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/1.cc +++ /dev/null @@ -1,52 +0,0 @@ -// 2001-10-30 Benjamin Kosnik - -// Copyright (C) 2001-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include -#include - -void -test01() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii"; - wstring aux = strlit; - wstring::size_type i = aux.rfind(L"/"); - if (i != wstring::npos) - aux.assign(aux, i + 1, wstring::npos); - VERIFY(aux == L"Hawaii"); - - aux = strlit; - i = aux.rfind(L"r/"); - if (i != wstring::npos) - aux.assign(aux, i + 1, wstring::npos); - VERIFY(aux.c_str()[9] == L'B'); - VERIFY(aux == L"/Hanalei Bay/Kauai/Hawaii"); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc deleted file mode 100644 index 58172dce213..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/2.cc +++ /dev/null @@ -1,58 +0,0 @@ -// 2001-10-30 Benjamin Kosnik - -// Copyright (C) 2001-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include -#include - -// assign(const basic_string& __str, size_type __pos, size_type __n) -void -test02() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - wstring one = L"Selling England by the pound"; - wstring two = one; - wstring three = L"Brilliant trees"; - - one.assign(one, 8, 100); - VERIFY( one == L"England by the pound" ); - - one.assign(one, 8, 0); - VERIFY( one == L"" ); - - one.assign(two, 8, 7); - VERIFY( one == L"England" ); - - one.assign(three, 10, 100); - VERIFY( one == L"trees" ); - - three.assign(one, 0, 3); - VERIFY( three == L"tre" ); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc deleted file mode 100644 index c323d64bfb5..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/3.cc +++ /dev/null @@ -1,58 +0,0 @@ -// 2001-10-30 Benjamin Kosnik - -// Copyright (C) 2001-2013 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 -// . - -// 21.3.5 string modifiers - -#include -#include - -// assign(const _CharT* __s, size_type __n) -// assign(const _CharT* __s) -void -test03() -{ - bool test __attribute__((unused)) = true; - - using namespace std; - - wstring one; - wstring two; - const wchar_t* source = L"Selling England by the pound"; - - one.assign(source); - VERIFY( one == L"Selling England by the pound" ); - - one.assign(source, 28); - VERIFY( one == L"Selling England by the pound" ); - - two.assign(source, 7); - VERIFY( two == L"Selling" ); - - one.assign(one.c_str() + 8, 20); - VERIFY( one == L"England by the pound" ); - - one.assign(one.c_str() + 8, 6); - VERIFY( one == L"by the" ); -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc deleted file mode 100644 index a513c698f6e..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/assign/wchar_t/move_assign.cc +++ /dev/null @@ -1,43 +0,0 @@ -// { dg-options "-std=gnu++0x" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2010-2013 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 -// . - -// NOTE: This makes use of the fact that we know how moveable -// is implemented on string (via swap). If the implementation changes -// this test may begin to fail. - -#include -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - std::wstring a, b; - a.push_back(L'1'); - b.assign(std::move(a)); - VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc deleted file mode 100644 index 4a6695b2031..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/1.cc +++ /dev/null @@ -1,189 +0,0 @@ -// 1999-06-03 bkoz - -// Copyright (C) 1999-2013 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 -// . - -// 21.3.5.4 basic_string::insert - -#include -#include -#include - -int test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - typedef std::string::iterator citerator; - csize_type csz01, csz02; - - const std::string str01("rodeo beach, marin"); - const std::string str02("baker beach, san francisco"); - std::string str03; - - // string& insert(size_type p1, const string& str, size_type p2, size_type n) - // requires: - // 1) p1 <= size() - // 2) p2 <= str.size() - // 3) rlen = min(n, str.size() - p2) - // throws: - // 1) out_of_range if p1 > size() || p2 > str.size() - // 2) length_error if size() >= npos - rlen - // effects: - // replaces *this with new string of length size() + rlen such that - // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1] - // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen] - // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...] - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - try { - str03.insert(csz01 + 1, str02, 0, 5); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - try { - str03.insert(0, str02, csz02 + 1, 5); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - csz01 = str01.max_size(); - try { - std::string str04(csz01, 'b'); - str03 = str04; - csz02 = str02.size(); - try { - str03.insert(0, str02, 0, 5); - VERIFY( false ); - } - catch(std::length_error& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - } - catch(std::bad_alloc& failure){ - VERIFY( true ); - } - catch(std::exception& failure){ - VERIFY( false ); - } - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(13, str02, 0, 12); - VERIFY( str03 == "rodeo beach, baker beach,marin" ); - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(0, str02, 0, 12); - VERIFY( str03 == "baker beach,rodeo beach, marin" ); - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(csz01, str02, 0, csz02); - VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" ); - - // string& insert(size_type __p, const string& string); - // insert(p1, str, 0, npos) - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(csz01, str02); - VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" ); - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(0, str02); - VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" ); - - // string& insert(size_type __p, const char* s, size_type n); - // insert(p1, string(s,n)) - str03 = str02; - csz01 = str03.size(); - str03.insert(0, "-break at the bridge", 20); - VERIFY( str03 == "-break at the bridgebaker beach, san francisco" ); - - // string& insert(size_type __p, const char* s); - // insert(p1, string(s)) - str03 = str02; - str03.insert(0, "-break at the bridge"); - VERIFY( str03 == "-break at the bridgebaker beach, san francisco" ); - - // string& insert(size_type __p, size_type n, char c) - // insert(p1, string(n,c)) - str03 = str02; - csz01 = str03.size(); - str03.insert(csz01, 5, 'z'); - VERIFY( str03 == "baker beach, san franciscozzzzz" ); - - // iterator insert(iterator p, char c) - // inserts a copy of c before the character referred to by p - str03 = str02; - citerator cit01 = str03.begin(); - str03.insert(cit01, 'u'); - VERIFY( str03 == "ubaker beach, san francisco" ); - - // iterator insert(iterator p, size_type n, char c) - // inserts n copies of c before the character referred to by p - str03 = str02; - cit01 = str03.begin(); - str03.insert(cit01, 5, 'u'); - VERIFY( str03 == "uuuuubaker beach, san francisco" ); - - // template - // void - // insert(iterator p, inputit first, inputit, last) - // ISO-14882: defect #7 part 1 clarifies this member function to be: - // insert(p - begin(), string(first,last)) - str03 = str02; - csz01 = str03.size(); - str03.insert(str03.begin(), str01.begin(), str01.end()); - VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" ); - - str03 = str02; - csz01 = str03.size(); - str03.insert(str03.end(), str01.begin(), str01.end()); - VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" ); - return test; -} - -int main() -{ - __gnu_test::set_memory_limits(); - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc deleted file mode 100644 index 8330813412b..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/insert/char/2.cc +++ /dev/null @@ -1,82 +0,0 @@ -// 1999-06-03 bkoz - -// Copyright (C) 1999-2013 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 -// . - -// 21.3.5.4 basic_string::insert - -#include -#include - -// More -// string& insert(size_type __p, const char* s, size_type n); -// string& insert(size_type __p, const char* s); -// but now s points inside the _Rep -int test02(void) -{ - bool test __attribute__((unused)) = true; - - std::string str01; - const char* title = "Everything was beautiful, and nothing hurt"; - // Increasing size: str01 is reallocated every time. - str01 = title; - str01.insert(0, str01.c_str() + str01.size() - 4, 4); - VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str(), 5); - VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(10, str01.c_str() + 4, 6); - VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str(), 10); - VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str() + 11, 13); - VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str()); - VERIFY( str01 == "Everything was beautiful, and nothing hurt" - "Everything was beautiful, and nothing hurt"); - // Again: no reallocations. - str01 = title; - str01.insert(0, str01.c_str() + str01.size() - 4, 4); - VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str(), 5); - VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(10, str01.c_str() + 4, 6); - VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str(), 10); - VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str() + 11, 13); - VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str()); - VERIFY( str01 == "Everything was beautiful, and nothing hurt" - "Everything was beautiful, and nothing hurt"); - return test; -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc deleted file mode 100644 index 205e6d9dced..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/1.cc +++ /dev/null @@ -1,189 +0,0 @@ -// 1999-06-03 bkoz - -// Copyright (C) 1999-2013 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 -// . - -// 21.3.5.4 basic_string::insert - -#include -#include -#include - -int test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - typedef std::wstring::iterator citerator; - csize_type csz01, csz02; - - const std::wstring str01(L"rodeo beach, marin"); - const std::wstring str02(L"baker beach, san francisco"); - std::wstring str03; - - // wstring& insert(size_type p1, const wstring& str, size_type p2, size_type n) - // requires: - // 1) p1 <= size() - // 2) p2 <= str.size() - // 3) rlen = min(n, str.size() - p2) - // throws: - // 1) out_of_range if p1 > size() || p2 > str.size() - // 2) length_error if size() >= npos - rlen - // effects: - // replaces *this with new wstring of length size() + rlen such that - // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1] - // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen] - // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...] - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - try { - str03.insert(csz01 + 1, str02, 0, 5); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - try { - str03.insert(0, str02, csz02 + 1, 5); - VERIFY( false ); - } - catch(std::out_of_range& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - - csz01 = str01.max_size(); - try { - std::wstring str04(csz01, L'b'); - str03 = str04; - csz02 = str02.size(); - try { - str03.insert(0, str02, 0, 5); - VERIFY( false ); - } - catch(std::length_error& fail) { - VERIFY( true ); - } - catch(...) { - VERIFY( false ); - } - } - catch(std::bad_alloc& failure){ - VERIFY( true ); - } - catch(std::exception& failure){ - VERIFY( false ); - } - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(13, str02, 0, 12); - VERIFY( str03 == L"rodeo beach, baker beach,marin" ); - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(0, str02, 0, 12); - VERIFY( str03 == L"baker beach,rodeo beach, marin" ); - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(csz01, str02, 0, csz02); - VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" ); - - // wstring& insert(size_type __p, const wstring& wstr); - // insert(p1, str, 0, npos) - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(csz01, str02); - VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" ); - - str03 = str01; - csz01 = str03.size(); - csz02 = str02.size(); - str03.insert(0, str02); - VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" ); - - // wstring& insert(size_type __p, const wchar_t* s, size_type n); - // insert(p1, wstring(s,n)) - str03 = str02; - csz01 = str03.size(); - str03.insert(0, L"-break at the bridge", 20); - VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" ); - - // wstring& insert(size_type __p, const wchar_t* s); - // insert(p1, wstring(s)) - str03 = str02; - str03.insert(0, L"-break at the bridge"); - VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" ); - - // wstring& insert(size_type __p, size_type n, wchar_t c) - // insert(p1, wstring(n,c)) - str03 = str02; - csz01 = str03.size(); - str03.insert(csz01, 5, L'z'); - VERIFY( str03 == L"baker beach, san franciscozzzzz" ); - - // iterator insert(iterator p, wchar_t c) - // inserts a copy of c before the character referred to by p - str03 = str02; - citerator cit01 = str03.begin(); - str03.insert(cit01, L'u'); - VERIFY( str03 == L"ubaker beach, san francisco" ); - - // iterator insert(iterator p, size_type n, wchar_t c) - // inserts n copies of c before the character referred to by p - str03 = str02; - cit01 = str03.begin(); - str03.insert(cit01, 5, L'u'); - VERIFY( str03 == L"uuuuubaker beach, san francisco" ); - - // template - // void - // insert(iterator p, inputit first, inputit, last) - // ISO-14882: defect #7 part 1 clarifies this member function to be: - // insert(p - begin(), wstring(first,last)) - str03 = str02; - csz01 = str03.size(); - str03.insert(str03.begin(), str01.begin(), str01.end()); - VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" ); - - str03 = str02; - csz01 = str03.size(); - str03.insert(str03.end(), str01.begin(), str01.end()); - VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" ); - return test; -} - -int main() -{ - __gnu_test::set_memory_limits(); - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc deleted file mode 100644 index 6040d1e040b..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/insert/wchar_t/2.cc +++ /dev/null @@ -1,82 +0,0 @@ -// 1999-06-03 bkoz - -// Copyright (C) 1999-2013 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 -// . - -// 21.3.5.4 basic_string::insert - -#include -#include - -// More -// wstring& insert(size_type __p, const wchar_t* s, size_type n); -// wstring& insert(size_type __p, const wchar_t* s); -// but now s points inside the _Rep -int test02(void) -{ - bool test __attribute__((unused)) = true; - - std::wstring str01; - const wchar_t* title = L"Everything was beautiful, and nothing hurt"; - // Increasing size: str01 is reallocated every time. - str01 = title; - str01.insert(0, str01.c_str() + str01.size() - 4, 4); - VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str(), 5); - VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(10, str01.c_str() + 4, 6); - VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str(), 10); - VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str() + 11, 13); - VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str()); - VERIFY( str01 == L"Everything was beautiful, and nothing hurt" - L"Everything was beautiful, and nothing hurt"); - // Again: no reallocations. - str01 = title; - str01.insert(0, str01.c_str() + str01.size() - 4, 4); - VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str(), 5); - VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(10, str01.c_str() + 4, 6); - VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str(), 10); - VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(15, str01.c_str() + 11, 13); - VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" ); - str01 = title; - str01.insert(0, str01.c_str()); - VERIFY( str01 == L"Everything was beautiful, and nothing hurt" - L"Everything was beautiful, and nothing hurt"); - return test; -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/1.cc new file mode 100644 index 00000000000..2e9a3cf85f6 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/1.cc @@ -0,0 +1,158 @@ +// 1999-07-08 bkoz + +// Copyright (C) 1999-2013 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 +// . + +// 21.3.5.2 basic_string::append + +#include +#include +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + typedef std::string::const_reference cref; + typedef std::string::reference ref; + csize_type csz01; + + const char str_lit01[] = "point bolivar, texas"; + const std::string str01(str_lit01); + const std::string str02("corpus, "); + const std::string str03; + std::string str05; + + + // string& append(const string&) + str05 = str02; + str05.append(str05); + VERIFY( str05 == "corpus, corpus, " ); + str05.append(str01); + VERIFY( str05 == "corpus, corpus, point bolivar, texas" ); + str05.append(str03); + VERIFY( str05 == "corpus, corpus, point bolivar, texas" ); + std::string str06; + str06.append(str05); + VERIFY( str06 == str05 ); + + + // string& append(const string&, size_type pos, size_type n) + str05.erase(); + str06.erase(); + csz01 = str03.size(); + try { + str06.append(str03, csz01 + 1, 0); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + csz01 = str01.size(); + try { + str06.append(str01, csz01 + 1, 0); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + str05 = str02; + str05.append(str01, 0, std::string::npos); + VERIFY( str05 == "corpus, point bolivar, texas" ); + VERIFY( str05 != str02 ); + + str06 = str02; + str06.append(str01, 15, std::string::npos); + VERIFY( str06 == "corpus, texas" ); + VERIFY( str02 != str06 ); + + + // string& append(const char* s) + str05.erase(); + str06.erase(); + str05.append(""); + VERIFY( str05 == str03 ); + + str05.append(str_lit01); + VERIFY( str05 == str01 ); + + str06 = str02; + str06.append("corpus, "); + VERIFY( str06 == "corpus, corpus, " ); + + + // string& append(const char* s, size_type n) + str05.erase(); + str06.erase(); + str05.append("", 0); + VERIFY( str05.size() == 0 ); + VERIFY( str05 == str03 ); + + str05.append(str_lit01, sizeof(str_lit01) - 1); + VERIFY( str05 == str01 ); + + str06 = str02; + str06.append("corpus, ", 6); + VERIFY( str06 == "corpus, corpus" ); + + str06 = str02; + str06.append("corpus, ", 12); + VERIFY( str06 != "corpus, corpus, " ); + + + // string& append(size_type n, char c) + str05.erase(); + str06.erase(); + str05.append(0, 'a'); + VERIFY( str05 == str03 ); + str06.append(8, '.'); + VERIFY( str06 == "........" ); + + + // template + // string& append(InputIter first, InputIter last) + str05.erase(); + str06.erase(); + str05.append(str03.begin(), str03.end()); + VERIFY( str05 == str03 ); + + str06 = str02; + str06.append(str01.begin(), str01.begin() + str01.find('r')); + VERIFY( str06 == "corpus, point boliva" ); + VERIFY( str06 != str01 ); + VERIFY( str06 != str02 ); + + str05 = str01; + str05.append(str05.begin(), str05.begin() + str05.find('r')); + VERIFY( str05 == "point bolivar, texaspoint boliva" ); + VERIFY( str05 != str01 ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/2.cc new file mode 100644 index 00000000000..8d12169e389 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/2.cc @@ -0,0 +1,66 @@ +// 2004-25-10 Paolo Carlini + +// Copyright (C) 2004-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include + +// append(const _CharT* __s, size_type __n) +// append(const _CharT* __s) +void +test02() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + string one; + string two; + string three; + const char * source = "Written in your eyes"; + + one.append(source); + VERIFY( one == "Written in your eyes" ); + + two.append(source, 20); + VERIFY( two == "Written in your eyes" ); + + three.append(source, 7); + VERIFY( three == "Written" ); + + three.clear(); + three.append(source + 8, 2); + VERIFY( three == "in" ); + + one.append(one.c_str(), 20); + VERIFY( one == "Written in your eyesWritten in your eyes" ); + + two.append(two.c_str() + 16, 4); + VERIFY( two == "Written in your eyeseyes" ); + + two.append(two.c_str(), 3); + VERIFY( two == "Written in your eyeseyesWri" ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/3.cc new file mode 100644 index 00000000000..47699d2396c --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/char/3.cc @@ -0,0 +1,55 @@ +// 2004-25-10 Paolo Carlini + +// Copyright (C) 2004-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include + +// Upon reallocation (basic_string::reserve) we were copying from +// deallocated memory. +void +test03() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + const char * source = "Kesto"; + + for (unsigned i = 0; i < 10; ++i) + { + string one(source); + string two(source); + for (unsigned j = 0; j < 18; ++j) + { + VERIFY( one == two ); + one.append(one); + one += 'x'; + two.append(two.c_str(), two.size()); + two += 'x'; + } + } +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc new file mode 100644 index 00000000000..c2e435fb9d9 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/1.cc @@ -0,0 +1,158 @@ +// 1999-07-08 bkoz + +// Copyright (C) 1999-2013 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 +// . + +// 21.3.5.2 basic_string::append + +#include +#include +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + typedef std::wstring::const_reference cref; + typedef std::wstring::reference ref; + csize_type csz01; + + const wchar_t str_lit01[] = L"point bolivar, texas"; + const std::wstring str01(str_lit01); + const std::wstring str02(L"corpus, "); + const std::wstring str03; + std::wstring str05; + + + // wstring& append(const wstring&) + str05 = str02; + str05.append(str05); + VERIFY( str05 == L"corpus, corpus, " ); + str05.append(str01); + VERIFY( str05 == L"corpus, corpus, point bolivar, texas" ); + str05.append(str03); + VERIFY( str05 == L"corpus, corpus, point bolivar, texas" ); + std::wstring str06; + str06.append(str05); + VERIFY( str06 == str05 ); + + + // wstring& append(const wstring&, size_type pos, size_type n) + str05.erase(); + str06.erase(); + csz01 = str03.size(); + try { + str06.append(str03, csz01 + 1, 0); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + csz01 = str01.size(); + try { + str06.append(str01, csz01 + 1, 0); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + str05 = str02; + str05.append(str01, 0, std::wstring::npos); + VERIFY( str05 == L"corpus, point bolivar, texas" ); + VERIFY( str05 != str02 ); + + str06 = str02; + str06.append(str01, 15, std::wstring::npos); + VERIFY( str06 == L"corpus, texas" ); + VERIFY( str02 != str06 ); + + + // wstring& append(const wchar_t* s) + str05.erase(); + str06.erase(); + str05.append(L""); + VERIFY( str05 == str03 ); + + str05.append(str_lit01); + VERIFY( str05 == str01 ); + + str06 = str02; + str06.append(L"corpus, "); + VERIFY( str06 == L"corpus, corpus, " ); + + + // wstring& append(const wchar_t* s, size_type n) + str05.erase(); + str06.erase(); + str05.append(L"", 0); + VERIFY( str05.size() == 0 ); + VERIFY( str05 == str03 ); + + str05.append(str_lit01, sizeof(str_lit01) / sizeof(wchar_t) - 1); + VERIFY( str05 == str01 ); + + str06 = str02; + str06.append(L"corpus, ", 6); + VERIFY( str06 == L"corpus, corpus" ); + + str06 = str02; + str06.append(L"corpus, ", 12); + VERIFY( str06 != L"corpus, corpus, " ); + + + // wstring& append(size_type n, char c) + str05.erase(); + str06.erase(); + str05.append(0, L'a'); + VERIFY( str05 == str03 ); + str06.append(8, L'.'); + VERIFY( str06 == L"........" ); + + + // template + // wstring& append(InputIter first, InputIter last) + str05.erase(); + str06.erase(); + str05.append(str03.begin(), str03.end()); + VERIFY( str05 == str03 ); + + str06 = str02; + str06.append(str01.begin(), str01.begin() + str01.find(L'r')); + VERIFY( str06 == L"corpus, point boliva" ); + VERIFY( str06 != str01 ); + VERIFY( str06 != str02 ); + + str05 = str01; + str05.append(str05.begin(), str05.begin() + str05.find(L'r')); + VERIFY( str05 == L"point bolivar, texaspoint boliva" ); + VERIFY( str05 != str01 ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/2.cc new file mode 100644 index 00000000000..6f1875b622d --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/2.cc @@ -0,0 +1,66 @@ +// 2004-25-10 Paolo Carlini + +// Copyright (C) 2004-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include + +// append(const _CharT* __s, size_type __n) +// append(const _CharT* __s) +void +test02() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + wstring one; + wstring two; + wstring three; + const wchar_t * source = L"Written in your eyes"; + + one.append(source); + VERIFY( one == L"Written in your eyes" ); + + two.append(source, 20); + VERIFY( two == L"Written in your eyes" ); + + three.append(source, 7); + VERIFY( three == L"Written" ); + + three.clear(); + three.append(source + 8, 2); + VERIFY( three == L"in" ); + + one.append(one.c_str(), 20); + VERIFY( one == L"Written in your eyesWritten in your eyes" ); + + two.append(two.c_str() + 16, 4); + VERIFY( two == L"Written in your eyeseyes" ); + + two.append(two.c_str(), 3); + VERIFY( two == L"Written in your eyeseyesWri" ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/3.cc new file mode 100644 index 00000000000..0867fa47f6b --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/append/wchar_t/3.cc @@ -0,0 +1,61 @@ +// 2004-25-10 Paolo Carlini + +// Copyright (C) 2004-2013 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 +// . + +// 21.3.5 string modifiers + +// { dg-options "-DITERATIONS=14" { target simulator } } + +#ifndef ITERATIONS +#define ITERATIONS 18 +#endif + +#include +#include + +// Upon reallocation (basic_string::reserve) we were copying from +// deallocated memory. +void +test03() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + const wchar_t * source = L"Kesto"; + + for (unsigned i = 0; i < 10; ++i) + { + wstring one(source); + wstring two(source); + for (unsigned j = 0; j < ITERATIONS; ++j) + { + VERIFY( one == two ); + one.append(one); + one += L'x'; + two.append(two.c_str(), two.size()); + two += L'x'; + } + } +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/1.cc new file mode 100644 index 00000000000..d7cf0aa0dac --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/1.cc @@ -0,0 +1,55 @@ +// 2001-10-30 Benjamin Kosnik + +// Copyright (C) 2001-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii"; + string aux = strlit; + string::size_type i = aux.rfind("/"); + if (i != string::npos) + aux.assign(aux, i + 1, string::npos); + VERIFY(aux == "Hawaii"); + + aux = strlit; + i = aux.rfind("r/"); + if (i != string::npos) + aux.assign(aux, i + 1, string::npos); + VERIFY(aux.c_str()[9] == 'B'); + VERIFY(aux == "/Hanalei Bay/Kauai/Hawaii"); + + aux.assign(10, 0); + VERIFY(aux.length() == 10); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/2.cc new file mode 100644 index 00000000000..be14bb64c88 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/2.cc @@ -0,0 +1,58 @@ +// 2001-10-30 Benjamin Kosnik + +// Copyright (C) 2001-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include +#include + +// assign(const basic_string& __str, size_type __pos, size_type __n) +void +test02() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + string one = "Selling England by the pound"; + string two = one; + string three = "Brilliant trees"; + + one.assign(one, 8, 100); + VERIFY( one == "England by the pound" ); + + one.assign(one, 8, 0); + VERIFY( one == "" ); + + one.assign(two, 8, 7); + VERIFY( one == "England" ); + + one.assign(three, 10, 100); + VERIFY( one == "trees" ); + + three.assign(one, 0, 3); + VERIFY( three == "tre" ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/3.cc new file mode 100644 index 00000000000..b4ab4ace1fd --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/3.cc @@ -0,0 +1,58 @@ +// 2001-10-30 Benjamin Kosnik + +// Copyright (C) 2001-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include + +// assign(const _CharT* __s, size_type __n) +// assign(const _CharT* __s) +void +test03() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + string one; + string two; + const char * source = "Selling England by the pound"; + + one.assign(source); + VERIFY( one == "Selling England by the pound" ); + + one.assign(source, 28); + VERIFY( one == "Selling England by the pound" ); + + two.assign(source, 7); + VERIFY( two == "Selling" ); + + one.assign(one.c_str() + 8, 20); + VERIFY( one == "England by the pound" ); + + one.assign(one.c_str() + 8, 6); + VERIFY( one == "by the" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/move_assign.cc new file mode 100644 index 00000000000..ceb853612c5 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/char/move_assign.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + +// Copyright (C) 2010-2013 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 +// . + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on string (via swap). If the implementation changes +// this test may begin to fail. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::string a, b; + a.push_back('1'); + b.assign(std::move(a)); + VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/1.cc new file mode 100644 index 00000000000..f158a5b2a64 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/1.cc @@ -0,0 +1,52 @@ +// 2001-10-30 Benjamin Kosnik + +// Copyright (C) 2001-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include +#include + +void +test01() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii"; + wstring aux = strlit; + wstring::size_type i = aux.rfind(L"/"); + if (i != wstring::npos) + aux.assign(aux, i + 1, wstring::npos); + VERIFY(aux == L"Hawaii"); + + aux = strlit; + i = aux.rfind(L"r/"); + if (i != wstring::npos) + aux.assign(aux, i + 1, wstring::npos); + VERIFY(aux.c_str()[9] == L'B'); + VERIFY(aux == L"/Hanalei Bay/Kauai/Hawaii"); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/2.cc new file mode 100644 index 00000000000..58172dce213 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/2.cc @@ -0,0 +1,58 @@ +// 2001-10-30 Benjamin Kosnik + +// Copyright (C) 2001-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include +#include + +// assign(const basic_string& __str, size_type __pos, size_type __n) +void +test02() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + wstring one = L"Selling England by the pound"; + wstring two = one; + wstring three = L"Brilliant trees"; + + one.assign(one, 8, 100); + VERIFY( one == L"England by the pound" ); + + one.assign(one, 8, 0); + VERIFY( one == L"" ); + + one.assign(two, 8, 7); + VERIFY( one == L"England" ); + + one.assign(three, 10, 100); + VERIFY( one == L"trees" ); + + three.assign(one, 0, 3); + VERIFY( three == L"tre" ); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/3.cc new file mode 100644 index 00000000000..c323d64bfb5 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/3.cc @@ -0,0 +1,58 @@ +// 2001-10-30 Benjamin Kosnik + +// Copyright (C) 2001-2013 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 +// . + +// 21.3.5 string modifiers + +#include +#include + +// assign(const _CharT* __s, size_type __n) +// assign(const _CharT* __s) +void +test03() +{ + bool test __attribute__((unused)) = true; + + using namespace std; + + wstring one; + wstring two; + const wchar_t* source = L"Selling England by the pound"; + + one.assign(source); + VERIFY( one == L"Selling England by the pound" ); + + one.assign(source, 28); + VERIFY( one == L"Selling England by the pound" ); + + two.assign(source, 7); + VERIFY( two == L"Selling" ); + + one.assign(one.c_str() + 8, 20); + VERIFY( one == L"England by the pound" ); + + one.assign(one.c_str() + 8, 6); + VERIFY( one == L"by the" ); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/move_assign.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/move_assign.cc new file mode 100644 index 00000000000..a513c698f6e --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/assign/wchar_t/move_assign.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + +// Copyright (C) 2010-2013 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 +// . + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on string (via swap). If the implementation changes +// this test may begin to fail. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::wstring a, b; + a.push_back(L'1'); + b.assign(std::move(a)); + VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc deleted file mode 100644 index 8667e4c553a..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/char/pop_back.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2011-2013 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 -// . - -// 21.4.6.5 basic_string::pop_back -// { dg-options "-std=gnu++0x" } - -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - const std::string cstr("Badger"); - std::string str = cstr; - str.pop_back(); - VERIFY( str.size() == cstr.size() - 1 ); - - str += cstr.back(); - VERIFY( str == cstr ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc new file mode 100644 index 00000000000..4a6695b2031 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/1.cc @@ -0,0 +1,189 @@ +// 1999-06-03 bkoz + +// Copyright (C) 1999-2013 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 +// . + +// 21.3.5.4 basic_string::insert + +#include +#include +#include + +int test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + typedef std::string::iterator citerator; + csize_type csz01, csz02; + + const std::string str01("rodeo beach, marin"); + const std::string str02("baker beach, san francisco"); + std::string str03; + + // string& insert(size_type p1, const string& str, size_type p2, size_type n) + // requires: + // 1) p1 <= size() + // 2) p2 <= str.size() + // 3) rlen = min(n, str.size() - p2) + // throws: + // 1) out_of_range if p1 > size() || p2 > str.size() + // 2) length_error if size() >= npos - rlen + // effects: + // replaces *this with new string of length size() + rlen such that + // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1] + // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen] + // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...] + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + try { + str03.insert(csz01 + 1, str02, 0, 5); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + try { + str03.insert(0, str02, csz02 + 1, 5); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + csz01 = str01.max_size(); + try { + std::string str04(csz01, 'b'); + str03 = str04; + csz02 = str02.size(); + try { + str03.insert(0, str02, 0, 5); + VERIFY( false ); + } + catch(std::length_error& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + } + catch(std::bad_alloc& failure){ + VERIFY( true ); + } + catch(std::exception& failure){ + VERIFY( false ); + } + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(13, str02, 0, 12); + VERIFY( str03 == "rodeo beach, baker beach,marin" ); + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(0, str02, 0, 12); + VERIFY( str03 == "baker beach,rodeo beach, marin" ); + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(csz01, str02, 0, csz02); + VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" ); + + // string& insert(size_type __p, const string& string); + // insert(p1, str, 0, npos) + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(csz01, str02); + VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" ); + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(0, str02); + VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" ); + + // string& insert(size_type __p, const char* s, size_type n); + // insert(p1, string(s,n)) + str03 = str02; + csz01 = str03.size(); + str03.insert(0, "-break at the bridge", 20); + VERIFY( str03 == "-break at the bridgebaker beach, san francisco" ); + + // string& insert(size_type __p, const char* s); + // insert(p1, string(s)) + str03 = str02; + str03.insert(0, "-break at the bridge"); + VERIFY( str03 == "-break at the bridgebaker beach, san francisco" ); + + // string& insert(size_type __p, size_type n, char c) + // insert(p1, string(n,c)) + str03 = str02; + csz01 = str03.size(); + str03.insert(csz01, 5, 'z'); + VERIFY( str03 == "baker beach, san franciscozzzzz" ); + + // iterator insert(iterator p, char c) + // inserts a copy of c before the character referred to by p + str03 = str02; + citerator cit01 = str03.begin(); + str03.insert(cit01, 'u'); + VERIFY( str03 == "ubaker beach, san francisco" ); + + // iterator insert(iterator p, size_type n, char c) + // inserts n copies of c before the character referred to by p + str03 = str02; + cit01 = str03.begin(); + str03.insert(cit01, 5, 'u'); + VERIFY( str03 == "uuuuubaker beach, san francisco" ); + + // template + // void + // insert(iterator p, inputit first, inputit, last) + // ISO-14882: defect #7 part 1 clarifies this member function to be: + // insert(p - begin(), string(first,last)) + str03 = str02; + csz01 = str03.size(); + str03.insert(str03.begin(), str01.begin(), str01.end()); + VERIFY( str03 == "rodeo beach, marinbaker beach, san francisco" ); + + str03 = str02; + csz01 = str03.size(); + str03.insert(str03.end(), str01.begin(), str01.end()); + VERIFY( str03 == "baker beach, san franciscorodeo beach, marin" ); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc new file mode 100644 index 00000000000..8330813412b --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/char/2.cc @@ -0,0 +1,82 @@ +// 1999-06-03 bkoz + +// Copyright (C) 1999-2013 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 +// . + +// 21.3.5.4 basic_string::insert + +#include +#include + +// More +// string& insert(size_type __p, const char* s, size_type n); +// string& insert(size_type __p, const char* s); +// but now s points inside the _Rep +int test02(void) +{ + bool test __attribute__((unused)) = true; + + std::string str01; + const char* title = "Everything was beautiful, and nothing hurt"; + // Increasing size: str01 is reallocated every time. + str01 = title; + str01.insert(0, str01.c_str() + str01.size() - 4, 4); + VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str(), 5); + VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(10, str01.c_str() + 4, 6); + VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str(), 10); + VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str() + 11, 13); + VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str()); + VERIFY( str01 == "Everything was beautiful, and nothing hurt" + "Everything was beautiful, and nothing hurt"); + // Again: no reallocations. + str01 = title; + str01.insert(0, str01.c_str() + str01.size() - 4, 4); + VERIFY( str01 == "hurtEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str(), 5); + VERIFY( str01 == "EveryEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(10, str01.c_str() + 4, 6); + VERIFY( str01 == "Everythingything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str(), 10); + VERIFY( str01 == "Everything was Everythingbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str() + 11, 13); + VERIFY( str01 == "Everything was was beautifulbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str()); + VERIFY( str01 == "Everything was beautiful, and nothing hurt" + "Everything was beautiful, and nothing hurt"); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/1.cc new file mode 100644 index 00000000000..205e6d9dced --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/1.cc @@ -0,0 +1,189 @@ +// 1999-06-03 bkoz + +// Copyright (C) 1999-2013 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 +// . + +// 21.3.5.4 basic_string::insert + +#include +#include +#include + +int test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + typedef std::wstring::iterator citerator; + csize_type csz01, csz02; + + const std::wstring str01(L"rodeo beach, marin"); + const std::wstring str02(L"baker beach, san francisco"); + std::wstring str03; + + // wstring& insert(size_type p1, const wstring& str, size_type p2, size_type n) + // requires: + // 1) p1 <= size() + // 2) p2 <= str.size() + // 3) rlen = min(n, str.size() - p2) + // throws: + // 1) out_of_range if p1 > size() || p2 > str.size() + // 2) length_error if size() >= npos - rlen + // effects: + // replaces *this with new wstring of length size() + rlen such that + // nstr[0] to nstr[p1] == thisstr[0] to thisstr[p1] + // nstr[p1 + 1] to nstr[p1 + rlen] == str[p2] to str[p2 + rlen] + // nstr[p1 + 1 + rlen] to nstr[...] == thisstr[p1 + 1] to thisstr[...] + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + try { + str03.insert(csz01 + 1, str02, 0, 5); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + try { + str03.insert(0, str02, csz02 + 1, 5); + VERIFY( false ); + } + catch(std::out_of_range& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + + csz01 = str01.max_size(); + try { + std::wstring str04(csz01, L'b'); + str03 = str04; + csz02 = str02.size(); + try { + str03.insert(0, str02, 0, 5); + VERIFY( false ); + } + catch(std::length_error& fail) { + VERIFY( true ); + } + catch(...) { + VERIFY( false ); + } + } + catch(std::bad_alloc& failure){ + VERIFY( true ); + } + catch(std::exception& failure){ + VERIFY( false ); + } + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(13, str02, 0, 12); + VERIFY( str03 == L"rodeo beach, baker beach,marin" ); + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(0, str02, 0, 12); + VERIFY( str03 == L"baker beach,rodeo beach, marin" ); + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(csz01, str02, 0, csz02); + VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" ); + + // wstring& insert(size_type __p, const wstring& wstr); + // insert(p1, str, 0, npos) + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(csz01, str02); + VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" ); + + str03 = str01; + csz01 = str03.size(); + csz02 = str02.size(); + str03.insert(0, str02); + VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" ); + + // wstring& insert(size_type __p, const wchar_t* s, size_type n); + // insert(p1, wstring(s,n)) + str03 = str02; + csz01 = str03.size(); + str03.insert(0, L"-break at the bridge", 20); + VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" ); + + // wstring& insert(size_type __p, const wchar_t* s); + // insert(p1, wstring(s)) + str03 = str02; + str03.insert(0, L"-break at the bridge"); + VERIFY( str03 == L"-break at the bridgebaker beach, san francisco" ); + + // wstring& insert(size_type __p, size_type n, wchar_t c) + // insert(p1, wstring(n,c)) + str03 = str02; + csz01 = str03.size(); + str03.insert(csz01, 5, L'z'); + VERIFY( str03 == L"baker beach, san franciscozzzzz" ); + + // iterator insert(iterator p, wchar_t c) + // inserts a copy of c before the character referred to by p + str03 = str02; + citerator cit01 = str03.begin(); + str03.insert(cit01, L'u'); + VERIFY( str03 == L"ubaker beach, san francisco" ); + + // iterator insert(iterator p, size_type n, wchar_t c) + // inserts n copies of c before the character referred to by p + str03 = str02; + cit01 = str03.begin(); + str03.insert(cit01, 5, L'u'); + VERIFY( str03 == L"uuuuubaker beach, san francisco" ); + + // template + // void + // insert(iterator p, inputit first, inputit, last) + // ISO-14882: defect #7 part 1 clarifies this member function to be: + // insert(p - begin(), wstring(first,last)) + str03 = str02; + csz01 = str03.size(); + str03.insert(str03.begin(), str01.begin(), str01.end()); + VERIFY( str03 == L"rodeo beach, marinbaker beach, san francisco" ); + + str03 = str02; + csz01 = str03.size(); + str03.insert(str03.end(), str01.begin(), str01.end()); + VERIFY( str03 == L"baker beach, san franciscorodeo beach, marin" ); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/2.cc new file mode 100644 index 00000000000..6040d1e040b --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/insert/wchar_t/2.cc @@ -0,0 +1,82 @@ +// 1999-06-03 bkoz + +// Copyright (C) 1999-2013 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 +// . + +// 21.3.5.4 basic_string::insert + +#include +#include + +// More +// wstring& insert(size_type __p, const wchar_t* s, size_type n); +// wstring& insert(size_type __p, const wchar_t* s); +// but now s points inside the _Rep +int test02(void) +{ + bool test __attribute__((unused)) = true; + + std::wstring str01; + const wchar_t* title = L"Everything was beautiful, and nothing hurt"; + // Increasing size: str01 is reallocated every time. + str01 = title; + str01.insert(0, str01.c_str() + str01.size() - 4, 4); + VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str(), 5); + VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(10, str01.c_str() + 4, 6); + VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str(), 10); + VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str() + 11, 13); + VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str()); + VERIFY( str01 == L"Everything was beautiful, and nothing hurt" + L"Everything was beautiful, and nothing hurt"); + // Again: no reallocations. + str01 = title; + str01.insert(0, str01.c_str() + str01.size() - 4, 4); + VERIFY( str01 == L"hurtEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str(), 5); + VERIFY( str01 == L"EveryEverything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(10, str01.c_str() + 4, 6); + VERIFY( str01 == L"Everythingything was beautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str(), 10); + VERIFY( str01 == L"Everything was Everythingbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(15, str01.c_str() + 11, 13); + VERIFY( str01 == L"Everything was was beautifulbeautiful, and nothing hurt" ); + str01 = title; + str01.insert(0, str01.c_str()); + VERIFY( str01 == L"Everything was beautiful, and nothing hurt" + L"Everything was beautiful, and nothing hurt"); + return test; +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc new file mode 100644 index 00000000000..8667e4c553a --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/char/1.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2013 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 +// . + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::string cstr("Badger"); + std::string str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc new file mode 100644 index 00000000000..75f5f508e63 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/pop_back/wchar_t/1.cc @@ -0,0 +1,41 @@ +// Copyright (C) 2011-2013 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 +// . + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + const std::wstring cstr(L"Badger"); + std::wstring str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/1.cc new file mode 100644 index 00000000000..a7a3b4b8862 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/1.cc @@ -0,0 +1,81 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include // for std::find +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::string::size_type csize_type; + typedef std::string::const_reference cref; + typedef std::string::reference ref; + + const char str_lit01[] = "ventura, california"; + const std::string str01(str_lit01); + std::string str02("del mar, california"); + std::string str03(" and "); + std::string str05; + + // string& replace(size_type pos, size_type n, const string& string) + // string& replace(size_type pos1, size_type n1, const string& string, + // size_type pos2, size_type n2) + // string& replace(size_type pos, size_type n1, const char* s, size_type n2) + // string& replace(size_type pos, size_type n1, const char* s) + // string& replace(size_type pos, size_type n1, size_type n2, char c) + // string& replace(iterator it1, iterator it2, const string& str) + // string& replace(iterator it1, iterator it2, const chat* s, size_type n) + // string& replace(iterator it1, iterator it2, const chat* s) + // string& replace(iterator it1, iterator it2, size_type n, char c) + // template + // string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) + + // with mods, from tstring.cc, from jason merrill, et. al. + std::string X = "Hello"; + std::string x = X; + + char ch = x[0]; + VERIFY( ch == 'H' ); + + std::string z = x.substr(2, 3); + VERIFY( z == "llo" ); + + x.replace(2, 2, "r"); + VERIFY( x == "Hero" ); + + x = X; + x.replace(0, 1, "j"); + VERIFY( x == "jello" ); + + int ar[] = { 'H', 'e', 'l', 'l', 'o' }; + x.replace(std::find(x.begin(), x.end(), 'l'), + std::find(x.rbegin(), x.rend(), 'l').base(), ar, + ar + sizeof(ar) / sizeof(ar[0])); + VERIFY( x == "jeHelloo" ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/2.cc new file mode 100644 index 00000000000..231ccd7f471 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/2.cc @@ -0,0 +1,45 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +void +test02() +{ + bool test __attribute__((unused)) = true; + const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii"; + std::string aux = strlit; + aux.replace(aux.begin()+5, aux.begin()+20, + aux.begin()+10, aux.begin()+15); + VERIFY(aux == "../thg piealei Bay/Kauai/Hawaii"); + + aux = strlit; + aux.replace(aux.begin() + 10, aux.begin() + 15, + aux.begin() + 5, aux.begin() + 20); + VERIFY(aux == "../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii"); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/3.cc new file mode 100644 index 00000000000..15c4ff9ad57 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/3.cc @@ -0,0 +1,73 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// Some more miscellaneous tests +void +test03() +{ + bool test __attribute__((unused)) = true; + const char* title01 = "nine types of ambiguity"; + const char* title02 = "ultra"; + std::string str01 = title01; + std::string str02 = title02; + + str01.replace(0, 4, str02); + VERIFY(str01 == "ultra types of ambiguity"); + + str01.replace(15, 9, str02, 2, 2); + VERIFY(str01 == "ultra types of tr"); + + str01 = title01; + str02.replace(0, 0, str01, 0, std::string::npos); + VERIFY(str02 == "nine types of ambiguityultra"); + + str02.replace(11, 2, title02, 5); + VERIFY(str02 == "nine types ultra ambiguityultra"); + + str02.replace(11, 5, title01, 2); + VERIFY(str02 == "nine types ni ambiguityultra"); + + str01.replace(str01.size(), 0, title02); + VERIFY(str01 == "nine types of ambiguityultra"); + + str01 = title01; + str02 = title02; + str01.replace(str01.begin(), str01.end(), str02); + VERIFY(str01 == "ultra"); + + str01.replace(str01.begin(), str01.begin(), title01, 4); + VERIFY(str01 == "nineultra"); + + str01.replace(str01.end(), str01.end(), title01 + 5, 5); + VERIFY(str01 == "nineultratypes"); + + str01.replace(str01.begin(), str01.end(), title02); + VERIFY(str01 == "ultra"); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/4.cc new file mode 100644 index 00000000000..056c194e0be --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/4.cc @@ -0,0 +1,66 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// Some more tests for +// template +// string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) +void +test04() +{ + bool test __attribute__((unused)) = true; + std::string str01 = "geogaddi"; + std::string str02; + + typedef std::string::iterator iterator; + typedef std::string::const_iterator const_iterator; + + iterator it1 = str01.begin(); + iterator it2 = str01.end(); + str02.replace(str02.begin(), str02.end(), it1, it2); + VERIFY(str02 == "geogaddi"); + + str02 = "boards"; + const_iterator c_it1 = str01.begin(); + const_iterator c_it2 = str01.end(); + str02.replace(str02.begin(), str02.end(), c_it1, c_it2); + VERIFY(str02 == "geogaddi"); + + str02 = "boards"; + const char* c_ptr1 = str01.c_str(); + const char* c_ptr2 = str01.c_str() + 8; + str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2); + VERIFY(str02 == "geogaddi"); + + str02 = "boards"; + char* ptr1 = &*str01.begin(); + char* ptr2 = ptr1 + str01.length(); + str02.replace(str02.begin(), str02.end(), ptr1, ptr2); + VERIFY(str02 == "geogaddi"); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/5.cc new file mode 100644 index 00000000000..b8dedab517c --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/5.cc @@ -0,0 +1,42 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// We wrongly used __n1 instead of __foldn1 in the length_error +// check at the beginning of replace(__pos, __n1, __s, __n2) +void +test05() +{ + bool test __attribute__((unused)) = true; + std::string str01 = "londinium"; + std::string str02 = "cydonia"; + + str01.replace(0, 20, str02.c_str(), 3); + VERIFY(str01 == "cyd"); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/6.cc new file mode 100644 index 00000000000..f9004c011db --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/char/6.cc @@ -0,0 +1,54 @@ +// 2004-01-26 Paolo Carlini + +// Copyright (C) 2004-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::string str01("Valle Del Salto"); + str01.replace(0, 5, str01.data() + 10, 5); + VERIFY( str01 == "Salto Del Salto" ); + + std::string str02("Colle di Val d'Elsa"); + str02.replace(0, 9, str02.data() + 10, 0); + VERIFY( str02 == "Val d'Elsa" ); + + std::string str03("Novi Ligure"); + str03.replace(11, 0, str03.data() + 4, 7); + VERIFY( str03 == "Novi Ligure Ligure"); + + std::string str04("Trebisacce"); + str04.replace(3, 4, str04.data(), 0); + VERIFY( str04 == "Trecce" ); + + std::string str05("Altopiano della Sila"); + str05.replace(1, 18, str05.data() + 19, 1); + VERIFY( str05 == "Aaa" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/1.cc new file mode 100644 index 00000000000..d05edcd5f5f --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/1.cc @@ -0,0 +1,81 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include // for std::find +#include + +bool test01(void) +{ + bool test __attribute__((unused)) = true; + typedef std::wstring::size_type csize_type; + typedef std::wstring::const_reference cref; + typedef std::wstring::reference ref; + + const wchar_t str_lit01[] = L"ventura, california"; + const std::wstring str01(str_lit01); + std::wstring str02(L"del mar, california"); + std::wstring str03(L" and "); + std::wstring str05; + + // wstring& replace(size_type pos, size_type n, const wstring& string) + // wstring& replace(size_type pos1, size_type n1, const wstring& string, + // size_type pos2, size_type n2) + // wstring& replace(size_type pos, size_type n1, const wchar_t* s, size_type n2) + // wstring& replace(size_type pos, size_type n1, const wchar_t* s) + // wstring& replace(size_type pos, size_type n1, size_type n2, wchar_t c) + // wstring& replace(iterator it1, iterator it2, const wstring& str) + // wstring& replace(iterator it1, iterator it2, const wchar_t* s, size_type n) + // wstring& replace(iterator it1, iterator it2, const wchar_t* s) + // wstring& replace(iterator it1, iterator it2, size_type n, char c) + // template + // wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) + + // with mods, from tstring.cc, from jason merrill, et. al. + std::wstring X = L"Hello"; + std::wstring x = X; + + wchar_t ch = x[0]; + VERIFY( ch == L'H' ); + + std::wstring z = x.substr(2, 3); + VERIFY( z == L"llo" ); + + x.replace(2, 2, L"r"); + VERIFY( x == L"Hero" ); + + x = X; + x.replace(0, 1, L"j"); + VERIFY( x == L"jello" ); + + wchar_t ar[] = { L'H', L'e', L'l', L'l', L'o' }; + x.replace(std::find(x.begin(), x.end(), L'l'), + std::find(x.rbegin(), x.rend(), L'l').base(), ar, + ar + sizeof(ar) / sizeof(ar[0])); + VERIFY( x == L"jeHelloo" ); + return test; +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/2.cc new file mode 100644 index 00000000000..a058816296c --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/2.cc @@ -0,0 +1,46 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include +#include + +void +test02() +{ + bool test __attribute__((unused)) = true; + const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii"; + std::wstring aux = strlit; + aux.replace(aux.begin()+5, aux.begin()+20, + aux.begin()+10, aux.begin()+15); + VERIFY(aux == L"../thg piealei Bay/Kauai/Hawaii"); + + aux = strlit; + aux.replace(aux.begin() + 10, aux.begin() + 15, + aux.begin() + 5, aux.begin() + 20); + VERIFY(aux == L"../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii"); +} + +int main() +{ + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/3.cc new file mode 100644 index 00000000000..2c7ca33ea55 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/3.cc @@ -0,0 +1,73 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// Some more miscellaneous tests +void +test03() +{ + bool test __attribute__((unused)) = true; + const wchar_t* title01 = L"nine types of ambiguity"; + const wchar_t* title02 = L"ultra"; + std::wstring str01 = title01; + std::wstring str02 = title02; + + str01.replace(0, 4, str02); + VERIFY(str01 == L"ultra types of ambiguity"); + + str01.replace(15, 9, str02, 2, 2); + VERIFY(str01 == L"ultra types of tr"); + + str01 = title01; + str02.replace(0, 0, str01, 0, std::wstring::npos); + VERIFY(str02 == L"nine types of ambiguityultra"); + + str02.replace(11, 2, title02, 5); + VERIFY(str02 == L"nine types ultra ambiguityultra"); + + str02.replace(11, 5, title01, 2); + VERIFY(str02 == L"nine types ni ambiguityultra"); + + str01.replace(str01.size(), 0, title02); + VERIFY(str01 == L"nine types of ambiguityultra"); + + str01 = title01; + str02 = title02; + str01.replace(str01.begin(), str01.end(), str02); + VERIFY(str01 == L"ultra"); + + str01.replace(str01.begin(), str01.begin(), title01, 4); + VERIFY(str01 == L"nineultra"); + + str01.replace(str01.end(), str01.end(), title01 + 5, 5); + VERIFY(str01 == L"nineultratypes"); + + str01.replace(str01.begin(), str01.end(), title02); + VERIFY(str01 == L"ultra"); +} + +int main() +{ + test03(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/4.cc new file mode 100644 index 00000000000..33994180978 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/4.cc @@ -0,0 +1,66 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// Some more tests for +// template +// wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) +void +test04() +{ + bool test __attribute__((unused)) = true; + std::wstring str01 = L"geogaddi"; + std::wstring str02; + + typedef std::wstring::iterator iterator; + typedef std::wstring::const_iterator const_iterator; + + iterator it1 = str01.begin(); + iterator it2 = str01.end(); + str02.replace(str02.begin(), str02.end(), it1, it2); + VERIFY(str02 == L"geogaddi"); + + str02 = L"boards"; + const_iterator c_it1 = str01.begin(); + const_iterator c_it2 = str01.end(); + str02.replace(str02.begin(), str02.end(), c_it1, c_it2); + VERIFY(str02 == L"geogaddi"); + + str02 = L"boards"; + const wchar_t* c_ptr1 = str01.c_str(); + const wchar_t* c_ptr2 = str01.c_str() + 8; + str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2); + VERIFY(str02 == L"geogaddi"); + + str02 = L"boards"; + wchar_t* ptr1 = &*str01.begin(); + wchar_t* ptr2 = ptr1 + str01.length(); + str02.replace(str02.begin(), str02.end(), ptr1, ptr2); + VERIFY(str02 == L"geogaddi"); +} + +int main() +{ + test04(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/5.cc new file mode 100644 index 00000000000..d248f1ed460 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/5.cc @@ -0,0 +1,42 @@ +// 1999-06-10 bkoz + +// Copyright (C) 1994-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +// We wrongly used __n1 instead of __foldn1 in the length_error +// check at the beginning of replace(__pos, __n1, __s, __n2) +void +test05() +{ + bool test __attribute__((unused)) = true; + std::wstring str01 = L"londinium"; + std::wstring str02 = L"cydonia"; + + str01.replace(0, 20, str02.c_str(), 3); + VERIFY(str01 == L"cyd"); +} + +int main() +{ + test05(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/6.cc new file mode 100644 index 00000000000..105248df98a --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/replace/wchar_t/6.cc @@ -0,0 +1,54 @@ +// 2004-01-26 Paolo Carlini + +// Copyright (C) 2004-2013 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 +// . + +// 21.3.5.6 basic_string::replace + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + std::wstring str01(L"Valle Del Salto"); + str01.replace(0, 5, str01.data() + 10, 5); + VERIFY( str01 == L"Salto Del Salto" ); + + std::wstring str02(L"Colle di Val d'Elsa"); + str02.replace(0, 9, str02.data() + 10, 0); + VERIFY( str02 == L"Val d'Elsa" ); + + std::wstring str03(L"Novi Ligure"); + str03.replace(11, 0, str03.data() + 4, 7); + VERIFY( str03 == L"Novi Ligure Ligure"); + + std::wstring str04(L"Trebisacce"); + str04.replace(3, 4, str04.data(), 0); + VERIFY( str04 == L"Trecce" ); + + std::wstring str05(L"Altopiano della Sila"); + str05.replace(1, 18, str05.data() + 19, 1); + VERIFY( str05 == L"Aaa" ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc b/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc deleted file mode 100644 index 75f5f508e63..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2011-2013 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 -// . - -// 21.4.6.5 basic_string::pop_back -// { dg-options "-std=gnu++0x" } - -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - const std::wstring cstr(L"Badger"); - std::wstring str = cstr; - str.pop_back(); - VERIFY( str.size() == cstr.size() - 1 ); - - str += cstr.back(); - VERIFY( str == cstr ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc deleted file mode 100644 index a7a3b4b8862..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/1.cc +++ /dev/null @@ -1,81 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include // for std::find -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::string::size_type csize_type; - typedef std::string::const_reference cref; - typedef std::string::reference ref; - - const char str_lit01[] = "ventura, california"; - const std::string str01(str_lit01); - std::string str02("del mar, california"); - std::string str03(" and "); - std::string str05; - - // string& replace(size_type pos, size_type n, const string& string) - // string& replace(size_type pos1, size_type n1, const string& string, - // size_type pos2, size_type n2) - // string& replace(size_type pos, size_type n1, const char* s, size_type n2) - // string& replace(size_type pos, size_type n1, const char* s) - // string& replace(size_type pos, size_type n1, size_type n2, char c) - // string& replace(iterator it1, iterator it2, const string& str) - // string& replace(iterator it1, iterator it2, const chat* s, size_type n) - // string& replace(iterator it1, iterator it2, const chat* s) - // string& replace(iterator it1, iterator it2, size_type n, char c) - // template - // string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) - - // with mods, from tstring.cc, from jason merrill, et. al. - std::string X = "Hello"; - std::string x = X; - - char ch = x[0]; - VERIFY( ch == 'H' ); - - std::string z = x.substr(2, 3); - VERIFY( z == "llo" ); - - x.replace(2, 2, "r"); - VERIFY( x == "Hero" ); - - x = X; - x.replace(0, 1, "j"); - VERIFY( x == "jello" ); - - int ar[] = { 'H', 'e', 'l', 'l', 'o' }; - x.replace(std::find(x.begin(), x.end(), 'l'), - std::find(x.rbegin(), x.rend(), 'l').base(), ar, - ar + sizeof(ar) / sizeof(ar[0])); - VERIFY( x == "jeHelloo" ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc deleted file mode 100644 index 231ccd7f471..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/2.cc +++ /dev/null @@ -1,45 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -void -test02() -{ - bool test __attribute__((unused)) = true; - const char* strlit = "../the long pier/Hanalei Bay/Kauai/Hawaii"; - std::string aux = strlit; - aux.replace(aux.begin()+5, aux.begin()+20, - aux.begin()+10, aux.begin()+15); - VERIFY(aux == "../thg piealei Bay/Kauai/Hawaii"); - - aux = strlit; - aux.replace(aux.begin() + 10, aux.begin() + 15, - aux.begin() + 5, aux.begin() + 20); - VERIFY(aux == "../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii"); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc deleted file mode 100644 index 15c4ff9ad57..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/3.cc +++ /dev/null @@ -1,73 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -// Some more miscellaneous tests -void -test03() -{ - bool test __attribute__((unused)) = true; - const char* title01 = "nine types of ambiguity"; - const char* title02 = "ultra"; - std::string str01 = title01; - std::string str02 = title02; - - str01.replace(0, 4, str02); - VERIFY(str01 == "ultra types of ambiguity"); - - str01.replace(15, 9, str02, 2, 2); - VERIFY(str01 == "ultra types of tr"); - - str01 = title01; - str02.replace(0, 0, str01, 0, std::string::npos); - VERIFY(str02 == "nine types of ambiguityultra"); - - str02.replace(11, 2, title02, 5); - VERIFY(str02 == "nine types ultra ambiguityultra"); - - str02.replace(11, 5, title01, 2); - VERIFY(str02 == "nine types ni ambiguityultra"); - - str01.replace(str01.size(), 0, title02); - VERIFY(str01 == "nine types of ambiguityultra"); - - str01 = title01; - str02 = title02; - str01.replace(str01.begin(), str01.end(), str02); - VERIFY(str01 == "ultra"); - - str01.replace(str01.begin(), str01.begin(), title01, 4); - VERIFY(str01 == "nineultra"); - - str01.replace(str01.end(), str01.end(), title01 + 5, 5); - VERIFY(str01 == "nineultratypes"); - - str01.replace(str01.begin(), str01.end(), title02); - VERIFY(str01 == "ultra"); -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc deleted file mode 100644 index 056c194e0be..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/4.cc +++ /dev/null @@ -1,66 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -// Some more tests for -// template -// string& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) -void -test04() -{ - bool test __attribute__((unused)) = true; - std::string str01 = "geogaddi"; - std::string str02; - - typedef std::string::iterator iterator; - typedef std::string::const_iterator const_iterator; - - iterator it1 = str01.begin(); - iterator it2 = str01.end(); - str02.replace(str02.begin(), str02.end(), it1, it2); - VERIFY(str02 == "geogaddi"); - - str02 = "boards"; - const_iterator c_it1 = str01.begin(); - const_iterator c_it2 = str01.end(); - str02.replace(str02.begin(), str02.end(), c_it1, c_it2); - VERIFY(str02 == "geogaddi"); - - str02 = "boards"; - const char* c_ptr1 = str01.c_str(); - const char* c_ptr2 = str01.c_str() + 8; - str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2); - VERIFY(str02 == "geogaddi"); - - str02 = "boards"; - char* ptr1 = &*str01.begin(); - char* ptr2 = ptr1 + str01.length(); - str02.replace(str02.begin(), str02.end(), ptr1, ptr2); - VERIFY(str02 == "geogaddi"); -} - -int main() -{ - test04(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc deleted file mode 100644 index b8dedab517c..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/5.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -// We wrongly used __n1 instead of __foldn1 in the length_error -// check at the beginning of replace(__pos, __n1, __s, __n2) -void -test05() -{ - bool test __attribute__((unused)) = true; - std::string str01 = "londinium"; - std::string str02 = "cydonia"; - - str01.replace(0, 20, str02.c_str(), 3); - VERIFY(str01 == "cyd"); -} - -int main() -{ - test05(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc deleted file mode 100644 index f9004c011db..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/char/6.cc +++ /dev/null @@ -1,54 +0,0 @@ -// 2004-01-26 Paolo Carlini - -// Copyright (C) 2004-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - std::string str01("Valle Del Salto"); - str01.replace(0, 5, str01.data() + 10, 5); - VERIFY( str01 == "Salto Del Salto" ); - - std::string str02("Colle di Val d'Elsa"); - str02.replace(0, 9, str02.data() + 10, 0); - VERIFY( str02 == "Val d'Elsa" ); - - std::string str03("Novi Ligure"); - str03.replace(11, 0, str03.data() + 4, 7); - VERIFY( str03 == "Novi Ligure Ligure"); - - std::string str04("Trebisacce"); - str04.replace(3, 4, str04.data(), 0); - VERIFY( str04 == "Trecce" ); - - std::string str05("Altopiano della Sila"); - str05.replace(1, 18, str05.data() + 19, 1); - VERIFY( str05 == "Aaa" ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc deleted file mode 100644 index d05edcd5f5f..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/1.cc +++ /dev/null @@ -1,81 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include // for std::find -#include - -bool test01(void) -{ - bool test __attribute__((unused)) = true; - typedef std::wstring::size_type csize_type; - typedef std::wstring::const_reference cref; - typedef std::wstring::reference ref; - - const wchar_t str_lit01[] = L"ventura, california"; - const std::wstring str01(str_lit01); - std::wstring str02(L"del mar, california"); - std::wstring str03(L" and "); - std::wstring str05; - - // wstring& replace(size_type pos, size_type n, const wstring& string) - // wstring& replace(size_type pos1, size_type n1, const wstring& string, - // size_type pos2, size_type n2) - // wstring& replace(size_type pos, size_type n1, const wchar_t* s, size_type n2) - // wstring& replace(size_type pos, size_type n1, const wchar_t* s) - // wstring& replace(size_type pos, size_type n1, size_type n2, wchar_t c) - // wstring& replace(iterator it1, iterator it2, const wstring& str) - // wstring& replace(iterator it1, iterator it2, const wchar_t* s, size_type n) - // wstring& replace(iterator it1, iterator it2, const wchar_t* s) - // wstring& replace(iterator it1, iterator it2, size_type n, char c) - // template - // wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) - - // with mods, from tstring.cc, from jason merrill, et. al. - std::wstring X = L"Hello"; - std::wstring x = X; - - wchar_t ch = x[0]; - VERIFY( ch == L'H' ); - - std::wstring z = x.substr(2, 3); - VERIFY( z == L"llo" ); - - x.replace(2, 2, L"r"); - VERIFY( x == L"Hero" ); - - x = X; - x.replace(0, 1, L"j"); - VERIFY( x == L"jello" ); - - wchar_t ar[] = { L'H', L'e', L'l', L'l', L'o' }; - x.replace(std::find(x.begin(), x.end(), L'l'), - std::find(x.rbegin(), x.rend(), L'l').base(), ar, - ar + sizeof(ar) / sizeof(ar[0])); - VERIFY( x == L"jeHelloo" ); - return test; -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc deleted file mode 100644 index a058816296c..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/2.cc +++ /dev/null @@ -1,46 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include -#include - -void -test02() -{ - bool test __attribute__((unused)) = true; - const wchar_t* strlit = L"../the long pier/Hanalei Bay/Kauai/Hawaii"; - std::wstring aux = strlit; - aux.replace(aux.begin()+5, aux.begin()+20, - aux.begin()+10, aux.begin()+15); - VERIFY(aux == L"../thg piealei Bay/Kauai/Hawaii"); - - aux = strlit; - aux.replace(aux.begin() + 10, aux.begin() + 15, - aux.begin() + 5, aux.begin() + 20); - VERIFY(aux == L"../the lone long pier/Hanr/Hanalei Bay/Kauai/Hawaii"); -} - -int main() -{ - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc deleted file mode 100644 index 2c7ca33ea55..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/3.cc +++ /dev/null @@ -1,73 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -// Some more miscellaneous tests -void -test03() -{ - bool test __attribute__((unused)) = true; - const wchar_t* title01 = L"nine types of ambiguity"; - const wchar_t* title02 = L"ultra"; - std::wstring str01 = title01; - std::wstring str02 = title02; - - str01.replace(0, 4, str02); - VERIFY(str01 == L"ultra types of ambiguity"); - - str01.replace(15, 9, str02, 2, 2); - VERIFY(str01 == L"ultra types of tr"); - - str01 = title01; - str02.replace(0, 0, str01, 0, std::wstring::npos); - VERIFY(str02 == L"nine types of ambiguityultra"); - - str02.replace(11, 2, title02, 5); - VERIFY(str02 == L"nine types ultra ambiguityultra"); - - str02.replace(11, 5, title01, 2); - VERIFY(str02 == L"nine types ni ambiguityultra"); - - str01.replace(str01.size(), 0, title02); - VERIFY(str01 == L"nine types of ambiguityultra"); - - str01 = title01; - str02 = title02; - str01.replace(str01.begin(), str01.end(), str02); - VERIFY(str01 == L"ultra"); - - str01.replace(str01.begin(), str01.begin(), title01, 4); - VERIFY(str01 == L"nineultra"); - - str01.replace(str01.end(), str01.end(), title01 + 5, 5); - VERIFY(str01 == L"nineultratypes"); - - str01.replace(str01.begin(), str01.end(), title02); - VERIFY(str01 == L"ultra"); -} - -int main() -{ - test03(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc deleted file mode 100644 index 33994180978..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/4.cc +++ /dev/null @@ -1,66 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -// Some more tests for -// template -// wstring& replace(iterator it1, iterator it2, InputIter j1, InputIter j2) -void -test04() -{ - bool test __attribute__((unused)) = true; - std::wstring str01 = L"geogaddi"; - std::wstring str02; - - typedef std::wstring::iterator iterator; - typedef std::wstring::const_iterator const_iterator; - - iterator it1 = str01.begin(); - iterator it2 = str01.end(); - str02.replace(str02.begin(), str02.end(), it1, it2); - VERIFY(str02 == L"geogaddi"); - - str02 = L"boards"; - const_iterator c_it1 = str01.begin(); - const_iterator c_it2 = str01.end(); - str02.replace(str02.begin(), str02.end(), c_it1, c_it2); - VERIFY(str02 == L"geogaddi"); - - str02 = L"boards"; - const wchar_t* c_ptr1 = str01.c_str(); - const wchar_t* c_ptr2 = str01.c_str() + 8; - str02.replace(str02.begin(), str02.end(), c_ptr1, c_ptr2); - VERIFY(str02 == L"geogaddi"); - - str02 = L"boards"; - wchar_t* ptr1 = &*str01.begin(); - wchar_t* ptr2 = ptr1 + str01.length(); - str02.replace(str02.begin(), str02.end(), ptr1, ptr2); - VERIFY(str02 == L"geogaddi"); -} - -int main() -{ - test04(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc deleted file mode 100644 index d248f1ed460..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/5.cc +++ /dev/null @@ -1,42 +0,0 @@ -// 1999-06-10 bkoz - -// Copyright (C) 1994-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -// We wrongly used __n1 instead of __foldn1 in the length_error -// check at the beginning of replace(__pos, __n1, __s, __n2) -void -test05() -{ - bool test __attribute__((unused)) = true; - std::wstring str01 = L"londinium"; - std::wstring str02 = L"cydonia"; - - str01.replace(0, 20, str02.c_str(), 3); - VERIFY(str01 == L"cyd"); -} - -int main() -{ - test05(); - return 0; -} diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc b/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc deleted file mode 100644 index 105248df98a..00000000000 --- a/libstdc++-v3/testsuite/21_strings/basic_string/replace/wchar_t/6.cc +++ /dev/null @@ -1,54 +0,0 @@ -// 2004-01-26 Paolo Carlini - -// Copyright (C) 2004-2013 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 -// . - -// 21.3.5.6 basic_string::replace - -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - std::wstring str01(L"Valle Del Salto"); - str01.replace(0, 5, str01.data() + 10, 5); - VERIFY( str01 == L"Salto Del Salto" ); - - std::wstring str02(L"Colle di Val d'Elsa"); - str02.replace(0, 9, str02.data() + 10, 0); - VERIFY( str02 == L"Val d'Elsa" ); - - std::wstring str03(L"Novi Ligure"); - str03.replace(11, 0, str03.data() + 4, 7); - VERIFY( str03 == L"Novi Ligure Ligure"); - - std::wstring str04(L"Trebisacce"); - str04.replace(3, 4, str04.data(), 0); - VERIFY( str04 == L"Trecce" ); - - std::wstring str05(L"Altopiano della Sila"); - str05.replace(1, 18, str05.data() + 19, 1); - VERIFY( str05 == L"Aaa" ); -} - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc new file mode 100644 index 00000000000..d4898b3d202 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/emplace/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::deque d1; + d1.emplace(d1.cbegin(), 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc new file mode 100644 index 00000000000..915aa688a91 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/modifiers/insert/const_iterator.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::deque d1; + int n = 0; + d1.insert(d1.cbegin(), n); + d1.insert(d1.cbegin(), 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc index ccb63ef83ee..9788b4d952d 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1714 } +// { dg-error "no matching" "" { target *-*-* } 1724 } #include diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc index 0a5db6362b5..a85b5c3f9f8 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1647 } +// { dg-error "no matching" "" { target *-*-* } 1657 } #include diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc index 7572322c6b4..162bdf0bf95 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1647 } +// { dg-error "no matching" "" { target *-*-* } 1657 } #include #include diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc index b109d3896e4..7e8356fd763 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1798 } +// { dg-error "no matching" "" { target *-*-* } 1808 } #include diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc new file mode 100644 index 00000000000..d5aef75d61e --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/emplace/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::list l1; + l1.emplace(l1.cbegin(), 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc new file mode 100644 index 00000000000..156bc0a58cb --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/modifiers/insert/const_iterator.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::list l1; + int n = 0; + l1.insert(l1.cbegin(), n); + l1.insert(l1.cbegin(), 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index 4ccd652bbd2..218b862e348 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1545 } +// { dg-error "no matching" "" { target *-*-* } 1559 } #include diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index 6bc01b7ec7c..3f0b74939b1 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1497 } +// { dg-error "no matching" "" { target *-*-* } 1511 } #include diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index 1f39056e376..b861f46fde2 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1497 } +// { dg-error "no matching" "" { target *-*-* } 1511 } #include #include diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index 902f55ab2fd..fd38c0b36d6 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1497 } +// { dg-error "no matching" "" { target *-*-* } 1511 } #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc new file mode 100644 index 00000000000..b8993d84342 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::vector vb1; + vb1.insert(vb1.cbegin(), true); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc new file mode 100644 index 00000000000..8e2a194ac17 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/emplace/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::vector v1; + v1.emplace(v1.cbegin(), 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc new file mode 100644 index 00000000000..5e5ef9e3739 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/const_iterator.cc @@ -0,0 +1,29 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + std::vector v1; + int n = 0; + v1.insert(v1.cbegin(), n); + v1.insert(v1.cbegin(), 1); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc index 2dbc60240a2..e9434677282 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1252 } +// { dg-error "no matching" "" { target *-*-* } 1264 } #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc index 7fc56bd4286..ba14bcef2ad 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1178 } +// { dg-error "no matching" "" { target *-*-* } 1190 } #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc index 6a374618ce5..c9ac43782c4 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1178 } +// { dg-error "no matching" "" { target *-*-* } 1190 } #include #include diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc index 3f5abb903cb..343edc2c7f3 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1293 } +// { dg-error "no matching" "" { target *-*-* } 1305 } #include diff --git a/libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc b/libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc deleted file mode 100644 index 5202909c23f..00000000000 --- a/libstdc++-v3/testsuite/ext/vstring/assign/move_assign.cc +++ /dev/null @@ -1,54 +0,0 @@ -// { dg-options "-std=gnu++0x" } -// { dg-require-string-conversions "" } - -// Copyright (C) 2010-2013 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 -// . - -// NOTE: This makes use of the fact that we know how moveable -// is implemented on vstring (via swap). If the implementation changes -// this test may begin to fail. - -#include -#include -#include - -void test01() -{ - bool test __attribute__((unused)) = true; - - __gnu_cxx::__sso_string a, b; - a.push_back('1'); - b.assign(std::move(a)); - VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); -} - -void test02() -{ - bool test __attribute__((unused)) = true; - - __gnu_cxx::__rc_string a, b; - a.push_back('1'); - b.assign(std::move(a)); - VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); -} - -int main() -{ - test01(); - test02(); - return 0; -} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/assign/move_assign.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/assign/move_assign.cc new file mode 100644 index 00000000000..5202909c23f --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/assign/move_assign.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// { dg-require-string-conversions "" } + +// Copyright (C) 2010-2013 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 +// . + +// NOTE: This makes use of the fact that we know how moveable +// is implemented on vstring (via swap). If the implementation changes +// this test may begin to fail. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::__sso_string a, b; + a.push_back('1'); + b.assign(std::move(a)); + VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); +} + +void test02() +{ + bool test __attribute__((unused)) = true; + + __gnu_cxx::__rc_string a, b; + a.push_back('1'); + b.assign(std::move(a)); + VERIFY( b.size() == 1 && b[0] == '1' && a.size() == 0 ); +} + +int main() +{ + test01(); + test02(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/char/54577.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/char/54577.cc deleted file mode 100644 index 979828bb10e..00000000000 --- a/libstdc++-v3/testsuite/ext/vstring/modifiers/char/54577.cc +++ /dev/null @@ -1,33 +0,0 @@ -// { dg-options "-std=gnu++11" } -// { dg-do compile } - -// Copyright (C) 2013 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 - -void test01() -{ - __gnu_cxx::__vstring vs1; - vs1.push_back('1'); - vs1.erase(vs1.cbegin()); - - __gnu_cxx::__vstring vs2; - vs2.push_back('2'); - vs2.push_back('3'); - vs2.erase(vs2.cbegin(), vs2.cend()); -} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc deleted file mode 100644 index cec1d226079..00000000000 --- a/libstdc++-v3/testsuite/ext/vstring/modifiers/char/pop_back.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2011-2013 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 -// . - -// 21.4.6.5 basic_string::pop_back -// { dg-options "-std=gnu++0x" } - -#include -#include - -template -int test01() -{ - bool test __attribute__((unused)) = true; - - const StrT cstr("Badger"); - StrT str = cstr; - str.pop_back(); - VERIFY( str.size() == cstr.size() - 1 ); - - str += cstr.back(); - VERIFY( str == cstr ); - - return test; -} - -int main() -{ - test01<__gnu_cxx::__sso_string>(); - test01<__gnu_cxx::__rc_string>(); - return 0; -} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/erase/char/54577.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/erase/char/54577.cc new file mode 100644 index 00000000000..979828bb10e --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/erase/char/54577.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + __gnu_cxx::__vstring vs1; + vs1.push_back('1'); + vs1.erase(vs1.cbegin()); + + __gnu_cxx::__vstring vs2; + vs2.push_back('2'); + vs2.push_back('3'); + vs2.erase(vs2.cbegin(), vs2.cend()); +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/erase/wchar_t/54577.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/erase/wchar_t/54577.cc new file mode 100644 index 00000000000..f514099972b --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/erase/wchar_t/54577.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + __gnu_cxx::__wvstring wvs1; + wvs1.push_back(L'1'); + wvs1.erase(wvs1.cbegin()); + + __gnu_cxx::__wvstring wvs2; + wvs2.push_back(L'2'); + wvs2.push_back(L'3'); + wvs2.erase(wvs2.cbegin(), wvs2.cend()); +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc new file mode 100644 index 00000000000..223ab66ab7d --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + __gnu_cxx::__vstring vs1; + vs1.insert(vs1.cbegin(), '1'); +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc new file mode 100644 index 00000000000..57fee54fdc4 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + __gnu_cxx::__wvstring wvs1; + wvs1.insert(wvs1.cbegin(), L'1'); +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/char/1.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/char/1.cc new file mode 100644 index 00000000000..cec1d226079 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/char/1.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2011-2013 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 +// . + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include +#include + +template +int test01() +{ + bool test __attribute__((unused)) = true; + + const StrT cstr("Badger"); + StrT str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); + + return test; +} + +int main() +{ + test01<__gnu_cxx::__sso_string>(); + test01<__gnu_cxx::__rc_string>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/wchar_t/1.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/wchar_t/1.cc new file mode 100644 index 00000000000..ee8de53a915 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/pop_back/wchar_t/1.cc @@ -0,0 +1,45 @@ +// Copyright (C) 2011-2013 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 +// . + +// 21.4.6.5 basic_string::pop_back +// { dg-options "-std=gnu++0x" } + +#include +#include + +template +int test01() +{ + bool test __attribute__((unused)) = true; + + const StrT cstr(L"Badger"); + StrT str = cstr; + str.pop_back(); + VERIFY( str.size() == cstr.size() - 1 ); + + str += cstr.back(); + VERIFY( str == cstr ); + + return test; +} + +int main() +{ + test01<__gnu_cxx::__wsso_string>(); + test01<__gnu_cxx::__wrc_string>(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc new file mode 100644 index 00000000000..0838443db77 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + __gnu_cxx::__vstring vs1; + vs1.replace(vs1.cbegin(), vs1.cend(), vs1); + vs1.replace(vs1.cbegin(), vs1.cend(), "1", 1); + vs1.replace(vs1.cbegin(), vs1.cend(), "2"); + vs1.replace(vs1.cbegin(), vs1.cend(), 1, '3'); +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc new file mode 100644 index 00000000000..a909c9ca5a4 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 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 + +void test01() +{ + __gnu_cxx::__wvstring wvs1; + wvs1.replace(wvs1.cbegin(), wvs1.cend(), wvs1); + wvs1.replace(wvs1.cbegin(), wvs1.cend(), L"1", 1); + wvs1.replace(wvs1.cbegin(), wvs1.cend(), L"2"); + wvs1.replace(wvs1.cbegin(), wvs1.cend(), 1, L'3'); +} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/54577.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/54577.cc deleted file mode 100644 index f514099972b..00000000000 --- a/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/54577.cc +++ /dev/null @@ -1,33 +0,0 @@ -// { dg-options "-std=gnu++11" } -// { dg-do compile } - -// Copyright (C) 2013 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 - -void test01() -{ - __gnu_cxx::__wvstring wvs1; - wvs1.push_back(L'1'); - wvs1.erase(wvs1.cbegin()); - - __gnu_cxx::__wvstring wvs2; - wvs2.push_back(L'2'); - wvs2.push_back(L'3'); - wvs2.erase(wvs2.cbegin(), wvs2.cend()); -} diff --git a/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc b/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc deleted file mode 100644 index ee8de53a915..00000000000 --- a/libstdc++-v3/testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2011-2013 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 -// . - -// 21.4.6.5 basic_string::pop_back -// { dg-options "-std=gnu++0x" } - -#include -#include - -template -int test01() -{ - bool test __attribute__((unused)) = true; - - const StrT cstr(L"Badger"); - StrT str = cstr; - str.pop_back(); - VERIFY( str.size() == cstr.size() - 1 ); - - str += cstr.back(); - VERIFY( str == cstr ); - - return test; -} - -int main() -{ - test01<__gnu_cxx::__wsso_string>(); - test01<__gnu_cxx::__wrc_string>(); - return 0; -} diff --git a/libstdc++-v3/testsuite/util/exception/safety.h b/libstdc++-v3/testsuite/util/exception/safety.h index c063c9bddb7..5ba9b13ce37 100644 --- a/libstdc++-v3/testsuite/util/exception/safety.h +++ b/libstdc++-v3/testsuite/util/exception/safety.h @@ -265,7 +265,7 @@ namespace __gnu_test : _F_erase_point(&_Tp::erase), _F_erase_range(&_Tp::erase) { } }; - // Specializations, old C++03 signatures. + // Specialization, old C++03 signature. template struct erase_base> { @@ -280,24 +280,6 @@ namespace __gnu_test _F_erase_range(&container_type::erase) { } }; - template class _Tp4> - struct erase_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>> - { - typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4> - container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::const_iterator const_iterator; - - iterator (container_type::* _F_erase_point)(const_iterator); - iterator (container_type::* _F_erase_range)(const_iterator, - const_iterator); - - erase_base() - : _F_erase_point(&container_type::erase), - _F_erase_range(&container_type::erase) { } - }; - // Specialization, as forward_list has erase_after. template struct erase_base> @@ -698,47 +680,7 @@ namespace __gnu_test insert_base() : _F_insert_point(&_Tp::insert) { } }; - // Specializations, old C++03 signatures. - template - struct insert_base> - { - typedef std::deque<_Tp1, _Tp2> container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::value_type value_type; - - iterator (container_type::* _F_insert_point)(iterator, - const value_type&); - - insert_base() : _F_insert_point(&container_type::insert) { } - }; - - template - struct insert_base> - { - typedef std::list<_Tp1, _Tp2> container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::value_type value_type; - - iterator (container_type::* _F_insert_point)(iterator, - const value_type&); - - insert_base() : _F_insert_point(&container_type::insert) { } - }; - - template - struct insert_base> - { - typedef std::vector<_Tp1, _Tp2> container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::value_type value_type; - - iterator (container_type::* _F_insert_point)(iterator, - const value_type&); - - insert_base() : _F_insert_point(&container_type::insert) { } - }; - - // Specialization, as string insertion has a different signature. + // Specialization, old C++03 signature. template struct insert_base> { @@ -751,17 +693,19 @@ namespace __gnu_test insert_base() : _F_insert_point(&container_type::insert) { } }; - // Likewise for __versa_string. + // Specialization, by value. template class _Tp4> struct insert_base<__gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4>> { typedef __gnu_cxx::__versa_string<_Tp1, _Tp2, _Tp3, _Tp4> - container_type; - typedef typename container_type::iterator iterator; - typedef typename container_type::value_type value_type; + container_type; + typedef typename container_type::iterator iterator; + typedef typename container_type::const_iterator const_iterator; + typedef typename container_type::value_type value_type; - iterator (container_type::* _F_insert_point)(iterator, value_type); + iterator (container_type::* _F_insert_point)(const_iterator, + value_type); insert_base() : _F_insert_point(&container_type::insert) { } }; -- cgit v1.2.1