range.pass.cpp revision 06086258d3d8c48a916ec51c33e1ad8f46821b81
1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <forward_list> 11 12// template <class InputIterator> 13// forward_list(InputIterator first, InputIterator last); 14 15#include <forward_list> 16#include <cassert> 17#include <iterator> 18 19#include "test_iterators.h" 20#include "min_allocator.h" 21 22int main() 23{ 24 { 25 typedef int T; 26 typedef std::forward_list<T> C; 27 typedef input_iterator<const T*> I; 28 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 29 C c(I(std::begin(t)), I(std::end(t))); 30 unsigned n = 0; 31 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) 32 assert(*i == n); 33 assert(n == std::end(t) - std::begin(t)); 34 } 35#if __cplusplus >= 201103L 36 { 37 typedef int T; 38 typedef std::forward_list<T, min_allocator<T>> C; 39 typedef input_iterator<const T*> I; 40 const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; 41 C c(I(std::begin(t)), I(std::end(t))); 42 unsigned n = 0; 43 for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n) 44 assert(*i == n); 45 assert(n == std::end(t) - std::begin(t)); 46 } 47#endif 48} 49