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// <list>
11
12// explicit list(size_type n);
13
14#include <list>
15#include <cassert>
16#include "DefaultOnly.h"
17#include "../../../stack_allocator.h"
18#include "min_allocator.h"
19
20template <class T, class Allocator>
21void
22test3(unsigned n, Allocator const &alloc = Allocator())
23{
24#if _LIBCPP_STD_VER > 11
25    typedef std::list<T, Allocator> C;
26    typedef typename C::const_iterator const_iterator;
27    {
28    C d(n, alloc);
29    assert(d.size() == n);
30    assert(std::distance(d.begin(), d.end()) == n);
31    assert(d.get_allocator() == alloc);
32    }
33#endif
34}
35
36
37int main()
38{
39    {
40        std::list<int> l(3);
41        assert(l.size() == 3);
42        assert(std::distance(l.begin(), l.end()) == 3);
43        std::list<int>::const_iterator i = l.begin();
44        assert(*i == 0);
45        ++i;
46        assert(*i == 0);
47        ++i;
48        assert(*i == 0);
49    }
50    {
51        std::list<int, stack_allocator<int, 3> > l(3);
52        assert(l.size() == 3);
53        assert(std::distance(l.begin(), l.end()) == 3);
54        std::list<int>::const_iterator i = l.begin();
55        assert(*i == 0);
56        ++i;
57        assert(*i == 0);
58        ++i;
59        assert(*i == 0);
60    }
61#if _LIBCPP_STD_VER > 11
62    {
63        typedef std::list<int, min_allocator<int> > C;
64        C l(3, min_allocator<int> ());
65        assert(l.size() == 3);
66        assert(std::distance(l.begin(), l.end()) == 3);
67        C::const_iterator i = l.begin();
68        assert(*i == 0);
69        ++i;
70        assert(*i == 0);
71        ++i;
72        assert(*i == 0);
73        test3<int, min_allocator<int>> (3);
74    }
75#endif
76#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
77    {
78        std::list<DefaultOnly> l(3);
79        assert(l.size() == 3);
80        assert(std::distance(l.begin(), l.end()) == 3);
81    }
82#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
83#if __cplusplus >= 201103L
84    {
85        std::list<int, min_allocator<int>> l(3);
86        assert(l.size() == 3);
87        assert(std::distance(l.begin(), l.end()) == 3);
88        std::list<int, min_allocator<int>>::const_iterator i = l.begin();
89        assert(*i == 0);
90        ++i;
91        assert(*i == 0);
92        ++i;
93        assert(*i == 0);
94    }
95#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
96    {
97        std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
98        assert(l.size() == 3);
99        assert(std::distance(l.begin(), l.end()) == 3);
100    }
101#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
102#endif
103}
104