How can I find the largest (in size) of two integer types?

前端 未结 5 1526
独厮守ぢ
独厮守ぢ 2021-02-09 18:02

For instance:

template 
void fun(const Type1 &v1, const Type2 &v2)
{
    largest::type val          


        
5条回答
  •  滥情空心
    2021-02-09 18:35

    You can use the sizeof built-in function of c to get the memory size of the type. You can also call it on an instance of a type. For example:

    return (sizeof(v1) > sizeof(v2));

提交回复
热议问题