Home | History | Annotate | Download | only in iterator.traits
      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 // <iterator>
     11 
     12 // template<class T>
     13 // struct iterator_traits<T*>
     14 // {
     15 //   typedef ptrdiff_t                  difference_type;
     16 //   typedef T                          value_type;
     17 //   typedef T*                         pointer;
     18 //   typedef T&                         reference;
     19 //   typedef random_access_iterator_tag iterator_category;
     20 // };
     21 
     22 #include <iterator>
     23 #include <type_traits>
     24 
     25 struct A {};
     26 
     27 int main()
     28 {
     29     typedef std::iterator_traits<A*> It;
     30     static_assert((std::is_same<It::difference_type, std::ptrdiff_t>::value), "");
     31     static_assert((std::is_same<It::value_type, A>::value), "");
     32     static_assert((std::is_same<It::pointer, A*>::value), "");
     33     static_assert((std::is_same<It::reference, A&>::value), "");
     34     static_assert((std::is_same<It::iterator_category, std::random_access_iterator_tag>::value), "");
     35 }
     36