mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-28 08:15:29 +03:00
Add template utils for constructing all elements in an std::array
This avoids the excessive repetition needed for the case where array members have no default constructor. eg: ```c++ std::array<Type, 10> channels{util::MakeFilledArray<Type, 10>(typeConstructorArg, <...>)}; ```
This commit is contained in:
parent
34bf413661
commit
fd0420443c
@ -260,4 +260,15 @@ namespace skyline::util {
|
|||||||
return &value;
|
return &value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
template<typename T, typename... TArgs, size_t... Is>
|
||||||
|
std::array<T, sizeof...(Is)> MakeFilledArray(std::index_sequence<Is...>, TArgs &&... args)
|
||||||
|
{
|
||||||
|
return {(void(Is), T(args...))...};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T, size_t Size, typename... TArgs>
|
||||||
|
std::array<T, Size> MakeFilledArray(TArgs &&... args) {
|
||||||
|
return MakeFilledArray<T>(std::make_index_sequence<Size>(), std::forward<TArgs>(args)...);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user