How to do static_assert with macros?

后端 未结 5 2086
温柔的废话
温柔的废话 2020-12-02 01:27

I have tried to use this suggestion to do a static assert, but I do not get a compilation error if I use it within a method of a template.

The example follows :

5条回答
  •  -上瘾入骨i
    2020-12-02 01:51

    If you add call to the method in question (a.foo();), the static assert will fail (just then the method will be compiled). You do know that you should not static assert on run time values like "k" I presume.

提交回复
热议问题