Home | History | Annotate | Download | only in pointer.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 Ptr>
     13 // struct pointer_traits
     14 // {
     15 //     typedef <details> element_type;
     16 //     ...
     17 // };
     18 
     19 #include <memory>
     20 #include <type_traits>
     21 
     22 #include "test_macros.h"
     23 
     24 struct A
     25 {
     26     typedef char element_type;
     27 };
     28 
     29 template <class T>
     30 struct B
     31 {
     32     typedef char element_type;
     33 };
     34 
     35 template <class T>
     36 struct C
     37 {
     38 };
     39 
     40 template <class T, class U>
     41 struct D
     42 {
     43 };
     44 
     45 template <class T, class U>
     46 struct E
     47 {
     48     static int element_type;
     49 };
     50 
     51 template <class T>
     52 struct F {
     53 private:
     54   typedef int element_type;
     55 };
     56 
     57 int main()
     58 {
     59     static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), "");
     60     static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), "");
     61     static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), "");
     62     static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), "");
     63     static_assert((std::is_same<std::pointer_traits<E<double, int> >::element_type, double>::value), "");
     64 #if TEST_STD_VER >= 11
     65     static_assert((std::is_same<std::pointer_traits<F<double>>::element_type, double>::value), "");
     66 #endif
     67 
     68 }
     69