operator<<(std::filesystem::directory_entry)
来自 cppreference.cn
< cpp | filesystem | directory entry
template< class CharT, class Traits > friend std::basic_ostream<CharT,Traits>& |
(since 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"
[编辑] 参见
(C++17) |
对带引号的路径执行流输入和输出 (函数) |