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// <vector>
11
12// Test nested types and default template args:
13
14// template <class Allocator>
15// class vector<bool, Allocator
16// {
17// public:
18//     typedef T                                        value_type;
19//     typedef Allocator                                allocator_type;
20//     typedef implementation-defined                   iterator;
21//     typedef implementation-defined                   const_iterator;
22//     typedef typename allocator_type::size_type       size_type;
23//     typedef typename allocator_type::difference_type difference_type;
24//     typedef typename allocator_type::pointer         pointer;
25//     typedef typename allocator_type::const_pointer   const_pointer;
26//     typedef std::reverse_iterator<iterator>          reverse_iterator;
27//     typedef std::reverse_iterator<const_iterator>    const_reverse_iterator;
28// };
29
30#include <vector>
31#include <iterator>
32#include <type_traits>
33
34#include "test_allocator.h"
35#include "../../Copyable.h"
36#include "min_allocator.h"
37
38template <class Allocator>
39void
40test()
41{
42    typedef std::vector<bool, Allocator> C;
43
44    static_assert((std::is_same<typename C::value_type, bool>::value), "");
45    static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
46    static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
47    static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
48    static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
49
50    static_assert((std::is_signed<typename C::difference_type>::value), "");
51    static_assert((std::is_unsigned<typename C::size_type>::value), "");
52    static_assert((std::is_same<typename C::difference_type,
53        typename std::iterator_traits<typename C::iterator>::difference_type>::value), "");
54    static_assert((std::is_same<typename C::difference_type,
55        typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), "");
56
57   static_assert((std::is_same<
58        typename std::iterator_traits<typename C::iterator>::iterator_category,
59        std::random_access_iterator_tag>::value), "");
60    static_assert((std::is_same<
61        typename std::iterator_traits<typename C::const_iterator>::iterator_category,
62        std::random_access_iterator_tag>::value), "");
63    static_assert((std::is_same<
64        typename C::reverse_iterator,
65        std::reverse_iterator<typename C::iterator> >::value), "");
66    static_assert((std::is_same<
67        typename C::const_reverse_iterator,
68        std::reverse_iterator<typename C::const_iterator> >::value), "");
69}
70
71int main()
72{
73    test<test_allocator<bool> >();
74    test<std::allocator<bool> >();
75    static_assert((std::is_same<std::vector<bool>::allocator_type,
76                                std::allocator<bool> >::value), "");
77#if TEST_STD_VER >= 11
78    test<min_allocator<bool> >();
79#endif
80}
81