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) (Filesystem TS)
template < class CharT, class Traits >

std:: basic_istream < CharT,Traits > &

operator >> ( std:: basic_istream < CharT,Traits > & is, path & p ) ;
(2) (Filesystem TS)

Führt Stream-Eingabe oder -Ausgabe auf dem Pfad p durch. std:: quoted wird verwendet, damit Leerzeichen keine Trunkierung verursachen, wenn sie später durch den Stream-Eingabeoperator gelesen werden.

Inhaltsverzeichnis

Parameter

os - Stream für die Ausgabe
is - Stream für die Eingabe
p - Pfad zum Einfügen oder Extrahieren

Rückgabewert

1) os
2) is

Exceptions

Kann implementierungsdefinierte Ausnahmen auslösen.

Mögliche Implementierung

Erste 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;
}
Zweite 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;
}

Beispiel