blob: 39807f09e294f47663806fbe7c05cbbdefc086f9 [file] [log] [blame]
Brian Silvermanfad8f552018-08-04 23:36:19 -07001//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2011-2013. 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#include <boost/container/detail/config_begin.hpp>
11#include <boost/container/uses_allocator_fwd.hpp>
12
13#include <boost/container/uses_allocator.hpp>
14#include "propagation_test_allocator.hpp"
15
16struct not_uses_allocator
17{};
18
19struct uses_allocator_and_not_convertible_to_int
20{
21 typedef uses_allocator_and_not_convertible_to_int allocator_type;
22};
23
24struct uses_allocator_and_convertible_to_int
25{
26 typedef char allocator_type;
27};
28
29struct uses_erased_type_allocator
30{
31 typedef boost::container::erased_type allocator_type;
32};
33
34
35int main()
36{
37 using namespace boost::container;
38 //Using dummy classes
39 BOOST_STATIC_ASSERT(( false == uses_allocator
40 < not_uses_allocator, int>::value ));
41
42 BOOST_STATIC_ASSERT(( false == uses_allocator
43 < uses_allocator_and_not_convertible_to_int, int>::value ));
44
45 BOOST_STATIC_ASSERT(( true == uses_allocator
46 < uses_allocator_and_convertible_to_int, int>::value ));
47
48 BOOST_STATIC_ASSERT(( true == uses_allocator
49 < uses_erased_type_allocator, int>::value ));
50
51 //Using an allocator-like class
52 BOOST_STATIC_ASSERT(( false == uses_allocator
53 < allocator_argument_tester<NotUsesAllocator, 0>
54 , propagation_test_allocator<float, 0>
55 >::value ));
56 BOOST_STATIC_ASSERT(( true == uses_allocator
57 < allocator_argument_tester<ConstructiblePrefix, 0>
58 , propagation_test_allocator<float, 0>
59 >::value ));
60 BOOST_STATIC_ASSERT(( true == uses_allocator
61 < allocator_argument_tester<ConstructibleSuffix, 0>
62 , propagation_test_allocator<float, 0>
63 >::value ));
64 BOOST_STATIC_ASSERT(( true == uses_allocator
65 < allocator_argument_tester<ErasedTypeSuffix, 0>
66 , propagation_test_allocator<float, 0>
67 >::value ));
68 BOOST_STATIC_ASSERT(( true == uses_allocator
69 < allocator_argument_tester<ErasedTypePrefix, 0>
70 , propagation_test_allocator<float, 0>
71 >::value ));
72 BOOST_STATIC_ASSERT(( true == constructible_with_allocator_prefix
73 < allocator_argument_tester<ConstructiblePrefix, 0> >::value ));
74
75 BOOST_STATIC_ASSERT(( true == constructible_with_allocator_suffix
76 < allocator_argument_tester<ConstructibleSuffix, 0> >::value ));
77
78 BOOST_STATIC_ASSERT(( true == constructible_with_allocator_prefix
79 < allocator_argument_tester<ErasedTypePrefix, 0> >::value ));
80
81 BOOST_STATIC_ASSERT(( true == constructible_with_allocator_suffix
82 < allocator_argument_tester<ErasedTypeSuffix, 0> >::value ));
83 return 0;
84}