diff options
author | Jason Merrill <jason@redhat.com> | 2008-07-21 15:40:39 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2008-07-21 15:40:39 -0400 |
commit | 988499f434108234543101579471a2fb25bf537f (patch) | |
tree | efdfd86136a070108ac69fda382332c5475473a6 /libstdc++-v3/include/ext | |
parent | 39a13be5cbfe0e9623782de3733cd8265e6230d4 (diff) | |
download | gcc-988499f434108234543101579471a2fb25bf537f.zip gcc-988499f434108234543101579471a2fb25bf537f.tar.gz gcc-988499f434108234543101579471a2fb25bf537f.tar.bz2 |
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.
...
From-SVN: r138043
Diffstat (limited to 'libstdc++-v3/include/ext')
-rw-r--r-- | libstdc++-v3/include/ext/rc_string_base.h | 5 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/sso_string_base.h | 4 | ||||
-rw-r--r-- | libstdc++-v3/include/ext/vstring.h | 84 |
3 files changed, 92 insertions, 1 deletions
diff --git a/libstdc++-v3/include/ext/rc_string_base.h b/libstdc++-v3/include/ext/rc_string_base.h index 0d3224c..82c614c 100644 --- a/libstdc++-v3/include/ext/rc_string_base.h +++ b/libstdc++-v3/include/ext/rc_string_base.h @@ -308,7 +308,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) #ifdef __GXX_EXPERIMENTAL_CXX0X__ __rc_string_base(__rc_string_base&& __rcs) : _M_dataplus(__rcs._M_get_allocator(), __rcs._M_data()) - { __rcs._M_data(_S_empty_rep._M_refcopy()); } + { __rcs._M_data(_S_empty_rep._M_refcopy()); } + + __rc_string_base(std::initializer_list<_CharT> __l, const _Alloc& __a) + : _M_dataplus(__a, _S_construct(__l.begin(), __l.end(), __a)) { } #endif __rc_string_base(size_type __n, _CharT __c, const _Alloc& __a); diff --git a/libstdc++-v3/include/ext/sso_string_base.h b/libstdc++-v3/include/ext/sso_string_base.h index 9c8c1bc..3335818 100644 --- a/libstdc++-v3/include/ext/sso_string_base.h +++ b/libstdc++-v3/include/ext/sso_string_base.h @@ -184,6 +184,10 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) #ifdef __GXX_EXPERIMENTAL_CXX0X__ __sso_string_base(__sso_string_base&& __rcs); + + __sso_string_base(std::initializer_list<_CharT> __l, const _Alloc& __a) + : _M_dataplus(__a, _M_local_data) + { _M_construct(__l.begin(), __l.end()); } #endif __sso_string_base(size_type __n, _CharT __c, const _Alloc& __a); diff --git a/libstdc++-v3/include/ext/vstring.h b/libstdc++-v3/include/ext/vstring.h index 0e74bfa..6002b19 100644 --- a/libstdc++-v3/include/ext/vstring.h +++ b/libstdc++-v3/include/ext/vstring.h @@ -36,6 +36,7 @@ #pragma GCC system_header +#include <initializer_list> #include <ext/vstring_util.h> #include <ext/rc_string_base.h> #include <ext/sso_string_base.h> @@ -156,6 +157,14 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) */ __versa_string(__versa_string&& __str) : __vstring_base(std::forward<__vstring_base>(__str)) { } + + /** + * @brief Construct string from an initializer list. + * @param l std::initializer_list of characters. + * @param a Allocator to use (default is default allocator). + */ + __versa_string(std::initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) + : __vstring_base(__l, __a) { } #endif /** @@ -257,6 +266,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) this->swap(__str); return *this; } + + /** + * @brief Set value to string constructed from initializer list. + * @param l std::initializer_list. + */ + __versa_string& + operator=(std::initializer_list<_CharT> __l) + { + this->assign (__l.begin(), __l.end()); + return *this; + } #endif /** @@ -623,6 +643,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) 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. + */ + __versa_string& + operator+=(std::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. @@ -690,6 +721,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) append(size_type __n, _CharT __c) { return _M_replace_aux(this->size(), size_type(0), __n, __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. + */ + __versa_string& + append(std::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. @@ -807,6 +849,17 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) 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. + */ + __versa_string& + assign(std::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. @@ -839,6 +892,18 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) 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, std::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. @@ -1295,6 +1360,25 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx) __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. + */ + __versa_string& replace(iterator __i1, iterator __i2, + std::initializer_list<_CharT> __l) + { return this->replace(__i1, __i2, __l.begin(), __l.end()); } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + private: template<class _Integer> __versa_string& |