Home | History | Annotate | Download | only in istreambuf.iterator
      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 charT, class traits = char_traits<charT> >
     13 // class istreambuf_iterator
     14 //     : public iterator<input_iterator_tag, charT,
     15 //                       typename traits::off_type, unspecified,
     16 //                       charT>
     17 // {
     18 // public:
     19 //     typedef charT                         char_type;
     20 //     typedef traits                        traits_type;
     21 //     typedef typename traits::int_type     int_type;
     22 //     typedef basic_streambuf<charT,traits> streambuf_type;
     23 //     typedef basic_istream<charT,traits>   istream_type;
     24 //     ...
     25 
     26 #include <iterator>
     27 #include <string>
     28 #include <type_traits>
     29 
     30 int main()
     31 {
     32     typedef std::istreambuf_iterator<char> I1;
     33     static_assert((std::is_convertible<I1,
     34         std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type,
     35         char*, char> >::value), "");
     36     static_assert((std::is_same<I1::char_type, char>::value), "");
     37     static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
     38     static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
     39     static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
     40     static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
     41 
     42     typedef std::istreambuf_iterator<wchar_t> I2;
     43     static_assert((std::is_convertible<I2,
     44         std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type,
     45         wchar_t*, wchar_t> >::value), "");
     46     static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
     47     static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
     48     static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
     49     static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
     50     static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
     51 }
     52