void_pointer.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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 Alloc> 13// struct allocator_traits 14// { 15// typedef Alloc::void_pointer 16// | pointer_traits<pointer>::rebind<void> 17// void_pointer; 18// ... 19// }; 20 21#include <memory> 22#include <type_traits> 23 24template <class T> 25struct Ptr {}; 26 27template <class T> 28struct A 29{ 30 typedef T value_type; 31 typedef Ptr<T> pointer; 32}; 33 34template <class T> 35struct B 36{ 37 typedef T value_type; 38}; 39 40template <class T> 41struct CPtr {}; 42 43template <class T> 44struct C 45{ 46 typedef T value_type; 47 typedef CPtr<void> void_pointer; 48}; 49 50int main() 51{ 52 static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), ""); 53 static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), ""); 54 static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), ""); 55} 56