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 NotAnIterator>
     13 // struct iterator_traits
     14 // {
     15 // };
     16 
     17 #include <iterator>
     18 
     19 struct not_an_iterator
     20 {
     21 };
     22 
     23 template <class T>
     24 struct has_value_type
     25 {
     26 private:
     27     struct two {char lx; char lxx;};
     28     template <class U> static two test(...);
     29     template <class U> static char test(typename U::value_type* = 0);
     30 public:
     31     static const bool value = sizeof(test<T>(0)) == 1;
     32 };
     33 
     34 int main()
     35 {
     36     typedef std::iterator_traits<not_an_iterator> It;
     37     static_assert(!(has_value_type<It>::value), "");
     38 }
     39