blob: 85a70a017976b27efb05cc3dbfc7048ae2230430 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
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 Clowe9d03062015-04-16 21:36:54 +000022//
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 Hinnantbc8d3f92010-05-11 19:42:16 +000026
27#include <iterator>
28#include <type_traits>
Marshall Clowe9d03062015-04-16 21:36:54 +000029#include <string>
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000030
31int 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 Clowe9d03062015-04-16 21:36:54 +000040 static_assert( std::is_trivially_copy_constructible<I1>::value, "");
41 static_assert( std::is_trivially_destructible<I1>::value, "");
42
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000043 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 Clowe9d03062015-04-16 21:36:54 +000050 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 Hinnantbc8d3f92010-05-11 19:42:16 +000056}