With std::common_type
, this is straightforward:
template <class... Args, class = std::common_type_t<Args...>>
void foo(Args &&... args) {
}
This will only be guaranteed to be SFINAE
-friendly from C++17
onwards, though. Clang
and GCC
both implement it that way already.