std::experi...ream_joiner(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay bestie, welcome to the std::experi...ream_joiner(3) page β€” yes, it's the std::experimental::make_ostream_joiner(3) manual, straight from the C++ Standard Libary and living its best library fundamentals TS v2 life ✨

std::experimental::make_ostream_joiner β€” std::experimental::make_ostream_joiner


πŸ“œ Synopsis πŸ“œ

This cutie is 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 );

It creates an ostream_joiner object, deducing the template arguments from the types of the function arguments. periodt πŸ’…


πŸŽ€ 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))

no cap, that's the exact vibe πŸ”₯


πŸ’» Example πŸ’»

// Run this code

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

1, 2, 3, 4

this iconic page is from http://cppreference.com, dated 2024.06.10 β€” bye bestie, go slay some iterators πŸ’–πŸ«Ά

πŸ“¦ where this page comes from