Skip to content

Instantly share code, notes, and snippets.

@lshort
Created May 25, 2014 06:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lshort/e8fe650fb548054ee05d to your computer and use it in GitHub Desktop.
Save lshort/e8fe650fb548054ee05d to your computer and use it in GitHub Desktop.
template<typename return_type, typename arg1_type, typename ...params>
auto _L1( return_type (*fp) (arg1_type x, params...args), arg1_type x)
{ return [fp, x] (params...args) { return fp(x,args...); }; };
double mult(double x, double y) { return x*y; }
auto to_radians = _L1(mult,M_PI/180.0);
auto cos_in_degrees = _L(cos) * to_radians;
cout << cos_in_degrees(45.0) << endl;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment