I was wondering if it was possible to use a vector as the initializer list for a vector. So, if I have
struct somedata{
string str1;
string str2;
}
struct moredata{
string str1;
string str2;
string str3;
}
template<class Dataholder>
Dataholder queryUser(args){
auto vec = get_vector_from_user(args)
Dataholder dat{vec}; // The elements of vec become the structured variables in dat.
return dat;
}
So, the user might input 2 or 3 strings when get_vector_from_user() is called. However, I know that the programmer will always template queryUser and that there will be the same number of elements in vec as strings in the Dataholder template. Is it possible to initialize a struct with the members of a vector? Thanks!