error: no matching function for call to 'get<i>(std::tuple<int, int>&)'

57 Views Asked by At

I'm quiet new to C++, so I can't really figure out the issue. I really hope someone can help me.

Whenever I run a loop and try to set a tuple's value inside of that loop, I get an error saying:

error: no matching function for call to 'get<i>(std::tuple<int, int>&)

Here is a piece a code to reproduce the error:

#include <vector>
#include <type_traits>

using namespace std;

int example(int nums, int target)
{
    return 0;
}

int main(int argc, char const *argv[])
{
    tuple<int, int> x;
    
    for (int i = 0; i < 2; ++i) {
        get<i>(x) = (i+1);
    }
    
    cout << get<0>(params);
    cout << get<1>(params);
    return 0;
}
0

There are 0 best solutions below