tgen
Loading...
Searching...
No Matches

Printer helper for standard types. More...

Inheritance diagram for tgen::print:

Public Member Functions

template<typename T>
 print (const T &val, char sep=' ')
 Cretes a printer object.

Friends

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

Detailed Description

Printer helper for standard types.

Just call std::cout << tgen::print(x) to print x, or std::cout << tgen::println(x) to print x and \n. Works with std::initializer_list.

Prints std::pair, std::tuple and containers nicely (separade by a space). Matrices (container<container<T>>) are also handleled nicely, printing one row per line.

Examples

std::tuple<int, double, std::string> tu = {5, 0.1, "str"};
std::cout << tgen::print(tu);
// "5 0.1 str"
std::cout << tgen::print({{1, 2}, {3, 4}}, ',');
// "1,2\n3,4"
Printer helper for standard types.
Definition tgen.h:423

Definition at line 423 of file tgen.h.

Constructor & Destructor Documentation

◆ print()

template<typename T>
tgen::print::print ( const T & val,
char sep = ' ' )
inline

Cretes a printer object.

Parameters
valValue to be printed.
sepSeparator for values printed in the same line.

Definition at line 426 of file tgen.h.

◆ operator<<

std::ostream & operator<< ( std::ostream & out,
const print & pr )
friend

Prints printer object.

Parameters
outStream to print to.
prPrinter object.

Definition at line 500 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