[cfe-commits] [libcxx] r124508 - in /libcxx/trunk: include/ test/containers/associative/map/map.access/ test/containers/associative/multimap/ test/containers/associative/multiset/ test/containers/associative/set/ test/containers/sequences/array/ test/containers/sequences/deque/ test/containers/sequences/forwardlist/forwardlist.iter/ test/containers/sequences/list/ test/containers/sequences/vector.bool/ test/containers/sequences/vector/ test/containers/unord/unord.map/ test/containers/unord/unord.multimap/ test/contain...

Howard Hinnant hhinnant at apple.com
Fri Jan 28 15:46:28 PST 2011


Author: hhinnant
Date: Fri Jan 28 17:46:28 2011
New Revision: 124508

URL: http://llvm.org/viewvc/llvm-project?rev=124508&view=rev
Log:
Bug 9096 - list::iterator not default constructible

Added:
    libcxx/trunk/test/containers/sequences/deque/iterators.pass.cpp
    libcxx/trunk/test/containers/sequences/list/iterators.pass.cpp
    libcxx/trunk/test/containers/sequences/vector.bool/iterators.pass.cpp
    libcxx/trunk/test/containers/sequences/vector/iterators.pass.cpp
Modified:
    libcxx/trunk/include/list
    libcxx/trunk/test/containers/associative/map/map.access/iterator.pass.cpp
    libcxx/trunk/test/containers/associative/multimap/iterator.pass.cpp
    libcxx/trunk/test/containers/associative/multiset/iterator.pass.cpp
    libcxx/trunk/test/containers/associative/set/iterator.pass.cpp
    libcxx/trunk/test/containers/sequences/array/begin.pass.cpp
    libcxx/trunk/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
    libcxx/trunk/test/containers/unord/unord.map/iterators.pass.cpp
    libcxx/trunk/test/containers/unord/unord.multimap/iterators.pass.cpp
    libcxx/trunk/test/containers/unord/unord.multiset/iterators.pass.cpp
    libcxx/trunk/test/containers/unord/unord.set/iterators.pass.cpp

Modified: libcxx/trunk/include/list
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/include/list (original)
+++ libcxx/trunk/include/list Fri Jan 28 17:46:28 2011
@@ -237,6 +237,8 @@
     typedef typename pointer_traits<pointer>::difference_type difference_type;
 
     _LIBCPP_INLINE_VISIBILITY
+    __list_iterator() {}
+    _LIBCPP_INLINE_VISIBILITY
     reference operator*() const {return __ptr_->__value_;}
     _LIBCPP_INLINE_VISIBILITY
     pointer operator->() const {return &(operator*());}
@@ -290,6 +292,8 @@
     typedef typename pointer_traits<pointer>::difference_type difference_type;
 
     _LIBCPP_INLINE_VISIBILITY
+    __list_const_iterator() {}
+    _LIBCPP_INLINE_VISIBILITY
     __list_const_iterator(__list_iterator<_Tp, _VoidPtr> __p) : __ptr_(__p.__ptr_) {}
 
     _LIBCPP_INLINE_VISIBILITY

