范围v3中范围的结构化绑定声明

时间:2019-04-12 06:51:21

标签: c++ c++17 range-v3 structured-bindings

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中有类似的功能吗?

0 个答案:

没有答案
相关问题