File tuple.hpp

template<typename T>
struct Tuple
#include <tuple.hpp>

A tuple that consists of two values of the same type.

Template Parameters:

T – The type of the values

Public Functions

inline Tuple()
inline Tuple(T first, T second)
Parameters:
  • first – The first value

  • second – The second value

inline Tuple<T> &operator=(const T &rhs)

Assigns a specific value to the first and second value of this tuple.

Parameters:

rhs – A reference to the value to be assigned

Returns:

A reference to the modified tuple

inline Tuple<T> &operator+=(const T &rhs)

Adds a specific value to the first and second value of this tuple.

Parameters:

rhs – A reference to the value to be added

Returns:

A reference to the modified tuple

inline Tuple<T> &operator+=(const Tuple<T> &rhs)

Adds the first and second value of a given tuple to the first and second value of this tuple, respectively,

Parameters:

rhs – A reference to the tuple, whose first and second value should be added

Returns:

A reference to the modified tuple

inline Tuple<T> &operator-=(const T &rhs)

Subtracts a specific value from the first and second value of this tuple.

Parameters:

rhs – A reference to the value to be subtracted

Returns:

A reference to the modified tuple

inline Tuple<T> &operator-=(const Tuple<T> &rhs)

Subtracts the first and second value of a given tuple from the first and second value of this tuple, respectively.

Parameters:

rhs – A reference to the tuple, whose first and second value should be subtracted

Returns:

A reference to the modified tuple

inline Tuple<T> &operator*=(const T &rhs)

Multiplies the first and second value of this tuple with a specific value.

Parameters:

rhs – A reference to the value to be multiplied by

Returns:

A reference to the modified tuple

Public Members

T first

The first value.

T second

The second value.

Friends

inline friend Tuple<T> operator+(Tuple<T> lhs, const T &rhs)

Creates and returns a new tuple that results from adding a specific value to the first and second value of an existing tuple.

Parameters:
  • lhs – The original tuple

  • rhs – A reference to the value to be added

Returns:

The tuple that has been created

inline friend Tuple<T> operator+(Tuple<T> lhs, const Tuple<T> &rhs)

Creates and returns a new tuple that results from adding the first and second value of a specific tuple to the first and second value of an existing tuple, respectively.

Parameters:
  • lhs – The original tuple

  • rhs – A reference to the tuple, whose first and second value should be added

Returns:

The tuple that has been created

inline friend Tuple<T> operator-(Tuple<T> lhs, const T &rhs)

Creates and returns a new tuple that results from subtracting a specific value from the first and second value of an existing tuple, respectively.

Parameters:
  • lhs – The original tuple

  • rhs – A reference to the value to be subtracted

Returns:

The tuple that has been created

inline friend Tuple<T> operator-(Tuple<T> lhs, const Tuple<T> &rhs)

Creates and returns a new tuple that results from subtracting the first and second value of a specific tuple from the first and second value of an existing tuple, respectively.

Parameters:
  • lhs – The original tuple

  • rhs – A reference to the value to be subtracted

Returns:

The tuple that has been created

inline friend Tuple<T> operator*(Tuple<T> lhs, const T &rhs)

Creates and returns a new tuple that results from multiplying the first and second value of an existing tuple with a specific value.

Parameters:
  • lhs – The original tuple

  • rhs – A reference to the value to be multiplied by

Returns:

The tuple that has been created