std :: assert发生了什么 [英] What happened to std::assert
问题描述
此答案,并且有很多重复项,表明我应该对提取的C标头使用#include <c*>
来自C ++代码,我应该用std::*
调用它们.
This answer and it's multitude of duplicates indicate that I should be using #include <c*>
for the C headers that I pull from in C++ code, and that I should be calling them with std::*
.
我一直在这样做,但是我注意到一个例外.即使正确地#include <cassert>
,似乎也没有定义std::assert
.
I have been doing that but I notice an exception. std::assert
doesn't seem to be defined, even when I correctly #include <cassert>
.
这是怎么回事?这是实施监督还是实际例外?
What's going on here? Is this an implementation oversight, or an actual exception?
推荐答案
assert
是宏,而不是函数.因此,它需要与普通的assert(condition)
一起使用.
assert
is a macro, not a function. Hence, it needs to be used with plain old assert(condition)
.
以下是支持链接: http://en.cppreference.com/w/cpp /error/assert .
这篇关于std :: assert发生了什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!