- ranges[meta header]
- std::ranges[meta namespace]
- class template[meta id-type]
- cpp20[meta cpp]
namespace std::ranges {
template<input_range V>
requires view<V> && input_range<range_reference_t<V>>
class join_view : public view_interface<join_view<V>> { …… }; // (1)
namespace views {
inline constexpr /*unspecified*/ join = /*unspecified*/; // (2)
}
}
- input_range[link input_range.md]
- view[link view.md]
- range_reference_t[link range_reference_t.md]
- (1): 要素がRangeであるRangeの各要素を繋げて1つのRangeとして扱う
view
- (2):
join_view
を生成するRangeアダプタオブジェクト
borrowed |
sized |
output |
input |
forward |
bidirectional |
random_access |
contiguous |
common |
viewable |
view |
|
|
|
〇 |
(1) |
(2) |
|
|
(3) |
○ |
○ |
外側RangeとはV
のことであり、内側Rangeとはrange_reference_t<V>
のことである。const
の場合V
をconst V
として同様。
- (2): 式
views::join(E)
の効果はjoin_view{E}
と等しい。
名前 |
説明 |
対応バージョン |
empty |
Rangeが空かどうかを判定する |
C++20 |
operator bool |
Rangeが空でないかどうかを判定する |
C++20 |
front |
先頭要素への参照を取得する |
C++20 |
back |
末尾要素への参照を取得する |
C++20 |
cbegin |
定数イテレータを取得する |
C++23 |
cend |
定数イテレータ(番兵)を取得する |
C++23 |
#include <ranges>
#include <vector>
#include <string>
#include <iostream>
int main() {
using namespace std;
vector<string> sv = {"hello", "world"};
for (char c : sv | views::join) {
cout << c << ',';
}
cout << '\n';
}
- views::join[color ff0000]
h,e,l,l,o,w,o,r,l,d,
ネストされた char
のRangeが平坦な char
のRangeになっている。
- Clang: 13.0.0 [mark verified]
- GCC: 10.1.0 [mark verified]
- ICC: ?
- Visual C++: 2019 Update 10 [mark verified]