Add custom messages in assert?

后端 未结 8 1018
心在旅途
心在旅途 2020-12-04 07:18

Is there a way to add or edit the message thrown by assert? I\'d like to use something like

assert(a == b, \"A must be equal to B\");

Then

8条回答
  •  星月不相逢
    2020-12-04 07:42

    assert is a macro/function combination. you can define your own macro/function, using __FILE__, __BASE_FILE__, __LINE__ etc, with your own function that takes a custom message

提交回复
热议问题