1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <memory>
10 
11 // template <class Alloc>
12 // struct allocator_traits
13 // {
14 //   typedef Alloc::is_always_equal
15 //         | is_empty                     is_always_equal;
16 //     ...
17 // };
18 
19 #include <memory>
20 #include <type_traits>
21 
22 #include "test_macros.h"
23 
24 template <class T>
25 struct A
26 {
27     typedef T value_type;
28     typedef std::true_type is_always_equal;
29 };
30 
31 template <class T>
32 struct B
33 {
34     typedef T value_type;
35 };
36 
37 template <class T>
38 struct C
39 {
40     typedef T value_type;
41     int not_empty_;  // some random member variable
42 };
43 
main(int,char **)44 int main(int, char**)
45 {
46     static_assert((std::is_same<std::allocator_traits<A<char> >::is_always_equal, std::true_type>::value), "");
47     static_assert((std::is_same<std::allocator_traits<B<char> >::is_always_equal, std::true_type>::value), "");
48     static_assert((std::is_same<std::allocator_traits<C<char> >::is_always_equal, std::false_type>::value), "");
49 
50     static_assert((std::is_same<std::allocator_traits<A<const char> >::is_always_equal, std::true_type>::value), "");
51     static_assert((std::is_same<std::allocator_traits<B<const char> >::is_always_equal, std::true_type>::value), "");
52     static_assert((std::is_same<std::allocator_traits<C<const char> >::is_always_equal, std::false_type>::value), "");
53 
54   return 0;
55 }
56