#include <iostream>
template<typename T>
bool pair_comparer(T a, T b) {
return a != b;
}
template<typename T, typename... Args>
bool pair_comparer(T a, T b, Args... args) {
return a == b && pair_comparer(args...);
}
int main() {
bool areSame = pair_comparer(1, 1, 2, 2, 6, 6);
std::cout << "areSame " << areSame << endl; // prints 0
return 0;
}
I don't expect the example to compile , but it is . How is the call to pair_comparer
with two arguments resolved here ? Is there something I am missing
Aucun commentaire:
Enregistrer un commentaire