This question already has an answer here:
- c++ : convert vector to tuple 3 answers
I've got an interesting problem where I need to dynamically create a tuple from a vector where the number of type parameters of tuple equals the length of the vector.
vector<int> v1 = {1,2,3};
tuple<int, int, int> t1 = create_tuple(v1);
vector<int> v2 = {1,2};
tuple<int, int> t2 = create_tuple(v2);
vector<int> v3 = {1};
tuple<int> t3 = create_tuple(v3);
I'm guessing this can only be done, if possible, at compile time?
Aucun commentaire:
Enregistrer un commentaire