4684ddb6aa
- import libcxx - reduce targets to the one when compiled as a tools Change-Id: Iabb8427f80ff8e89463559a28bcb8b4f2bdbc496
77 lines
3.1 KiB
C++
77 lines
3.1 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// 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>
|
|
|
|
// template <class InputIterator>
|
|
// list(InputIterator first, InputIterator last, const Allocator& = Allocator());
|
|
|
|
#include <list>
|
|
#include <cassert>
|
|
#include "test_iterators.h"
|
|
#include "../../../stack_allocator.h"
|
|
#include "../../../min_allocator.h"
|
|
|
|
int main()
|
|
{
|
|
{
|
|
int a[] = {0, 1, 2, 3};
|
|
std::list<int> l(input_iterator<const int*>(a),
|
|
input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
|
|
assert(l.size() == sizeof(a)/sizeof(a[0]));
|
|
assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
|
|
int j = 0;
|
|
for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
|
|
assert(*i == j);
|
|
}
|
|
{
|
|
int a[] = {0, 1, 2, 3};
|
|
std::list<int> l(input_iterator<const int*>(a),
|
|
input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
|
|
std::allocator<int>());
|
|
assert(l.size() == sizeof(a)/sizeof(a[0]));
|
|
assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
|
|
int j = 0;
|
|
for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
|
|
assert(*i == j);
|
|
}
|
|
{
|
|
int a[] = {0, 1, 2, 3};
|
|
std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a),
|
|
input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
|
|
assert(l.size() == sizeof(a)/sizeof(a[0]));
|
|
assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
|
|
int j = 0;
|
|
for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
|
|
assert(*i == j);
|
|
}
|
|
#if __cplusplus >= 201103L
|
|
{
|
|
int a[] = {0, 1, 2, 3};
|
|
std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
|
|
input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
|
|
assert(l.size() == sizeof(a)/sizeof(a[0]));
|
|
assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
|
|
int j = 0;
|
|
for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
|
|
assert(*i == j);
|
|
}
|
|
{
|
|
int a[] = {0, 1, 2, 3};
|
|
std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
|
|
input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
|
|
min_allocator<int>());
|
|
assert(l.size() == sizeof(a)/sizeof(a[0]));
|
|
assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
|
|
int j = 0;
|
|
for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
|
|
assert(*i == j);
|
|
}
|
|
#endif
|
|
}
|