I want to implement a data structure with compile time constant size(like std::array
). I want to be able to initialize this data structure like this:
MyStruct<3, int> example = {1, 2, 3};
This work fine using constructor like: MyStruct(std::initializer_list<T> elements)
, but the compiler doesn't enforce the same size for my internal structure and elements
, even if they are both known at compile time.
I can't use static_assert
because elements.size()
is not compile time constant.
Is there any way to enforce at compile time same size for elements
as in MyStruct
?