Closed
Description
Describe the bug
I can't find a Cpp2 syntax to value initialise an argument passed to a function using its default constructor.
To Reproduce
Run cppfront on this code:
log: (message: std::string_view,
context: std::string,
event_id: int) =
{
std::println("{} {} {}", message, context, event_id);
}
main: () = {
log("event", (), 123); // (1) Error in C++ compiler
log("event", _, 123); // (2) Error in C++ compiler
log("event", {}, 123); // (3) Error in cppfront
}
(1) produces this error:
main.cpp2:10:19: error: expected expression
10 | log("event", (), 123);
| ^
(2) produces this error:
main.cpp2:10:18: error: use of undeclared identifier '_'
10 | log("event", _, 123);
| ^
(3) produces a cppfront syntax error.
Repro on Godbolt
Additional context
I was translating the ranges::find_end
example from cppreference and have used explicit arguments like this:
found4:= std::ranges::find_end(
secret, "SWORD"sv,
std::ranges::equal_to(),
std::identity(),
:(c: char) std::tolower(c));
instead of the original:
const auto found4 = std::ranges::find_end(secret, "SWORD"sv,
{},
{},
[](char c) { return std::tolower(c); });