Title: Generalize string-literal of contract like C++26's static_assert.
Description:
Custom text output after a contract failure isn't part of the Contracts' MVP.
If Cpp2's contracts feature is going to have this anyways,
we could craft better diagnostics messages
if its second argument behaved like that of static_assert in C++26.
Minimal reproducer (https://cpp2.godbolt.org/z/GYqdx3WTE):
// After P2361R6 and P2741R3:
static_assert(std::is_same_v<int, decltype(0)>, std::string("0") + " was not `int`.");
main: () = {
[[assert: std::is_same_v<int, decltype(0)>, std::string("0") + " was not `int`."]]
}
Commands:
cppfront main.cpp2
clang++18 -std=c++26 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp
Expected result: Program returned: 0.
Actual result and error: main.cpp2(4,47): error: expected contract message string (at 'std').
See also:



Title: Generalize string-literal of contract like C++26's
static_assert.Description:
Custom text output after a contract failure isn't part of the Contracts' MVP.
If Cpp2's contracts feature is going to have this anyways,
we could craft better diagnostics messages
if its second argument behaved like that of
static_assertin C++26.Minimal reproducer (https://cpp2.godbolt.org/z/GYqdx3WTE):
Commands:
cppfront main.cpp2 clang++18 -std=c++26 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cppExpected result:
Program returned: 0.Actual result and error:
main.cpp2(4,47): error: expected contract message string (at 'std').See also: