How to return an arbitrary type (either void or non-void) from a template functor wrapper? I use the wrapper for pre- and post- conditions, so I need to store the returned value in a local variable before returning it from wrapper. But when the returned type is void the compiler gives and error, because variables can't have a void type. What can be done here?
template <typename Functor, typename... Args>
auto Decorate(Functor f, Args&&... args)
-> decltype(f(std::forward<Args>(args)...)) {
// preconditions
const auto result = f(std::forward<Args>(args)...);
// postconditions
return result;
}