Compile-time assertion?

后端 未结 12 1002
春和景丽
春和景丽 2020-11-27 06:09

Is there a way I can assert that two constant expressions are equal at compile time?

e.g. I want this to cause a compile-time error

enum { foo=263,          


        
12条回答
  •  粉色の甜心
    2020-11-27 06:37

    I suggest to take a look at the Eigen library static assert mechanism:

    http://eigen.tuxfamily.org/dox/StaticAssert_8h_source.html

提交回复
热议问题