【发布时间】:2020-09-05 07:32:36
【问题描述】:
如果我有这样的文件,一切都会按预期进行:
#include <filesystem>
#include <iostream>
int main() {
std::filesystem::path o = "C:\\Windows\\write.exe";
auto s = o.parent_path();
std::cout << s << std::endl;
}
但是,如果可能的话,我想使用这样的一行:
filesystem::path o = "C:\\Windows\\write.exe";
我试过了,但我得到一个错误:
// using-declaration may not name namespace 'std::filesystem'
using std::filesystem;
这也是错误的:
using namespace std::filesystem;
// error: 'filesystem' has not been declared
filesystem::path o = "C:\\Windows\\write.exe";
有可能做我正在尝试的事情吗?
【问题讨论】:
标签: c++ namespaces c++17 using