operator<<(std::filesystem::directory_entry)

来自cppreference.com


 
 
 
 
template<class CharT, class Traits >

friendstd::basic_ostream<CharT,Traits>&

    operator<<(std::basic_ostream<CharT,Traits>& os, const directory_entry& d );
(C++17 起)

进行目录条目 d 上的流输出。等价于 return os << d.path();

此函数模板对常规的无限定有限定查找不可见,而只能在 std::filesystem::directory_entry 为实参的关联类时由实参依赖查找找到。这阻止 usingnamespace std::filesystem;using 指令存在时不想要的转换。using-指令

目录

[编辑]参数

os - 要进行输出的流
d - 要插入的 directory_entry

[编辑]返回值

os

[编辑]异常

可能会抛出由实现定义的异常。

[编辑]示例

#include <filesystem>#include <iostream>namespace fs = std::filesystem;   int main(){constauto entries ={fs::directory_entry{fs::current_path()}, fs::directory_entry{fs::temp_directory_path()}};   for(const fs::directory_entry& de : entries)std::cout<< de <<'\n';}

可能的输出:

"/home/猫" "/tmp"

[编辑]参阅

进行路径上的流输入及输出
(函数)[编辑]
close