Is There Anything Like a Templatized Case-Statement
问题 So I have this really ugly code: template <typename T> std::conditional_t<sizeof(T) == sizeof(char), char, conditional_t<sizeof(T) == sizeof(short), short, conditional_t<sizeof(T) == sizeof(long), long, enable_if_t<sizeof(T) == sizeof(long long), long long>>>> foo(T bar){return reinterpret_cast<decltype(foo(bar))>(bar);} I'm using nested conditional_t s to make a case-statement of sorts. Is there something out there that accomplishes this more elegantly or do I need to cook up my own