命名空间
变体
操作

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

来自 cppreference.cn
 
 
 
 
template< class CharT, class Traits >

friend std::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` 是参数的关联类时,才能通过实参依赖查找找到。这避免了在存在 using namespace std::filesystem; using 指令时发生不期望的转换。

目录

[编辑] 参数

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

[编辑] 返回值

os

[编辑] 异常

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

[编辑] 示例

#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;
 
int main()
{
    const auto 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"

[编辑] 参阅

对带引号的路径执行流输入和输出
(函数) [编辑]