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 // Test fails due to use of is_trivially_* trait.
     13 // XFAIL: gcc-4.9
     14 
     15 // template<class charT, class traits = char_traits<charT> >
     16 // class istreambuf_iterator
     17 //     : public iterator<input_iterator_tag, charT,
     18 //                       typename traits::off_type, unspecified,
     19 //                       charT>
     20 // {
     21 // public:
     22 //     typedef charT                         char_type;
     23 //     typedef traits                        traits_type;
     24 //     typedef typename traits::int_type     int_type;
     25 //     typedef basic_streambuf<charT,traits> streambuf_type;
     26 //     typedef basic_istream<charT,traits>   istream_type;
     27 //     ...
     28 //
     29 // All specializations of istreambuf_iterator shall have a trivial copy constructor,
     30 //    a constexpr default constructor and a trivial destructor.
     31 
     32 #include <iterator>
     33 #include <string>
     34 #include <type_traits>
     35 
     36 #include "test_macros.h"
     37 
     38 int main()
     39 {
     40     typedef std::istreambuf_iterator<char> I1;
     41     static_assert((std::is_same<I1::iterator_category, std::input_iterator_tag>::value), "");
     42     static_assert((std::is_same<I1::value_type, char>::value), "");
     43     static_assert((std::is_same<I1::difference_type, std::char_traits<char>::off_type>::value), "");
     44     LIBCPP_STATIC_ASSERT((std::is_same<I1::pointer, char*>::value), "");
     45     static_assert((std::is_same<I1::reference, char>::value), "");
     46     static_assert((std::is_same<I1::char_type, char>::value), "");
     47     static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), "");
     48     static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), "");
     49     static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), "");
     50     static_assert((std::is_same<I1::istream_type, std::istream>::value), "");
     51     static_assert((std::is_nothrow_default_constructible<I1>::value), "" );
     52     static_assert((std::is_trivially_copy_constructible<I1>::value), "" );
     53     static_assert((std::is_trivially_destructible<I1>::value), "" );
     54 
     55     typedef std::istreambuf_iterator<wchar_t> I2;
     56     static_assert((std::is_same<I2::iterator_category, std::input_iterator_tag>::value), "");
     57     static_assert((std::is_same<I2::value_type, wchar_t>::value), "");
     58     static_assert((std::is_same<I2::difference_type, std::char_traits<wchar_t>::off_type>::value), "");
     59     LIBCPP_STATIC_ASSERT((std::is_same<I2::pointer, wchar_t*>::value), "");
     60     static_assert((std::is_same<I2::reference, wchar_t>::value), "");
     61     static_assert((std::is_same<I2::char_type, wchar_t>::value), "");
     62     static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), "");
     63     static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), "");
     64     static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), "");
     65     static_assert((std::is_same<I2::istream_type, std::wistream>::value), "");
     66     static_assert((std::is_nothrow_default_constructible<I2>::value), "" );
     67     static_assert((std::is_trivially_copy_constructible<I2>::value), "" );
     68     static_assert((std::is_trivially_destructible<I2>::value), "" );
     69 }
     70