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 Iter>
     13 // struct iterator_traits
     14 // {
     15 //   typedef typename Iter::difference_type difference_type;
     16 //   typedef typename Iter::value_type value_type;
     17 //   typedef typename Iter::pointer pointer;
     18 //   typedef typename Iter::reference reference;
     19 //   typedef typename Iter::iterator_category iterator_category;
     20 // };
     21 
     22 #include <iterator>
     23 #include <type_traits>
     24 
     25 struct A {};
     26 
     27 struct test_iterator
     28 {
     29     typedef int                       difference_type;
     30     typedef A                         value_type;
     31     typedef A*                        pointer;
     32     typedef A&                        reference;
     33     typedef std::forward_iterator_tag iterator_category;
     34 };
     35 
     36 int main()
     37 {
     38     typedef std::iterator_traits<test_iterator> It;
     39     static_assert((std::is_same<It::difference_type, int>::value), "");
     40     static_assert((std::is_same<It::value_type, A>::value), "");
     41     static_assert((std::is_same<It::pointer, A*>::value), "");
     42     static_assert((std::is_same<It::iterator_category, std::forward_iterator_tag>::value), "");
     43 }
     44