# std::experimental::make_ostream_joiner

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

Creates an ostream_joiner object, deducing the template arguments from the types of the function arguments.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <experimental/iterator>

template< class CharT, class Traits, class DelimT >
std::experimental::ostream_joiner<std::decay_t<DelimT>, CharT, Traits>
    make_ostream_joiner( std::basic_ostream<CharT, Traits>& os,
                         DelimT&& delimiter ); // (library fundamentals TS v2)
```

Creates an `ostream_joiner` object, deducing the template arguments from the types of the function arguments.

### Parameters

- `os` - the `basic_ostream` object that the iterator is to be associated to
- `delimiter` - the delimiter

### Return value

An `ostream_joiner` object, created as if by `std::experimental::ostream_joiner<std::decay_t<DelimT>, CharT, Traits>(os, std::forward<DelimT>(delimiter))`

### Example

```cpp
#include <experimental/iterator>
#include <iostream>
#include <vector>

int main()
{
    std::vector<int> x{1, 2, 3, 4};
    std::copy(x.begin(), x.end(),
              std::experimental::make_ostream_joiner(std::cout, ", "));
}
```

Output:

```text
1, 2, 3, 4
```

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