Struct pair


#include <include/flecs/addons/cpp/pair.hpp>

template <typename First, typename Second>
struct pair : _::pair_base


No description yet.

Mentioned in


Ancestors: pair_base


pair overload
operator const type &
operator type &
operator* overload
operator-> overload


Lines 10-52 in include/flecs/addons/cpp/pair.hpp.

template <typename First, typename Second>
struct pair : _::pair_base { 
    // Traits used to deconstruct the pair

    // The actual type of the pair is determined by which type of the pair is
    // empty. If both types are empty or not empty, the pair assumes the type
    // of the first element.
    using type = conditional_t<!is_empty<First>::value || is_empty<Second>::value, First, Second>;
    using first = First;
    using second = Second;

    pair(type& v) : ref_(v) { }

    // This allows the class to be used as a temporary object
    pair(const type& v) : ref_(const_cast<type&>(v)) { }

    operator type&() { 
        return ref_;

    operator const type&() const { 
        return ref_;

    type* operator->() {
        return &ref_;

    const type* operator->() const {
        return &ref_;

    type& operator*() {
        return ref_;

    const type& operator*() const {
        return ref_;

    type& ref_;