|
| 1 | +# 推論補助 |
| 2 | +* ranges[meta header] |
| 3 | +* std::ranges[meta namespace] |
| 4 | +* function[meta id-type] |
| 5 | +* cpp23[meta cpp] |
| 6 | + |
| 7 | +```cpp |
| 8 | +namespace std::ranges { |
| 9 | + template<class R, class P> |
| 10 | + join_with_view(R&&, P&&) -> join_with_view<views::all_t<R>, views::all_t<P>>; |
| 11 | +} |
| 12 | +``` |
| 13 | +
|
| 14 | +## 概要 |
| 15 | +
|
| 16 | +[`join_with_view`](../join_with_view.md)クラステンプレートの型推論補助。 |
| 17 | +
|
| 18 | +この推論補助によって、元のRangeとパターンが暗黙的に[all view](../all.md)でラップされる。 |
| 19 | +
|
| 20 | +## 例 |
| 21 | +```cpp example |
| 22 | +#include <ranges> |
| 23 | +#include <vector> |
| 24 | +#include <string> |
| 25 | +#include <concepts> |
| 26 | +
|
| 27 | +int main() { |
| 28 | + std::vector<std::string> words = {"hello", "world", "join"}; |
| 29 | + std::string delimiter = "-"; |
| 30 | +
|
| 31 | + std::ranges::join_with_view r1{words, delimiter}; |
| 32 | + static_assert(std::same_as< |
| 33 | + decltype(r1), |
| 34 | + std::ranges::join_with_view< |
| 35 | + std::ranges::ref_view<std::vector<std::string>>, |
| 36 | + std::ranges::ref_view<std::string> |
| 37 | + > |
| 38 | + >); |
| 39 | +
|
| 40 | + std::ranges::join_with_view r2{ |
| 41 | + std::vector<std::string>{"a", "b", "c"}, |
| 42 | + std::string{"--"} |
| 43 | + }; |
| 44 | + static_assert(std::same_as< |
| 45 | + decltype(r2), |
| 46 | + std::ranges::join_with_view< |
| 47 | + std::ranges::owning_view<std::vector<std::string>>, |
| 48 | + std::ranges::owning_view<std::string> |
| 49 | + > |
| 50 | + >); |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +### 出力 |
| 55 | +``` |
| 56 | +``` |
| 57 | + |
| 58 | +## バージョン |
| 59 | +### 言語 |
| 60 | +- C++23 |
| 61 | + |
| 62 | +### 処理系 |
| 63 | +- [Clang](/implementation.md#clang): ?? |
| 64 | +- [GCC](/implementation.md#gcc): 13.2 [mark verified] |
| 65 | +- [ICC](/implementation.md#icc): ?? |
| 66 | +- [Visual C++](/implementation.md#visual_cpp): ?? |
0 commit comments