Lots of windows fixes and some more improvements.
This commit is contained in:
42
source/mijin/util/misc.hpp
Normal file
42
source/mijin/util/misc.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#if !defined(MIJIN_UTIL_MISC_HPP_INCLUDED)
|
||||
#define MIJIN_UTIL_MISC_HPP_INCLUDED 1
|
||||
|
||||
#include <array>
|
||||
#include <utility>
|
||||
|
||||
namespace mijin
|
||||
{
|
||||
|
||||
//
|
||||
// public functions
|
||||
//
|
||||
|
||||
template<auto V, typename T>
|
||||
constexpr decltype(auto) idValue(T&& value)
|
||||
{
|
||||
return std::forward<T>(value);
|
||||
}
|
||||
|
||||
namespace impl
|
||||
{
|
||||
template<typename T, typename... TArgs>
|
||||
struct ConstructArrayHelper
|
||||
{
|
||||
template<std::size_t... I>
|
||||
static constexpr std::array<T, sizeof...(I)> construct(const TArgs&... args, std::index_sequence<I...>)
|
||||
{
|
||||
return {idValue<I>(T(args...))...};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template<typename T, std::size_t count, typename... TArgs>
|
||||
constexpr std::array<T, count> constructArray(const TArgs&... args)
|
||||
{
|
||||
return impl::ConstructArrayHelper<T, TArgs...>::construct(args..., std::make_index_sequence<count>());
|
||||
}
|
||||
}
|
||||
#endif // !defined(MIJIN_UTIL_MISC_HPP_INCLUDED)
|
||||
Reference in New Issue
Block a user