1 | ////////////////////////////////////////////////////////////////////////////// |
2 | // |
3 | // (C) Copyright Ion Gaztanaga 2015-2015. Distributed under the Boost |
4 | // Software License, Version 1.0. (See accompanying file |
5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
6 | // |
7 | // See http://www.boost.org/libs/container for documentation. |
8 | // |
9 | ////////////////////////////////////////////////////////////////////////////// |
10 | |
11 | #include <boost/container/vector.hpp> |
12 | |
13 | struct empty |
14 | { |
15 | friend bool operator == (const empty &, const empty &){ return true; } |
16 | friend bool operator < (const empty &, const empty &){ return true; } |
17 | }; |
18 | |
19 | template class ::boost::container::vector<empty>; |
20 | volatile ::boost::container::vector<empty> dummy; |
21 | |
22 | #include <boost/container/allocator.hpp> |
23 | #include "movable_int.hpp" |
24 | #include "dummy_test_allocator.hpp" |
25 | #include <boost/move/detail/force_ptr.hpp> |
26 | |
27 | class CustomAllocator |
28 | { |
29 | public: |
30 | typedef int value_type; |
31 | typedef value_type* pointer; |
32 | typedef const value_type* const_pointer; |
33 | typedef unsigned short size_type; |
34 | typedef short difference_type; |
35 | |
36 | pointer allocate(size_type count) |
37 | { return boost::move_detail::force_ptr<pointer>(p: new char[sizeof(value_type)*count]); } |
38 | |
39 | void deallocate(pointer ptr, size_type ) |
40 | { delete [](char*)ptr; } |
41 | |
42 | friend bool operator==(CustomAllocator const&, CustomAllocator const&) BOOST_NOEXCEPT |
43 | { return true; } |
44 | |
45 | friend bool operator!=(CustomAllocator const& x, CustomAllocator const& y) BOOST_NOEXCEPT |
46 | { return !(x == y); } |
47 | }; |
48 | |
49 | |
50 | namespace boost { |
51 | namespace container { |
52 | |
53 | //Explicit instantiation to detect compilation errors |
54 | template class boost::container::vector |
55 | < test::movable_and_copyable_int |
56 | , test::simple_allocator<test::movable_and_copyable_int> >; |
57 | |
58 | template class boost::container::vector |
59 | < test::movable_and_copyable_int |
60 | , allocator<test::movable_and_copyable_int> >; |
61 | |
62 | template class vec_iterator<int*, true >; |
63 | template class vec_iterator<int*, false>; |
64 | |
65 | //Test stored_size option |
66 | template class boost::container::vector< test::movable_and_copyable_int |
67 | , new_allocator<test::movable_and_copyable_int> |
68 | , vector_options< stored_size<unsigned short> >::type |
69 | >; |
70 | |
71 | //test custom allocator with small size_type |
72 | template class boost::container::vector<int, CustomAllocator>; |
73 | |
74 | } //namespace boost { |
75 | } //namespace container { |
76 | |
77 | int main() |
78 | { |
79 | return 0; |
80 | } |
81 | |