diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 15:56:02 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-11-08 15:56:02 -0800 |
commit | e0268fa1035a718341c53921eee9318d4a8033cd (patch) | |
tree | 2b3eeb07928f9521498332002444dbfa44f34dfb /system/include/libcxx/map | |
parent | a11272805c16be75f5e6d00c8214afcac7ba9d05 (diff) | |
parent | ad1da1e6685d4483e096d7e0bbd8e38e686bd322 (diff) |
Merge pull request #1767 from waywardmonkeys/update-libcxx1.7.2
Update libcxx
Diffstat (limited to 'system/include/libcxx/map')
-rw-r--r-- | system/include/libcxx/map | 380 |
1 files changed, 280 insertions, 100 deletions
diff --git a/system/include/libcxx/map b/system/include/libcxx/map index 953743a6..009e8e21 100644 --- a/system/include/libcxx/map +++ b/system/include/libcxx/map @@ -77,7 +77,12 @@ public: map(map&& m, const allocator_type& a); map(initializer_list<value_type> il, const key_compare& comp = key_compare()); map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); - ~map(); + template <class InputIterator> + map(InputIterator first, InputIterator last, const allocator_type& a) + : map(first, last, Compare(), a) {} // C++14 + map(initializer_list<value_type> il, const allocator_type& a) + : map(il, Compare(), a) {} // C++14 + ~map(); map& operator=(const map& m); map& operator=(map&& m) @@ -149,13 +154,34 @@ public: // map operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template<typename K> + iterator find(const K& x); // C++14 + template<typename K> + const_iterator find(const K& x) const; // C++14 + template<typename K> + size_type count(const K& x) const; + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template<typename K> + iterator lower_bound(const K& x); // C++14 + template<typename K> + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template<typename K> + iterator upper_bound(const K& x); // C++14 + template<typename K> + const_iterator upper_bound(const K& x) const; // C++14 + pair<iterator,iterator> equal_range(const key_type& k); pair<const_iterator,const_iterator> equal_range(const key_type& k) const; + template<typename K> + pair<iterator,iterator> equal_range(const K& x); // C++14 + template<typename K> + pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; template <class Key, class T, class Compare, class Allocator> @@ -252,6 +278,11 @@ public: multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); + template <class InputIterator> + multimap(InputIterator first, InputIterator last, const allocator_type& a) + : multimap(first, last, Compare(), a) {} // C++14 + multimap(initializer_list<value_type> il, const allocator_type& a) + : multimap(il, Compare(), a) {} // C++14 ~multimap(); multimap& operator=(const multimap& m); @@ -317,13 +348,34 @@ public: // map operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template<typename K> + iterator find(const K& x); // C++14 + template<typename K> + const_iterator find(const K& x) const; // C++14 + template<typename K> + size_type count(const K& x) const; + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template<typename K> + iterator lower_bound(const K& x); // C++14 + template<typename K> + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template<typename K> + iterator upper_bound(const K& x); // C++14 + template<typename K> + const_iterator upper_bound(const K& x) const; // C++14 + pair<iterator,iterator> equal_range(const key_type& k); pair<const_iterator,const_iterator> equal_range(const key_type& k) const; + template<typename K> + pair<iterator,iterator> equal_range(const K& x); // C++14 + template<typename K> + pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; template <class Key, class T, class Compare, class Allocator> @@ -409,6 +461,20 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);} + +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () ( const _K2& __x, const _CP& __y ) const + {return static_cast<const _Compare&>(*this) (__x, __y.__cc.first);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () (const _CP& __x, const _K2& __y) const + {return static_cast<const _Compare&>(*this) (__x.__cc.first, __y);} +#endif }; template <class _Key, class _CP, class _Compare> @@ -437,6 +503,20 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return comp(__x, __y.__cc.first);} + +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () ( const _K2& __x, const _CP& __y ) const + {return comp (__x, __y.__cc.first);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () (const _CP& __x, const _K2& __y) const + {return comp (__x.__cc.first, __y);} +#endif }; template <class _Allocator> @@ -495,8 +575,77 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> class multimap; template <class _TreeIterator> class __map_const_iterator; +#if __cplusplus >= 201103L + +template <class _Key, class _Tp> +union __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + typedef pair<key_type, mapped_type> __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template <class ..._Args> + _LIBCPP_INLINE_VISIBILITY + __value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(const __value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(const __value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(__value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__value_type() {__cc.~value_type();} +}; + +#else + +template <class _Key, class _Tp> +struct __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __value_type() {} + + template <class _A0> + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0) + : __cc(__a0) {} + + template <class _A0, class _A1> + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template <class _TreeIterator> -class _LIBCPP_TYPE_VIS __map_iterator +class _LIBCPP_TYPE_VIS_ONLY __map_iterator { _TreeIterator __i_; @@ -555,13 +704,13 @@ public: bool operator!=(const __map_iterator& __x, const __map_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; - template <class> friend class _LIBCPP_TYPE_VIS __map_const_iterator; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; }; template <class _TreeIterator> -class _LIBCPP_TYPE_VIS __map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator { _TreeIterator __i_; @@ -624,14 +773,14 @@ public: bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; - template <class, class, class> friend class _LIBCPP_TYPE_VIS __tree_const_iterator; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; }; template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS map +class _LIBCPP_TYPE_VIS_ONLY map { public: // types: @@ -644,7 +793,7 @@ public: typedef value_type& reference; typedef const value_type& const_reference; - class _LIBCPP_TYPE_VIS value_compare + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function<value_type, value_type, bool> { friend class map; @@ -660,49 +809,7 @@ public: private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename map::value_type value_type; - typedef typename map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename map::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type<key_type, mapped_type> __value_type; typedef __map_value_compare<key_type, __value_type, key_compare> __vc; typedef typename allocator_traits<allocator_type>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -757,6 +864,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : map(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map(const map& __m) : __tree_(__m.__tree_) @@ -815,6 +929,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + map(initializer_list<value_type> __il, const allocator_type& __a) + : map(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map& operator=(initializer_list<value_type> __il) { @@ -961,6 +1081,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} @@ -970,18 +1101,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair<iterator,iterator> equal_range(const key_type& __k) {return __tree_.__equal_range_unique(__k);} _LIBCPP_INLINE_VISIBILITY pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} +#endif private: typedef typename __base::__node __node; @@ -1152,7 +1316,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1186,7 +1350,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Compare, class _Allocator> @@ -1346,7 +1510,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS multimap +class _LIBCPP_TYPE_VIS_ONLY multimap { public: // types: @@ -1359,7 +1523,7 @@ public: typedef value_type& reference; typedef const value_type& const_reference; - class _LIBCPP_TYPE_VIS value_compare + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function<value_type, value_type, bool> { friend class multimap; @@ -1375,49 +1539,8 @@ public: }; private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename multimap::value_type value_type; - typedef typename multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename multimap::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type<key_type, mapped_type> __value_type; typedef __map_value_compare<key_type, __value_type, key_compare> __vc; typedef typename allocator_traits<allocator_type>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -1472,6 +1595,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multimap(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap(const multimap& __m) : __tree_(__m.__tree_.value_comp(), @@ -1531,6 +1661,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multimap(initializer_list<value_type> __il, const allocator_type& __a) + : multimap(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap& operator=(initializer_list<value_type> __il) { @@ -1666,6 +1802,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} @@ -1675,18 +1822,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair<iterator,iterator> equal_range(const key_type& __k) {return __tree_.__equal_range_multi(__k);} _LIBCPP_INLINE_VISIBILITY pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} +#endif private: typedef typename __base::__node __node; |