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 { 33 static int allocator_type() { return 0; } 34 }; 35 36 struct E { 37 private: 38 typedef int allocator_type; 39 }; 40 41 int main() 42 { 43 static_assert((!std::uses_allocator<int, std::allocator<int> >::value), ""); 44 static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), ""); 45 static_assert((!std::uses_allocator<A, std::allocator<int> >::value), ""); 46 static_assert((!std::uses_allocator<B, std::allocator<int> >::value), ""); 47 static_assert(( std::uses_allocator<B, double>::value), ""); 48 static_assert((!std::uses_allocator<C, decltype(C::allocator_type)>::value), ""); 49 static_assert((!std::uses_allocator<D, decltype(D::allocator_type)>::value), ""); 50 #if TEST_STD_VER >= 11 51 static_assert((!std::uses_allocator<E, int>::value), ""); 52 #endif 53 } 54