libcommon: make_array_n clarification [METR-19529]

This commit is contained in:
Vladimir Chebotarev 2016-02-12 11:52:48 +03:00
parent 559983f2ea
commit 25cc1376b0

View File

@ -4,6 +4,11 @@
#include <type_traits>
#include <array>
/** \brief Produces std::array of specified size, containing copies of provided object.
* Copy is performed N-1 times, and the last element is being moved.
* This helper allows to initialize std::array in place.
*/
namespace ext
{
@ -13,6 +18,7 @@ namespace ext
template<std::size_t size, typename T, std::size_t... indexes>
constexpr auto make_array_n_impl(T && value, std::index_sequence<indexes...>)
{
/// Comma is used to make N-1 copies of value
return std::array<std::decay_t<T>, size>{ (static_cast<void>(indexes), value)..., std::forward<T>(value) };
}