basic_string.h (front, back): Add.

2010-05-31  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/bits/basic_string.h (front, back): Add.
	* include/debug/string: Adjust.
	* include/ext/vstring.h (front, back): Tweak the implementation
	to follow more closely the letter of the specs.
	* testsuite/21_strings/basic_string/element_access/char/
	front_back.cc: New.
	* testsuite/21_strings/basic_string/element_access/wchar_t/
	front_back.cc: Likewise.
	* config/abi/pre/gnu.ver: Export new symbols.
	* testsuite/util/testsuite_abi.cc: Adjust.
	* configure.ac: Bump minor version to 6:15:0.
	* configure: Regenerate.

From-SVN: r160071
This commit is contained in:
Paolo Carlini 2010-05-31 14:14:42 +00:00 committed by Paolo Carlini
parent 877a19bfb8
commit 1e2c0906ee
10 changed files with 182 additions and 15 deletions

View File

@ -1,3 +1,18 @@
2010-05-31 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/basic_string.h (front, back): Add.
* include/debug/string: Adjust.
* include/ext/vstring.h (front, back): Tweak the implementation
to follow more closely the letter of the specs.
* testsuite/21_strings/basic_string/element_access/char/
front_back.cc: New.
* testsuite/21_strings/basic_string/element_access/wchar_t/
front_back.cc: Likewise.
* config/abi/pre/gnu.ver: Export new symbols.
* testsuite/util/testsuite_abi.cc: Adjust.
* configure.ac: Bump minor version to 6:15:0.
* configure: Regenerate.
2010-05-28 Paolo Carlini <paolo.carlini@oracle.com> 2010-05-28 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_vector.h (vector<>::data): Fix return type * include/bits/stl_vector.h (vector<>::data): Fix return type

View File

