根据大小 C++ 扣除类型

Deducting type depending on size C++

是否可以在编译时根据大小选择类型?

不工作的原型将是

template<typename T, typename U>
struct Bigger 
{
    using type = (sizeof(T) > sizeof(U)) ? T : U;  
};

是的,std::conditional_t可以作为编译时使用"conditional operator":

using type = std::conditional_t<(sizeof(T) > sizeof(U)), T, U>;