int myfun()
{
return 42;
}
I know I can write
auto myvar = myfun();
but what if I just want to declare myvar (without using a common typedef)?
the_type_returned_by_myfun myvar;
What can be written instead of the_type_returned_by_myfun?
You can use
decltype.And if the function happens to have parameters, you can produce fake parameters with
std::declval.