Struct gl::io::range_formatter
template <std::ranges::range R>
ClassList > io > range_formatter
A customizable stream proxy for formatting and printing C++ ranges. More...
#include <gl/io/ranges.hpp>
Public Attributes
| Type | Name |
|---|---|
| R | range The underlying range view being formatted. |
| std::string_view | sep = ", "The string separating each element. |
| std::string_view | open = "["The opening string/bracket. |
| std::string_view | close = "]"The closing string/bracket. |
Detailed Description
This struct acts as a wrapper around any std::ranges::range, allowing it to be piped into a standard output stream with configurable separators and bounding characters.
Example Usage
std::vector<int> vec = {1, 2, 3};
std::cout << gl::io::range_formatter{vec} << '\n';
std::cout << gl::io::range_formatter{vec, " | ", "<", ">"} << '\n';
Output:
See Also
Template parameters:
RThe specific type of the range being formatted.
Public Attributes Documentation
variable range
The underlying range view being formatted.
variable sep
The string separating each element.
variable open
The opening string/bracket.
variable close
The closing string/bracket.
Friends Documentation
friend operator<<
Serializes the formatted range to an output stream.
inline std::ostream & io::range_formatter::operator<< (
std::ostream & os,
range_formatter formatter
)
Parameters:
osThe target output stream.formatterThe configured formatter instance.
Returns:
The stream reference for chaining.
The documentation for this class was generated from the following file include/gl/io/ranges.hpp