更新时间:2023-11-12 10:47:52
您正在寻找的是
auto b=std::ranges::to<std::vector>(std::ranges::iota_view(0, 5));
不幸的是,提案错过了C ++ 20,仅仅是因为没有时间审查其措辞(在之前的版本中添加了您尝试过的构造函数不可行)。希望它将在C ++ 23周期的早期合并并实现。
Unfortunately, that proposal missed C++20 simply because there wasn’t time to review its wording (after a previous version that added the constructor you tried was found unworkable). Hopefully it’ll be merged—and implemented—early in the C++23 cycle.