我想assert
在 Visual Studio 2019 中将 C 与 C++20 一起使用(使用 编译std:c++latest
),但我找不到要导入的正确模块。是否已经支持,如果支持,我应该导入哪个模块?
import std.core;
constexpr auto f()
{
return "Hello world!";
}
int main()
{
static_assert(f() == "Hello world!"); // Compile time assert works.
//assert(f() == "Hello world!"); // How to import runtime assert()?
//[[assert: f() == "Hello world!"]] // Contracts were removed from cpp20.
std::cout << f();
}
输出:世界你好!