diff options
| author | Paolo Carlini <paolo.carlini@oracle.com> | 2010-05-31 14:14:42 +0000 |
|---|---|---|
| committer | Paolo Carlini <paolo@gcc.gnu.org> | 2010-05-31 14:14:42 +0000 |
| commit | 1e2c0906eeaf6050034a17d06c9d40c16a3f29cd (patch) | |
| tree | 7e03ee0ccbc4d0692ccc1eb272a0551cde8653f2 /libstdc++-v3/include | |
| parent | 877a19bfb8f34344702b206a549c61f7466fdf01 (diff) | |
| download | gcc-1e2c0906eeaf6050034a17d06c9d40c16a3f29cd.zip gcc-1e2c0906eeaf6050034a17d06c9d40c16a3f29cd.tar.gz gcc-1e2c0906eeaf6050034a17d06c9d40c16a3f29cd.tar.bz2 | |
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
Diffstat (limited to 'libstdc++-v3/include')
| -rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 34 | ||||
| -rw-r--r-- | libstdc++-v3/include/debug/string | 5 | ||||
| -rw-r--r-- | libstdc++-v3/include/ext/vstring.h | 12 |
3 files changed, 45 insertions, 6 deletions
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index d6d9989..fe9e1a3 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -851,6 +851,40 @@ _GLIBCXX_BEGIN_NAMESPACE(std) 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. * @param n The index of the character to access. diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index 160488e..fe31ffb 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -262,6 +262,11 @@ namespace __gnu_debug using _Base::at; +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + using _Base::front; + using _Base::back; +#endif + // 21.3.5 modifiers: basic_string& operator+=(const basic_string& __str) diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index fc469cb..dffd35a 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -62,8 +62,8 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) typedef _Alloc allocator_type; typedef typename _CharT_alloc_type::size_type size_type; typedef typename _CharT_alloc_type::difference_type difference_type; - typedef typename _CharT_alloc_type::reference reference; - typedef typename _CharT_alloc_type::const_reference const_reference; + typedef value_type& reference; + typedef const value_type& const_reference; typedef typename _CharT_alloc_type::pointer pointer; typedef typename _CharT_alloc_type::const_pointer const_pointer; typedef __gnu_cxx::__normal_iterator<pointer, __versa_string> iterator; @@ -598,7 +598,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) */ reference front() - { return *begin(); } + { return operator[](0); } /** * Returns a read-only (constant) reference to the data at the first @@ -606,7 +606,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) */ const_reference front() const - { return *begin(); } + { return operator[](0); } /** * Returns a read/write reference to the data at the last @@ -614,7 +614,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) */ reference back() - { return *(end() - 1); } + { return operator[](this->size() - 1); } /** * Returns a read-only (constant) reference to the data at the @@ -622,7 +622,7 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) */ const_reference back() const - { return *(end() - 1); } + { return operator[](this->size() - 1); } #endif // Modifiers: |
