首页 > 解决方案 > Will the macro `assert` be removed in C++20?

问题描述

According to cppreference, assert will be used as a C++ attribute.

However, there already exist tons of projects heavily dependent on the macro assert, is there any bad effect?

标签: c++standardsassertdefensive-programmingc++20

解决方案


不。引入 C++20 合约的提案p0542r5说:

请注意,虽然assert(expression)将扩展为具有适当标头的类似函数的宏,但assert:不是类似函数的调用,因此不会展开。


推荐阅读