mercredi 5 septembre 2018

Can the return type of the function be obtained from within the function?

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++ can I, within foo, refer to the big nasty return type without repeating it, at the line marked // <-- here?

Aucun commentaire:

Enregistrer un commentaire