Функциональные объекты
class _swap{
static size_t counter = 0;
static void increment() { ++counter; }
public:
_swap(){}
void operator ()(int& a, int& b){
int tmp = a;
a = b;
b = tmp;
increment();
}
int getNrCalls() {return counter; }
};
int main() {
_swap swap;
int a = 3, b = 5;
swap(a, b);
return 0;
}Last updated