Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 1.33 KB

File metadata and controls

60 lines (47 loc) · 1.33 KB

コンストラクタ

  • ranges[meta header]
  • std::ranges[meta namespace]
  • join_with_view[meta class]
  • function[meta id-type]
  • cpp23[meta cpp]
join_with_view()
  requires default_initializable<V> && default_initializable<Pattern> = default; // (1) C++23

constexpr explicit join_with_view(V base, Pattern pattern);                      // (2) C++23

概要

join_with_viewオブジェクトを構築する。

  • (1) : デフォルト構築
  • (2) : 元となるviewとデリミタパターンを指定して構築

効果

  • (1) : base_pattern_をデフォルト構築する
  • (2) : base_std::move(base)で、pattern_std::move(pattern)で初期化する

#include <iostream>
#include <ranges>
#include <vector>
#include <string>

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

  std::ranges::join_with_view view{words, delimiter};
  for (char c : view) {
    std::cout << c;
  }
  std::cout << std::endl;
}
  • join_with_view[color ff0000]

出力

hello-world-join

バージョン

言語

  • C++23

処理系