template <typename... Ts> struct ToInfoArray { static constexpr std::array<Info, sizeof...(Ts)> value = { { Ts::info... } }; };
Demo
Do you use std :: array, array [] or std :: initializer_list as a type for InfoArray?
std::array<T,N> . This is a collection that behaves (with comparable performance) in the same way as a regular array, but provides an additional interface for working with its elements; he himself is a copied type.
std::initializer_list is not here for many reasons. When it is used as a data element (with an initializer in the class), stored elements become invalid after the execution of any of the constructors. It is not guaranteed to be a literal type, so it cannot be marked as constexpr . Its size is not used (available) in constant expressions. It does not provide random access logic (without resorting to pointer arithmetic); the only way to list its elements is to iterate from begin() to end() , which, in addition, gives pointers to constant elements. std::initializer_list was intended to be serviced primarily as a function parameter.
source share