[libcxx] <iterator> header dependencies

Hi, all.

I noticed several issues with missing header dependencies. Specifically the following code compiles with libstdc++ but not libc++:

$ cat istream-1.cc
#include
typedef std::istreambuf_iterator iter;

bool foo(const iter& a, const iter& b)
{
return a == b;
}

$ clang++ -stdlib=libc++ istream-1.cc
In file included from istream-1.cc:1:
/opt/data/llvm/install/bin/…/include/c++/v1/iterator:948:32: error: implicit instantiation of undefined template ‘std::__1::char_traits’
typename _Traits::off_type, _CharT*,
^
istream-1.cc:6:14: note: in instantiation of template class ‘std::__1::istreambuf_iterator<char, std::__1::char_traits >’ requested here
return a == b;
^
/opt/data/llvm/install/bin/…/include/c++/v1/iosfwd:100:53: note: template is declared here
template struct _LIBCPP_TEMPLATE_VIS char_traits;

(snip)

I.e., the definition of char_traits is missing. It can be fixed by including the <__string> header, but then it would fail due to missing std::basic_streambuf. Including will make the code compile.

Two more issues:

$ cat iostream-iter.cc

#include
typedef std::istream_iterator<char, char> istream_iter;
typedef std::ostream_iterator<char, char> ostream_iter;

void foo(istream_iter::istream_type& stream)
{
istream_iter iter(stream);
}

void bar(ostream_iter::ostream_type) { }

$ clang++ -stdlib=libc++ iostream-iter.cc
iostream-iter.cc:10:36: error: implicit instantiation of undefined template ‘std::__1::basic_ostream<char, std::__1::char_traits >’
void bar(ostream_iter::ostream_type) { }
^
/opt/data/llvm/install/bin/…/include/c++/v1/iosfwd:111:32: note: template is declared here
class _LIBCPP_TEMPLATE_VIS basic_ostream;
^
In file included from iostream-iter.cc:1:
/opt/data/llvm/install/bin/…/include/c++/v1/iterator:892:33: error: invalid operands to binary expression (‘std::__1::istream_iterator<char, char, std::__1::char_traits, long>::istream_type’
(aka ‘basic_istream<char, std::__1::char_traits >’) and ‘int’)
if (!(*_in_stream >> _value))

iostream-iter.cc:7:18: note: in instantiation of member function 'std::__1::istream_iterator<char, char, std::__1::char_traits<char>, long>::istream_iterator' requested here
istream_iter iter(stream);
^
2 errors generated.

Here foo requires the definitions of basic_istream::operator>> (for fundamental types) to be available, and bar requires basic_ostream copy c-tor (note that the stream is passed by value). These errors can be fixed by including <istream> and <ostream> respectively.

My question is: should these headers be included into <iterator> or am I missing some wording in the C++ standard, that requires the user to include them?