operator<<,>>(std::filesystem::path) (3) - Linux Manuals
operator<<,>>(std::filesystem::path): operator<<,>>(std::filesystem::path)
Command to display operator<<,>>(std::filesystem::path)
manual in Linux: $ man 3 operator<<,>>(std::filesystem::path)
NAME
operator<<,>>(std::filesystem::path) - operator<<,>>(std::filesystem::path)
Synopsis
template< class CharT, class Traits >
std::basic_ostream<CharT,Traits>& (1) (since C++17)
operator<<( std::basic_ostream<CharT,Traits>& os, const std::filesystem::path& p );
template< class CharT, class Traits >
std::basic_istream<CharT,Traits>& (2) (since C++17)
operator>>( std::basic_istream<CharT,Traits>& is, std::filesystem::path& p );
Performs stream input or output on the path p. std::quoted is used so that spaces do not cause truncation when later read by stream input operator.
These function templates are not visible to ordinary unqualified or qualified_lookup , and can only be found by argument-dependent_lookup when std::filesystem::path is an associated class of the arguments. This prevents undesirable conversions in the presence of a using namespace std::filesystem; using-directive.
Parameters
os - stream to perform output on
is - stream to perform input on
p - path to insert or extract
Return value
1) os
2) is
Exceptions
(none)
Defect reports
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR Applied to Behavior as published Correct behavior
LWG_2989 C++17 allowed insertion of everything convertible to path in the presence of a using-directive made hidden friend
Possible implementation
First version
template< class CharT, class Traits >
std::basic_ostream<CharT,Traits>&
operator<<( std::basic_ostream<CharT,Traits>& os, const path& p )
{
os << std::quoted(p.string<CharT,Traits>());
return os;
}
Second version
template< class CharT, class Traits >
std::basic_istream<CharT,Traits>&
operator>>( std::basic_istream<CharT,Traits>& is, path& p )
{
std::basic_string<CharT, Traits> t;
is >> std::quoted(t);
p = t;
return is;
}
Example
// Run this code
#include <iostream>
#include <filesystem>
int main()
{
std::cout << std::filesystem::current_path() << '\n';
}
Possible output:
"/home/user"
Pages related to operator<<,>>(std::filesystem::path)
- operator<<,>>(std::fisher_f_distribution) (3) - operator<<,>>(std::fisher_f_distribution)
- operator<<,>>(std::basic_string) (3) - operator<<,>>(std::basic_string)
- operator<<,>>(std::bernoulli_distribution) (3) - operator<<,>>(std::bernoulli_distribution)
- operator<<,>>(std::binomial_distribution) (3) - operator<<,>>(std::binomial_distribution)
- operator<<,>>(std::bitset) (3) - operator<<,>>(std::bitset)
- operator<<,>>(std::cauchy_distribution) (3) - operator<<,>>(std::cauchy_distribution)
- operator<<,>>(std::chi_squared_distribution) (3) - operator<<,>>(std::chi_squared_distribution)
- operator<<,>>(std::complex) (3) - operator<<,>>(std::complex)
- operator<<,>>(std::discard_block_engine) (3) - operator<<,>>(std::discard_block_engine)
- operator<<,>>(std::discrete_distribution) (3) - operator<<,>>(std::discrete_distribution)
- operator<<,>>(std::experimental::filesystem::path) (3) - operator<<,>>(std::experimental::filesystem::path)
- operator<<,>>(std::exponential_distribution) (3) - operator<<,>>(std::exponential_distribution)
- operator<<,>>(std::extreme_value_distribution) (3) - operator<<,>>(std::extreme_value_distribution)
- operator<<,>>(std::gamma_distribution) (3) - operator<<,>>(std::gamma_distribution)
- operator<<,>>(std::geometric_distribution) (3) - operator<<,>>(std::geometric_distribution)
- operator<<,>>(std::independent_bits_engine) (3) - operator<<,>>(std::independent_bits_engine)
- operator<<,>>(std::linear_congruential_engine) (3) - operator<<,>>(std::linear_congruential_engine)
- operator<<,>>(std::lognormal_distribution) (3) - operator<<,>>(std::lognormal_distribution)
- operator<<,>>(std::mersenne_twister_engine) (3) - operator<<,>>(std::mersenne_twister_engine)
- operator<<,>>(std::negative_binomial_distribution) (3) - operator<<,>>(std::negative_binomial_distribution)
- operator<<,>>(std::normal_distribution) (3) - operator<<,>>(std::normal_distribution)
- operator<<,>>(std::piecewise_constant_distribution) (3) - operator<<,>>(std::piecewise_constant_distribution)
- operator<<,>>(std::piecewise_linear_distribution) (3) - operator<<,>>(std::piecewise_linear_distribution)