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 value 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 &inst)
 Prints the value to a std::ostream.

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 3528 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 value.

Examples

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

Definition at line 3535 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 value {2, 3}.
std::cout << inst << std::endl; // Prints "2 3".

Definition at line 3536 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.
tgen::pair<int>::value inst = {2, 3};
std::cout << inst.first() << std::endl; // Prints "2".
T first() const
Returns the first element of a pair value.
Definition tgen.h:3539

Definition at line 3539 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.
tgen::pair<int>::value inst = {2, 3};
std::cout << inst.second() << std::endl; // Prints "3".
T second() const
Returns the second element of a pair value.
Definition tgen.h:3540

Definition at line 3540 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 value, separated by comma.
tgen::pair<int>::value inst = {2, 3};
std::cout << inst.separator(',') << std::endl; // Prints "2,3".
value & separator(char sep)
Sets separator for printing.
Definition tgen.h:3543

Definition at line 3543 of file tgen.h.

◆ to_std()

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

Converts the value to a std::pair.

Returns
A std::pair representing the value.

Examples

// Converts instant 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 value to a std::pair.
Definition tgen.h:3554

Definition at line 3554 of file tgen.h.

◆ operator<<

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

Prints the value to a std::ostream.

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

Examples

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

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