std::ranges:: views:: istream, std::ranges:: basic_istream_view, std::ranges:: istream_view, std::ranges:: wistream_view
|
定義済みヘッダー
<ranges>
|
||
|
template
<
std::
movable
Val,
class
CharT,
class
Traits
=
std::
char_traits
<
CharT
>
>
|
(1) | (C++20以降) |
|
ヘルパーテンプレート
|
||
|
template
<
class
Val
>
using istream_view = ranges :: basic_istream_view < Val, char > ; |
(2) | (C++20以降) |
|
template
<
class
Val
>
using wistream_view = ranges :: basic_istream_view < Val, wchar_t > ; |
(3) | (C++20以降) |
|
カスタマイゼーションポイントオブジェクト
|
||
|
namespace
views
{
template
<
class
T
>
|
(4) | (C++20以降) |
|
ヘルパーコンセプト
|
||
|
template
<
class
Val,
class
CharT,
class
Traits
>
concept
/*stream-extractable*/
=
|
(5) | ( 説明専用* ) |
U
は
std::
remove_reference_t
<
decltype
(
e
)
>
である。
U
が
std::
basic_istream
<
typename
U
::
char_type
,
typename
U
::
traits_type
>
から公開かつ明確に派生していない場合、不適格(ill-formed)となり、
置換失敗
が発生する可能性があります。
Val
の左辺値が型
std::
basic_istream
<
CharT, Traits
>
の左辺値から抽出可能な場合に満たされる。
basic_istream_view
のイテレータ型はムーブオンリーです:これは
LegacyIterator
要件を満たさず、したがってC++20以前の
アルゴリズム
では動作しません。
目次 |
カスタマイゼーションポイントオブジェクト
名前
views::istream<T>
は
カスタマイゼーションポイントオブジェクト
を表し、これは
関数オブジェクト
のconstな
リテラル
semiregular
クラス型である。詳細は
CustomizationPointObject
を参照。
データメンバ
| メンバー | 定義 |
std::
basic_istream
<
CharT, Traits
>
*
stream_
|
入力ストリームへのポインタ
( 説明専用メンバーオブジェクト* ) |
Val
value_
|
格納された値
( 説明専用メンバーオブジェクト* ) |
メンバー関数
basic_istream_view
を構築する
(public member function) |
|||
|
イテレータを返す
(公開メンバ関数) |
|||
|
を返す
std::default_sentinel
(公開メンバ関数) |
|||
std::ranges::view_interface から継承 std::ranges::view_interface |
|||
|
(C++23)
|
範囲の先頭を指す定数イテレータを返す
(
std::ranges::view_interface<D>
の公開メンバ関数)
|
||
|
(C++23)
|
範囲の定数イテレータに対するセンチネルを返す
(
std::ranges::view_interface<D>
の公開メンバ関数)
|
||
|
|
(C++23まで) |
std::ranges::basic_istream_view:: basic_istream_view
|
constexpr
explicit
basic_istream_view ( std:: basic_istream < CharT, Traits > & stream ) ; |
(C++20以降) | |
stream_
を
std::
addressof
(
stream
)
で初期化し、
value_
を値初期化します。
std::ranges::basic_istream_view:: begin
|
constexpr
auto
begin
(
)
;
|
(C++20以降) | |
以下と等価:
*
stream_
>>
value_
;
return
iterator
{
*
this
}
;
.
std::ranges::basic_istream_view:: end
|
constexpr
std::
default_sentinel_t
end
(
)
const
noexcept
;
|
(C++20以降) | |
std:: default_sentinel を返します。
ネストされたクラス
basic_istream_view
のイテレータ型
( 説明専用メンバクラス* ) |
例
#include <algorithm> #include <iomanip> #include <iostream> #include <iterator> #include <ranges> #include <sstream> #include <string> int main() { auto words = std::istringstream{"today is yesterday’s tomorrow"}; for (const auto& s : std::views::istream<std::string>(words)) std::cout << std::quoted(s, '/') << ' '; std::cout << '\n'; auto floats = std::istringstream{"1.1 2.2\t3.3\v4.4\f55\n66\r7.7 8.8"}; std::ranges::copy ( std::views::istream<float>(floats), std::ostream_iterator<float>{std::cout, ", "} ); std::cout << '\n'; }
出力:
/today/ /is/ /yesterday’s/ /tomorrow/ 1.1, 2.2, 3.3, 4.4, 55, 66, 7.7, 8.8,
欠陥報告
以下の動作変更欠陥報告書は、以前に公開された C++ 標準に対して遡及的に適用されました。
| DR | Applied to | Behavior as published | Correct behavior |
|---|---|---|---|
| LWG 3568 | C++20 | P2325R3 accidentally made the stored value default-initialized | restored to value-initialization |
| P2325R3 | C++20 |
default constructor was provided as
view
must be
default_initializable
|
removed along with
the requirement |
| P2432R1 | C++20 |
ranges::istream_view
was a function template
and did not follow the naming convention |
made an alias template;
customization point objects added |
関連項目
|
std::basic_istream
から読み込む入力イテレータ
(クラステンプレート) |