70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: auTupleUtils.hpp
|
||
|
Date: 2022-2-1
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#pragma once
|
||
|
|
||
|
#if !defined(AURORA_RUNTIME_MAKE_PAIR)
|
||
|
#define AURORA_RUNTIME_MAKE_PAIR std::make_pair
|
||
|
#endif
|
||
|
|
||
|
template<typename... Args>
|
||
|
static auline auto AuMakePair(Args&&... args)
|
||
|
{
|
||
|
return AURORA_RUNTIME_MAKE_PAIR(AuForward<Args>(args)...);
|
||
|
}
|
||
|
|
||
|
#if !defined(AURORA_RUNTIME_MAKE_TUPLE)
|
||
|
#define AURORA_RUNTIME_MAKE_TUPLE std::make_tuple
|
||
|
#endif
|
||
|
|
||
|
template<typename... Args>
|
||
|
static auline auto AuMakeTuple(Args&&... args)
|
||
|
{
|
||
|
return AURORA_RUNTIME_MAKE_TUPLE(AuForward<Args>(args)...);
|
||
|
}
|
||
|
|
||
|
#if !defined(AURORA_RUNTIME_GET_TUPLE)
|
||
|
#define AURORA_RUNTIME_GET_TUPLE std::get
|
||
|
#endif
|
||
|
|
||
|
template<AuUInt N, typename... Args>
|
||
|
static auline auto &AuGet(Args&&... args)
|
||
|
{
|
||
|
return AURORA_RUNTIME_GET_TUPLE<N>(AuForward<Args>(args)...);
|
||
|
}
|
||
|
|
||
|
#if !defined(AURORA_RUNTIME_TUPLE_CAT)
|
||
|
#define AURORA_RUNTIME_TUPLE_CAT std::tuple_cat
|
||
|
#endif
|
||
|
|
||
|
template<typename... Args>
|
||
|
static auline auto AuTupleCat(Args&&... args)
|
||
|
{
|
||
|
return AURORA_RUNTIME_TUPLE_CAT(AuForward<Args>(args)...);
|
||
|
}
|
||
|
|
||
|
#if !defined(AURORA_RUNTIME_APPLY)
|
||
|
#define AURORA_RUNTIME_APPLY std::apply
|
||
|
#endif
|
||
|
|
||
|
template <class F, class Tuple>
|
||
|
static auline auto AuTupleApply(F &&f, Tuple &&t)
|
||
|
{
|
||
|
return AURORA_RUNTIME_APPLY(f, t);
|
||
|
}
|
||
|
|
||
|
template <typename Tuple, AuUInt... Is>
|
||
|
auto AuTuplePopFrontImpl(const Tuple &tuple, std::index_sequence<Is...>)
|
||
|
{
|
||
|
return AURORA_RUNTIME_MAKE_TUPLE(AuGet<1 + Is>(tuple)...);
|
||
|
}
|
||
|
|
||
|
template <typename Tuple>
|
||
|
auto AuTuplePopFront(const Tuple &tuple)
|
||
|
{
|
||
|
return AuTuplePopFrontImpl(tuple, std::make_index_sequence<std::tuple_size<Tuple>::value - 1>());
|
||
|
}
|