Marshall Clow | 3ebf26f | 2014-03-11 04:32:12 +0000 | [diff] [blame] | 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 | #include <memory> |
| 11 | #include <cassert> |
| 12 | |
| 13 | #if __cplusplus >= 201103L |
| 14 | // #include <memory> |
| 15 | // |
| 16 | // template <class Alloc> |
| 17 | // struct allocator_traits |
| 18 | // { |
| 19 | // typedef Alloc allocator_type; |
| 20 | // typedef typename allocator_type::value_type |
| 21 | // value_type; |
| 22 | // |
| 23 | // typedef Alloc::pointer | value_type* pointer; |
| 24 | // typedef Alloc::const_pointer |
| 25 | // | pointer_traits<pointer>::rebind<const value_type> |
| 26 | // const_pointer; |
| 27 | // typedef Alloc::void_pointer |
| 28 | // | pointer_traits<pointer>::rebind<void> |
| 29 | // void_pointer; |
| 30 | // typedef Alloc::const_void_pointer |
| 31 | // | pointer_traits<pointer>::rebind<const void> |
| 32 | // const_void_pointer; |
| 33 | |
| 34 | template <typename Alloc> |
| 35 | void test_pointer() |
| 36 | { |
| 37 | typename std::allocator_traits<Alloc>::pointer vp; |
| 38 | typename std::allocator_traits<Alloc>::const_pointer cvp; |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 39 | |
Marshall Clow | 3ebf26f | 2014-03-11 04:32:12 +0000 | [diff] [blame] | 40 | static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); |
| 41 | static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); |
| 42 | static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); |
| 43 | static_assert(std::is_same<bool, decltype( vp >= vp)>::value, ""); |
| 44 | static_assert(std::is_same<bool, decltype( vp < vp)>::value, ""); |
| 45 | static_assert(std::is_same<bool, decltype( vp <= vp)>::value, ""); |
| 46 | |
| 47 | static_assert(std::is_same<bool, decltype( vp == cvp)>::value, ""); |
| 48 | static_assert(std::is_same<bool, decltype(cvp == vp)>::value, ""); |
| 49 | static_assert(std::is_same<bool, decltype( vp != cvp)>::value, ""); |
| 50 | static_assert(std::is_same<bool, decltype(cvp != vp)>::value, ""); |
| 51 | static_assert(std::is_same<bool, decltype( vp > cvp)>::value, ""); |
| 52 | static_assert(std::is_same<bool, decltype(cvp > vp)>::value, ""); |
| 53 | static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, ""); |
| 54 | static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, ""); |
| 55 | static_assert(std::is_same<bool, decltype( vp < cvp)>::value, ""); |
| 56 | static_assert(std::is_same<bool, decltype(cvp < vp)>::value, ""); |
| 57 | static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, ""); |
| 58 | static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, ""); |
| 59 | |
| 60 | static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, ""); |
| 61 | static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, ""); |
| 62 | static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, ""); |
| 63 | static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, ""); |
| 64 | static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, ""); |
| 65 | static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, ""); |
| 66 | } |
| 67 | |
| 68 | template <typename Alloc> |
| 69 | void test_void_pointer() |
| 70 | { |
| 71 | typename std::allocator_traits<Alloc>::void_pointer vp; |
| 72 | typename std::allocator_traits<Alloc>::const_void_pointer cvp; |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 73 | |
Marshall Clow | 3ebf26f | 2014-03-11 04:32:12 +0000 | [diff] [blame] | 74 | static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); |
| 75 | static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); |
| 76 | static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); |
| 77 | static_assert(std::is_same<bool, decltype( vp >= vp)>::value, ""); |
| 78 | static_assert(std::is_same<bool, decltype( vp < vp)>::value, ""); |
| 79 | static_assert(std::is_same<bool, decltype( vp <= vp)>::value, ""); |
| 80 | |
| 81 | static_assert(std::is_same<bool, decltype( vp == cvp)>::value, ""); |
| 82 | static_assert(std::is_same<bool, decltype(cvp == vp)>::value, ""); |
| 83 | static_assert(std::is_same<bool, decltype( vp != cvp)>::value, ""); |
| 84 | static_assert(std::is_same<bool, decltype(cvp != vp)>::value, ""); |
| 85 | static_assert(std::is_same<bool, decltype( vp > cvp)>::value, ""); |
| 86 | static_assert(std::is_same<bool, decltype(cvp > vp)>::value, ""); |
| 87 | static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, ""); |
| 88 | static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, ""); |
| 89 | static_assert(std::is_same<bool, decltype( vp < cvp)>::value, ""); |
| 90 | static_assert(std::is_same<bool, decltype(cvp < vp)>::value, ""); |
| 91 | static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, ""); |
| 92 | static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, ""); |
| 93 | |
| 94 | static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, ""); |
| 95 | static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, ""); |
| 96 | static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, ""); |
| 97 | static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, ""); |
| 98 | static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, ""); |
| 99 | static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, ""); |
| 100 | } |
| 101 | |
| 102 | struct Foo { int x; }; |
| 103 | |
| 104 | int main() |
| 105 | { |
Marshall Clow | 38d9005 | 2014-10-18 11:03:33 +0000 | [diff] [blame] | 106 | test_pointer<std::allocator<char>> (); |
| 107 | test_pointer<std::allocator<int>> (); |
| 108 | test_pointer<std::allocator<Foo>> (); |
Marshall Clow | 3ebf26f | 2014-03-11 04:32:12 +0000 | [diff] [blame] | 109 | |
Marshall Clow | 38d9005 | 2014-10-18 11:03:33 +0000 | [diff] [blame] | 110 | test_void_pointer<std::allocator<char>> (); |
| 111 | test_void_pointer<std::allocator<int>> (); |
| 112 | test_void_pointer<std::allocator<Foo>> (); |
Marshall Clow | 3ebf26f | 2014-03-11 04:32:12 +0000 | [diff] [blame] | 113 | } |
| 114 | #else |
| 115 | int main() {} |
| 116 | #endif |