I have a template function taking a function pointer as an argument, and a normal function like so:
template <void()>
int foo() {static int c = 0; return ++c;}
void bar() {}
If I understand correctly, two different function pointers can have different binary representations, even if using them would call the same function. Does this also apply to when they are used as template arguments?
Will passing "pointers to bar" (obtained at different times from different places, but calling the function pointer would call bar) to foo always call the same instantiation of foo?
Any two pointers to
barfunction shall be equals. Extract from C++ 11 Specification Draft : 5.10 2 ... Two pointers compare equal if they ... both point to the same function.So I cannot imagine any reason why passing different pointers to
barcould create different instantiations offoobecause all those pointers are equals per specification.