【发布时间】:2021-10-31 01:50:25
【问题描述】:
vector<string> foo(vector<string> s) { return s; }
assert(foo(vector<string>{"hello", "world"}) ==
vector<string>{"hello", "world"});
- 错误:宏“assert”传递了 2 个参数,但只需要 1 个
- 错误:未在此范围内声明“断言”
也许在 gcc 11.1.0 中定义断言
# define assert(expr) \
(static_cast <bool> (expr) \
? void (0) \
: __assert_fail (#expr, __FILE__, __LINE__, __ASSERT_FUNCTION))
编译器标志是
-Wall -std=c++20
【问题讨论】:
标签: c++