Closed bluetarpmedia closed 1 month ago
Edited: ~Thanks, good catch! I see there isn't a similar forward
algorithm so I just need to adjust this for move
...~
Sorry, replied on wrong issue...
Thanks! I've added is
constraints on wildcarded parameters and locals.
With the above commit, the following now works (and the last line would be an error if not commented out):
print: (r: _ is std::regular) = {
std::cout << "satisfies std::regular\n";
}
print: (_) = {
std::cout << "fallback\n";
}
irregular: type = {}
main: () = {
print(42); // prints: satisfies std::regular
print(irregular()); // prints: fallback
ok : _ is std::regular = 42;
//err: _ is std::regular = irregular();
}
Nice work Herb!
(I can't find an issue/discussion about this so apologies if I've missed it.)
Suggestion Allow concept placeholder type constraints in Cpp2 with the
_
wildcard, as an equivalent of constrainedauto
in C++.I'd like to write the Cpp2 equivalent of the following C++:
This works in Cpp2 (see example):
But it reads quite verbose to me compared to the original C++. Something like the following would be closer to the original, I think:
Will your feature suggestion eliminate X% of security vulnerabilities of a given kind in current C++ code? No
Will your feature suggestion automate or eliminate X% of current C++ guidance literature? No