6 ms·
This is fixed in C++23 by adding explicit object parameters to the member function (and lambda) syntax: [x](this auto) -> future<T> { co_await some
by scatters 4y ago
This is fixed in C++23 by adding explicit object parameters to the member function (and lambda) syntax:
[x](this auto) -> future<T> {
co_await something();
co_return x;
}
The lambda capture is copied into the coroutine frame on launch, meaning that it won't dangle.
- sitzkrieg 4y agothis looks so far and away from C++ of ye old its kinda funny. you could pass that as some new language
- MathMonkeyMan 4y agofuture<c++>
- jcelerier 4y ago> you could pass that as some new language ...why would you think that a new standard isn't a new language?
- ijlx 4y agoI mean, between consecutive standard releases not as much changes; it's pretty clear that they're the same language with some slight differences/new features. I think the point is C++ has had so much change over the years it almost seems unrecognizable compared to its earlier forms. Almost makes me think of the ship of Theseus. How do we define the point that it's so different it could be considered a different language? Backwards compatibility strikes me as a factor, but backwards compatibility is violated by languages all the time and it's still considered "the same language."
- Rebelgecko 4y agoC++ seems to have more churn than most other languages. e.g. if you're familiar with C99, you can read through a C17 code base and not even realize you're looking at something different. Even going back to C89 it's not that different. Other than some fancy syntax like comments using //, not much has changed. Sure, the standard library might have threads.h now or whatever, but your code is going to use the same letters on the keyboard. There's similar to other languages I'm familiar, even across major revisions the operators and syntax doesn't change much.
- jcelerier 4y agoProgramming language grammars don't have a notion of "change much" - it's exactly the same language or it's another
- Rebelgecko 4y agoI don't think a grammar (at least the way I've used/written them, but I'm def not an expert) captures things like new headers or functions in the standard library.
- usrnm 4y ago> it's exactly the same language or it's another Have you ever heard of python?
- jcelerier 4y agoevery point release is a new language, yes
- jmt_ 4y agoI would have never recognized this syntax as modern day C++ without being told. The language has evolved so much in the last 30+ years that I don't know how anyone is able to keep up unless they've been doing it for decades. As a junior dev, C++ scares the hell out of me - I'd rather wrestle with C, footguns and all, than wrestle with the foot-semiautomatic-rifles C++ provides.