Loading…
C++Now 2018 has ended
Thursday, May 10 • 2:30pm - 4:00pm
My Little *this Deduction: Friendship is ... Uniform?

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Feedback form is now closed.
This is a talk about a will-have-been-proposed-by-c++now new feature. Here's your standardese buzzword-bingo board (not all cells are covered by this talk, make sure to keep track!):

[uniform call syntax] [recursive lambdas] [const-ref-volatile method templates]
[simplifies language] [move from lambda] [no new keywords]
[executors] [curiously recurring template pattern] [call-by-value methods]

OK, so, here goes:

This lecture is about a small idea by Ben Deane at CppCon 2017. The idea was to make lambdas' call operator aware of whether it was an rvalue or lvalue. The simplest solution was suuuuuper simple (no spoilers though). However, as is customary with anything Ben & Jason touch, it solved ALL THE THINGS! Well, almost. Bear with me.

All this time, Ben Deane, Berry Revzin, Simon Brand, and Gašper Ažman have been working diligently to bring you the following:

- Ever wanted to write a recursive lambda? It's obvious how to, now. Still converts to function pointer. No new keywords.
- Have you ever been peeved about writing a const, &, and a && value accessor? Now it's one template. Same syntax as above.
- Did you ever want to return the derived type from a method, as opposed to the base class type? It's the same template. boost::operator without CRTP!
- Did you ever wonder whether it's size(thing) or thing.size()? No more. Uniform Call Syntax is opt in, works, and ABI compatible. And with no breakage! And no new keywords!
- [captured=std::move(foo)] {
return std::move(captured); /* can I move? Should I copy? Am *I* an rvalue? Now you can know! */
}
- Oh, and this feature makes the language more uniform, not less. We're getting rid of the specialness of methods. You still can't define them elsewhere though. Unless *maybe*! If you care, come to the talk! (Or to a committee meeting, I guess.)
- And Uniform Call Syntax can bind to the *second* (or third...) parameter, if called as method: foo.find(in) or find(in, foo) can be the same function!
- Why Uniform Call Syntax failed before, and why it won't (ok, has a lesser chance to) fail now.
- How about methods that take *this by value?
- And, of course, the Magic of Friendship!

This talk is about how the development of the feature went, what was thrown out, what was defended, where it is now, and about how it will be - hopefully with audience participation. It's all our language, after all!

Speakers
avatar for Gašper Ažman

Gašper Ažman

SDE R&D, Citadel Securities


Thursday May 10, 2018 2:30pm - 4:00pm MDT
Hudson Commons