名稱空間
變體
操作

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

來自 cppreference.com
< cpp‎ | experimental‎ | fs‎ | path
 
 
實驗性
技術規範
檔案系統庫 (檔案系統 TS)
庫基礎 (庫基礎 TS)
庫基礎 2 (庫基礎 TS v2)
庫基礎 3 (庫基礎 TS v3)
並行性擴充套件 (並行性 TS)
並行性擴充套件 2 (並行性 TS v2)
併發性擴充套件 (併發性 TS)
併發擴充套件 2 (concurrency TS v2)
概念 (概念 TS)
範圍 (範圍 TS)
反射 (反射 TS)
數學特殊函式 (特殊函式 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) (檔案系統 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;
}

[編輯] 示例