construct_default.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <vector>
11
12// vector(const Alloc& = Alloc());
13
14#include <vector>
15#include <cassert>
16
17#include "../../../test_allocator.h"
18#include "../../../NotConstructible.h"
19#include "../../../stack_allocator.h"
20
21template <class C>
22void
23test0()
24{
25    C c;
26    assert(c.__invariants());
27    assert(c.empty());
28    assert(c.get_allocator() == typename C::allocator_type());
29}
30
31template <class C>
32void
33test1(const typename C::allocator_type& a)
34{
35    C c(a);
36    assert(c.__invariants());
37    assert(c.empty());
38    assert(c.get_allocator() == a);
39}
40
41int main()
42{
43    {
44    test0<std::vector<int> >();
45    test0<std::vector<NotConstructible> >();
46    test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
47    test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
48        (test_allocator<NotConstructible>(5));
49    }
50    {
51        std::vector<int, stack_allocator<int, 10> > v;
52        assert(v.empty());
53    }
54}
55