Modified: libcxx/trunk/test/containers/associative/map/map.access/iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/associative/map/map.access/iterator.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/associative/map/map.access/iterator.pass.cpp (original)
+++ libcxx/trunk/test/containers/associative/map/map.access/iterator.pass.cpp Fri Jan 28 17:46:28 2011
@@ -63,7 +63,8 @@
         std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
         assert(std::distance(m.begin(), m.end()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
-        std::map<int, double>::iterator i = m.begin();
+        std::map<int, double>::iterator i;
+        i = m.begin();
         std::map<int, double>::const_iterator k = i;
         assert(i == k);
         for (int j = 1; j <= m.size(); ++j, ++i)
@@ -108,7 +109,8 @@
         assert(std::distance(m.cbegin(), m.cend()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
         assert(std::distance(m.crbegin(), m.crend()) == m.size());
-        std::map<int, double>::const_iterator i = m.begin();
+        std::map<int, double>::const_iterator i;
+        i = m.begin();
         for (int j = 1; j <= m.size(); ++j, ++i)
         {
             assert(i->first == j);

Modified: libcxx/trunk/test/containers/associative/multimap/iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/associative/multimap/iterator.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/associative/multimap/iterator.pass.cpp (original)
+++ libcxx/trunk/test/containers/associative/multimap/iterator.pass.cpp Fri Jan 28 17:46:28 2011
@@ -63,7 +63,8 @@
         std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
         assert(std::distance(m.begin(), m.end()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
-        std::multimap<int, double>::iterator i = m.begin();
+        std::multimap<int, double>::iterator i;
+        i = m.begin();
         std::multimap<int, double>::const_iterator k = i;
         assert(i == k);
         for (int j = 1; j <= 8; ++j)
@@ -109,7 +110,8 @@
         assert(std::distance(m.cbegin(), m.cend()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
         assert(std::distance(m.crbegin(), m.crend()) == m.size());
-        std::multimap<int, double>::const_iterator i = m.begin();
+        std::multimap<int, double>::const_iterator i;
+        i = m.begin();
         for (int j = 1; j <= 8; ++j)
             for (double d = 1; d <= 2; d += .5, ++i)
             {

Modified: libcxx/trunk/test/containers/associative/multiset/iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/associative/multiset/iterator.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/associative/multiset/iterator.pass.cpp (original)
+++ libcxx/trunk/test/containers/associative/multiset/iterator.pass.cpp Fri Jan 28 17:46:28 2011
@@ -63,7 +63,8 @@
         std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
         assert(std::distance(m.begin(), m.end()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
-        std::multiset<int>::iterator i = m.begin();
+        std::multiset<int>::iterator i;
+        i = m.begin();
         std::multiset<int>::const_iterator k = i;
         assert(i == k);
         for (int j = 1; j <= 8; ++j)
@@ -104,7 +105,8 @@
         assert(std::distance(m.cbegin(), m.cend()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
         assert(std::distance(m.crbegin(), m.crend()) == m.size());
-        std::multiset<int, double>::const_iterator i = m.begin();
+        std::multiset<int, double>::const_iterator i;
+        i = m.begin();
         for (int j = 1; j <= 8; ++j)
             for (int k = 0; k < 3; ++k, ++i)
                 assert(*i == j);

Modified: libcxx/trunk/test/containers/associative/set/iterator.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/associative/set/iterator.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/associative/set/iterator.pass.cpp (original)
+++ libcxx/trunk/test/containers/associative/set/iterator.pass.cpp Fri Jan 28 17:46:28 2011
@@ -63,7 +63,8 @@
         std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
         assert(std::distance(m.begin(), m.end()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
-        std::set<int>::iterator i = m.begin();
+        std::set<int>::iterator i;
+        i = m.begin();
         std::set<int>::const_iterator k = i;
         assert(i == k);
         for (int j = 1; j <= m.size(); ++j, ++i)
@@ -103,7 +104,8 @@
         assert(std::distance(m.cbegin(), m.cend()) == m.size());
         assert(std::distance(m.rbegin(), m.rend()) == m.size());
         assert(std::distance(m.crbegin(), m.crend()) == m.size());
-        std::set<int, double>::const_iterator i = m.begin();
+        std::set<int, double>::const_iterator i;
+        i = m.begin();
         for (int j = 1; j <= m.size(); ++j, ++i)
             assert(*i == j);
     }

Modified: libcxx/trunk/test/containers/sequences/array/begin.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/array/begin.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/array/begin.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/array/begin.pass.cpp Fri Jan 28 17:46:28 2011
@@ -20,7 +20,8 @@
         typedef double T;
         typedef std::array<T, 3> C;
         C c = {1, 2, 3.5};
-        C::iterator i = c.begin();
+        C::iterator i;
+        i = c.begin();
         assert(*i == 1);
         assert(&*i == c.data());
         *i = 5.5;

Added: libcxx/trunk/test/containers/sequences/deque/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/deque/iterators.pass.cpp?rev=124508&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/deque/iterators.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/deque/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque;
+
+// iterator, const_iterator
+
+#include <deque>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+    typedef std::deque<int> C;
+    C c;
+    C::iterator i;
+    i = c.begin();
+    C::const_iterator j;
+    j = c.cbegin();
+    assert(i == j);
+}

Modified: libcxx/trunk/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp (original)
+++ libcxx/trunk/test/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -67,5 +67,6 @@
         typedef int T;
         typedef std::forward_list<T> C;
         C::iterator i;
+        C::const_iterator j;
     }
 }

Added: libcxx/trunk/test/containers/sequences/list/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/list/iterators.pass.cpp?rev=124508&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/list/iterators.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/list/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <list>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::list<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+}

Added: libcxx/trunk/test/containers/sequences/vector.bool/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector.bool/iterators.pass.cpp?rev=124508&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector.bool/iterators.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector.bool/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef bool T;
+        typedef std::vector<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+}

Added: libcxx/trunk/test/containers/sequences/vector/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/sequences/vector/iterators.pass.cpp?rev=124508&view=auto
==============================================================================
--- libcxx/trunk/test/containers/sequences/vector/iterators.pass.cpp (added)
+++ libcxx/trunk/test/containers/sequences/vector/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator       begin();
+// iterator       end();
+// const_iterator begin()  const;
+// const_iterator end()    const;
+// const_iterator cbegin() const;
+// const_iterator cend()   const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+int main()
+{
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        C c;
+        C::iterator i = c.begin();
+        C::iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        const C c;
+        C::const_iterator i = c.begin();
+        C::const_iterator j = c.end();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        C c;
+        C::const_iterator i = c.cbegin();
+        C::const_iterator j = c.cend();
+        assert(std::distance(i, j) == 0);
+        assert(i == j);
+        assert(i == c.end());
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+        C c(std::begin(t), std::end(t));
+        C::iterator i = c.begin();
+        assert(*i == 0);
+        ++i;
+        assert(*i == 1);
+        *i = 10;
+        assert(*i == 10);
+        assert(std::distance(c.begin(), c.end()) == 10);
+    }
+    {
+        typedef int T;
+        typedef std::vector<T> C;
+        C::iterator i;
+        C::const_iterator j;
+    }
+}

Modified: libcxx/trunk/test/containers/unord/unord.map/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.map/iterators.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.map/iterators.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.map/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -43,6 +43,7 @@
         assert(c.size() == 4);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
     }
     {
         typedef std::unordered_map<int, std::string> C;
@@ -61,5 +62,6 @@
         assert(c.size() == 4);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
     }
 }

Modified: libcxx/trunk/test/containers/unord/unord.multimap/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.multimap/iterators.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.multimap/iterators.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.multimap/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -43,7 +43,8 @@
         assert(c.size() == 6);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
-        C::iterator i = c.begin();
+        C::iterator i;
+        i = c.begin();
         i->second = "ONE";
         assert(i->second == "ONE");
     }
@@ -64,5 +65,6 @@
         assert(c.size() == 6);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
     }
 }

Modified: libcxx/trunk/test/containers/unord/unord.multiset/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.multiset/iterators.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.multiset/iterators.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.multiset/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -42,6 +42,7 @@
         assert(c.size() == 6);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
     }
     {
         typedef std::unordered_multiset<int> C;
@@ -60,5 +61,6 @@
         assert(c.size() == 6);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
     }
 }

Modified: libcxx/trunk/test/containers/unord/unord.set/iterators.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/containers/unord/unord.set/iterators.pass.cpp?rev=124508&r1=124507&r2=124508&view=diff
==============================================================================
--- libcxx/trunk/test/containers/unord/unord.set/iterators.pass.cpp (original)
+++ libcxx/trunk/test/containers/unord/unord.set/iterators.pass.cpp Fri Jan 28 17:46:28 2011
@@ -42,6 +42,7 @@
         assert(c.size() == 4);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::iterator i;
     }
     {
         typedef std::unordered_set<int> C;
@@ -60,5 +61,6 @@
         assert(c.size() == 4);
         assert(std::distance(c.begin(), c.end()) == c.size());
         assert(std::distance(c.cbegin(), c.cend()) == c.size());
+        C::const_iterator i;
     }
 }





More information about the cfe-commits mailing list