@ -185,7 +185,10 @@ GLIBCXX_3.4 {
# where it is used for size_type on LLP64 platforms. # where it is used for size_type on LLP64 platforms.
_ZNSsC[12][EI][PRjmvyN]*; _ZNSsC[12][EI][PRjmvyN]*;
_ZNSsD*; _ZNSsD*;
_ZNSs[0-58-9][a-z]*; _ZNSs[0-58-9]a*;
_ZNSs5beginEv;
_ZNSs[0-58-9][c-e]*;
_ZNSs[0-58-9][g-z]*;
# _ZNSs[67][a-z]*E[PRcjmvy]*; # _ZNSs[67][a-z]*E[PRcjmvy]*;
_ZNSs6appendE[PRcjmvy]*; _ZNSs6appendE[PRcjmvy]*;
_ZNSs6assignE[PRcjmvy]*; _ZNSs6assignE[PRcjmvy]*;
@ -219,9 +222,12 @@ GLIBCXX_3.4 {
_ZNSsaSE[PRc]*; _ZNSsaSE[PRc]*;
_ZNSsixE*; _ZNSsixE*;
_ZNSspLE[PRc]*; _ZNSspLE[PRc]*;
_ZNKSs[0-9][a-b]*; _ZNKSs[0-3][a-b]*;
_ZNKSs[0-9][d-z]*; _ZNKSs[5-9][a-b]*;
_ZNKSs[0-9][d-e]*;
_ZNKSs[0-9][g-z]*;
_ZNKSs[0-9][0-9][a-z]*; _ZNKSs[0-9][0-9][a-z]*;
_ZNKSs4find*;
_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;
@ -240,7 +246,10 @@ GLIBCXX_3.4 {
# std::wstring # std::wstring
_ZNSbIwSt11char_traitsIwESaIwEEC[12][EI][PRjmvyN]*; _ZNSbIwSt11char_traitsIwESaIwEEC[12][EI][PRjmvyN]*;
_ZNSbIwSt11char_traitsIwESaIwEED*; _ZNSbIwSt11char_traitsIwESaIwEED*;
_ZNSbIwSt11char_traitsIwESaIwEE[0-58-9][a-z]*; _ZNSbIwSt11char_traitsIwESaIwEE[0-58-9]a*;
_ZNSbIwSt11char_traitsIwESaIwEE5beginEv;
_ZNSbIwSt11char_traitsIwESaIwEE[0-58-9][c-e]*;
_ZNSbIwSt11char_traitsIwESaIwEE[0-58-9][g-z]*;
# _ZNSbIwSt11char_traitsIwESaIwEE[67][a-b]*E[PRwjmvy]*; # _ZNSbIwSt11char_traitsIwESaIwEE[67][a-b]*E[PRwjmvy]*;
_ZNSbIwSt11char_traitsIwESaIwEE6appendE[PRwjmvy]*; _ZNSbIwSt11char_traitsIwESaIwEE6appendE[PRwjmvy]*;
_ZNSbIwSt11char_traitsIwESaIwEE6assignE[PRwjmvy]*; _ZNSbIwSt11char_traitsIwESaIwEE6assignE[PRwjmvy]*;
@ -274,10 +283,13 @@ GLIBCXX_3.4 {
_ZNSbIwSt11char_traitsIwESaIwEEaSE[PRw]*; _ZNSbIwSt11char_traitsIwESaIwEEaSE[PRw]*;
_ZNSbIwSt11char_traitsIwESaIwEEixE*; _ZNSbIwSt11char_traitsIwESaIwEEixE*;
_ZNSbIwSt11char_traitsIwESaIwEEpLE[PRw]*; _ZNSbIwSt11char_traitsIwESaIwEEpLE[PRw]*;
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][a-b]*; _ZNKSbIwSt11char_traitsIwESaIwEE[0-3][a-b]*;
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][d-z]*; _ZNKSbIwSt11char_traitsIwESaIwEE[5-9][a-b]*;
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][d-e]*;
_ZNKSbIwSt11char_traitsIwESaIwEE[0-9][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_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;
@ -1150,6 +1162,19 @@ GLIBCXX_3.4.14 {
} GLIBCXX_3.4.13; } GLIBCXX_3.4.13;
GLIBCXX_3.4.15 {
# string|wstring front and back member functions
_ZNSs5frontEv;
_ZNKSs5frontEv;
_ZNSbIwSt11char_traitsIwESaIwEE5frontEv;
_ZNKSbIwSt11char_traitsIwESaIwEE5frontEv;
_ZNSs4backEv;
_ZNKSs4backEv;
_ZNSbIwSt11char_traitsIwESaIwEE4backEv;
_ZNKSbIwSt11char_traitsIwESaIwEE4backEv;
} GLIBCXX_3.4.14;
# Symbols in the support library (libsupc++) have their own tag. # Symbols in the support library (libsupc++) have their own tag.
CXXABI_1.3 { CXXABI_1.3 {

View File

@ -2789,7 +2789,7 @@ ac_config_headers="$ac_config_headers config.h"
### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD ### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD
# For libtool versioning info, format is CURRENT:REVISION:AGE # For libtool versioning info, format is CURRENT:REVISION:AGE
libtool_VERSION=6:14:0 libtool_VERSION=6:15:0
# Find the rest of the source tree framework. # Find the rest of the source tree framework.

View File

@ -12,7 +12,7 @@ AC_CONFIG_HEADER(config.h)
### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD ### am handles this now? ORIGINAL_LD_FOR_MULTILIBS=$LD
# For libtool versioning info, format is CURRENT:REVISION:AGE # For libtool versioning info, format is CURRENT:REVISION:AGE
libtool_VERSION=6:14:0 libtool_VERSION=6:15:0
AC_SUBST(libtool_VERSION) AC_SUBST(libtool_VERSION)
# Find the rest of the source tree framework. # Find the rest of the source tree framework.

View File

@ -851,6 +851,40 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
return _M_data()[__n]; return _M_data()[__n];
} }
#ifdef __GXX_EXPERIMENTAL_CXX0X__
/**
* Returns a read/write reference to the data at the first
* element of the %string.
*/
reference
front()
{ return operator[](0); }
/**
* Returns a read-only (constant) reference to the data at the first
* element of the %string.
*/
const_reference
front() const
{ return operator[](0); }
/**
* Returns a read/write reference to the data at the last
* element of the %string.
*/
reference
back()
{ return operator[](this->size() - 1); }
/**
* Returns a read-only (constant) reference to the data at the
* last element of the %string.
*/
const_reference
back() const
{ return operator[](this->size() - 1); }
#endif
/** /**
* @brief Provides access to the data contained in the %string. * @brief Provides access to the data contained in the %string.
* @param n The index of the character to access. * @param n The index of the character to access.

View File

@ -262,6 +262,11 @@ namespace __gnu_debug
using _Base::at; using _Base::at;
#ifdef __GXX_EXPERIMENTAL_CXX0X__
using _Base::front;
using _Base::back;
#endif
// 21.3.5 modifiers: // 21.3.5 modifiers:
basic_string& basic_string&
operator+=(const basic_string& __str) operator+=(const basic_string& __str)

View File

@ -62,8 +62,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
typedef _Alloc allocator_type; typedef _Alloc allocator_type;
typedef typename _CharT_alloc_type::size_type size_type; typedef typename _CharT_alloc_type::size_type size_type;
typedef typename _CharT_alloc_type::difference_type difference_type; typedef typename _CharT_alloc_type::difference_type difference_type;
typedef typename _CharT_alloc_type::reference reference; typedef value_type& reference;
typedef typename _CharT_alloc_type::const_reference const_reference; typedef const value_type& const_reference;
typedef typename _CharT_alloc_type::pointer pointer; typedef typename _CharT_alloc_type::pointer pointer;
typedef typename _CharT_alloc_type::const_pointer const_pointer; typedef typename _CharT_alloc_type::const_pointer const_pointer;
typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator; typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator;
@ -598,7 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*/ */
reference reference
front() front()
{ return *begin(); } { return operator[](0); }
/** /**
* Returns a read-only (constant) reference to the data at the first * Returns a read-only (constant) reference to the data at the first
@ -606,7 +606,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*/ */
const_reference const_reference
front() const front() const
{ return *begin(); } { return operator[](0); }
/** /**
* Returns a read/write reference to the data at the last * Returns a read/write reference to the data at the last
@ -614,7 +614,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*/ */
reference reference
back() back()
{ return *(end() - 1); } { return operator[](this->size() - 1); }
/** /**
* Returns a read-only (constant) reference to the data at the * Returns a read-only (constant) reference to the data at the
@ -622,7 +622,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
*/ */
const_reference const_reference
back() const back() const
{ return *(end() - 1); } { return operator[](this->size() - 1); }
#endif #endif
// Modifiers: // Modifiers:

View File

@ -0,0 +1,43 @@
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// 2010-05-31 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 Free Software Foundation
//
// 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/>.
#include <string>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::string str("ramifications");
const std::string cstr("melodien");
VERIFY( str.front() == 'r' );
VERIFY( str.back() == 's' );
VERIFY( cstr.front() == 'm' );
VERIFY( cstr.back() == 'n' );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,43 @@
// { dg-options "-std=gnu++0x" }
// { dg-require-string-conversions "" }
// 2010-05-31 Paolo Carlini <paolo.carlini@oracle.com>
// Copyright (C) 2010 Free Software Foundation
//
// 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/>.
#include <string>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
std::wstring str(L"ramifications");
const std::wstring cstr(L"melodien");
VERIFY( str.front() == L'r' );
VERIFY( str.back() == L's' );
VERIFY( cstr.front() == L'm' );
VERIFY( cstr.back() == L'n' );
}
int main()
{
test01();
return 0;
}

View File

@ -1,6 +1,7 @@
// -*- C++ -*- // -*- C++ -*-
// Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. // Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010
// Free Software Foundation, Inc.
// This library is free software; you can redistribute it and/or // This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as // modify it under the terms of the GNU General Public License as
@ -186,6 +187,7 @@ check_version(symbol& test, bool added)
known_versions.push_back("GLIBCXX_3.4.12"); known_versions.push_back("GLIBCXX_3.4.12");
known_versions.push_back("GLIBCXX_3.4.13"); known_versions.push_back("GLIBCXX_3.4.13");
known_versions.push_back("GLIBCXX_3.4.14"); known_versions.push_back("GLIBCXX_3.4.14");
known_versions.push_back("GLIBCXX_3.4.15");
known_versions.push_back("GLIBCXX_LDBL_3.4"); known_versions.push_back("GLIBCXX_LDBL_3.4");
known_versions.push_back("GLIBCXX_LDBL_3.4.7"); known_versions.push_back("GLIBCXX_LDBL_3.4.7");
known_versions.push_back("GLIBCXX_LDBL_3.4.10"); known_versions.push_back("GLIBCXX_LDBL_3.4.10");