ranges::subrange 在编译器资源管理器的 MSVC 中
ranges::subrange in MSVC on Compiler Explorer
下面的代码可以正常编译和运行with GCC 8.3 and with Clang 10.0.1, whereas it fails miserably on MicroSoft shiny compiler。
#include <vector>
#include <range/v3/view/group_by.hpp>
int main(){
std::vector<int> edits{1,1,3,2,2,4,4,4,4,1,1,3,3,2};
auto xxx = ranges::subrange(edits.begin(), edits.end());
}
有没有我遗漏的标志?
您指定了 /std:c++17
和 ranges::subrange
is not present in C++ 17。 Ranges-v3 还需要 C++ 20,因为它使用概念。
使用 /std:c++latest
编译成功。
错误原来是来自 Ranges v3 中捆绑的 Concepts 仿真层,它显然无法在最新的 Visual C++ 的 C++17 模式下正常工作。根据文档,它需要实验性的编译器选项,即使它确实可以工作,所以最好在使用 Microsoft 的编译器时打开 C++ 20 支持。
下面的代码可以正常编译和运行with GCC 8.3 and with Clang 10.0.1, whereas it fails miserably on MicroSoft shiny compiler。
#include <vector>
#include <range/v3/view/group_by.hpp>
int main(){
std::vector<int> edits{1,1,3,2,2,4,4,4,4,1,1,3,3,2};
auto xxx = ranges::subrange(edits.begin(), edits.end());
}
有没有我遗漏的标志?
您指定了 /std:c++17
和 ranges::subrange
is not present in C++ 17。 Ranges-v3 还需要 C++ 20,因为它使用概念。
使用 /std:c++latest
编译成功。
错误原来是来自 Ranges v3 中捆绑的 Concepts 仿真层,它显然无法在最新的 Visual C++ 的 C++17 模式下正常工作。根据文档,它需要实验性的编译器选项,即使它确实可以工作,所以最好在使用 Microsoft 的编译器时打开 C++ 20 支持。