Created
April 25, 2021 15:20
-
-
Save srinivasyadav18/ca44eb69c923d2902405f13f7e04f21f to your computer and use it in GitHub Desktop.
Function object parameters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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