Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

c++ - What happened to std::assert

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::*.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

assert is a macro, not a function. Hence, it needs to be used with plain old assert(condition).

Here's a supporting link: http://en.cppreference.com/w/cpp/error/assert.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...