13ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow//===----------------------------------------------------------------------===// 23ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// 33ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// The LLVM Compiler Infrastructure 43ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// 53ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// This file is dual licensed under the MIT and the University of Illinois Open 63ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// Source Licenses. See LICENSE.TXT for details. 73ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// 83ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow//===----------------------------------------------------------------------===// 93ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 103ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow#include <memory> 113ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow#include <cassert> 123ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 133ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow#if __cplusplus >= 201103L 143ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// #include <memory> 153ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// 163ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// template <class Alloc> 173ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// struct allocator_traits 183ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// { 193ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// typedef Alloc allocator_type; 203ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// typedef typename allocator_type::value_type 213ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// value_type; 223ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// 233ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// typedef Alloc::pointer | value_type* pointer; 243ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// typedef Alloc::const_pointer 253ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// | pointer_traits<pointer>::rebind<const value_type> 263ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// const_pointer; 273ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// typedef Alloc::void_pointer 283ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// | pointer_traits<pointer>::rebind<void> 293ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// void_pointer; 303ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// typedef Alloc::const_void_pointer 313ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// | pointer_traits<pointer>::rebind<const void> 323ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow// const_void_pointer; 333ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 343ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowtemplate <typename Alloc> 353ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowvoid test_pointer() 363ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow{ 373ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow typename std::allocator_traits<Alloc>::pointer vp; 383ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow typename std::allocator_traits<Alloc>::const_pointer cvp; 393ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 403ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); 413ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); 423ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); 433ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp >= vp)>::value, ""); 443ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp < vp)>::value, ""); 453ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp <= vp)>::value, ""); 463ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 473ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp == cvp)>::value, ""); 483ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp == vp)>::value, ""); 493ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp != cvp)>::value, ""); 503ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp != vp)>::value, ""); 513ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp > cvp)>::value, ""); 523ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp > vp)>::value, ""); 533ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, ""); 543ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, ""); 553ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp < cvp)>::value, ""); 563ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp < vp)>::value, ""); 573ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, ""); 583ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, ""); 593ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 603ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, ""); 613ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, ""); 623ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, ""); 633ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, ""); 643ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, ""); 653ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, ""); 663ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow} 673ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 683ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowtemplate <typename Alloc> 693ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowvoid test_void_pointer() 703ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow{ 713ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow typename std::allocator_traits<Alloc>::void_pointer vp; 723ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow typename std::allocator_traits<Alloc>::const_void_pointer cvp; 733ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 743ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); 753ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); 763ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); 773ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp >= vp)>::value, ""); 783ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp < vp)>::value, ""); 793ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp <= vp)>::value, ""); 803ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 813ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp == cvp)>::value, ""); 823ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp == vp)>::value, ""); 833ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp != cvp)>::value, ""); 843ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp != vp)>::value, ""); 853ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp > cvp)>::value, ""); 863ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp > vp)>::value, ""); 873ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, ""); 883ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, ""); 893ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp < cvp)>::value, ""); 903ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp < vp)>::value, ""); 913ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, ""); 923ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, ""); 933ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 943ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, ""); 953ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, ""); 963ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, ""); 973ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, ""); 983ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, ""); 993ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, ""); 1003ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow} 1013ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 1023ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowstruct Foo { int x; }; 1033ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 1043ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowint main() 1053ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow{ 1063ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow test_pointer<std::allocator<char>> (); 1073ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow test_pointer<std::allocator<int>> (); 1083ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow test_pointer<std::allocator<Foo>> (); 1093ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow 1103ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow test_void_pointer<std::allocator<char>> (); 1113ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow test_void_pointer<std::allocator<int>> (); 1123ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow test_void_pointer<std::allocator<Foo>> (); 1133ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow} 1143ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow#else 1153ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clowint main() {} 1163ebf26f90df8d8d5e30c8c877a8491c4c839c69fMarshall Clow#endif 117