Here is a sample code:
#include <string>
#include <functional>
struct Foo {};
typedef bool func_type(Foo *&, const std::string&);
typedef std::function<bool(Foo*&, const std::string&)> FunctionalType;
bool f(Foo *, const std::string&)
{
}
int main()
{
#if 1
func_type *func;
func = f;
#else
FunctionalType f2;
f2 = f;
#endif
}
As you can see, I declared a function type with a "pointer reference" as the first argument Foo *&
, and I expect that a function with just a "pointer" as the first argument Foo *
cannot be assigned to this type variable.
The scope #if 1
cannot compile (as I expect); however, the alternative did not emit any errors:
FunctionalType f2;
f2 = f;
source
share