命名空间
变体
操作

运算符<<,>>(std::experimental::filesystem::path)

来自 cppreference.cn
< cpp‎ | experimental‎ | fs‎ | path
 
 
实验性
技术规范
文件系统库 (filesystem TS)
库基础 (library fundamentals TS)
库基础 2 (library fundamentals TS v2)
库基础 3 (library fundamentals TS v3)
并行性扩展 (parallelism TS)
并行性扩展 2 (parallelism TS v2)
并发性扩展 (concurrency TS)
并发性扩展 2 (concurrency TS v2)
概念 (concepts TS)
范围 (ranges TS)
反射 (reflection TS)
数学特殊函数 (special functions TR)
实验性非 TS
模式匹配
线性代数
std::execution
契约
2D 图形
 
 
 
template< class CharT, class Traits >

std::basic_ostream<CharT,Traits>&

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

std::basic_istream<CharT,Traits>&

    operator>>( std::basic_istream<CharT,Traits>& is, path& p );
(2) (filesystem 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;
}

[编辑] 示例