mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 16:18:19 -10:00
This moves towards defining the hooks in the code module that executes them. Also provides the API necessary for better documentation of hooks. This only covers a few hooks as a test and demonstration of the new API. If no issues are found with this it can be extended in the future.
33 lines
947 B
C++
33 lines
947 B
C++
#pragma once
|
|
|
|
#include <tuple>
|
|
#include <utility>
|
|
|
|
namespace util {
|
|
namespace tuples {
|
|
|
|
template <std::size_t I = 0, typename FuncT, typename... Tp>
|
|
inline typename std::enable_if<I == sizeof...(Tp), void>::type for_each(const std::tuple<Tp...>&, FuncT)
|
|
{
|
|
}
|
|
template <std::size_t I = 0, typename FuncT, typename... Tp>
|
|
inline typename std::enable_if < I<sizeof...(Tp), void>::type for_each(const std::tuple<Tp...>& t, FuncT f)
|
|
{
|
|
f(std::get<I>(t));
|
|
for_each<I + 1, FuncT, Tp...>(t, f);
|
|
}
|
|
|
|
template <std::size_t I = 0, typename FuncT, typename... Tp>
|
|
inline typename std::enable_if<I == sizeof...(Tp), void>::type for_each(std::tuple<Tp...>&&, FuncT)
|
|
{
|
|
}
|
|
template <std::size_t I = 0, typename FuncT, typename... Tp>
|
|
inline typename std::enable_if < I<sizeof...(Tp), void>::type for_each(std::tuple<Tp...>&& t, FuncT f)
|
|
{
|
|
f(std::move(std::get<I>(t)));
|
|
for_each<I + 1, FuncT, Tp...>(std::move(t), f);
|
|
}
|
|
|
|
} // namespace tuples
|
|
} // namespace util
|