Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | // ... |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 25 | // |
| 26 | // All specializations of istreambuf_iterator shall have a trivial copy constructor, |
| 27 | // a constexpr default constructor and a trivial destructor. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 28 | |
| 29 | #include <iterator> |
| 30 | #include <string> |
| 31 | #include <type_traits> |
| 32 | |
| 33 | int main() |
| 34 | { |
| 35 | typedef std::istreambuf_iterator<char> I1; |
| 36 | static_assert((std::is_convertible<I1, |
| 37 | std::iterator<std::input_iterator_tag, char, std::char_traits<char>::off_type, |
| 38 | char*, char> >::value), ""); |
| 39 | static_assert((std::is_same<I1::char_type, char>::value), ""); |
| 40 | static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), ""); |
| 41 | static_assert((std::is_same<I1::int_type, I1::traits_type::int_type>::value), ""); |
| 42 | static_assert((std::is_same<I1::streambuf_type, std::streambuf>::value), ""); |
| 43 | static_assert((std::is_same<I1::istream_type, std::istream>::value), ""); |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 44 | static_assert((std::is_nothrow_default_constructible<I1>::value), "" ); |
| 45 | static_assert((std::is_trivially_copy_constructible<I1>::value), "" ); |
| 46 | static_assert((std::is_trivially_destructible<I1>::value), "" ); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 47 | |
| 48 | typedef std::istreambuf_iterator<wchar_t> I2; |
| 49 | static_assert((std::is_convertible<I2, |
| 50 | std::iterator<std::input_iterator_tag, wchar_t, std::char_traits<wchar_t>::off_type, |
| 51 | wchar_t*, wchar_t> >::value), ""); |
| 52 | static_assert((std::is_same<I2::char_type, wchar_t>::value), ""); |
| 53 | static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), ""); |
| 54 | static_assert((std::is_same<I2::int_type, I2::traits_type::int_type>::value), ""); |
| 55 | static_assert((std::is_same<I2::streambuf_type, std::wstreambuf>::value), ""); |
| 56 | static_assert((std::is_same<I2::istream_type, std::wistream>::value), ""); |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 57 | static_assert((std::is_nothrow_default_constructible<I2>::value), "" ); |
| 58 | static_assert((std::is_trivially_copy_constructible<I2>::value), "" ); |
| 59 | static_assert((std::is_trivially_destructible<I2>::value), "" ); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 60 | } |