Bug 9096 - list::iterator not default constructible

llvm-svn: 124508
This commit is contained in:
Howard Hinnant 2011-01-28 23:46:28 +00:00
parent 9f9438b314
commit 2774545736
15 changed files with 267 additions and 10 deletions

View File

@ -236,6 +236,8 @@ public:
pointer;
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
@ -289,6 +291,8 @@ public:
pointer;
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_) {}

View File

@ -63,7 +63,8 @@ int main()
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 @@ int main()
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);

View File

@ -63,7 +63,8 @@ int main()
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 @@ int main()
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)
{

View File

@ -63,7 +63,8 @@ int main()
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 @@ int main()
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);

View File

@ -63,7 +63,8 @@ int main()
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 @@ int main()
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);
}

View File

@ -20,7 +20,8 @@ int main()
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;

View File

@ -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);
}

View File

@ -67,5 +67,6 @@ int main()
typedef int T;
typedef std::forward_list<T> C;
C::iterator i;
C::const_iterator j;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -43,6 +43,7 @@ int main()
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 @@ int main()
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;
}
}

View File

@ -43,7 +43,8 @@ int main()
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 @@ int main()
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;
}
}

View File

@ -42,6 +42,7 @@ int main()
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 @@ int main()
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;
}
}

View File

@ -42,6 +42,7 @@ int main()
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 @@ int main()
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;
}
}