vendredi 27 novembre 2015

Initializing C++ std::array with smaller arrays

How can I construct an std::array out of several smaller ones, plus not-array elements?

I.e.:

std::array<std::string, 2> strings = { "a", "b" };
std::array<std::string, 2> more_strings = { "c", "d" };
std::string another_string = "e";

std::array<std::string, 5> result = {strings, more_strings, another_string};

The same question applies to initializing std::initializer_list with smaller std::initializer_lists.

Aucun commentaire:

Enregistrer un commentaire