basic_string.h (basic_string::at): Move adjacent to other overload.
* include/bits/basic_string.h (basic_string::at): Move adjacent to other overload. (basic_string::pop_back): Define. * include/debug/string (__gnu_debug::basic_string::pop_back): Likewise. * include/ext/vstring.h (__versa_string::pop_back): Likewise. * config/abi/pre/gnu.ver: Add new symbols. * testsuite/21_strings/basic_string/modifiers/char/pop_back.cc: New. * testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc: New. * testsuite/21_strings/basic_string/range_access.cc: Split to ... * testsuite/21_strings/basic_string/range_access/char/1.cc: Here and ... * testsuite/21_strings/basic_string/range_access/wchar_t/1.cc: Here. * testsuite/ext/vstring/modifiers/char/pop_back.cc: New. * testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: New. From-SVN: r181049
This commit is contained in:
parent
d19fa6b5f1
commit
f1e09f0d14
@ -1,3 +1,19 @@
|
|||||||
|
2011-11-07 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
|
* include/bits/basic_string.h (basic_string::at): Move adjacent to other
|
||||||
|
overload.
|
||||||
|
(basic_string::pop_back): Define.
|
||||||
|
* include/debug/string (__gnu_debug::basic_string::pop_back): Likewise.
|
||||||
|
* include/ext/vstring.h (__versa_string::pop_back): Likewise.
|
||||||
|
* config/abi/pre/gnu.ver: Add new symbols.
|
||||||
|
* testsuite/21_strings/basic_string/modifiers/char/pop_back.cc: New.
|
||||||
|
* testsuite/21_strings/basic_string/modifiers/wchar_t/pop_back.cc: New.
|
||||||
|
* testsuite/21_strings/basic_string/range_access.cc: Split to ...
|
||||||
|
* testsuite/21_strings/basic_string/range_access/char/1.cc: Here and ...
|
||||||
|
* testsuite/21_strings/basic_string/range_access/wchar_t/1.cc: Here.
|
||||||
|
* testsuite/ext/vstring/modifiers/char/pop_back.cc: New.
|
||||||
|
* testsuite/ext/vstring/modifiers/wchar_t/pop_back.cc: New.
|
||||||
|
|
||||||
2011-11-06 Jonathan Wakely <jwakely.gcc@gmail.com>
|
2011-11-06 Jonathan Wakely <jwakely.gcc@gmail.com>
|
||||||
|
|
||||||
* doc/xml/manual/backwards_compatibility.xml: Fix autoconf tests for
|
* doc/xml/manual/backwards_compatibility.xml: Fix autoconf tests for
|
||||||
|
@ -225,9 +225,10 @@ GLIBCXX_3.4 {
|
|||||||
_ZNKSs[0-3][a-b]*;
|
_ZNKSs[0-3][a-b]*;
|
||||||
_ZNKSs[5-9][a-b]*;
|
_ZNKSs[5-9][a-b]*;
|
||||||
_ZNKSs[0-9][d-e]*;
|
_ZNKSs[0-9][d-e]*;
|
||||||
_ZNKSs[0-9][g-z]*;
|
_ZNKSs[0-79][g-z]*;
|
||||||
_ZNKSs[0-9][0-9][a-z]*;
|
_ZNKSs[0-9][0-9][a-z]*;
|
||||||
_ZNKSs4find*;
|
_ZNKSs4find*;
|
||||||
|
_ZNKSs8max_size*;
|
||||||
_ZNKSs[a-z]*;
|
_ZNKSs[a-z]*;
|
||||||
_ZNKSs4_Rep12_M_is_leakedEv;
|
_ZNKSs4_Rep12_M_is_leakedEv;
|
||||||
_ZNKSs4_Rep12_M_is_sharedEv;
|
_ZNKSs4_Rep12_M_is_sharedEv;
|
||||||
@ -286,10 +287,11 @@ GLIBCXX_3.4 {
|
|||||||
_ZNKSbIwSt11char_traitsIwESaIwEE[0-3][a-b]*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE[0-3][a-b]*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE[5-9][a-b]*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE[5-9][a-b]*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][d-e]*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][d-e]*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][g-z]*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE[0-79][g-z]*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][0-9][a-z]*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][0-9][a-z]*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE[a-z]*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE[a-z]*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE4find*;
|
_ZNKSbIwSt11char_traitsIwESaIwEE4find*;
|
||||||
|
_ZNKSbIwSt11char_traitsIwESaIwEE8max_size*;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE4_Rep12_M_is_leakedEv;
|
_ZNKSbIwSt11char_traitsIwESaIwEE4_Rep12_M_is_leakedEv;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE4_Rep12_M_is_sharedEv;
|
_ZNKSbIwSt11char_traitsIwESaIwEE4_Rep12_M_is_sharedEv;
|
||||||
_ZNKSbIwSt11char_traitsIwESaIwEE6_M_repEv;
|
_ZNKSbIwSt11char_traitsIwESaIwEE6_M_repEv;
|
||||||
@ -1302,6 +1304,11 @@ GLIBCXX_3.4.17 {
|
|||||||
_ZNSt14numeric_limitsInE*;
|
_ZNSt14numeric_limitsInE*;
|
||||||
_ZNSt14numeric_limitsIoE*;
|
_ZNSt14numeric_limitsIoE*;
|
||||||
|
|
||||||
|
# std::string::pop_back()
|
||||||
|
_ZNSs8pop_backEv;
|
||||||
|
# std::wstring::pop_back()
|
||||||
|
_ZNSbIwSt11char_traitsIwESaIwEE8pop_backEv;
|
||||||
|
|
||||||
} GLIBCXX_3.4.16;
|
} GLIBCXX_3.4.16;
|
||||||
|
|
||||||
# Symbols in the support library (libsupc++) have their own tag.
|
# Symbols in the support library (libsupc++) have their own tag.
|
||||||
|
@ -865,6 +865,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
return _M_data()[__n];
|
return _M_data()[__n];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Provides access to the data contained in the %string.
|
||||||
|
* @param __n The index of the character to access.
|
||||||
|
* @return Read/write reference to the character.
|
||||||
|
* @throw std::out_of_range If @a n is an invalid index.
|
||||||
|
*
|
||||||
|
* This function provides for safer data access. The parameter is
|
||||||
|
* first checked that it is in the range of the string. The function
|
||||||
|
* throws out_of_range if the check fails. Success results in
|
||||||
|
* unsharing the string.
|
||||||
|
*/
|
||||||
|
reference
|
||||||
|
at(size_type __n)
|
||||||
|
{
|
||||||
|
if (__n >= size())
|
||||||
|
__throw_out_of_range(__N("basic_string::at"));
|
||||||
|
_M_leak();
|
||||||
|
return _M_data()[__n];
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
/**
|
/**
|
||||||
* Returns a read/write reference to the data at the first
|
* Returns a read/write reference to the data at the first
|
||||||
@ -899,26 +919,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
{ return operator[](this->size() - 1); }
|
{ return operator[](this->size() - 1); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Provides access to the data contained in the %string.
|
|
||||||
* @param __n The index of the character to access.
|
|
||||||
* @return Read/write reference to the character.
|
|
||||||
* @throw std::out_of_range If @a n is an invalid index.
|
|
||||||
*
|
|
||||||
* This function provides for safer data access. The parameter is
|
|
||||||
* first checked that it is in the range of the string. The function
|
|
||||||
* throws out_of_range if the check fails. Success results in
|
|
||||||
* unsharing the string.
|
|
||||||
*/
|
|
||||||
reference
|
|
||||||
at(size_type __n)
|
|
||||||
{
|
|
||||||
if (__n >= size())
|
|
||||||
__throw_out_of_range(__N("basic_string::at"));
|
|
||||||
_M_leak();
|
|
||||||
return _M_data()[__n];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Modifiers:
|
// Modifiers:
|
||||||
/**
|
/**
|
||||||
* @brief Append a string to this string.
|
* @brief Append a string to this string.
|
||||||
@ -1394,6 +1394,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
iterator
|
iterator
|
||||||
erase(iterator __first, iterator __last);
|
erase(iterator __first, iterator __last);
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
/**
|
||||||
|
* @brief Remove the last character.
|
||||||
|
*
|
||||||
|
* The string must be non-empty.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pop_back()
|
||||||
|
{ erase(size()-1, 1); }
|
||||||
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Replace characters with value from another string.
|
* @brief Replace characters with value from another string.
|
||||||
* @param __pos Index of first character to replace.
|
* @param __pos Index of first character to replace.
|
||||||
|
@ -580,6 +580,16 @@ namespace __gnu_debug
|
|||||||
return iterator(__res, this);
|
return iterator(__res, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
void
|
||||||
|
pop_back()
|
||||||
|
{
|
||||||
|
__glibcxx_check_nonempty();
|
||||||
|
_Base::pop_back();
|
||||||
|
this->_M_invalidate_all();
|
||||||
|
}
|
||||||
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
|
||||||
basic_string&
|
basic_string&
|
||||||
replace(size_type __pos1, size_type __n1, const basic_string& __str)
|
replace(size_type __pos1, size_type __n1, const basic_string& __str)
|
||||||
{
|
{
|
||||||
|
@ -1140,6 +1140,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||||||
return iterator(this->_M_data() + __pos);
|
return iterator(this->_M_data() + __pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
/**
|
||||||
|
* @brief Remove the last character.
|
||||||
|
*
|
||||||
|
* The string must be non-empty.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
pop_back()
|
||||||
|
{ this->_M_erase(size()-1, 1); }
|
||||||
|
#endif // __GXX_EXPERIMENTAL_CXX0X__
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Replace characters with value from another string.
|
* @brief Replace characters with value from another string.
|
||||||
* @param __pos Index of first character to replace.
|
* @param __pos Index of first character to replace.
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2011 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
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 21.4.6.5 basic_string::pop_back
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2011 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
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 21.4.6.5 basic_string::pop_back
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
// { dg-do compile }
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
// Copyright (C) 2010, 2011 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 Pred 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
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 24.6.5, range access [iterator.range]
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void
|
||||||
|
test01()
|
||||||
|
{
|
||||||
|
std::string s("Hello, World!");
|
||||||
|
std::begin(s);
|
||||||
|
std::end(s);
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
// { dg-do compile }
|
// { dg-do compile }
|
||||||
// { dg-options "-std=gnu++0x" }
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
// Copyright (C) 2010 Free Software Foundation, Inc.
|
// Copyright (C) 2010. 2011 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
// software; you can redistribute it and/or modify it under the
|
// software; you can redistribute it and/or modify it under the
|
||||||
@ -25,10 +25,6 @@
|
|||||||
void
|
void
|
||||||
test01()
|
test01()
|
||||||
{
|
{
|
||||||
std::string s("Hello, World!");
|
|
||||||
std::begin(s);
|
|
||||||
std::end(s);
|
|
||||||
|
|
||||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||||
std::wstring ws(L"Hello, World!");
|
std::wstring ws(L"Hello, World!");
|
||||||
std::begin(ws);
|
std::begin(ws);
|
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2011 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
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 21.4.6.5 basic_string::pop_back
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
#include <ext/vstring.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
template<typename StrT>
|
||||||
|
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;
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (C) 2011 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
|
||||||
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
// 21.4.6.5 basic_string::pop_back
|
||||||
|
// { dg-options "-std=gnu++0x" }
|
||||||
|
|
||||||
|
#include <ext/vstring.h>
|
||||||
|
#include <testsuite_hooks.h>
|
||||||
|
|
||||||
|
template<typename StrT>
|
||||||
|
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;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user