我找到了这个页面,描述了c ++ 14和c ++ 17之间的变化:
https://isocpp.org/files/papers/p0636r0.html
...它链接到此页面,该页面描述了建议的文件系统更改:
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0218r0.html
我浏览了它.也有小的措辞改变为标准,但唯一的代码改变我看到的是那个去掉了"实验"和"V1"部分命名空间的变化,所以"的std ::实验::文件系统:: V1"变成了"的std ::文件系统",这是预料之中的.
据我所知,命名空间路径以外的任何内容都没有改变.有没有人知道是否有其他变化?
换句话说,我正在使用gcc和-std = c ++ 14.我现在可以用std :: experimental :: filesystem编写代码,并且将来只需更改这个命名空间就可以轻松切换到-std = c ++ 17吗?
我可以找到最重要的问题是重复:
我试图包含<filesystem>,但是当我使用命名空间时,它显示此错误:
std:: 没有成员“文件系统”
我知道在以前是这样<experimental/filesystem>,命名空间是 std::experimental::filesystem;
但是,当我这样做时,它也会给出这样的错误:
#error The <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft \
and will be REMOVED. It is superseded by the C++17 <filesystem> header providing std::filesystem. \
You can define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING to acknowledge that you have received this warning.
Run Code Online (Sandbox Code Playgroud)
我使用的是 Visual Studio 2019,C/C++ 语言设置设置为最新版本。
那么是什么原因导致了这个问题呢?
编辑1:导致错误的所有代码:
#include <iostream>
#include <Windows.h>
#include <filesystem>
namespace fs = std::filesystem;
int main() {
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编辑2:所有旧代码也有错误:
#include <iostream>
#include <Windows.h>
#include <experimental/filesystem>
namespace fs …Run Code Online (Sandbox Code Playgroud)