Skip to content

Latest commit

 

History

History
67 lines (56 loc) · 1.48 KB

File metadata and controls

67 lines (56 loc) · 1.48 KB

推論補助

  • ranges[meta header]
  • std::ranges[meta namespace]
  • join_with_view[meta class]
  • function[meta id-type]
  • cpp23[meta cpp]
namespace std::ranges {
  template<class R, class P>
  join_with_view(R&&, P&&) -> join_with_view<views::all_t<R>, views::all_t<P>>;
}

概要

join_with_viewクラステンプレートの型推論補助。

この推論補助によって、元のRangeとパターンが暗黙的にall viewでラップされる。

#include <ranges>
#include <vector>
#include <string>
#include <concepts>

int main() {
  std::vector<std::string> words = {"hello", "world", "join"};
  std::string delimiter = "-";

  std::ranges::join_with_view r1{words, delimiter};
  static_assert(std::same_as<
    decltype(r1),
    std::ranges::join_with_view<
      std::ranges::ref_view<std::vector<std::string>>,
      std::ranges::ref_view<std::string>
    >
  >);

  std::ranges::join_with_view r2{
    std::vector<std::string>{"a", "b", "c"},
    std::string{"--"}
  };
  static_assert(std::same_as<
    decltype(r2),
    std::ranges::join_with_view<
      std::ranges::owning_view<std::vector<std::string>>,
      std::ranges::owning_view<std::string>
    >
  >);
}

出力

バージョン

言語

  • C++23

処理系