Namespaces
Variants

operator<<,>> (std::experimental::filesystem::path)

From cppreference.net
template < class CharT, class Traits >

std:: basic_ostream < CharT,Traits > &

operator << ( std:: basic_ostream < CharT,Traits > & os, const path & p ) ;
(1) (文件系统 TS)
template < class CharT, class Traits >

std:: basic_istream < CharT,Traits > &

operator >> ( std:: basic_istream < CharT,Traits > & is, path & p ) ;
(2) (文件系统 TS)

对路径 p 执行流输入或输出操作。使用 std:: quoted 是为了确保当后续通过流输入运算符读取时,空格不会导致截断。

目录

参数

os - 执行输出操作的流
is - 执行输入操作的流
p - 要插入或提取的路径

返回值

1) os
2) is

异常

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

可能的实现

第一版本
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;
}
第二版本
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;
}

示例