Correctly propagating a `decltype(auto)` variable from a function
问题 (This is a follow-up from "Are there any realistic use cases for `decltype(auto)` variables?" ) Consider the following scenario - I want to pass a function f to another function invoke_log_return which will: Invoke f ; Print something to stdout ; Return the result of f , avoiding unnecessary copies/moves and allowing copy elision. Note that, if f throws, nothing should be printed to stdout . This is what I have so far: template <typename F> decltype(auto) invoke_log_return(F&& f) { decltype