Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Easy way to make vector triplet in CPP

Tags:

c++

vector

What would be an easy way to construct a vector triplet of ints in CPP?

i.e instead of a pair of 2 ints ,

std::vector<std::pair<int, int> > vec;

I want 3 int's tied together as one element of the vector.

I realized one way would be to make 2 sub-nested pairs, but this method gets messy. I am not aware of all the details of CPP, therefore please recommend an easier way if available. Thank you.

like image 606
rohanag Avatar asked Nov 27 '22 14:11

rohanag


1 Answers

std::vector<std::tuple<int,int,int>> myvec;

like image 69
johnathan Avatar answered Dec 18 '22 09:12

johnathan