Home | History | Annotate | Download | only in allocator.traits.types
      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::pointer | value_type* pointer;
     16 //     ...
     17 // };
     18 
     19 #include <memory>
     20 #include <type_traits>
     21 
     22 #include "test_macros.h"
     23 
     24 template <class T>
     25 struct Ptr {};
     26 
     27 template <class T>
     28 struct A
     29 {
     30     typedef T value_type;
     31     typedef Ptr<T> pointer;
     32 };
     33 
     34 template <class T>
     35 struct B
     36 {
     37     typedef T value_type;
     38 };
     39 
     40 template <class T>
     41 struct C {
     42     typedef T value_type;
     43 private:
     44     typedef void pointer;
     45 };
     46 
     47 int main()
     48 {
     49     static_assert((std::is_same<std::allocator_traits<A<char> >::pointer, Ptr<char> >::value), "");
     50     static_assert((std::is_same<std::allocator_traits<B<char> >::pointer, char*>::value), "");
     51 #if TEST_STD_VER >= 11
     52     static_assert((std::is_same<std::allocator_traits<C<char> >::pointer, char*>::value), "");
     53 #endif
     54 }
     55