我找到了range-v3库,并尝试遵循https://ericniebler.github.io/range-v3/index.html中的示例
我使用的是visual studio 2019,我通过vcpkg安装了range-v3库,但是...我在range::views nameaspace中找不到任何函数。什么问题?
在空项目中,我在命令行选项中添加了/std:c++latest /permissive-和/experimental:preprocessor,并包含了range/v3/all.hpp。我错过了什么吗?
std::vector<int> const vi{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
using namespace ranges;
auto rng = vi | views::remove_if([](int i) { return i % 2 == 1; }) // ican't find remove_if function
| views::transform([](int i) { return std::to_string(i); });
// rng == {"2","4","6","8","10"};
return 0;发布于 2020-01-05 04:18:23
因为vcpkg发布了range-v3的早期版本,它将内容放在ranges::view名称空间中。除此之外,还有许多其他的区别。请参考vcpkg版本附带的文档,祝您好运。
发布于 2020-01-05 08:17:04
vcpkg是一个很好的想法,但大多数端口在几个月后就过时了: boost、fmt、range-v3……
只需手动从Eric的github页面下载当前版本,并将路径设置为include文件夹-您不需要vcpkg作为仅用于头文件的库。
https://stackoverflow.com/questions/59589008
复制相似问题