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 T, class charT = char, class traits = char_traits<charT>, |
| 13 | // class Distance = ptrdiff_t> |
| 14 | // class istream_iterator |
| 15 | // : public iterator<input_iterator_tag, T, Distance, const T*, const T&> |
| 16 | // { |
| 17 | // public: |
| 18 | // typedef charT char_type; |
| 19 | // typedef traits traits_type; |
| 20 | // typedef basic_istream<charT,traits> istream_type; |
| 21 | // ... |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 22 | // |
| 23 | // If T is a literal type, then the default constructor shall be a constexpr constructor. |
| 24 | // If T is a literal type, then this constructor shall be a trivial copy constructor. |
| 25 | // If T is a literal type, then this destructor shall be a trivial destructor. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 26 | |
| 27 | #include <iterator> |
| 28 | #include <type_traits> |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 29 | #include <string> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 30 | |
| 31 | int main() |
| 32 | { |
| 33 | typedef std::istream_iterator<double> I1; |
| 34 | static_assert((std::is_convertible<I1, |
| 35 | std::iterator<std::input_iterator_tag, double, std::ptrdiff_t, |
| 36 | const double*, const double&> >::value), ""); |
| 37 | static_assert((std::is_same<I1::char_type, char>::value), ""); |
| 38 | static_assert((std::is_same<I1::traits_type, std::char_traits<char> >::value), ""); |
| 39 | static_assert((std::is_same<I1::istream_type, std::istream>::value), ""); |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 40 | static_assert( std::is_trivially_copy_constructible<I1>::value, ""); |
| 41 | static_assert( std::is_trivially_destructible<I1>::value, ""); |
| 42 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 43 | typedef std::istream_iterator<unsigned, wchar_t> I2; |
| 44 | static_assert((std::is_convertible<I2, |
| 45 | std::iterator<std::input_iterator_tag, unsigned, std::ptrdiff_t, |
| 46 | const unsigned*, const unsigned&> >::value), ""); |
| 47 | static_assert((std::is_same<I2::char_type, wchar_t>::value), ""); |
| 48 | static_assert((std::is_same<I2::traits_type, std::char_traits<wchar_t> >::value), ""); |
| 49 | static_assert((std::is_same<I2::istream_type, std::wistream>::value), ""); |
Marshall Clow | e9d0306 | 2015-04-16 21:36:54 +0000 | [diff] [blame] | 50 | static_assert( std::is_trivially_copy_constructible<I2>::value, ""); |
| 51 | static_assert( std::is_trivially_destructible<I2>::value, ""); |
| 52 | |
| 53 | typedef std::istream_iterator<std::string> I3; |
| 54 | static_assert(!std::is_trivially_copy_constructible<I3>::value, ""); |
| 55 | static_assert(!std::is_trivially_destructible<I3>::value, ""); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 56 | } |