From a RepeatedField which is defined to have exactly N
elements, I am filling up an std::array.
std::array<int, 6> entry;
size_t i = 0;
for (const auto& item: msg.items()){
assert(i < 6);
entry[i++] = item;
}
This works fine, but is there a better way to initialize it? filling up std::vector works fine with initialization lists, but std::array is really different.
Is it possible to use RepeatedFields in aggregate initialization of structs contaning std::array
?
What I tried so far does not even compile:
entry = {msg.items().begin(), msg.items().end()};
Which is understandable, because std::array doesn't have a constructor accepting an std::initializer_list
; But is what I am trying to do even possible?