Skip to content

Instantly share code, notes, and snippets.

@daghlny
Created July 12, 2018 01:30
Show Gist options
  • Save daghlny/b7308cf2bd9dd8f548aec044d7324dad to your computer and use it in GitHub Desktop.
Save daghlny/b7308cf2bd9dd8f548aec044d7324dad to your computer and use it in GitHub Desktop.
#include <iostream>
using std::cout;
using std::endl;
struct add {
int sum;
add& operator()(int val) {
sum += val;
return *this;
}
add(int initval): sum(initval) {}
operator int() { return sum; }
};
int main(void)
{
cout << add(3)(4)(5) << endl;
if (add(3)(4)(5) == 12)
cout << "Perfect!" << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment