CppCon 2014: Scott Meyers "Type Deduction and Why You Care"
Вставка
- Опубліковано 10 лют 2025
- www.cppcon.org
-
Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/Cpp...
--
C++98 had template type deduction, and it worked so intuitively, there was little need to understand what took place under the covers. C++11 extends type deduction to include universal references, applies it to auto variables and lambda expressions, then throws in a special auto-only deduction rule. C++14 pushes the boundary further, adding two forms of function return type deduction (auto and decltype(auto)) for arbitrary functions and offering auto parameters for lambdas. The result is that what could be treated as a black box in C++98 has become a topic that practicing C++ developers really need to understand. This talk will give you the information you need to do that.
--
Scott Meyers has been working with C++ since 1988. He recently finished his new book, "Effective Modern C++".
--
Videos Filmed & Edited by Bash Films: www.BashFilms.com
*-----*
Register Now For CppCon 2022: cppcon.org/reg...
*-----*
Just came here to revise the first two chapters of effective modern c++ by this guy himself.
By watching this video, I understood why he retired too soon! He must have been frustrated by the nonsensical additions being haphazardly thrown into C++ by committees! Thanks Scott! I'll always be your big fan!
Scott's talks make me shake my head in despair at the design decisions and complexity of the C++ type system.
Wonderful! It is not easy to be one C++ expert who is always syncing with latest standardization.
Wondeful talk in CPP histroy!
This is an excellent, or probably the best, video on c++ type system. At the same time, it shows the level of insanity of modem c++ design. It's hard to believe a programming language can be designed so complicated, confusing and ugly. It'll be very interesting if someone can make a video explaining not just what it is, but all the design considerations behind this mess.
Great talk. This is simple and we're all supposed to know this, yet it is so refreshing to see it all mentioned in once place.
Simple is once you understand it , I had to read the chapter 2 to 3 times but once I got it , it was simple 😢
Great talk! Too bad we don't get to see you in CppCon anymore :( Thanks for all the wonderful works you've done!
He has always seemed to me to be quite full of himself, but he is an undeniably good presenter. Great talk!
Yeah, definitely the guy you want to have as a teacher but never as someone to join you when drinking a beer. Not sure about Herb Sutter but about Scott.
I think he's earned the right to be sure in his abilities.
Excellent video about an exciting feature in C++11 ... thanks for uploading
Excellent talk by Richard Clayderman!! 😊
Good talk though it seems to me that those C++ committee members actually don't make things simple as possible. Do they realize that ordinary C++ programmers have to deal with the domain and application complexity as well on top of all these rules?
At 35:00, there are literally no >= 1 in the entire slide. It says >1, just like he meant it to. The comment from the audience is wrong, and Scott agreed for some strange reason.
The slides in the video are updated
at 34:48 when someone in the audience points out a mistake and Scott acknowledges it, has the slide been updated because it looks correct to me based on what it says and what Scott has been saying prior.
I think so.
This is truly attending a C++ class at a college
I don't know much about the industry, but isn't this guy some C++ legend or something? Lol.
This man is amazing!
'back in my day' (with C) to make a generic interface you made the underlying structs and funcs an int or long and let someone else build some more specialized wrappers on top that by explicitly casting and packing their arbitrary data types into those ints, in effect treating an int or long or w/e as if they were assembly-like general registers, so that users of the higher level wrappers didn't have to worry about any implicit type deduction rules and the implementers didn't have to worry about edge cases cropping up unexpectedly (this was in effect using C's version of inheritance combined with C's much stronger encapsulation to achieve the same effect, trading quick but complicated/possibly brittle templates with slower, explicit, but more strictly defined generics)
@CppCon i can see Scott point this and that in the slide but can't see anything what he is pointing on the slide placed on the left side of the video. it makes it hard to follow.
Even after I double checked the video and the hair was different, Scott is always Double Dream Feet in my mind
I think Luke Skywalker when I see his hair.
To be honest, I like N3922... Immediately before slide 20 I thought: "This does not make sense." And then slide 20 came: "Yeah, that's how it should be."
dankjewel meneer maand 3 zit erop
no conclusion of the hair poll?
The webpage he gave says He-Man won it, just.
And deservedly so! He should really cosplay as He-Man sometime, it would be hilarious… :D
Thank you Scott
Do we have a new talk on c++20 concept and constrains?
Actually, when you brought up the hair topic my mind went straight to John Fogerty.
Agreed. The type system of C++ is becoming a really screwed dump.
Maxim Ivanov not worse than javascipt
@@gareginasatryan6761 Difference is, nobody really gives a shit about performance in such languages (JS, Python), but for C++ which is supposed to be a high-performance language, it's bad indeed.
Do we have an explanation regarding why is there a special auto rule for doing type deduction for braced initializers?
Blaž Sovdat yes, we do. en.cppreference.com/w/cpp/language/direct_initialization see the second form.
and i thought that type deduction was easy. i was so wrong!
the opening speech 😭
The whole thing needs an overhaul. If some way of programming doesn't make any sense, it should be a compiling error, not a weird deduction rule. If auto were always without any vcr and if there is any implicit conversion, it's at least a warning, the rules would be way less.
An analog is the == in javascript. It tries to help but only messes.
Slide 17 is missing in the video, unfortunately
The standard doesn't guarantee that slides have to be contiguously allocated, it only requires a strict order. If you really need to iterate via raw page numbers without being at risk of a page fault, consider using a book or journal instead.
A confident programmer swag at 49:41
C++ will soon stand for convoluted ++
is it something with me? or
auto x3 {17}
was unintentional due to bugs in lexer? and than to cover for it necroSoft put a proposal in N9322 ?
It was supposed to work, because 'int x3{17}' works. Why one earth would you write 'int x3{17}', and want it to fail to compile with can't initialize int from initalizer_list.
@@movax20h I think he meant the syntax of `type t { ... }` as opposed to the much better syntax of `type t = { ... }`. At least I hope he means that because I personally detest that form of object construction and equally the method of type inference that C++ incorporates.
amazing! tnx >_
Another title: "Type deduction and why you probably shouldn't use it, because it's convoluted, difficult to ascertain, subject to change and probably will only save you a few lines of code at the cost of long-term code reuse and ability to interpret code".
Ehhhh. Not really true at all. Auto doesn't allow the kinds of bugs that explicit types introduce. He recommends using it in "code::dive C++14 for embedded"
can we use different names for rvalue and lvalue? after a while it gets tiring trying to follow the speaker >_
I suggest ^nanana and °nanana...
How about can and not? Can for l-value because you can assign, and not for r-value.
as awesome as Scott is, I still prefer c
Slides 17 and 37 missing
can someone explain what he said at 27:44 ?
"[...] so they're only ignored if you're making a completely independent value."
Being Swedish, to me he looks like a cross between Ted Gärdestad and Christer Petterson (w/o the alcoholism)
"Type deduction _of C++_ ..." you mean, right?
In other languages (which have type system more powerfull than C++'s and yet don't undergo uncontrollable complexity blowup) type inference is a very helpful tool, used daily with joy.
Guy has switched to D. is it true???
At 33:35 he looked exactly like John Bon Jovi!!!
He forgot Michael Angelo Batio (MAB).
Two reasons: (1) Life is complicated so anything that's going to do even halfass job at modelling it WILL be complicated. Just ask any physicist. (2) C++ cannot introduce features in the best and easiest possible way because of a certain real-life constraint called "backward compatibility". It's simply impossible to suddenly declare millions of line of code out there invalid because of some gorgeous theoretical advance in language development.
If he got a haircut Scott would look and sound just like Peter Gregory!
Exactly.
Although I don't know who Peter Gregory is.
Oh god, this is a mess.
This is more complicated than SFINAE :-)
he needs some conditioner
Standup ++
Life was good till the type system of C++ is screwed.
a braced initialiser has no type
naaaaah... you didn't say it three times... you didn't really mean it...