I'd like to use the C assert with C++20 in Visual Studio 2019 (compiling with std:c++latest), but I couldn't find the correct module to import. Is it already supported and if yes, which module I should import?
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();
}
Output: Hello world!
Modules do not contain macros. Importing legacy module headers will bring in macros, but import std.core; or whatever never will bring in a macro.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With