CppCon 2014: Scott Meyers "Type Deduction and Why You Care"

Поділитися
Вставка
  • Опубліковано 12 вер 2024
  • 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...
    *-----*

КОМЕНТАРІ • 75

  • @fmatthew5876
    @fmatthew5876 10 років тому +33

    Scott's talks make me shake my head in despair at the design decisions and complexity of the C++ type system.

  • @sunilpatidar5641
    @sunilpatidar5641 3 місяці тому +2

    Just came here to revise the first two chapters of effective modern c++ by this guy himself.

  • @karas44
    @karas44 2 роки тому +7

    Wondeful talk in CPP histroy!

  • @gast128
    @gast128 7 років тому +49

    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?

  • @erikvanvelzen
    @erikvanvelzen 10 років тому +10

    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.

    • @danteslog5887
      @danteslog5887 Рік тому

      Simple is once you understand it , I had to read the chapter 2 to 3 times but once I got it , it was simple 😢

  • @thestarinthesky_
    @thestarinthesky_ 9 місяців тому +3

    Great talk! Too bad we don't get to see you in CppCon anymore :( Thanks for all the wonderful works you've done!

  • @jianwang4188
    @jianwang4188 6 років тому +4

    Wonderful! It is not easy to be one C++ expert who is always syncing with latest standardization.

  • @rationalcoder
    @rationalcoder 8 років тому +18

    He has always seemed to me to be quite full of himself, but he is an undeniably good presenter. Great talk!

    • @llothar68
      @llothar68 7 років тому +1

      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.

    • @davidward6779
      @davidward6779 6 років тому +25

      I think he's earned the right to be sure in his abilities.

  • @treyquattro
    @treyquattro 6 років тому +16

    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.

  • @maxx666mayhem
    @maxx666mayhem 8 років тому +3

    Excellent video about an exciting feature in C++11 ... thanks for uploading

  • @arkadye
    @arkadye 10 років тому +25

    The webpage he gave says He-Man won it, just.

    • @Runoratsu
      @Runoratsu 6 років тому +3

      And deservedly so! He should really cosplay as He-Man sometime, it would be hilarious… :D

  • @NonTwinBrothers
    @NonTwinBrothers 10 місяців тому +1

    Excellent talk by Richard Clayderman!! 😊

  • @georganatoly6646
    @georganatoly6646 2 роки тому

    '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)

  • @sanjuuyonsai
    @sanjuuyonsai 10 років тому +9

    no conclusion of the hair poll?

  • @Dziaji
    @Dziaji 2 роки тому +1

    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.

  • @magetaaaaaa
    @magetaaaaaa Рік тому +1

    I don't know much about the industry, but isn't this guy some C++ legend or something? Lol.

  • @ayseryucel
    @ayseryucel 5 років тому +3

    @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.

  • @antiHUMANDesigns
    @antiHUMANDesigns 6 років тому +12

    I think Luke Skywalker when I see his hair.

  • @enricomariadeangelis2130
    @enricomariadeangelis2130 5 років тому +3

    This man is amazing!

  • @jakobullmann7586
    @jakobullmann7586 3 роки тому +2

    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."

  • @ulidtko
    @ulidtko 9 років тому +26

    Agreed. The type system of C++ is becoming a really screwed dump.

    • @gareginasatryan6761
      @gareginasatryan6761 7 років тому +6

      Maxim Ivanov not worse than javascipt

    • @andreitolkachev8295
      @andreitolkachev8295 2 роки тому +2

      @@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.

  • @disk0__
    @disk0__ 5 років тому +2

    Even after I double checked the video and the hair was different, Scott is always Double Dream Feet in my mind

  • @logicboard7746
    @logicboard7746 2 роки тому

    This is truly attending a C++ class at a college

  • @hanyanglee9018
    @hanyanglee9018 2 роки тому +1

    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.

  • @blazsovdat6433
    @blazsovdat6433 8 років тому +2

    Do we have an explanation regarding why is there a special auto rule for doing type deduction for braced initializers?

    • @tetramaximum
      @tetramaximum 6 років тому +2

      Blaž Sovdat yes, we do. en.cppreference.com/w/cpp/language/direct_initialization see the second form.

  • @mwont
    @mwont 8 років тому +10

    and i thought that type deduction was easy. i was so wrong!

  • @berajpatel8081
    @berajpatel8081 4 роки тому

    Thank you Scott

  • @michaelmorris2300
    @michaelmorris2300 6 років тому +20

    C++ will soon stand for convoluted ++

  • @hanyanglee9018
    @hanyanglee9018 2 роки тому

    Do we have a new talk on c++20 concept and constrains?

  • @joe-ti8rz
    @joe-ti8rz 7 років тому

    dankjewel meneer maand 3 zit erop

  • @timwhite7127
    @timwhite7127 9 місяців тому

    Actually, when you brought up the hair topic my mind went straight to John Fogerty.

  • @alexeybeloushko7240
    @alexeybeloushko7240 6 років тому +3

    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 ?

    • @movax20h
      @movax20h 4 роки тому

      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.

    • @anon_y_mousse
      @anon_y_mousse Рік тому

      @@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.

  • @HarikrishnaNalla9
    @HarikrishnaNalla9 3 роки тому

    A confident programmer swag at 49:41

  • @pspimf
    @pspimf 7 років тому +1

    Slide 17 is missing in the video, unfortunately

    • @jochen_schueller
      @jochen_schueller 4 роки тому +10

      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.

  • @Legorz3373
    @Legorz3373 Рік тому

    Slides 17 and 37 missing

  • @pavel_trpn
    @pavel_trpn Рік тому

    At 33:35 he looked exactly like John Bon Jovi!!!

  • @apivovarov2
    @apivovarov2 9 місяців тому

    Guy has switched to D. is it true???

  • @user-vs6kl8ph5v
    @user-vs6kl8ph5v 11 місяців тому

    the opening speech 😭

  • @hakoo2700
    @hakoo2700 4 роки тому

    amazing! tnx >_

  • @soulstudiosmusic
    @soulstudiosmusic 10 років тому +11

    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".

    • @lincolnsand5127
      @lincolnsand5127 4 роки тому +2

      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"

  • @almighty1984
    @almighty1984 Рік тому

    Being Swedish, to me he looks like a cross between Ted Gärdestad and Christer Petterson (w/o the alcoholism)

  • @GeorgeTsiros
    @GeorgeTsiros 5 років тому +1

    can we use different names for rvalue and lvalue? after a while it gets tiring trying to follow the speaker >_

    • @Webfra14
      @Webfra14 5 років тому +4

      I suggest ^nanana and °nanana...

    • @anon_y_mousse
      @anon_y_mousse Рік тому

      How about can and not? Can for l-value because you can assign, and not for r-value.

  • @wpavada3247
    @wpavada3247 7 років тому

    can someone explain what he said at 27:44 ?

    • @brainplot
      @brainplot 5 років тому

      "[...] so they're only ignored if you're making a completely independent value."

  • @Spiderboydk
    @Spiderboydk 9 років тому +6

    Oh god, this is a mess.
    This is more complicated than SFINAE :-)

  • @Babs42
    @Babs42 6 років тому

    He forgot Michael Angelo Batio (MAB).

  • @esad9341
    @esad9341 7 років тому +5

    as awesome as Scott is, I still prefer c

  • @ulidtko
    @ulidtko 9 років тому +2

    "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.

  • @risingpower
    @risingpower 8 років тому +13

    he needs some conditioner

  • @d46512
    @d46512 6 років тому +1

    If he got a haircut Scott would look and sound just like Peter Gregory!

    • @mohammedj2941
      @mohammedj2941 3 роки тому +1

      Exactly.
      Although I don't know who Peter Gregory is.

  • @JanPBtest
    @JanPBtest 9 років тому +3

    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.

  • @eddykohlmann471
    @eddykohlmann471 2 роки тому +1

    Standup ++

  • @jasonli1194
    @jasonli1194 5 років тому +1

    a braced initialiser has no type

    • @Webfra14
      @Webfra14 5 років тому +1

      naaaaah... you didn't say it three times... you didn't really mean it...

  • @rnk1415
    @rnk1415 6 років тому +2

    Life was good till the type system of C++ is screwed.