Struct pair


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

template <typename R, typename O>
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 R, typename O>
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 relation.
    using type = conditional_t<!is_empty<R>::value || is_empty<O>::value, R, O>;
    using relation = R;
    using object = O;

    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_;