I have the following body of code.
#include <iostream>
#include <vector>
#include <tuple>
int main() {
std::vector<std::tuple<int, int>> edges(4,{1,2});
for (auto i = std::begin (edges); i != std::end (edges); ++i) {
std::cout << std::get<0>(i) << " "<< std::get<1>(i)<< " ";
}
}
In my eyes this makes sense, I have a vector of tuples which I'm initialising. I then iterate through the vector printing each of the two elements of the tuple individually.
However the code doesn't work returning
8:26: error: no matching function for call to 'get'
std::cout << std::get<0>(i) << " "<< std::get<1>(i)<< " ";
^~~~~~~~~~~
Could someone please explain why?