3

c++2a 工作草案具有std::ranges::subrange实用程序,可以将范围和视图解压缩为迭代器和哨兵;例如:

std::optional<int> foo(std::vector<int> const &v, std::size_t const n)
{
  auto [it, e] = std::ranges::subrange(v | std::ranges::view::drop(n));

  it = std::ranges::find_if(it, e, [](auto const i) { return i % 2 == 0; });
  if (it == e)
    return {};
  return {*it};
}

range-v3 中是否有类似的设施?

4

0 回答 0