operator<<(std::filesystem::directory_entry)
From cppreference.com
< cpp | filesystem | directory entry
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
std::filesystem::directory_entry
Member functions
Modifiers
Observers
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
Non-member functions
operator<<
template< class CharT, class Traits >
(since C++17)
friend std::basic_ostream <CharT,Traits>&
Performs stream output on the directory entry d. Equivalent to return os << d.path();.
This function template is not visible to ordinary unqualified or qualified lookup, and can only be found by argument-dependent lookup when std::filesystem::directory_entry is an associated class of the arguments. This prevents undesirable conversions in the presence of a using namespace std::filesystem; using-directive.
[edit] Parameters
os
-
stream to perform output on
d
-
directory_entry
to be inserted
[edit] Return value
os
[edit] Exceptions
May throw implementation-defined exceptions.
[edit] Example
Run this code
#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'; }
Possible output:
"/home/猫" "/tmp"