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 | |
parent | 08cc44e74d28ab49958b246b6d1f3ee827c21d24 (diff) | |
download | gcc-b23fdac1bed6b8eedb8615526bfe75e16f70488a.tar.gz |
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')
62 files changed, 2189 insertions, 22 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 55ca3f676cd..7c9da490f45 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,79 @@ +2008-07-21 Jason Merrill <jason@redhat.com> + + 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. + * testsuite/21_strings/basic_string/init-list.cc: New test. + * testsuite/23_containers/vector/init-list.cc: New test. + * testsuite/23_containers/deque/init-list.cc: New test. + * testsuite/23_containers/list/init-list.cc: New test. + * testsuite/23_containers/map/init-list.cc: New test. + * testsuite/23_containers/multimap/init-list.cc: New test. + * testsuite/23_containers/set/init-list.cc: New test. + * testsuite/23_containers/multiset/init-list.cc: New test. + * testsuite/23_containers/unordered_map/init-list.cc: New test. + * testsuite/23_containers/unordered_multimap/init-list.cc: New test. + * testsuite/23_containers/unordered_set/init-list.cc: New test. + * testsuite/23_containers/unordered_multiset/init-list.cc: New test. + * testsuite/26_numerics/valarray/init-list.cc: New test. + * testsuite/28_regex/init-list.cc: New test. + * testsuite/ext/vstring/init-list.cc: New test. + * testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: + Update error lineno. + * testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: + Update error lineno. + * testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc: + Update error lineno. + * testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc: + Update error lineno. + * testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: + Update error lineno. + * testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: + Update error lineno. + * testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc: + Update error lineno. + * testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc: + Update error lineno. + * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: + Update error lineno. + * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: + Update error lineno. + * testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc: + Update error lineno. + * testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc: + Update error lineno. + 2008-07-21 Mark Mitchell <mark@codesourcery.com> * config/os/gnu-linux/arm-eabi-extra.ver: New file. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index ced293a0dd1..7b31a1cfa47 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -147,9 +147,12 @@ GLIBCXX_3.4 { # Names not in an 'extern' block are mangled names. # std::string - _ZNSsC*; + _ZNSsC[12][EI][PRjmvN]*; _ZNSsD*; - _ZNSs[0-9][a-z]*; + _ZNSs[0-58-9][a-z]*; + _ZNSs[67][a-z]*E[PRcjmv]*; + _ZNSs7[a-z]*EES2_[NPRjm]*; + _ZNSs7[a-z]*EES2_S[12]*; _ZNSs12_Alloc_hiderC*; _ZNSs12_M_leak_hardEv; _ZNSs12_S_constructE[jm]cRKSaIcE; @@ -172,9 +175,9 @@ GLIBCXX_3.4 { _ZNSs4_Rep20_S_empty_rep_storageE; _ZNSs4_Rep11_S_max_sizeE; _ZNSs4_Rep11_S_terminalE; - _ZNSsaSE*; + _ZNSsaSE[PRc]*; _ZNSsixE*; - _ZNSspLE*; + _ZNSspLE[PRc]*; _ZNKSs[0-9][a-z]*; _ZNKSs[0-9][0-9][a-z]*; _ZNKSs[a-z]*; @@ -189,9 +192,12 @@ GLIBCXX_3.4 { _ZStplIcSt11char_traitsIcESaIcEESbIT_T0_T1_E*; # std::wstring - _ZNSbIwSt11char_traitsIwESaIwEEC*; + _ZNSbIwSt11char_traitsIwESaIwEEC[12][EI][PRjmvN]*; _ZNSbIwSt11char_traitsIwESaIwEED*; - _ZNSbIwSt11char_traitsIwESaIwEE[0-9][a-z]*; + _ZNSbIwSt11char_traitsIwESaIwEE[0-58-9][a-z]*; + _ZNSbIwSt11char_traitsIwESaIwEE[67][a-z]*E[PRwjmv]*; + _ZNSbIwSt11char_traitsIwESaIwEE7[a-z]*EES6_[NPRjm]*; + _ZNSbIwSt11char_traitsIwESaIwEE7[a-z]*EES6_S[56]*; _ZNSbIwSt11char_traitsIwESaIwEE12_Alloc_hiderC*; _ZNSbIwSt11char_traitsIwESaIwEE12_M_leak_hardEv; _ZNSbIwSt11char_traitsIwESaIwEE12_S_constructE[jm]wRKS1_; @@ -214,9 +220,9 @@ GLIBCXX_3.4 { _ZNSbIwSt11char_traitsIwESaIwEE4_Rep20_S_empty_rep_storageE; _ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_max_sizeE; _ZNSbIwSt11char_traitsIwESaIwEE4_Rep11_S_terminalE; - _ZNSbIwSt11char_traitsIwESaIwEEaSE*; + _ZNSbIwSt11char_traitsIwESaIwEEaSE[PRw]*; _ZNSbIwSt11char_traitsIwESaIwEEixE*; - _ZNSbIwSt11char_traitsIwESaIwEEpLE*; + _ZNSbIwSt11char_traitsIwESaIwEEpLE[PRw]*; _ZNKSbIwSt11char_traitsIwESaIwEE[0-9][a-z]*; _ZNKSbIwSt11char_traitsIwESaIwEE[0-9][0-9][a-z]*; _ZNKSbIwSt11char_traitsIwESaIwEE[a-z]*; @@ -889,6 +895,24 @@ GLIBCXX_3.4.11 { _ZNSt6chrono12system_clock12is_monotonicE; _ZNSt6chrono12system_clock3nowEv; + # string/wstring initializer_list overloads + _ZNSs6appendESt16initializer_listIcE; + _ZNSs6assignESt16initializer_listIcE; + _ZNSs6insertEN9__gnu_cxx17__normal_iteratorIPcSsEESt16initializer_listIcE; + _ZNSs7replaceEN9__gnu_cxx17__normal_iteratorIPcSsEES2_St16initializer_listIcE; + _ZNSsC1ESt16initializer_listIcERKSaIcE; + _ZNSsC2ESt16initializer_listIcERKSaIcE; + _ZNSsaSESt16initializer_listIcE; + _ZNSspLESt16initializer_listIcE; + _ZNSbIwSt11char_traitsIwESaIwEE6appendESt16initializer_listIwE; + _ZNSbIwSt11char_traitsIwESaIwEE6assignESt16initializer_listIwE; + _ZNSbIwSt11char_traitsIwESaIwEE6insertEN9__gnu_cxx17__normal_iteratorIPwS2_EESt16initializer_listIwE; + _ZNSbIwSt11char_traitsIwESaIwEE7replaceEN9__gnu_cxx17__normal_iteratorIPwS2_EES6_St16initializer_listIwE; + _ZNSbIwSt11char_traitsIwESaIwEEC1ESt16initializer_listIwERKS1_; + _ZNSbIwSt11char_traitsIwESaIwEEC2ESt16initializer_listIwERKS1_; + _ZNSbIwSt11char_traitsIwESaIwEEaSESt16initializer_listIwE; + _ZNSbIwSt11char_traitsIwESaIwEEpLESt16initializer_listIwE; + } GLIBCXX_3.4.10; # Symbols in the support library (libsupc++) have their own tag. 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& diff --git a/libstdc++-v3/include/bits/basic_string.tcc b/libstdc++-v3/include/bits/basic_string.tcc index 49b649446d3..3201e361830 100644 --- a/libstdc++-v3/include/bits/basic_string.tcc +++ b/libstdc++-v3/include/bits/basic_string.tcc @@ -235,6 +235,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) : _M_dataplus(_S_construct(__beg, __end, __a), __a) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _CharT, typename _Traits, typename _Alloc> + basic_string<_CharT, _Traits, _Alloc>:: + basic_string(initializer_list<_CharT> __l, const _Alloc& __a) + : _M_dataplus(_S_construct(__l.begin(), __l.end(), __a), __a) + { } +#endif + template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc>& basic_string<_CharT, _Traits, _Alloc>:: diff --git a/libstdc++-v3/include/bits/stl_bvector.h b/libstdc++-v3/include/bits/stl_bvector.h index 045f20378a6..ad0ed87a115 100644 --- a/libstdc++-v3/include/bits/stl_bvector.h +++ b/libstdc++-v3/include/bits/stl_bvector.h @@ -62,6 +62,8 @@ #ifndef _STL_BVECTOR_H #define _STL_BVECTOR_H 1 +#include <initializer_list> + _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) typedef unsigned long _Bit_type; @@ -529,6 +531,14 @@ template<typename _Alloc> #ifdef __GXX_EXPERIMENTAL_CXX0X__ vector(vector&& __x) : _Base(std::forward<_Base>(__x)) { } + + vector(initializer_list<bool> __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_initialize_range(__l.begin(), __l.end(), + random_access_iterator_tag()); + } #endif template<typename _InputIterator> @@ -566,6 +576,13 @@ template<typename _Alloc> this->swap(__x); return *this; } + + vector& + operator=(initializer_list<bool> __l) + { + this->assign (__l.begin(), __l.end()); + return *this; + } #endif // assign(), a generalized assignment member function. Two @@ -584,6 +601,12 @@ template<typename _Alloc> _M_assign_dispatch(__first, __last, _Integral()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + assign(initializer_list<bool> __l) + { this->assign(__l.begin(), __l.end()); } +#endif + iterator begin() { return this->_M_impl._M_start; } @@ -777,6 +800,11 @@ template<typename _Alloc> insert(iterator __position, size_type __n, const bool& __x) { _M_fill_insert(__position, __n, __x); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void insert(iterator __p, initializer_list<bool> __l) + { this->insert(__p, __l.begin(), __l.end()); } +#endif + void pop_back() { --this->_M_impl._M_finish; } diff --git a/libstdc++-v3/include/bits/stl_deque.h b/libstdc++-v3/include/bits/stl_deque.h index b778f15a075..070fc078909 100644 --- a/libstdc++-v3/include/bits/stl_deque.h +++ b/libstdc++-v3/include/bits/stl_deque.h @@ -65,6 +65,7 @@ #include <bits/concept_check.h> #include <bits/stl_iterator_base_types.h> #include <bits/stl_iterator_base_funcs.h> +#include <initializer_list> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) @@ -740,6 +741,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ deque(deque&& __x) : _Base(std::forward<_Base>(__x)) { } + + /** + * @brief Builds a %deque from an initializer list. + * @param l An initializer_list. + * @param a An allocator object. + * + * Create a %deque consisting of copies of the elements in the + * initializer_list @a l. + * + * This will call the element type's copy constructor N times + * (where N is l.size()) and do no memory reallocation. + */ + deque(initializer_list<value_type> __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__l.begin(), __l.end(), + random_access_iterator_tag()); + } #endif /** @@ -801,6 +821,24 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief Assigns an initializer list to a %deque. + * @param l An initializer_list. + * + * This function fills a %deque with copies of the elements in the + * initializer_list @a l. + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. Old data may be lost. + */ + deque& + operator=(initializer_list<value_type> __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } #endif /** @@ -837,6 +875,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_assign_dispatch(__first, __last, _Integral()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Assigns an initializer list to a %deque. + * @param l An initializer_list. + * + * This function fills a %deque with copies of the elements in the + * initializer_list @a l. + * + * Note that the assignment completely changes the %deque and that the + * resulting %deque's size is the same as the number of elements + * assigned. Old data may be lost. + */ + void + assign(initializer_list<value_type> __l) + { this->assign(__l.begin(), __l.end()); } +#endif + /// Get a copy of the memory allocation object. allocator_type get_allocator() const @@ -1253,6 +1308,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) iterator insert(iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts an initializer list into the %deque. + * @param p An iterator into the %deque. + * @param l An initializer_list. + * + * This function will insert copies of the data in the + * initializer_list @a l into the %deque before the location + * specified by @a p. This is known as "list insert." + */ + void + insert(iterator __p, initializer_list<value_type> __l) + { this->insert(__p, __l.begin(), __l.end()); } #endif /** diff --git a/libstdc++-v3/include/bits/stl_list.h b/libstdc++-v3/include/bits/stl_list.h index 08fb89ef117..b38fa55cf79 100644 --- a/libstdc++-v3/include/bits/stl_list.h +++ b/libstdc++-v3/include/bits/stl_list.h @@ -63,6 +63,7 @@ #define _STL_LIST_H 1 #include <bits/concept_check.h> +#include <initializer_list> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) @@ -541,6 +542,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ list(list&& __x) : _Base(std::forward<_Base>(__x)) { } + + /** + * @brief Builds a %list from an initializer_list + * @param l An initializer_list of value_type. + * @param a An allocator object. + * + * Create a %list consisting of copies of the elements in the + * initializer_list @a l. This is linear in l.size(). + */ + list(initializer_list<value_type> __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); } #endif /** @@ -597,6 +611,20 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief %List initializer list assignment operator. + * @param l An initializer_list of value_type. + * + * Replace the contents of the %list with copies of the elements + * in the initializer_list @a l. This is linear in l.size(). + */ + list& + operator=(initializer_list<value_type> __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } #endif /** @@ -634,6 +662,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_assign_dispatch(__first, __last, _Integral()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Assigns an initializer_list to a %list. + * @param l An initializer_list of value_type. + * + * Replace the contents of the %list with copies of the elements + * in the initializer_list @a l. This is linear in l.size(). + */ + void + assign(initializer_list<value_type> __l) + { this->assign(__l.begin(), __l.end()); } +#endif + /// Get a copy of the memory allocation object. allocator_type get_allocator() const @@ -951,6 +992,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) iterator insert(iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts the contents of an initializer_list into %list + * before specified iterator. + * @param p An iterator into the %list. + * @param l An initializer_list of value_type. + * + * This function will insert copies of the data in the + * initializer_list @a l into the %list before the location + * specified by @a p. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + void + insert(iterator __p, initializer_list<value_type> __l) + { this->insert(__p, __l.begin(), __l.end()); } #endif /** diff --git a/libstdc++-v3/include/bits/stl_map.h b/libstdc++-v3/include/bits/stl_map.h index cd85b9ab75d..b402b8292c5 100644 --- a/libstdc++-v3/include/bits/stl_map.h +++ b/libstdc++-v3/include/bits/stl_map.h @@ -186,6 +186,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ map(map&& __x) : _M_t(std::forward<_Rep_type>(__x._M_t)) { } + + /** + * @brief Builds a %map from an initializer_list. + * @param l An initializer_list. + * @param comp A comparison object. + * @param a An allocator object. + * + * Create a %map consisting of copies of the elements in the + * initializer_list @a l. + * This is linear in N if the range is already sorted, and NlogN + * otherwise (where N is @a l.size()). + */ + map(initializer_list<value_type> __l, + const _Compare& __c = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__c, __a) + { _M_t._M_insert_unique(__l.begin(), __l.end()); } #endif /** @@ -259,6 +276,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief %Map list assignment operator. + * @param l An initializer_list. + * + * This function fills a %map with copies of the elements in the + * initializer list @a l. + * + * Note that the assignment completely changes the %map and + * that the resulting %map's size is the same as the number + * of elements assigned. Old data may be lost. + */ + map& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif /// Get a copy of the memory allocation object. @@ -476,7 +512,6 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) * inserted. * * Complexity similar to that of the range constructor. - * */ void insert(std::initializer_list<value_type> __list) diff --git a/libstdc++-v3/include/bits/stl_multimap.h b/libstdc++-v3/include/bits/stl_multimap.h index ade2750170f..0834c95cfd6 100644 --- a/libstdc++-v3/include/bits/stl_multimap.h +++ b/libstdc++-v3/include/bits/stl_multimap.h @@ -63,6 +63,7 @@ #define _STL_MULTIMAP_H 1 #include <bits/concept_check.h> +#include <initializer_list> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) @@ -183,6 +184,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ multimap(multimap&& __x) : _M_t(std::forward<_Rep_type>(__x._M_t)) { } + + /** + * @brief Builds a %multimap from an initializer_list. + * @param l An initializer_list. + * @param comp A comparison functor. + * @param a An allocator object. + * + * Create a %multimap consisting of copies of the elements from + * the initializer_list. This is linear in N if the list is already + * sorted, and NlogN otherwise (where N is @a __l.size()). + */ + multimap(initializer_list<value_type> __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) + { _M_t._M_insert_equal(__l.begin(), __l.end()); } #endif /** @@ -256,6 +273,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief %Multimap list assignment operator. + * @param l An initializer_list. + * + * This function fills a %multimap with copies of the elements + * in the initializer list @a l. + * + * Note that the assignment completely changes the %multimap and + * that the resulting %multimap's size is the same as the number + * of elements assigned. Old data may be lost. + */ + multimap& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif /// Get a copy of the memory allocation object. @@ -444,6 +480,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) insert(_InputIterator __first, _InputIterator __last) { _M_t._M_insert_equal(__first, __last); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Attempts to insert a list of std::pairs into the %multimap. + * @param list A std::initializer_list<value_type> of pairs to be + * inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list<value_type> __l) + { this->insert(__l.begin(), __l.end()); } +#endif + /** * @brief Erases an element from a %multimap. * @param position An iterator pointing to the element to be erased. diff --git a/libstdc++-v3/include/bits/stl_multiset.h b/libstdc++-v3/include/bits/stl_multiset.h index 2cdbdfe4cf3..2fea83f847c 100644 --- a/libstdc++-v3/include/bits/stl_multiset.h +++ b/libstdc++-v3/include/bits/stl_multiset.h @@ -63,6 +63,7 @@ #define _STL_MULTISET_H 1 #include <bits/concept_check.h> +#include <initializer_list> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) @@ -196,6 +197,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ multiset(multiset&& __x) : _M_t(std::forward<_Rep_type>(__x._M_t)) { } + + /** + * @brief Builds a %multiset from an initializer_list. + * @param l An initializer_list. + * @param comp A comparison functor. + * @param a An allocator object. + * + * Create a %multiset consisting of copies of the elements from + * the list. This is linear in N if the list is already sorted, + * and NlogN otherwise (where N is @a l.size()). + */ + multiset(initializer_list<value_type> __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) + { _M_t._M_insert_equal(__l.begin(), __l.end()); } #endif /** @@ -228,6 +245,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief %Multiset list assignment operator. + * @param l An initializer_list. + * + * This function fills a %multiset with copies of the elements in the + * initializer list @a l. + * + * Note that the assignment completely changes the %multiset and + * that the resulting %multiset's size is the same as the number + * of elements assigned. Old data may be lost. + */ + multiset& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif // accessors: @@ -406,6 +442,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) insert(_InputIterator __first, _InputIterator __last) { _M_t._M_insert_equal(__first, __last); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Attempts to insert a list of elements into the %multiset. + * @param list A std::initializer_list<value_type> of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list<value_type> __l) + { this->insert(__l.begin(), __l.end()); } +#endif + /** * @brief Erases an element from a %multiset. * @param position An iterator pointing to the element to be erased. diff --git a/libstdc++-v3/include/bits/stl_set.h b/libstdc++-v3/include/bits/stl_set.h index 2ef51de858f..98c74e9a27c 100644 --- a/libstdc++-v3/include/bits/stl_set.h +++ b/libstdc++-v3/include/bits/stl_set.h @@ -63,6 +63,7 @@ #define _STL_SET_H 1 #include <bits/concept_check.h> +#include <initializer_list> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) @@ -203,6 +204,22 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ set(set&& __x) : _M_t(std::forward<_Rep_type>(__x._M_t)) { } + + /** + * @brief Builds a %set from an initializer_list. + * @param l An initializer_list. + * @param comp A comparison functor. + * @param a An allocator object. + * + * Create a %set consisting of copies of the elements in the list. + * This is linear in N if the list is already sorted, and NlogN + * otherwise (where N is @a l.size()). + */ + set(initializer_list<value_type> __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _M_t(__comp, __a) + { _M_t._M_insert_unique(__l.begin(), __l.end()); } #endif /** @@ -235,6 +252,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief %Set list assignment operator. + * @param l An initializer_list. + * + * This function fills a %set with copies of the elements in the + * initializer list @a l. + * + * Note that the assignment completely changes the %set and + * that the resulting %set's size is the same as the number + * of elements assigned. Old data may be lost. + */ + set& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif // accessors: @@ -418,6 +454,19 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) insert(_InputIterator __first, _InputIterator __last) { _M_t._M_insert_unique(__first, __last); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Attempts to insert a list of elements into the %set. + * @param list A std::initializer_list<value_type> of elements + * to be inserted. + * + * Complexity similar to that of the range constructor. + */ + void + insert(initializer_list<value_type> __l) + { this->insert(__l.begin(), __l.end()); } +#endif + /** * @brief Erases an element from a %set. * @param position An iterator pointing to the element to be erased. diff --git a/libstdc++-v3/include/bits/stl_vector.h b/libstdc++-v3/include/bits/stl_vector.h index aa874089d52..9ccd9b8ca23 100644 --- a/libstdc++-v3/include/bits/stl_vector.h +++ b/libstdc++-v3/include/bits/stl_vector.h @@ -65,6 +65,7 @@ #include <bits/stl_iterator_base_funcs.h> #include <bits/functexcept.h> #include <bits/concept_check.h> +#include <initializer_list> _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) @@ -262,6 +263,25 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) */ vector(vector&& __x) : _Base(std::forward<_Base>(__x)) { } + + /** + * @brief Builds a %vector from an initializer list. + * @param l An initializer_list. + * @param a An allocator. + * + * Create a %vector consisting of copies of the elements in the + * initializer_list @a l. + * + * This will call the element type's copy constructor N times + * (where N is @a l.size()) and do no memory reallocation. + */ + vector(initializer_list<value_type> __l, + const allocator_type& __a = allocator_type()) + : _Base(__a) + { + _M_range_initialize(__l.begin(), __l.end(), + random_access_iterator_tag()); + } #endif /** @@ -327,6 +347,24 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) this->swap(__x); return *this; } + + /** + * @brief %Vector list assignment operator. + * @param l An initializer_list. + * + * This function fills a %vector with copies of the elements in the + * initializer list @a l. + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. Old data may be lost. + */ + vector& + operator=(initializer_list<value_type> __l) + { + this->assign(__l.begin(), __l.end()); + return *this; + } #endif /** @@ -364,6 +402,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) _M_assign_dispatch(__first, __last, _Integral()); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Assigns an initializer list to a %vector. + * @param l An initializer_list. + * + * This function fills a %vector with copies of the elements in the + * initializer list @a l. + * + * Note that the assignment completely changes the %vector and + * that the resulting %vector's size is the same as the number + * of elements assigned. Old data may be lost. + */ + void + assign(initializer_list<value_type> __l) + { this->assign(__l.begin(), __l.end()); } +#endif + /// Get a copy of the memory allocation object. using _Base::get_allocator; @@ -766,6 +821,23 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D) iterator insert(iterator __position, value_type&& __x) { return emplace(__position, std::move(__x)); } + + /** + * @brief Inserts an initializer_list into the %vector. + * @param position An iterator into the %vector. + * @param l An initializer_list. + * + * This function will insert copies of the data in the + * initializer_list @a l into the %vector before the location + * specified by @a position. + * + * Note that this kind of operation could be expensive for a + * %vector and if it is frequently used the user should + * consider using std::list. + */ + void + insert(iterator __position, initializer_list<value_type> __l) + { this->insert(__position, __l.begin(), __l.end()); } #endif /** diff --git a/libstdc++-v3/include/debug/deque b/libstdc++-v3/include/debug/deque index c37381f084f..845e0dcaaf2 100644 --- a/libstdc++-v3/include/debug/deque +++ b/libstdc++-v3/include/debug/deque @@ -94,6 +94,10 @@ namespace __debug deque(deque&& __x) : _Base(std::forward<deque>(__x)), _Safe_base() { this->_M_swap(__x); } + + deque(initializer_list<value_type> __l, + const allocator_type& __a = allocator_type()) + : _Base(__l, __a), _Safe_base() { } #endif ~deque() { } @@ -115,6 +119,14 @@ namespace __debug swap(__x); return *this; } + + deque& + operator=(initializer_list<value_type> __l) + { + *static_cast<_Base*>(this) = __l; + this->_M_invalidate_all(); + return *this; + } #endif template<class _InputIterator> @@ -133,6 +145,15 @@ namespace __debug this->_M_invalidate_all(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + assign(initializer_list<value_type> __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + } +#endif + using _Base::get_allocator; // iterators: @@ -318,6 +339,13 @@ namespace __debug iterator insert(iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } + + void + insert(iterator __p, initializer_list<value_type> __l) + { + _Base::insert(__p, __l); + this->_M_invalidate_all(); + } #endif void diff --git a/libstdc++-v3/include/debug/list b/libstdc++-v3/include/debug/list index 7ab0bddff99..312aeebef92 100644 --- a/libstdc++-v3/include/debug/list +++ b/libstdc++-v3/include/debug/list @@ -123,6 +123,10 @@ namespace __debug list(list&& __x) : _Base(std::forward<list>(__x)), _Safe_base() { this->_M_swap(__x); } + + list(initializer_list<value_type> __l, + const allocator_type& __a = allocator_type()) + : _Base(__l, __a), _Safe_base() { } #endif ~list() { } @@ -144,6 +148,21 @@ namespace __debug swap(__x); return *this; } + + list& + operator=(initializer_list<value_type> __l) + { + static_cast<_Base&>(*this) = __l; + this->_M_invalidate_all(); + return *this; + } + + void + assign(initializer_list<value_type> __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + } #endif template<class _InputIterator> @@ -331,6 +350,13 @@ namespace __debug iterator insert(iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } + + void + insert(iterator __p, initializer_list<value_type> __l) + { + __glibcxx_check_insert(__p); + _Base::insert(__p, __l); + } #endif void diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index 16575644da2..8232c742a63 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -98,6 +98,11 @@ namespace __debug map(map&& __x) : _Base(std::forward<map>(__x)), _Safe_base() { this->_M_swap(__x); } + + map(initializer_list<value_type> __l, + const _Compare& __c = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __c, __a), _Safe_base() { } #endif ~map() { } @@ -119,6 +124,14 @@ namespace __debug swap(__x); return *this; } + + map& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } #endif // _GLIBCXX_RESOLVE_LIB_DEFECTS @@ -198,6 +211,12 @@ namespace __debug __res.second); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + insert(std::initializer_list<value_type> __list) + { _Base::insert(__list); } +#endif + iterator insert(iterator __position, const value_type& __x) { diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index 72f4411685b..b7c5ee7181c 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -99,6 +99,11 @@ namespace __debug multimap(multimap&& __x) : _Base(std::forward<multimap>(__x)), _Safe_base() { this->_M_swap(__x); } + + multimap(initializer_list<value_type> __l, + const _Compare& __c = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __c, __a), _Safe_base() { } #endif ~multimap() { } @@ -120,6 +125,14 @@ namespace __debug swap(__x); return *this; } + + multimap& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } #endif using _Base::get_allocator; @@ -185,6 +198,12 @@ namespace __debug insert(const value_type& __x) { return iterator(_Base::insert(__x), this); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + insert(std::initializer_list<value_type> __list) + { _Base::insert(__list); } +#endif + iterator insert(iterator __position, const value_type& __x) { diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index ffe5b51548f..f108531638e 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -96,6 +96,11 @@ namespace __debug multiset(multiset&& __x) : _Base(std::forward<multiset>(__x)), _Safe_base() { this->_M_swap(__x); } + + multiset(initializer_list<value_type> __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __comp, __a), _Safe_base() { } #endif ~multiset() { } @@ -117,6 +122,14 @@ namespace __debug swap(__x); return *this; } + + multiset& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } #endif using _Base::get_allocator; @@ -197,6 +210,12 @@ namespace __debug _Base::insert(__first, __last); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + insert(initializer_list<value_type> __l) + { _Base::insert(__l); } +#endif + void erase(iterator __position) { diff --git a/libstdc++-v3/include/debug/safe_association.h b/libstdc++-v3/include/debug/safe_association.h index 42c050050b8..a413b01f872 100644 --- a/libstdc++-v3/include/debug/safe_association.h +++ b/libstdc++-v3/include/debug/safe_association.h @@ -105,6 +105,14 @@ namespace __gnu_debug __l, __n, __hf, __eql, __a) { } + _Safe_association(std::initializer_list<value_type> __l, + size_type __n, + const hasher& __hf, + const key_equal& __eql, + const allocator_type& __a = allocator_type()) + : _Base(__l, __n, __hf, __eql, __a) + { } + _Safe_association(const _Base& __x) : _Base(__x) { } _Safe_association(_Safe_association&& __x) @@ -152,6 +160,10 @@ namespace __gnu_debug _Base::insert(__first.base(), __last.base()); } + void + insert(std::initializer_list<value_type> __l) + { _Base::insert(__l); } + const_iterator find(const key_type& __key) const { return const_iterator(_Base::find(__key), this); } diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index 3115610d1e1..00711cd321d 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -96,6 +96,11 @@ namespace __debug set(set&& __x) : _Base(std::forward<set>(__x)), _Safe_base() { this->_M_swap(__x); } + + set(initializer_list<value_type> __l, + const _Compare& __comp = _Compare(), + const allocator_type& __a = allocator_type()) + : _Base(__l, __comp, __a), _Safe_base() { } #endif ~set() { } @@ -117,6 +122,14 @@ namespace __debug swap(__x); return *this; } + + set& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } #endif using _Base::get_allocator; @@ -202,6 +215,12 @@ namespace __debug _Base::insert(__first, __last); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + insert(initializer_list<value_type> __l) + { _Base::insert(__l); } +#endif + void erase(iterator __position) { diff --git a/libstdc++-v3/include/debug/string b/libstdc++-v3/include/debug/string index 070ca1fe58b..68882fed581 100644 --- a/libstdc++-v3/include/debug/string +++ b/libstdc++-v3/include/debug/string @@ -115,6 +115,12 @@ namespace __gnu_debug : _Base(__gnu_debug::__check_valid_range(__begin, __end), __end, __a) { } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc()) + : _Base(__l, __a) + { } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + ~basic_string() { } basic_string& @@ -142,6 +148,16 @@ namespace __gnu_debug return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + basic_string& + operator=(initializer_list<_CharT> __l) + { + *static_cast<_Base*>(this) = __l; + this->_M_invalidate_all(); + return *this; + } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + // 21.3.2 iterators: iterator begin() @@ -259,6 +275,16 @@ namespace __gnu_debug return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + basic_string& + operator+=(initializer_list<_CharT> __l) + { + _M_base() += __l; + this->_M_invalidate_all(); + return *this; + } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + basic_string& append(const basic_string& __str) { @@ -372,6 +398,16 @@ namespace __gnu_debug return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + basic_string& + assign(initializer_list<_CharT> __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + return *this; + } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + basic_string& insert(size_type __pos1, const basic_string& __str) { @@ -441,6 +477,15 @@ namespace __gnu_debug this->_M_invalidate_all(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + insert(iterator __p, initializer_list<_CharT> __l) + { + _Base::insert(__p, __l); + this->_M_invalidate_all(); + } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + basic_string& erase(size_type __pos = 0, size_type __n = _Base::npos) { @@ -564,6 +609,17 @@ namespace __gnu_debug return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + basic_string& replace(iterator __i1, iterator __i2, + initializer_list<_CharT> __l) + { + __glibcxx_check_erase_range(__i1, __i2); + _Base::replace(__i1.base(), __i2.base(), __l); + this->_M_invalidate_all(); + return *this; + } +#endif // __GXX_EXPERIMENTAL_CXX0X__ + size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const { diff --git a/libstdc++-v3/include/debug/unordered_map b/libstdc++-v3/include/debug/unordered_map index 590d4a3478f..79590f56755 100644 --- a/libstdc++-v3/include/debug/unordered_map +++ b/libstdc++-v3/include/debug/unordered_map @@ -40,6 +40,7 @@ #else # include <c++0x_warning.h> #endif +#include <initializer_list> #include <debug/safe_association.h> #include <debug/safe_iterator.h> @@ -64,6 +65,7 @@ namespace __debug public: typedef typename _Safe_assoc::size_type size_type; + typedef typename _Safe_assoc::value_type value_type; typedef typename _Safe_assoc::hasher hasher; typedef typename _Safe_assoc::key_equal key_equal; typedef typename _Safe_assoc::allocator_type allocator_type; @@ -91,6 +93,13 @@ namespace __debug unordered_map(unordered_map&& __x) : _Safe_assoc(std::forward<_Safe_assoc>(__x)), _Safe_base() { } + unordered_map(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Safe_assoc(__l, __n, __hf, __eql, __a) { } + unordered_map& operator=(unordered_map&& __x) { @@ -100,6 +109,14 @@ namespace __debug return *this; } + unordered_map& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } + void swap(unordered_map&& __x) { @@ -164,6 +181,7 @@ namespace __debug public: typedef typename _Safe_assoc::size_type size_type; + typedef typename _Safe_assoc::value_type value_type; typedef typename _Safe_assoc::hasher hasher; typedef typename _Safe_assoc::key_equal key_equal; typedef typename _Safe_assoc::allocator_type allocator_type; @@ -185,6 +203,13 @@ namespace __debug : _Safe_assoc(__f, __l, __n, __hf, __eql, __a) { } + unordered_multimap(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Safe_assoc(__l, __n, __hf, __eql, __a) { } + unordered_multimap(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } @@ -200,6 +225,14 @@ namespace __debug return *this; } + unordered_multimap& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } + void swap(unordered_multimap&& __x) { diff --git a/libstdc++-v3/include/debug/unordered_set b/libstdc++-v3/include/debug/unordered_set index b4b9be8a140..4c5d4d5ce34 100644 --- a/libstdc++-v3/include/debug/unordered_set +++ b/libstdc++-v3/include/debug/unordered_set @@ -41,6 +41,7 @@ # include <c++0x_warning.h> #endif +#include <initializer_list> #include <debug/safe_association.h> #include <debug/safe_iterator.h> @@ -65,6 +66,7 @@ namespace __debug public: typedef typename _Safe_assoc::size_type size_type; + typedef typename _Safe_assoc::value_type value_type; typedef typename _Safe_assoc::hasher hasher; typedef typename _Safe_assoc::key_equal key_equal; typedef typename _Safe_assoc::allocator_type allocator_type; @@ -86,6 +88,13 @@ namespace __debug : _Safe_assoc(__f, __l, __n, __hf, __eql, __a) { } + unordered_set(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Safe_assoc(__l, __n, __hf, __eql, __a) { } + unordered_set(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } @@ -101,6 +110,14 @@ namespace __debug return *this; } + unordered_set& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } + void swap(unordered_set&& __x) { @@ -162,6 +179,7 @@ namespace __debug public: typedef typename _Safe_assoc::size_type size_type; + typedef typename _Safe_assoc::value_type value_type; typedef typename _Safe_assoc::hasher hasher; typedef typename _Safe_assoc::key_equal key_equal; typedef typename _Safe_assoc::allocator_type allocator_type; @@ -183,6 +201,13 @@ namespace __debug : _Safe_assoc(__f, __l, __n, __hf, __eql, __a) { } + unordered_multiset(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Safe_assoc(__l, __n, __hf, __eql, __a) { } + unordered_multiset(const _Safe_assoc& __x) : _Safe_assoc(__x), _Safe_base() { } @@ -198,6 +223,14 @@ namespace __debug return *this; } + unordered_multiset& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l); + return *this; + } + void swap(unordered_multiset&& __x) { diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index f0c63a6ad76..a00419200d0 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -106,6 +106,11 @@ namespace __debug this->_M_swap(__x); __x._M_guaranteed_capacity = 0; } + + vector(initializer_list<value_type> __l, + const allocator_type& __a = allocator_type()) + : _Base(__l, __a), _Safe_base(), + _M_guaranteed_capacity(__l.size()) { } #endif ~vector() { } @@ -128,6 +133,15 @@ namespace __debug swap(__x); return *this; } + + vector& + operator=(initializer_list<value_type> __l) + { + static_cast<_Base&>(*this) = __l; + this->_M_invalidate_all(); + _M_update_guaranteed_capacity(); + return *this; + } #endif template<typename _InputIterator> @@ -148,6 +162,16 @@ namespace __debug _M_update_guaranteed_capacity(); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + void + assign(initializer_list<value_type> __l) + { + _Base::assign(__l); + this->_M_invalidate_all(); + _M_update_guaranteed_capacity(); + } +#endif + using _Base::get_allocator; // iterators: @@ -367,6 +391,10 @@ namespace __debug iterator>::__type insert(iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } + + void + insert(iterator __position, initializer_list<value_type> __l) + { this->insert(__position, __l.begin(), __l.end()); } #endif void diff --git a/libstdc++-v3/include/ext/rc_string_base.h b/libstdc++-v3/include/ext/rc_string_base.h index 0d3224cea10..82c614c431a 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 9c8c1bc79d6..33358189478 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 0e74bfa8cb2..6002b197d74 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& diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map index e338ef7805c..2b7d328f387 100644 --- a/libstdc++-v3/include/std/unordered_map +++ b/libstdc++-v3/include/std/unordered_map @@ -46,6 +46,7 @@ #include <utility> #include <type_traits> +#include <initializer_list> #include <bits/stl_algobase.h> #include <bits/allocator.h> #include <bits/stl_function.h> // equal_to, _Identity, _Select1st diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set index 13b412b1eb5..1cabae987cc 100644 --- a/libstdc++-v3/include/std/unordered_set +++ b/libstdc++-v3/include/std/unordered_set @@ -46,6 +46,7 @@ #include <utility> #include <type_traits> +#include <initializer_list> #include <bits/stl_algobase.h> #include <bits/allocator.h> #include <bits/stl_function.h> // equal_to, _Identity, _Select1st diff --git a/libstdc++-v3/include/std/valarray b/libstdc++-v3/include/std/valarray index 31799c04cce..b0fa5124805 100644 --- a/libstdc++-v3/include/std/valarray +++ b/libstdc++-v3/include/std/valarray @@ -45,6 +45,7 @@ #include <cmath> #include <algorithm> #include <debug/debug.h> +#include <initializer_list> _GLIBCXX_BEGIN_NAMESPACE(std) @@ -144,6 +145,11 @@ _GLIBCXX_BEGIN_NAMESPACE(std) /// Construct an array with the same size and values in @a ia. valarray(const indirect_array<_Tp>&); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /// Construct an array with an initializer_list of values. + valarray(initializer_list<_Tp>); +#endif + template<class _Dom> valarray(const _Expr<_Dom, _Tp>& __e); @@ -209,6 +215,18 @@ _GLIBCXX_BEGIN_NAMESPACE(std) */ valarray<_Tp>& operator=(const indirect_array<_Tp>&); +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + /** + * @brief Assign elements to an initializer_list. + * + * Assign elements of array to values in @a l. Results are undefined + * if @a l does not have the same size as this array. + * + * @param l initializer_list to get values from. + */ + valarray& operator=(initializer_list<_Tp>); +#endif + template<class _Dom> valarray<_Tp>& operator= (const _Expr<_Dom, _Tp>&); @@ -615,6 +633,14 @@ _GLIBCXX_BEGIN_NAMESPACE(std) (__ia._M_array, __ia._M_index, _Array<_Tp>(_M_data), _M_size); } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp> + inline + valarray<_Tp>::valarray(initializer_list<_Tp> __l) + : _M_size(__l.size()), _M_data(__valarray_get_storage<_Tp>(__l.size())) + { std::__valarray_copy_construct (__l.begin(), __l.end(), _M_data); } +#endif + template<typename _Tp> template<class _Dom> inline valarray<_Tp>::valarray(const _Expr<_Dom, _Tp>& __e) @@ -638,6 +664,16 @@ _GLIBCXX_BEGIN_NAMESPACE(std) return *this; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + template<typename _Tp> + inline valarray<_Tp>& + valarray<_Tp>::operator=(initializer_list<_Tp> __l) + { + _GLIBCXX_DEBUG_ASSERT(_M_size == __l.size()); + std::__valarray_copy(__l.begin(), __l.size(), _M_data); + } +#endif + template<typename _Tp> inline valarray<_Tp>& valarray<_Tp>::operator=(const _Tp& __t) diff --git a/libstdc++-v3/include/tr1_impl/hashtable b/libstdc++-v3/include/tr1_impl/hashtable index 55056ef3da8..33857a43ab3 100644 --- a/libstdc++-v3/include/tr1_impl/hashtable +++ b/libstdc++-v3/include/tr1_impl/hashtable @@ -434,6 +434,12 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 void insert(_InputIterator __first, _InputIterator __last); +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + void + insert(initializer_list<value_type> __l) + { this->insert(__l.begin(), __l.end()); } +#endif + iterator erase(iterator); diff --git a/libstdc++-v3/include/tr1_impl/regex b/libstdc++-v3/include/tr1_impl/regex index f99e0067850..d5e80b1b065 100644 --- a/libstdc++-v3/include/tr1_impl/regex +++ b/libstdc++-v3/include/tr1_impl/regex @@ -730,6 +730,13 @@ namespace regex_constants : _M_flags(__f), _M_pattern(__first, __last), _M_mark_count(0) { _M_compile(); } +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + basic_regex(initializer_list<_Ch_type> __l, + flag_type __f = regex_constants::ECMAScript) + : _M_flags(__f), _M_pattern(__l.begin(), __l.end()), _M_mark_count(0) + { _M_compile(); } +#endif + /** * @brief Destroys a basic regular expression. */ @@ -854,6 +861,13 @@ namespace regex_constants flag_type __flags = regex_constants::ECMAScript) { return this->assign(string_type(__first, __last), __flags); } +#ifdef _GLIBCXX_INCLUDE_AS_CXX0X + basic_regex& + assign(initializer_list<_Ch_type> __l, + flag_type __f = regex_constants::ECMAScript) + { return this->assign(__l.begin(), __l.end(), __f); } +#endif + // [7.8.4] const operations /** * @brief Gets the number of marked subexpressions within the regular diff --git a/libstdc++-v3/include/tr1_impl/unordered_map b/libstdc++-v3/include/tr1_impl/unordered_map index bb69479f277..4f914495ddb 100644 --- a/libstdc++-v3/include/tr1_impl/unordered_map +++ b/libstdc++-v3/include/tr1_impl/unordered_map @@ -179,6 +179,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 typedef __unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc> _Base; public: + typedef typename _Base::value_type value_type; typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; @@ -205,6 +206,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 unordered_map(unordered_map&& __x) : _Base(std::forward<_Base>(__x)) { } + unordered_map(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a) + { } + unordered_map& operator=(unordered_map&& __x) { @@ -213,6 +222,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 this->swap(__x); return *this; } + + unordered_map& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif }; @@ -227,6 +244,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 typedef __unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc> _Base; public: + typedef typename _Base::value_type value_type; typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; @@ -254,6 +272,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 unordered_multimap(unordered_multimap&& __x) : _Base(std::forward<_Base>(__x)) { } + unordered_multimap(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a) + { } + unordered_multimap& operator=(unordered_multimap&& __x) { @@ -262,6 +288,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 this->swap(__x); return *this; } + + unordered_multimap& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif }; diff --git a/libstdc++-v3/include/tr1_impl/unordered_set b/libstdc++-v3/include/tr1_impl/unordered_set index 80b1ec5f003..5640ebe1f77 100644 --- a/libstdc++-v3/include/tr1_impl/unordered_set +++ b/libstdc++-v3/include/tr1_impl/unordered_set @@ -175,6 +175,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 typedef __unordered_set<_Value, _Hash, _Pred, _Alloc> _Base; public: + typedef typename _Base::value_type value_type; typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; @@ -201,6 +202,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 unordered_set(unordered_set&& __x) : _Base(std::forward<_Base>(__x)) { } + unordered_set(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a) + { } + unordered_set& operator=(unordered_set&& __x) { @@ -209,6 +218,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 this->swap(__x); return *this; } + + unordered_set& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif }; @@ -223,6 +240,7 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc> _Base; public: + typedef typename _Base::value_type value_type; typedef typename _Base::size_type size_type; typedef typename _Base::hasher hasher; typedef typename _Base::key_equal key_equal; @@ -250,6 +268,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 unordered_multiset(unordered_multiset&& __x) : _Base(std::forward<_Base>(__x)) { } + unordered_multiset(initializer_list<value_type> __l, + size_type __n = 10, + const hasher& __hf = hasher(), + const key_equal& __eql = key_equal(), + const allocator_type& __a = allocator_type()) + : _Base(__l.begin(), __l.end(), __n, __hf, __eql, __a) + { } + unordered_multiset& operator=(unordered_multiset&& __x) { @@ -258,6 +284,14 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1 this->swap(__x); return *this; } + + unordered_multiset& + operator=(initializer_list<value_type> __l) + { + this->clear(); + this->insert(__l.begin(), __l.end()); + return *this; + } #endif }; diff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am index d41f3ebf290..6ea357f2ce9 100644 --- a/libstdc++-v3/src/Makefile.am +++ b/libstdc++-v3/src/Makefile.am @@ -273,6 +273,16 @@ atomic.lo: atomic.cc atomic.o: atomic.cc $(CXXCOMPILE) -x c++ -std=gnu++0x -c $< +string-inst.lo: string-inst.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +string-inst.o: string-inst.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +wstring-inst.lo: wstring-inst.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +wstring-inst.o: wstring-inst.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + chrono.lo: chrono.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< chrono.o: chrono.cc diff --git a/libstdc++-v3/src/Makefile.in b/libstdc++-v3/src/Makefile.in index 27c9b70c0be..b674061d3a8 100644 --- a/libstdc++-v3/src/Makefile.in +++ b/libstdc++-v3/src/Makefile.in @@ -867,6 +867,16 @@ atomic.lo: atomic.cc atomic.o: atomic.cc $(CXXCOMPILE) -x c++ -std=gnu++0x -c $< +string-inst.lo: string-inst.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +string-inst.o: string-inst.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + +wstring-inst.lo: wstring-inst.cc + $(LTCXXCOMPILE) -std=gnu++0x -c $< +wstring-inst.o: wstring-inst.cc + $(CXXCOMPILE) -std=gnu++0x -c $< + chrono.lo: chrono.cc $(LTCXXCOMPILE) -std=gnu++0x -c $< chrono.o: chrono.cc diff --git a/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc b/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc new file mode 100644 index 00000000000..71e03f1d626 --- /dev/null +++ b/libstdc++-v3/testsuite/21_strings/basic_string/init-list.cc @@ -0,0 +1,81 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <string> +#include <testsuite_hooks.h> + +using namespace std; + +int test01(void) +{ + bool test = true; + + string s1 = { 'a', 'b', 'c' }; + VERIFY(s1 == "abc"); + + s1 = { 'd', 'e', 'f' }; + VERIFY(s1 == "def"); + + s1 += { 'g', 'h', 'i' }; + VERIFY(s1 == "defghi"); + + s1.append({ 'j', 'k', 'l' }); + VERIFY(s1 == "defghijkl"); + + s1.assign({ 'm', 'n', 'o' }); + VERIFY(s1 == "mno"); + + // There aren't actually overloads of insert and replace taking size_type + // and initializer_list, but test the usage anyway. + s1.insert(2, { 'p', 'q', 'r' }); + VERIFY(s1 == "mnpqro"); + + s1.replace(2, 3, { 's', 't', 'u' }); + VERIFY(s1 == "mnstuo"); + + string::iterator i1, i2; + + i1 = s1.begin()+2; + s1.insert(i1, { 'v', 'w', 'x' }); + VERIFY(s1 == "mnvwxstuo"); + + i1 = s1.begin()+2; + i2 = i1+6; + s1.replace(i1, i2, { 'y', 'z' }); + VERIFY(s1 == "mnyzo"); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/init-list.cc b/libstdc++-v3/testsuite/23_containers/deque/init-list.cc new file mode 100644 index 00000000000..715ff948732 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/deque/init-list.cc @@ -0,0 +1,69 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <deque> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::deque<int, tracker_allocator<int> > Container; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + Container c({ 2, 4, 1 }); + ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; + ok &= (c[0] == 2); + ok &= (c[1] == 4); + } + ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin() + 7, { 234, 42, 1 }); + ok = check_construct_destroy("Insert init-list", 3, 0) && ok; + ok &= (c[7] == 234); + } + ok = check_construct_destroy("Insert init-list", 3, 13) && ok; + + { + Container c; + tracker_allocator_counter::reset(); + c = { 13, 0, 42 }; + ok = check_construct_destroy("Assign init-list", 3, 0) && ok; + ok &= (c[0] == 13); + } + ok = check_construct_destroy("Assign init-list", 3, 3) && ok; + + return ok ? 0 : 1;; +} diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc index 2cb464cb86c..242fc98a030 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1436 } +// { dg-error "no matching" "" { target *-*-* } 1504 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc index 57c865f34c0..2664aac468d 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1375 } +// { dg-error "no matching" "" { target *-*-* } 1443 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc index a46674c52dc..66b76b79a49 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1375 } +// { dg-error "no matching" "" { target *-*-* } 1443 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc index 3ae748ca316..cff5332deb5 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1520 } +// { dg-error "no matching" "" { target *-*-* } 1588 } // { dg-excess-errors "" } #include <deque> diff --git a/libstdc++-v3/testsuite/23_containers/list/init-list.cc b/libstdc++-v3/testsuite/23_containers/list/init-list.cc new file mode 100644 index 00000000000..0dd5ac919cd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/list/init-list.cc @@ -0,0 +1,74 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <list> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::list<int, tracker_allocator<int> > Container; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + Container c({ 2, 4, 1 }); + ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; + Container::iterator i = c.begin(); + ok &= (*i++ == 2); + ok &= (*i++ == 4); + } + ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + Container::iterator i = c.begin(); + ++i; ++i; ++i; ++i; ++i; ++i; ++i; + c.insert(i, { 234, 42, 1 }); + ok = check_construct_destroy("Insert init-list", 3, 0) && ok; + ok &= (*--i == 1); + ok &= (*--i == 42); + } + ok = check_construct_destroy("Insert init-list", 3, 13) && ok; + + { + Container c; + tracker_allocator_counter::reset(); + c = { 13, 0, 42 }; + ok = check_construct_destroy("Assign init-list", 3, 0) && ok; + Container::iterator i = c.begin(); + ok &= (*i++ == 13); + } + ok = check_construct_destroy("Assign init-list", 3, 3) && ok; + + return ok ? 0 : 1;; +} diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc index 8eeff630927..23c541a8d29 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1325 } +// { dg-error "no matching" "" { target *-*-* } 1383 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc index 06b71622421..479c416590f 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1294 } +// { dg-error "no matching" "" { target *-*-* } 1352 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc index bfe871077d7..3fd79856a5e 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1294 } +// { dg-error "no matching" "" { target *-*-* } 1352 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc index d75ed067e24..9b5e13a6e25 100644 --- a/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/list/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1294 } +// { dg-error "no matching" "" { target *-*-* } 1352 } // { dg-excess-errors "" } #include <list> diff --git a/libstdc++-v3/testsuite/23_containers/map/init-list.cc b/libstdc++-v3/testsuite/23_containers/map/init-list.cc new file mode 100644 index 00000000000..637303e1ac9 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/map/init-list.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + map<int,double> m({ { 1, 1.0 }, { 2, 2.0 }, { 42, 237.0 } }); + VERIFY(m.size() == 3); + VERIFY(m[1] == 1.0); + VERIFY(m[2] == 2.0); + VERIFY(m[42] == 237.0); + + m = { {5, 55.0}, { 6, 66.0 } }; + VERIFY(m.size() == 2); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + + m.insert({ { 7, 77.0 }, { 8, 88.0 } }); + VERIFY(m.size() == 4); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + VERIFY(m[7] == 77.0); + VERIFY(m[8] == 88.0); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc b/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc new file mode 100644 index 00000000000..6043cc17905 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multimap/init-list.cc @@ -0,0 +1,72 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + typedef multimap<int,double> Container; + typedef Container::iterator iterator; + typedef pair<iterator,iterator> itpair; + Container m({ { 1, 1.0 }, { 1, 2.0 }, { 1, 237.0 } }); + VERIFY(m.size() == 3); + itpair ip = m.equal_range(1); + VERIFY(distance(ip.first, ip.second) == 3); + iterator i = ip.first; + VERIFY((*i++).second == 1.0); + VERIFY((*i++).second == 2.0); + VERIFY((*i++).second == 237.0); + + m = { {5, 55.0}, { 5, 66.0 }, { 42, 4242.0 } }; + VERIFY(m.size() == 3); + ip = m.equal_range(5); + VERIFY(distance(ip.first, ip.second) == 2); + i = ip.first; + VERIFY((*i++).second == 55.0); + VERIFY((*i++).second == 66.0); + + m.insert({ { 7, 77.0 }, { 7, 88.0 } }); + VERIFY(m.size() == 5); + VERIFY(m.count(5) == 2); + VERIFY(m.count(42) == 1); + VERIFY(m.count(7) == 2); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/multiset/init-list.cc b/libstdc++-v3/testsuite/23_containers/multiset/init-list.cc new file mode 100644 index 00000000000..9b34f227286 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/multiset/init-list.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + multiset<int> m({ 1, 5, 5, 37 }); + VERIFY(m.size() == 4); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 2); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 37, 37, 102 }; + VERIFY(m.size() == 5); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42, 42 }); + VERIFY(m.size() == 7); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 2); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/set/init-list.cc b/libstdc++-v3/testsuite/23_containers/set/init-list.cc new file mode 100644 index 00000000000..256ecb38aba --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/set/init-list.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + set<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42 }); + VERIFY(m.size() == 4); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 1); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/init-list.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/init-list.cc new file mode 100644 index 00000000000..983bf2da3b7 --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/init-list.cc @@ -0,0 +1,63 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <unordered_map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_map<int,double> m({ { 1, 1.0 }, { 2, 2.0 }, { 42, 237.0 } }); + VERIFY(m.size() == 3); + VERIFY(m[1] == 1.0); + VERIFY(m[2] == 2.0); + VERIFY(m[42] == 237.0); + + m = { {5, 55.0}, { 6, 66.0 } }; + VERIFY(m.size() == 2); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + + m.insert({ { 7, 77.0 }, { 8, 88.0 } }); + VERIFY(m.size() == 4); + VERIFY(m[5] == 55.0); + VERIFY(m[6] == 66.0); + VERIFY(m[7] == 77.0); + VERIFY(m[8] == 88.0); + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multimap/init-list.cc b/libstdc++-v3/testsuite/23_containers/unordered_multimap/init-list.cc new file mode 100644 index 00000000000..ba35b38d85b --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multimap/init-list.cc @@ -0,0 +1,77 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } +// XFAIL this test until debug mode container is fixed. +// { dg-excess-errors "" } + +#include <set> +#include <unordered_map> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + typedef unordered_multimap<int,double> Container; + typedef Container::const_iterator iterator; + typedef pair<iterator,iterator> itpair; + + Container m({ { 1, 1.0 }, { 1, 2.0 }, { 1, 237.0 } }); + VERIFY(m.size() == 3); + itpair ip = m.equal_range(1); + VERIFY(distance(ip.first, ip.second) == 3); + set<double> s = { 1.0, 2.0, 237.0 }; + for (iterator i = ip.first; i != ip.second; ++i) + s.erase (i->second); + VERIFY(s.empty()); + + m = { {5, 55.0}, { 5, 66.0 }, { 42, 4242.0 } }; + VERIFY(m.size() == 3); + ip = m.equal_range(5); + VERIFY(distance(ip.first, ip.second) == 2); + s = { 55.0, 66.0 }; + for (iterator i = ip.first; i != ip.second; ++i) + s.erase (i->second); + VERIFY(s.empty()); + + m.insert({ { 7, 77.0 }, { 7, 88.0 } }); + VERIFY(m.size() == 5); + VERIFY(m.count(5) == 2); + VERIFY(m.count(42) == 1); + VERIFY(m.count(7) == 2); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_multiset/init-list.cc b/libstdc++-v3/testsuite/23_containers/unordered_multiset/init-list.cc new file mode 100644 index 00000000000..22d9a49b59f --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_multiset/init-list.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_multiset<int> m({ 1, 5, 5, 37 }); + VERIFY(m.size() == 4); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 2); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 37, 37, 102 }; + VERIFY(m.size() == 5); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42, 42 }); + VERIFY(m.size() == 7); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 3); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 2); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc new file mode 100644 index 00000000000..8a4b05deebd --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/init-list.cc @@ -0,0 +1,68 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <unordered_set> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + unordered_set<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m.count(1) == 1); + VERIFY(m.count(5) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(42) == 0); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(1) == 0); + + m.insert({ 42 }); + VERIFY(m.size() == 4); + VERIFY(m.count(28) == 1); + VERIFY(m.count(37) == 1); + VERIFY(m.count(102) == 1); + VERIFY(m.count(42) == 1); + VERIFY(m.count(1) == 0); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/init-list.cc b/libstdc++-v3/testsuite/23_containers/vector/init-list.cc new file mode 100644 index 00000000000..9a3b52c27da --- /dev/null +++ b/libstdc++-v3/testsuite/23_containers/vector/init-list.cc @@ -0,0 +1,69 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <vector> +#include <testsuite_allocator.h> + +using namespace __gnu_test; + +int main() +{ + typedef std::vector<int, tracker_allocator<int> > Container; + const int arr10[10] = { 2, 4, 1, 7, 3, 8, 10, 5, 9, 6 }; + bool ok = true; + + tracker_allocator_counter::reset(); + { + Container c({ 2, 4, 1 }); + ok = check_construct_destroy("Construct from init-list", 3, 0) && ok; + ok &= (c[0] == 2); + ok &= (c[1] == 4); + } + ok = check_construct_destroy("Construct from init-list", 3, 3) && ok; + + { + Container c(arr10, arr10 + 10); + tracker_allocator_counter::reset(); + c.insert(c.begin() + 7, { 234, 42, 1 }); + ok = check_construct_destroy("Insert init-list", 13, 10) && ok; + ok &= (c[7] == 234); + } + ok = check_construct_destroy("Insert init-list", 13, 23) && ok; + + { + Container c; + tracker_allocator_counter::reset(); + c = { 13, 0, 42 }; + ok = check_construct_destroy("Assign init-list", 3, 0) && ok; + ok &= (c[0] == 13); + } + ok = check_construct_destroy("Assign init-list", 3, 3) && ok; + + return ok ? 0 : 1;; +} diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc index 64c6a98dfb5..c5e445fa6db 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/assign_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 986 } +// { dg-error "no matching" "" { target *-*-* } 1058 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc index 34e602da583..dd115afd520 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_1_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 926 } +// { dg-error "no matching" "" { target *-*-* } 998 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc index f1af46c43a2..50e51cb8f3f 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/constructor_2_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 926 } +// { dg-error "no matching" "" { target *-*-* } 998 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc index a95f57857d8..31642d75c5d 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/requirements/dr438/insert_neg.cc @@ -19,7 +19,7 @@ // USA. // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1027 } +// { dg-error "no matching" "" { target *-*-* } 1099 } // { dg-excess-errors "" } #include <vector> diff --git a/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc b/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc new file mode 100644 index 00000000000..3f4ed5bab3a --- /dev/null +++ b/libstdc++-v3/testsuite/26_numerics/valarray/init-list.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <valarray> +#include <testsuite_hooks.h> + +using namespace std; + +int test01() +{ + bool test __attribute__((unused)) = true; + + valarray<int> m({ 1, 5, 37 }); + VERIFY(m.size() == 3); + VERIFY(m[0] == 1); + VERIFY(m[1] == 5); + VERIFY(m[2] == 37); + + m = { 28, 37, 102 }; + VERIFY(m.size() == 3); + VERIFY(m[0] == 28); + VERIFY(m[1] == 37); + VERIFY(m[2] == 102); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); +} diff --git a/libstdc++-v3/testsuite/28_regex/init-list.cc b/libstdc++-v3/testsuite/28_regex/init-list.cc new file mode 100644 index 00000000000..6852507ee0e --- /dev/null +++ b/libstdc++-v3/testsuite/28_regex/init-list.cc @@ -0,0 +1,58 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <regex> +#include <testsuite_hooks.h> + +using namespace std; + +int test01(void) +{ + bool test = true; + + regex r = { 'a', 'b', 'c' }; + cmatch res; + // Enable when regex class actually implemented. + // VERIFY(regex_match ("abc", res, r)); + VERIFY(!regex_match ("ab", res, r)); + + r = { 'd', 'e', 'f' }; + // Enable when regex class actually implemented. + // VERIFY(regex_match ("def", res, r)); + VERIFY(!regex_match ("abc", res, r)); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/ext/vstring/init-list.cc b/libstdc++-v3/testsuite/ext/vstring/init-list.cc new file mode 100644 index 00000000000..27da6828193 --- /dev/null +++ b/libstdc++-v3/testsuite/ext/vstring/init-list.cc @@ -0,0 +1,79 @@ +// Copyright (C) 2008 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. +// +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// { dg-options "-std=gnu++0x" } + +#include <ext/vstring.h> +#include <testsuite_hooks.h> + +int test01(void) +{ + bool test = true; + + __gnu_cxx::__vstring s1 = { 'a', 'b', 'c' }; + VERIFY(s1 == "abc"); + + s1 = { 'd', 'e', 'f' }; + VERIFY(s1 == "def"); + + s1 += { 'g', 'h', 'i' }; + VERIFY(s1 == "defghi"); + + s1.append({ 'j', 'k', 'l' }); + VERIFY(s1 == "defghijkl"); + + s1.assign({ 'm', 'n', 'o' }); + VERIFY(s1 == "mno"); + + // There aren't actually overloads of insert and replace taking size_type + // and initializer_list, but test the usage anyway. + s1.insert(2, { 'p', 'q', 'r' }); + VERIFY(s1 == "mnpqro"); + + s1.replace(2, 3, { 's', 't', 'u' }); + VERIFY(s1 == "mnstuo"); + + __gnu_cxx::__vstring::iterator i1, i2; + + i1 = s1.begin()+2; + s1.insert(i1, { 'v', 'w', 'x' }); + VERIFY(s1 == "mnvwxstuo"); + + i1 = s1.begin()+2; + i2 = i1+6; + s1.replace(i1, i2, { 'y', 'z' }); + VERIFY(s1 == "mnyzo"); + + return test; +} + +int main() +{ + __gnu_test::set_memory_limits(); + test01(); + return 0; +} |