Is it possible to use function return type as an argument in declaration of another function in C++?

decltype (MyFunction_1) will give you the type of MyFunction_1 (i.e. the function type std::tuple<int, bool, double> ()), you need to emulate a function calling 1 (via adding ()) to get the return type (i.e. std::tuple<int, bool, double>), e.g.

void MyFunction_2 (decltype (MyFunction_1()) &params);
//                                       ^^

1 The expression is evaluated at compile-time, the function won’t be called at run-time actually.

Leave a Comment