Okay I'm going to give a simple example of my problem:
void Increment(Tuple<int, int>& tuple) {
++tuple.Get<0>();
}
int main() {
Tuple<int, int> tuple;
tuple.Get<0>() = 8;
Increment(tuple);
printf("%i\n", tuple.Get<0>()); // prints 9, as expected
return 0;
}
This compiles just fine, and all is peachy. The Increment function just increments the first element in the tuple, and then I print that element. However, wouldn't it be nice if my Increment function could be used on any kind of element?
template <typename T>
void Increment(Tuple<T, T>& tuple) {
++tuple.Get<0>(); // <-- compile ERROR
}
int main() {
Tuple<int, int> tuple;
tuple.Get<0>() = 8;
Increment<int>(tuple);
printf("%i\n", tuple.Get<0>());
return 0;
}
My second example spits out the following error at compile-time:
error: expected primary-expression before ')' token
I'm at my wits end trying to figure out why this causes problems. Since the template parameter is 'int', the generated code should be identical to my hard-coded example. How can I get this to work?