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

> C++ Atlas: `cppatlas.com/w/cpp/experimental/fs/path/operator_ltltgtgt` | Source: https://en.cppreference.com/w/cpp/experimental/fs/path/operator_ltltgtgt | Domain: Technical specifications

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.

## Official Specification Summary (cppreference)

```cpp
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)
```

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.

### 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

May throw implementation-defined exceptions.

### Possible implementation

```cpp
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**

```cpp
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

> Note: This section is incomplete Reason: no example

---
Attribution: content from https://en.cppreference.com/w/cpp/experimental/fs/path/operator_ltltgtgt (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.