diff options
| author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-21 19:40:39 +0000 |
|---|---|---|
| committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-07-21 19:40:39 +0000 |
| commit | b23fdac1bed6b8eedb8615526bfe75e16f70488a (patch) | |
| tree | efdfd86136a070108ac69fda382332c5475473a6 /libstdc++-v3/include/bits/basic_string.h | |
| parent | 08cc44e74d28ab49958b246b6d1f3ee827c21d24 (diff) | |
| download | ppe42-gcc-b23fdac1bed6b8eedb8615526bfe75e16f70488a.tar.gz ppe42-gcc-b23fdac1bed6b8eedb8615526bfe75e16f70488a.zip | |
Add initializer_list support as per N2679.
* include/debug/unordered_map: Add initializer_list support.
* include/debug/safe_association.h: Likewise.
* include/debug/unordered_set: Likewise.
* include/debug/vector: Likewise.
* include/debug/deque: Likewise.
* include/debug/map.h: Likewise.
* include/debug/set.h: Likewise.
* include/debug/string: Likewise.
* include/debug/list: Likewise.
* include/debug/multimap.h: Likewise.
* include/tr1_impl/unordered_map: Likewise.
* include/tr1_impl/hashtable: Likewise.
* include/tr1_impl/unordered_set: Likewise.
* include/tr1_impl/regex: Likewise.
* include/std/valarray: Likewise.
* include/std/unordered_map: Likewise.
* include/std/unordered_set: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_map.h: Likewise.
* include/bits/stl_set.h: Likewise.
* include/bits/basic_string.h: Likewise.
* include/bits/basic_string.tcc: Likewise.
* include/bits/stl_multimap.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_multiset.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
* include/ext/vstring.h: Likewise.
* include/ext/rc_string_base.h: Likewise.
* include/ext/sso_string_base.h: Likewise.
* src/Makefile.am (w?string-inst): Build with -std=gnu++0x.
* src/Makefile.in: Likewise.
* config/abi/pre/gnu.ver: Add new w?string exports.
...
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@138043 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/include/bits/basic_string.h')
| -rw-r--r-- | libstdc++-v3/include/bits/basic_string.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h index 19c79d11cf7..de4cf80234d 100644 --- a/libstdc++-v3/include/bits/basic_string.h +++ b/libstdc++-v3/include/bits/basic_string.h @@ -45,6 +45,7 @@ #include <ext/atomicity.h> #include <debug/debug.h> +#include <initializer_list> _GLIBCXX_BEGIN_NAMESPACE(std) @@ -477,6 +478,15 @@ _GLIBCXX_BEGIN_NAMESPACE(std) */ basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc()); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Construct string from an initializer list. + * @param l std::initializer_list of characters. + * @param a Allocator to use (default is default allocator). + */ + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()); +#endif // __GXX_EXPERIMENTAL_CXX0X__ + /** * @brief Construct string as copy of a range. * @param beg Start of range. @@ -523,6 +533,19 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Set value to string constructed from initializer list. + * @param l std::initializer_list. + */ + basic_string& + operator=(initializer_list<_CharT> __l) + { + this->assign (__l.begin(), __l.end()); + return *this; + } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + // Iterators: /** * Returns a read/write iterator that points to the first character in @@ -794,6 +817,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Append an initializer_list of characters. + * @param l The initializer_list of characters to be appended. + * @return Reference to this string. + */ + basic_string& + operator+=(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.end()); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + /** * @brief Append a string to this string. * @param str The string to append. @@ -849,6 +883,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) basic_string& append(size_type __n, _CharT __c); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Append an initializer_list of characters. + * @param l The initializer_list of characters to append. + * @return Reference to this string. + */ + basic_string& + append(initializer_list<_CharT> __l) + { return this->append(__l.begin(), __l.end()); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + /** * @brief Append a range of characters. * @param first Iterator referencing the first character to append. @@ -957,6 +1002,17 @@ _GLIBCXX_BEGIN_NAMESPACE(std) assign(_InputIterator __first, _InputIterator __last) { return this->replace(_M_ibegin(), _M_iend(), __first, __last); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Set value to an initializer_list of characters. + * @param l The initializer_list of characters to assign. + * @return Reference to this string. + */ + basic_string& + assign(initializer_list<_CharT> __l) + { return this->assign(__l.begin(), __l.end()); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + /** * @brief Insert multiple characters. * @param p Iterator referencing location in string to insert at. @@ -989,6 +1045,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std) insert(iterator __p, _InputIterator __beg, _InputIterator __end) { this->replace(__p, __p, __beg, __end); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Insert an initializer_list of characters. + * @param p Iterator referencing location in string to insert at. + * @param l The initializer_list of characters to insert. + * @throw std::length_error If new length exceeds @c max_size(). + */ + void + insert(iterator __p, initializer_list<_CharT> __l) + { this->insert(__p, __l.begin(), __l.end()); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + /** * @brief Insert value of a string. * @param pos1 Iterator referencing location in string to insert at. @@ -1434,6 +1502,25 @@ _GLIBCXX_BEGIN_NAMESPACE(std) __k1.base(), __k2 - __k1); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Replace range of characters with initializer_list. + * @param i1 Iterator referencing start of range to replace. + * @param i2 Iterator referencing end of range to replace. + * @param l The initializer_list of characters to insert. + * @return Reference to this string. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Removes the characters in the range [i1,i2). In place, characters + * in the range [k1,k2) are inserted. If the length of result exceeds + * max_size(), length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + basic_string& replace(iterator __i1, iterator __i2, + initializer_list<_CharT> __l) + { return this->replace(__i1, __i2, __l.begin(), __l.end()); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + private: template<class _Integer> basic_string& |

