Using a function pointer with a trailing return type

You have to use auto

using fp = auto (*)(int) -> int;
typedef auto (*fp)(int) -> int; // alternatively

Trailing return type syntax means you put the auto before the function name to indicate that the return type follows (or in the case of c++14, should be deduced). For function pointers, the same rule applies except that it can’t deduce it (for obvious reasons).

This is true for functions as well though, your example

main() -> int {... }

is not valid either without the preceding auto

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)