Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/138.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;-“无操作员”<<&引用;匹配这些操作数目录\迭代器()_C++_Visual Studio 2017 - Fatal编程技术网

C++ C++;-“无操作员”<<&引用;匹配这些操作数目录\迭代器()

C++ C++;-“无操作员”<<&引用;匹配这些操作数目录\迭代器(),c++,visual-studio-2017,C++,Visual Studio 2017,我已经在上复制了示例代码,所以我有: #include "pch.h" //for visual studios benefit #include <fstream> #include <iostream> #include <filesystem> namespace fs = std::filesystem; int main() { fs::create_directories("sandbox/a/b"); std::ofstream

我已经在上复制了示例代码,所以我有:

#include "pch.h" //for visual studios benefit
#include <fstream>
#include <iostream>
#include <filesystem>
namespace fs = std::filesystem;

int main()
{
    fs::create_directories("sandbox/a/b");
    std::ofstream("sandbox/file1.txt");
    std::ofstream("sandbox/file2.txt");
    for (auto& p : fs::directory_iterator("sandbox"))
        std::cout << p << '\n'; //this line on the first '<<' is where the error occurs
    fs::remove_all("sandbox");
    return 0; //included by me
}
#包括“pch.h”/
#包括
#包括
#包括
名称空间fs=std::filesystem;
int main()
{
创建目录(“沙盒/a/b”);
std::ofstream(“sandbox/file1.txt”);
std::ofstream(“sandbox/file2.txt”);
for(auto&p:fs::directory\u迭代器(“沙盒”))
std::cout对于Visual Studio 2017(如果我没有弄错的话,请参阅15.8和15.9),
文件系统
仅公开实验版本,因此请使用:

namespace fs = std::experimental::filesystem;
更改此项:

namespace fs = std::filesystem;
为此:

namespace fs = std::experimental::filesystem;

因为VS 17使用了一个实验版本的
文件系统

使用
std::experimental
命名空间:

namespace fs = std::experimental::filesystem;

directory\u entry
没有直接的流媒体支持;它通过
path
操作符获取。嘿,彼得,我相信你是对的,但我看不出这个答案比我的答案和Matthieu的答案更进一步。:/嗯,在阅读了你的T.C之后,我现在不确定是否正确,回答很好!我不知道我是否能够确定是否使用
path()
实验性
namspace比另一个更正确。因此,我不会接受答案,直到我对主题有了更多的了解。但是,它们都可以工作,呈现稍微不同的输出。使用
path()
将呈现“”在每个查找周围,而
实验性
名称空间将不会。但是数据仍然是相同的。
实验性
为您提供了较旧的文件系统TS实现,它是。
namespace fs = std::experimental::filesystem;