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 // <memory>
11 
12 // template <class T, class Alloc> struct uses_allocator;
13 
14 #include <memory>
15 #include <vector>
16 
17 #include "test_macros.h"
18 
19 struct A
20 {
21 };
22 
23 struct B
24 {
25     typedef int allocator_type;
26 };
27 
28 struct C {
29   static int allocator_type;
30 };
31 
32 struct D {
allocator_typeD33   static int allocator_type() { return 0; }
34 };
35 
36 struct E {
37 private:
38   typedef int allocator_type;
39 };
40 
41 template <bool Expected, class T, class A>
42 void
test()43 test()
44 {
45     static_assert((std::uses_allocator<T, A>::value == Expected), "");
46 #if TEST_STD_VER > 14
47     static_assert((std::uses_allocator_v<T, A> == Expected), "");
48 #endif
49 }
50 
main()51 int main()
52 {
53     test<false, int, std::allocator<int> >();
54     test<true, std::vector<int>, std::allocator<int> >();
55     test<false, A, std::allocator<int> >();
56     test<false, B, std::allocator<int> >();
57     test<true, B, double>();
58     test<false, C, decltype(C::allocator_type)>();
59     test<false, D, decltype(D::allocator_type)>();
60 #if TEST_STD_VER >= 11
61     test<false, E, int>();
62 #endif
63 
64 
65 //     static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
66 //     static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
67 //     static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
68 //     static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
69 //     static_assert(( std::uses_allocator<B, double>::value), "");
70 //     static_assert((!std::uses_allocator<C, decltype(C::allocator_type)>::value), "");
71 //     static_assert((!std::uses_allocator<D, decltype(D::allocator_type)>::value), "");
72 // #if TEST_STD_VER >= 11
73 //     static_assert((!std::uses_allocator<E, int>::value), "");
74 // #endif
75 }
76