tgen
Loading...
Searching...
No Matches

Printer helper for printing containers or sequential generator elements as columns. More...

Public Member Functions

 print_cols (const Args &...args)
 Creates a printer object that prints as columns.

Friends

std::ostream & operator<< (std::ostream &out, const print_cols &pr)
 Prints printer object as columns.

Detailed Description

template<typename... Args>
struct tgen::print_cols< Args >

Printer helper for printing containers or sequential generator elements as columns.

If you pass multiple parameters for the printer, it will print the i-th element of each on the i-th line.

Warning
When you have multiple columns, do not pass arguments that call for random generation directly in the same function call, e.g. print_cols(tgen::next(1, 10), tgen::next(1, 10)) or print_cols(tgen::list(5, 1, 10).gen(), tgen::list(5, 1, 10).gen()). Function arguments are evaluated in unspecified order, so which random draws appear in which column can vary between compilers. Evaluate each random value into a named variable first, then pass those variables to print_cols.

Examples

std::vector<int> a = {1, 2};
std::cout << tgen::print_cols(a, b);
List value.
Definition tgen.h:1674
Printer helper for printing containers or sequential generator elements as columns.
Definition tgen.h:612
1 3
2 4

Definition at line 612 of file tgen.h.

Constructor & Destructor Documentation

◆ print_cols()

template<typename... Args>
tgen::print_cols< Args >::print_cols ( const Args &... args)
inline

Creates a printer object that prints as columns.

Parameters
argsArguments. Each argument should be either a container or a sequential generator value (e.g. list::value, str::value, permutation::value).

Definition at line 615 of file tgen.h.

◆ operator<<

template<typename... Args>
std::ostream & operator<< ( std::ostream & out,
const print_cols< Args > & pr )
friend

Prints printer object as columns.

Parameters
outStream to print to.
prPrinter object.

Definition at line 660 of file tgen.h.


The documentation for this struct was generated from the following files:
  • /home/runner/work/tgen/tgen/single_include/tgen.h
  • base.dox