[libcxx-commits] [PATCH] D133560: [libc++] split `<istream>` header

Hui via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 16 14:48:20 PDT 2022


huixie90 added a comment.

In D133560#3796745 <https://reviews.llvm.org/D133560#3796745>, @ldionne wrote:

> The approach we generally take is to create a `libcxx/include/__fwd/foo.h` header. Would that work here?

Do you mean by creating a header that only contains the forward declaration like

  template <class _Chart>
  class basic_istream;

But the `std::ranges::istream_view` class itself has a constraint that `>>` needs to be valid

  template <class _Val, class _CharT, class _Traits>
  concept __stream_extractable = requires(basic_istream<_CharT, _Traits>& __is, _Val& __t) { __is >> __t; };
  
  template <movable _Val, class _CharT, class _Traits = char_traits<_CharT>>
    requires default_initializable<_Val> && __stream_extractable<_Val, _CharT, _Traits>
  class basic_istream_view; 

That means the declaration of `basic_istream_view` already requires all the member `>>` and free `>>` from the `basic_istream`. So only a forward declaration of `basic_istream` isn't enough.

And this is the main reason I made the `basic_istream.h` header contains all the `>>` declarations.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133560/new/

https://reviews.llvm.org/D133560



More information about the libcxx-commits mailing list