<div dir="ltr">Sorry if I missed it, but what about std::set? </div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 3, 2015 at 12:10 PM, Eric Fiselier <span dir="ltr"><<a href="mailto:eric@efcs.ca" target="_blank">eric@efcs.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ericwf<br>
Date: Tue Mar 3 14:10:01 2015<br>
New Revision: 231119<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=231119&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=231119&view=rev</a><br>
Log:<br>
Allow declaration of map and multimap iterator with incomplete mapped type. Patch from eugenis<br>
<br>
Added:<br>
libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp<br>
Modified:<br>
libcxx/trunk/include/__tree<br>
libcxx/trunk/include/map<br>
libcxx/trunk/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp<br>
<br>
Modified: libcxx/trunk/include/__tree<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=231119&r1=231118&r2=231119&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__tree?rev=231119&r1=231118&r2=231119&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/__tree (original)<br>
+++ libcxx/trunk/include/__tree Tue Mar 3 14:10:01 2015<br>
@@ -614,8 +614,6 @@ class _LIBCPP_TYPE_VIS_ONLY __tree_itera<br>
{<br>
typedef _NodePtr __node_pointer;<br>
typedef typename pointer_traits<__node_pointer>::element_type __node;<br>
- typedef typename __node::base __node_base;<br>
- typedef typename __node_base::pointer __node_base_pointer;<br>
<br>
__node_pointer __ptr_;<br>
<br>
@@ -644,17 +642,21 @@ public:<br>
{return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}<br>
<br>
_LIBCPP_INLINE_VISIBILITY<br>
- __tree_iterator& operator++()<br>
- {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_)));<br>
- return *this;}<br>
+ __tree_iterator& operator++() {<br>
+ __ptr_ = static_cast<__node_pointer>(<br>
+ __tree_next(static_cast<typename __node::base::pointer>(__ptr_)));<br>
+ return *this;<br>
+ }<br>
_LIBCPP_INLINE_VISIBILITY<br>
__tree_iterator operator++(int)<br>
{__tree_iterator __t(*this); ++(*this); return __t;}<br>
<br>
_LIBCPP_INLINE_VISIBILITY<br>
- __tree_iterator& operator--()<br>
- {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_)));<br>
- return *this;}<br>
+ __tree_iterator& operator--() {<br>
+ __ptr_ = static_cast<__node_pointer>(<br>
+ __tree_prev(static_cast<typename __node::base::pointer>(__ptr_)));<br>
+ return *this;<br>
+ }<br>
_LIBCPP_INLINE_VISIBILITY<br>
__tree_iterator operator--(int)<br>
{__tree_iterator __t(*this); --(*this); return __t;}<br>
@@ -683,14 +685,6 @@ class _LIBCPP_TYPE_VIS_ONLY __tree_const<br>
{<br>
typedef _ConstNodePtr __node_pointer;<br>
typedef typename pointer_traits<__node_pointer>::element_type __node;<br>
- typedef typename __node::base __node_base;<br>
- typedef typename pointer_traits<__node_pointer>::template<br>
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES<br>
- rebind<__node_base><br>
-#else<br>
- rebind<__node_base>::other<br>
-#endif<br>
- __node_base_pointer;<br>
<br>
__node_pointer __ptr_;<br>
<br>
@@ -735,17 +729,39 @@ public:<br>
{return pointer_traits<pointer>::pointer_to(__ptr_->__value_);}<br>
<br>
_LIBCPP_INLINE_VISIBILITY<br>
- __tree_const_iterator& operator++()<br>
- {__ptr_ = static_cast<__node_pointer>(__tree_next(static_cast<__node_base_pointer>(__ptr_)));<br>
- return *this;}<br>
+ __tree_const_iterator& operator++() {<br>
+ typedef typename pointer_traits<__node_pointer>::template<br>
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES<br>
+ rebind<typename __node::base><br>
+#else<br>
+ rebind<typename __node::base>::other<br>
+#endif<br>
+ __node_base_pointer;<br>
+<br>
+ __ptr_ = static_cast<__node_pointer>(<br>
+ __tree_next(static_cast<__node_base_pointer>(__ptr_)));<br>
+ return *this;<br>
+ }<br>
+<br>
_LIBCPP_INLINE_VISIBILITY<br>
__tree_const_iterator operator++(int)<br>
{__tree_const_iterator __t(*this); ++(*this); return __t;}<br>
<br>
_LIBCPP_INLINE_VISIBILITY<br>
- __tree_const_iterator& operator--()<br>
- {__ptr_ = static_cast<__node_pointer>(__tree_prev(static_cast<__node_base_pointer>(__ptr_)));<br>
- return *this;}<br>
+ __tree_const_iterator& operator--() {<br>
+ typedef typename pointer_traits<__node_pointer>::template<br>
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES<br>
+ rebind<typename __node::base><br>
+#else<br>
+ rebind<typename __node::base>::other<br>
+#endif<br>
+ __node_base_pointer;<br>
+<br>
+ __ptr_ = static_cast<__node_pointer>(<br>
+ __tree_prev(static_cast<__node_base_pointer>(__ptr_)));<br>
+ return *this;<br>
+ }<br>
+<br>
_LIBCPP_INLINE_VISIBILITY<br>
__tree_const_iterator operator--(int)<br>
{__tree_const_iterator __t(*this); --(*this); return __t;}<br>
<br>
Modified: libcxx/trunk/include/map<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=231119&r1=231118&r2=231119&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/map?rev=231119&r1=231118&r2=231119&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/include/map (original)<br>
+++ libcxx/trunk/include/map Tue Mar 3 14:10:01 2015<br>
@@ -644,14 +644,25 @@ struct __value_type<br>
<br>
#endif<br>
<br>
+template <class _Tp><br>
+struct __extract_key_value_types;<br>
+<br>
+template <class _Key, class _Tp><br>
+struct __extract_key_value_types<__value_type<_Key, _Tp> ><br>
+{<br>
+ typedef _Key const __key_type;<br>
+ typedef _Tp __mapped_type;<br>
+};<br>
+<br>
template <class _TreeIterator><br>
class _LIBCPP_TYPE_VIS_ONLY __map_iterator<br>
{<br>
_TreeIterator __i_;<br>
<br>
typedef typename _TreeIterator::__pointer_traits __pointer_traits;<br>
- typedef const typename _TreeIterator::value_type::value_type::first_type __key_type;<br>
- typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type;<br>
+ typedef typename _TreeIterator::value_type __value_type;<br>
+ typedef typename __extract_key_value_types<__value_type>::__key_type __key_type;<br>
+ typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type;<br>
public:<br>
typedef bidirectional_iterator_tag iterator_category;<br>
typedef pair<__key_type, __mapped_type> value_type;<br>
@@ -715,8 +726,9 @@ class _LIBCPP_TYPE_VIS_ONLY __map_const_<br>
_TreeIterator __i_;<br>
<br>
typedef typename _TreeIterator::__pointer_traits __pointer_traits;<br>
- typedef const typename _TreeIterator::value_type::value_type::first_type __key_type;<br>
- typedef typename _TreeIterator::value_type::value_type::second_type __mapped_type;<br>
+ typedef typename _TreeIterator::value_type __value_type;<br>
+ typedef typename __extract_key_value_types<__value_type>::__key_type __key_type;<br>
+ typedef typename __extract_key_value_types<__value_type>::__mapped_type __mapped_type;<br>
public:<br>
typedef bidirectional_iterator_tag iterator_category;<br>
typedef pair<__key_type, __mapped_type> value_type;<br>
@@ -736,10 +748,9 @@ public:<br>
_LIBCPP_INLINE_VISIBILITY<br>
__map_const_iterator(_TreeIterator __i) _NOEXCEPT : __i_(__i) {}<br>
_LIBCPP_INLINE_VISIBILITY<br>
- __map_const_iterator(<br>
- __map_iterator<typename _TreeIterator::__non_const_iterator> __i)<br>
- _NOEXCEPT<br>
- : __i_(__i.__i_) {}<br>
+ __map_const_iterator(__map_iterator<<br>
+ typename _TreeIterator::__non_const_iterator> __i) _NOEXCEPT<br>
+ : __i_(__i.__i_) {}<br>
<br>
_LIBCPP_INLINE_VISIBILITY<br>
reference operator*() const {return __i_->__cc;}<br>
@@ -829,7 +840,7 @@ public:<br>
typedef typename __alloc_traits::const_pointer const_pointer;<br>
typedef typename __alloc_traits::size_type size_type;<br>
typedef typename __alloc_traits::difference_type difference_type;<br>
- typedef __map_iterator<typename __base::iterator> iterator;<br>
+ typedef __map_iterator<typename __base::iterator> iterator;<br>
typedef __map_const_iterator<typename __base::const_iterator> const_iterator;<br>
typedef _VSTD::reverse_iterator<iterator> reverse_iterator;<br>
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;<br>
<br>
Modified: libcxx/trunk/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp?rev=231119&r1=231118&r2=231119&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp?rev=231119&r1=231118&r2=231119&view=diff</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp (original)<br>
+++ libcxx/trunk/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp Tue Mar 3 14:10:01 2015<br>
@@ -15,15 +15,15 @@<br>
<br>
#include <map><br>
<br>
-#if !__has_feature(cxx_noexcept)<br>
-<br>
struct X<br>
{<br>
std::map<int, X> m;<br>
+ std::map<int, X>::iterator i;<br>
+ std::map<int, X>::const_iterator ci;<br>
+ std::map<int, X>::reverse_iterator ri;<br>
+ std::map<int, X>::const_reverse_iterator cri;<br>
};<br>
<br>
-#endif<br>
-<br>
int main()<br>
{<br>
}<br>
<br>
Added: libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp?rev=231119&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp?rev=231119&view=auto</a><br>
==============================================================================<br>
--- libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp (added)<br>
+++ libcxx/trunk/test/std/containers/associative/multimap/multimap.cons/default_recursive.pass.cpp Tue Mar 3 14:10:01 2015<br>
@@ -0,0 +1,29 @@<br>
+//===----------------------------------------------------------------------===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is dual licensed under the MIT and the University of Illinois Open<br>
+// Source Licenses. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+// <map><br>
+<br>
+// class multimap<br>
+<br>
+// multimap();<br>
+<br>
+#include <map><br>
+<br>
+struct X<br>
+{<br>
+ std::multimap<int, X> m;<br>
+ std::multimap<int, X>::iterator i;<br>
+ std::multimap<int, X>::const_iterator ci;<br>
+ std::multimap<int, X>::reverse_iterator ri;<br>
+ std::multimap<int, X>::const_reverse_iterator cri;<br>
+};<br>
+<br>
+int main()<br>
+{<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>