我有以下代码体。
#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)<< " ";
}
}
Run Code Online (Sandbox Code Playgroud)
在我看来这是有道理的,我有一个正在初始化的元组向量。然后,我迭代矢量,分别打印元组的两个元素。
但是代码无法返回
8:26: error: no matching function for call to 'get'
std::cout << std::get<0>(i) << " "<< std::get<1>(i)<< " ";
^~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
有人可以解释一下为什么吗?