template<class F, class S, class T>
Corrade::Containers::Triple class new in Git master

A tuple of three values.

Like Pair, but for three elements. Also a lightweight alternative to a three-element std::tuple that guarantees usability in constexpr contexts even in C++11. On the other hand, to simplify both the implementation and usage semantics, the type doesn't support references — wrap them in a Reference in order to store them in a Triple. Such type composition allows you to both rebind the reference and update the referenced value and the intent is clear.

Similarly to other containers and equivalently to std::make_tuple(), there's also triple(). The following two lines are equivalent:

auto a = Containers::Triple<float, int, bool>{35.0f, 7, true};
auto b = Containers::triple(35.0f, 7, true);

Similarly to a Pair, access to the triple elements is done using first(), second() and third() member functions, direct access to the members isn't provided. This is done in order to future-proof the design and have extra flexibility in how the internals are defined.

STL compatibility

Instances of Triple are explicitly copy- and move-convertible to and from a three-element std::tuple if you include Corrade/Containers/TripleStl.h. The conversion is provided in a separate header to avoid overhead from an unconditional #include <tuple>. Additionally, the triple(T&&) overload also allows for such a conversion. Example:

std::tuple<float, int, bool> a{35.0f, 7, true};
Containers::Triple<float, int, bool> b{a};

std::tuple<bool, int*, bool> c(Containers::triple(false, &b.second(), true));

auto d = Containers::triple(std::tuple<char, double, bool>{'p', 3.14, true});
    // d is Containers::triple<char, double, bool>

Public types

using FirstType = F
First type.
using SecondType = S
Second type.
using ThirdType = T
Second type.

Constructors, destructors, conversion operators

Triple(Corrade::DefaultInitT) explicit constexpr noexcept(…)
Construct a default-initialized triple.
Triple(Corrade::ValueInitT) explicit constexpr noexcept(…)
Construct a value-initialized triple.
Triple(Corrade::NoInitT) explicit noexcept
Construct a triple without initializing its contents.
Triple() constexpr noexcept(…)
Default constructor.
Triple(const F& first, const S& second, const T& third) constexpr noexcept(…)
Constructor.
Triple(const F& first, const S& second, T&& third) constexpr noexcept(…)
Triple(const F& first, S&& second, const T& third) constexpr noexcept(…)
Triple(F&& first, const S& second, const T& third) constexpr noexcept(…)
Triple(const F& first, S&& second, T&& third) constexpr noexcept(…)
Triple(F&& first, const S& second, T&& third) constexpr noexcept(…)
Triple(F&& first, S&& second, const T& third) constexpr noexcept(…)
Triple(F&& first, S&& second, T&& third) constexpr noexcept(…)
template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::from(std::declval<const U&>()))>
Triple(const U& other) explicit noexcept(…)
Copy-construct a triple from external representation.
template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::from(std::declval<U && >()))>
Triple(U&& other) explicit noexcept(…)
Move-construct a triple from external representation.
template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::to(std::declval<const Triple<F, S, T>&>()))>
operator U() const & explicit
Copy-convert the triple to external representation.
template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::to(std::declval<Triple<F, S, T> && >()))>
operator U() && explicit
Move-convert the triple to external representation.

Public functions

auto operator==(const Triple<F, S, T>& other) const -> bool constexpr
Equality comparison.
auto operator!=(const Triple<F, S, T>& other) const -> bool constexpr
Non-equality comparison.
auto first() & -> F&
First element.
auto first() && -> F&&
auto first() const & -> const F& constexpr
auto first() const && -> const F&& constexpr
auto second() & -> S&
Second element.
auto second() && -> S&&
auto second() const & -> const S& constexpr
auto second() const && -> const S&& constexpr
auto third() & -> T&
Third element.
auto third() && -> T&&
auto third() const & -> const T& constexpr
auto third() const && -> const T&& constexpr

Function documentation

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(Corrade::DefaultInitT) explicit constexpr noexcept(…)

Construct a default-initialized triple.

Trivial types are not initialized, default constructor called otherwise. Because of the differing behavior for trivial types it's better to explicitly use either the Triple(ValueInitT) or the Triple(NoInitT) variant instead.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(Corrade::ValueInitT) explicit constexpr noexcept(…)

Construct a value-initialized triple.

Trivial types are zero-initialized, default constructor called otherwise. This is the same as Triple().

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(Corrade::NoInitT) explicit noexcept

Construct a triple without initializing its contents.

Enabled only for trivial types and types that implement the NoInit constructor. The contents are not initialized. Useful if you will be overwriting both members later anyway or if you need to initialize in a way that's not expressible via any other Triple constructor.

For trivial types is equivalent to Triple(DefaultInitT).

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple() constexpr noexcept(…)

Default constructor.

Alias to Triple(ValueInitT).

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(const F& first, const S& second, const T& third) constexpr noexcept(…)

Constructor.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(const F& first, const S& second, T&& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(const F& first, S&& second, const T& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(F&& first, const S& second, const T& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(const F& first, S&& second, T&& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(F&& first, const S& second, T&& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(F&& first, S&& second, const T& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
Corrade::Containers::Triple<F, S, T>::Triple(F&& first, S&& second, T&& third) constexpr noexcept(…)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T> template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::from(std::declval<const U&>()))>
Corrade::Containers::Triple<F, S, T>::Triple(const U& other) explicit noexcept(…)

Copy-construct a triple from external representation.

template<class F, class S, class T> template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::from(std::declval<U && >()))>
Corrade::Containers::Triple<F, S, T>::Triple(U&& other) explicit noexcept(…)

Move-construct a triple from external representation.

template<class F, class S, class T> template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::to(std::declval<const Triple<F, S, T>&>()))>
Corrade::Containers::Triple<F, S, T>::operator U() const & explicit

Copy-convert the triple to external representation.

template<class F, class S, class T> template<class U, class = decltype(Implementation::TripleConverter<F, S, T, U>::to(std::declval<Triple<F, S, T> && >()))>
Corrade::Containers::Triple<F, S, T>::operator U() && explicit

Move-convert the triple to external representation.

template<class F, class S, class T>
F&& Corrade::Containers::Triple<F, S, T>::first() &&

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
const F& Corrade::Containers::Triple<F, S, T>::first() const & constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
const F&& Corrade::Containers::Triple<F, S, T>::first() const && constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
S&& Corrade::Containers::Triple<F, S, T>::second() &&

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
const S& Corrade::Containers::Triple<F, S, T>::second() const & constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
const S&& Corrade::Containers::Triple<F, S, T>::second() const && constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
T&& Corrade::Containers::Triple<F, S, T>::third() &&

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
const T& Corrade::Containers::Triple<F, S, T>::third() const & constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T>
const T&& Corrade::Containers::Triple<F, S, T>::third() const && constexpr

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class F, class S, class T> template<class F, class S, class T>
Triple<typename std::decay<F>::type, typename std::decay<S>::type, typename std::decay<T>::type> triple(F&& first, S&& second, T&& third) constexpr

Make a triple.

Convernience alternative to Triple::Triple(const F&, const S&, const T&) and overloads. The following two lines are equivalent:

auto a = Containers::Triple<float, int, bool>{35.0f, 7, true};
auto b = Containers::triple(35.0f, 7, true);

template<class F, class S, class T> template<class T>
auto triple(T&& other)

Make a triple from external representation.

template<class F, class S, class T> template<class F, class S, class T>
Utility::Debug& operator<<(Utility::Debug& debug, const Triple<F, S, T>& value)

Debug output operator.