Skip to content

Instantly share code, notes, and snippets.

@srinivasyadav18
Created April 25, 2021 15:20
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 srinivasyadav18/ca44eb69c923d2902405f13f7e04f21f to your computer and use it in GitHub Desktop.
Save srinivasyadav18/ca44eb69c923d2902405f13f7e04f21f to your computer and use it in GitHub Desktop.
Function object parameters
/*
I have a function object or function F (given by user).
I want to calculate number of parameters that F takes.
Or I want to store parameters in parameter pack
Or apply some operations on parameters like,
check if first parameter (or nth parameter) is ref or
const ref or value etc..
*/
struct add_one
{
template <typename T>
T operator()(T const& v)
{
return v + 1;
}
};
/*
Suppose here add_one is the function object then, is there
any way to know if v is taken by reference or value etc...
add_one is supplied by user.
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment