For example, I want to control the operator between A
and B
to something depending on the template I'm assigning it to (in main
).
// Theoretical operation template function
template <OPERATION>
void Example(int A, int B) {
A OPERATION B;
}
int main(void) {
Example< += >(10, 20);
Example< -= >(10, 20);
Example< *= >(10, 20);
Example< |= >(10, 20);
}
I know this is not valid C++ syntax but I'm only doing this for the purpose of explanation. Is this possible? Thanks in advance.