Why is −1 > sizeof(int)?

后端 未结 4 822
[愿得一人]
[愿得一人] 2020-11-30 14:41

Consider the following code:

template class StaticAssert;
template<> class StaticAssert {};
StaticAssert< (-1 < sizeof(in         


        
4条回答
  •  孤街浪徒
    2020-11-30 15:21

    Because unsigned is stronger then signed and -1 converted to unsigned value as of size_t , so actually -1 == 0xFFFFFFFF > 4

    This is how it should work according to C++ standard

提交回复
热议问题