tgen
Loading...
Searching...
No Matches

Pair value. More...

Inheritance diagram for tgen::pair< T >::value:

Public Member Functions

 value (const std::pair< T, T > &pair)
 Creates a pair value from a std::pair.
 value (const T &first, const T &second)
 Creates a pair value from first and second values.
first () const
 Returns the first element of a pair value.
second () const
 Returns the second element of a pair value.
valueseparator (char sep)
 Sets separator for printing.
auto to_std () const
 Converts the pair to a std::pair.
Public Member Functions inherited from tgen::gen_value_base< value >
bool operator< (const value &rhs) const

Friends

std::ostream & operator<< (std::ostream &out, const value &val)
 Prints the pair to an output stream.

Detailed Description

template<typename T>
struct tgen::pair< T >::value

Pair value.

It can be deterministically operated upon and printed through std::cout.

Definition at line 4194 of file tgen.h.

Constructor & Destructor Documentation

◆ value() [1/2]

template<typename T>
tgen::pair< T >::value::value ( const std::pair< T, T > & pair)
inline

Creates a pair value from a std::pair.

Parameters
pairThe std::pair representing the pair.

Examples

// Creates and prints a pair from a std::pair.
std::pair<int, int> p = {2, 3};
std::cout << val << std::endl; // Prints "2 3".
Pair value.
Definition tgen.h:4194

Definition at line 4201 of file tgen.h.

◆ value() [2/2]

template<typename T>
tgen::pair< T >::value::value ( const T & first,
const T & second )
inline

Creates a pair value from first and second values.

Parameters
firstFirst element of the pair.
secondSecond element of the pair.

Examples

// Creates and prints a pair {2, 3}.
std::cout << val << std::endl; // Prints "2 3".

Definition at line 4202 of file tgen.h.

Member Function Documentation

◆ first()

template<typename T>
T tgen::pair< T >::value::first ( ) const
inline

Returns the first element of a pair value.

Returns
The first element of the pair.

Examples

// Prints the first element of a pair.
std::cout << val.first() << std::endl; // Prints "2".

Definition at line 4205 of file tgen.h.

◆ second()

template<typename T>
T tgen::pair< T >::value::second ( ) const
inline

Returns the second element of a pair value.

Returns
The second element of the pair.

Examples

// Prints the second element of a pair.
std::cout << val.second() << std::endl; // Prints "3".

Definition at line 4206 of file tgen.h.

◆ separator()

template<typename T>
value & tgen::pair< T >::value::separator ( char sep)
inline

Sets separator for printing.

Complexity

O(1).

Examples

// Prints a pair, separated by comma.
std::cout << val.separator(',') << std::endl; // Prints "2,3".

Definition at line 4209 of file tgen.h.

◆ to_std()

template<typename T>
auto tgen::pair< T >::value::to_std ( ) const
inline

Converts the pair to a std::pair.

Returns
A std::pair representing the pair.

to_std() is called recursevely on type T, if it applies.

Examples

// Converts the pair to std::pair.
std::pair<int, int> p = tgen::pair<int>::value(2, 3).to_std();
// p = {2, 3}.
auto to_std() const
Converts the pair to a std::pair.
Definition tgen.h:4220

Definition at line 4220 of file tgen.h.

◆ operator<<

template<typename T>
std::ostream & operator<< ( std::ostream & out,
const value & val )
friend

Prints the pair to an output stream.

The pair elements are printed with one space as a separator by default, and with no end of line.

Examples

// Prints a pair.
std::cout <<
tgen::pair<int>::value(2, 3) << std::endl; // Prints "2 3".

Definition at line 4215 of file tgen.h.


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