It seems like there's an error when using the trailing return type in the function pointer declaration for Func_ptr. I know I can do it if I put the declaration and initialization in the same statement or simply use the standard declaration by specifying the return type directly, but I want to understand the language's limitations, so can someone please explain what this error means in the code below:
"a variable declared with an auto type specifier cannot appear in its own initializer"
#include <utility>
#include <iostream>
int Func(const std::pair<int, int>& p)
{
std::cout << p.first << "->" << p.second << std::endl;
return 1;
}
int main()
{
auto (*Func_ptr)(const std::pair<int, int>& p) -> int;
//Error below, Func_ptr underlined, "a variable declared with the auto
//specifier cannot appear in its own initializer
Func_ptr = Func;
}