Can the return type of a function be obtained in a simple way within the function?
For example, given:
template <typename P>
static inline auto foo(P p) -> typename std::remove_reference<decltype(*p)>::type {
typename std::remove_reference<decltype(*p)>::type f{}; // <-- here
...
}
In C++11 can I refer to the big nasty return type of foo
, within foo
itself, without repeating it, at the line marked // <-- here
?
Call the function with a decltype
.
decltype(foo(p)) f{};