std::ranges:: views:: repeat, std::ranges:: repeat_view
|
ヘッダーで定義
<ranges>
|
||
|
template
<
std::
move_constructible
W,
std::
semiregular
Bound
=
std::
unreachable_sentinel_t
>
|
(1) | (C++23以降) |
|
namespace
views
{
inline
constexpr
/* 未規定 */
repeat
=
/* 未規定 */
;
|
(2) | (C++23以降) |
|
呼び出しシグネチャ
|
||
|
template
<
class
W
>
requires
/* 下記参照 */
|
(C++23以降) | |
|
template
<
class
W,
class
Bound
>
requires
/* 下記参照 */
|
(C++23以降) | |
|
ヘルパーコンセプト
|
||
|
concept
/*integer-like-with-usable-difference-type*/
=
/*is-signed-integer-like*/
<
T
>
||
|
(3) | ( 説明専用* ) |
repeat_view
は
random_access_range
をモデル化します。
Bound
が
std::unreachable_sentinel_t
でない場合、
repeat_view
はさらに
sized_range
と
common_range
もモデル化します。
目次 |
カスタマイゼーションポイントオブジェクト
views::repeat
は
カスタマイゼーションポイントオブジェクト
を表し、これは
関数オブジェクト
の const な
リテラル
semiregular
クラス型です。詳細は
CustomizationPointObject
を参照してください。
データメンバ
| メンバー | 定義 |
movable-box
<
W
>
value_
|
ビューの繰り返し要素
( 説明専用メンバーオブジェクト* ) |
Bound
bound_
|
センチネル値
( 説明専用メンバーオブジェクト* ) |
メンバー関数
repeat_view
を作成する
(public member function) |
|
repeat_view
の先頭イテレータを取得する
(public member function) |
|
repeat_view
の終端を示すセンチネルを取得する
(public member function) |
|
repeat_view
のサイズを取得する(サイズ指定可能な場合)
(public member function) |
|
std::ranges::view_interface から継承 |
|
派生ビューが空かどうかを返す(
sized_range
または
forward_range
を満たす場合のみ提供)
(
std::ranges::view_interface<D>
のpublic member function)
|
|
|
(C++23)
|
範囲の先頭を指す定数イテレータを返す
(
std::ranges::view_interface<D>
のpublic member function)
|
|
(C++23)
|
範囲の定数イテレータのセンチネルを返す
(
std::ranges::view_interface<D>
のpublic member function)
|
|
派生ビューが空でないかどうかを返す(
ranges::empty
が適用可能な場合のみ提供)
(
std::ranges::view_interface<D>
のpublic member function)
|
|
派生ビューの先頭要素を返す(
forward_range
を満たす場合に提供)
(
std::ranges::view_interface<D>
のpublic member function)
|
|
派生ビューの末尾要素を返す(
bidirectional_range
かつ
common_range
を満たす場合のみ提供)
(
std::ranges::view_interface<D>
のpublic member function)
|
|
派生ビューの
n
番目
の要素を返す(
random_access_range
を満たす場合のみ提供)
(
std::ranges::view_interface<D>
のpublic member function)
|
|
std::ranges::repeat_view:: repeat_view
|
repeat_view
(
)
requires
std::
default_initializable
<
W
>
=
default
;
|
(1) | (C++23以降) |
|
constexpr
explicit
repeat_view
(
const
W
&
value, Bound bound
=
Bound
(
)
)
;
|
(2) | (C++23以降) |
|
constexpr
explicit
repeat_view
(
W
&&
value, Bound bound
=
Bound
(
)
)
;
|
(3) | (C++23以降) |
|
template
<
class
...
WArgs
,
class
...
BoundArgs
>
requires
std::
constructible_from
<
W, WArgs...
>
|
(4) | (C++23以降) |
value_
を
std::
make_from_tuple
<
T
>
(
std
::
move
(
value_args
)
)
で初期化し、
bound_
を
std::
make_from_tuple
<
Bound
>
(
std
::
move
(
bound_args
)
)
で初期化します。
パラメータ
| value | - | 繰り返し生成される値 |
| bound | - | 境界値 |
| value_args | - |
value_
の初期化子を含むタプル
|
| bound_args | - |
bound_
の初期化子を含むタプル
|
std::ranges::repeat_view:: begin
|
constexpr
/*iterator*/
begin
(
)
const
;
|
(C++23以降) | |
iterator
(
std::
addressof
(
*
value_
)
)
を返します。
std::ranges::repeat_view:: end
|
constexpr
/*iterator*/
end
(
)
const
requires ( ! std:: same_as < Bound, std:: unreachable_sentinel_t > ) ; |
(1) | (since C++23) |
|
constexpr
std::
unreachable_sentinel_t
end
(
)
const
;
|
(2) | (since C++23) |
std::ranges::repeat_view:: size
|
constexpr
auto
size
(
)
const
requires ( ! std:: same_as < Bound, std:: unreachable_sentinel_t > ) ; |
(C++23以降) | |
to-unsigned-like
(
bound_
)
を返します。
推論ガイド
|
template
<
class
W,
class
Bound
=
std::
unreachable_sentinel_t
>
repeat_view ( W, Bound = Bound ( ) ) - > repeat_view < W, Bound > ; |
(C++23以降) | |
ネストされたクラス
|
イテレータ型
( 説明専用メンバクラス* ) |
注記
| 機能テスト マクロ | 値 | 標準 | 機能 |
|---|---|---|---|
__cpp_lib_ranges_repeat
|
202207L
|
(C++23) |
std::ranges::repeat_view
|
例
#include <iostream> #include <ranges> #include <string_view> using namespace std::literals; int main() { // 境界付きオーバーロード for (auto s : std::views::repeat("C++"sv, 3)) std::cout << s << ' '; std::cout << '\n'; // 境界なしオーバーロード for (auto s : std::views::repeat("I know that you know that"sv) | std::views::take(3)) std::cout << s << ' '; std::cout << "...\n"; }
出力:
C++ C++ C++ I know that you know that I know that you know that I know that you know that ...
不具合報告
以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。
| DR | 適用対象 | 公開時の動作 | 正しい動作 |
|---|---|---|---|
| LWG 4053 | C++20 |
views::repeat
の単項呼び出しで
引数のdecayが行われなかった |
引数をdecayする |
| LWG 4054 | C++20 |
repeat_view
で
views::repeat
を呼び出した場合、
ネストした
repeat_view
が
作成されなかった |
ネストした
repeat_view
を作成する
|
関連項目
|
(C++20)
|
view
初期値を繰り返しインクリメントして生成されるシーケンスからなる
(クラステンプレート) (カスタマイゼーションポイントオブジェクト) |