CppCon 2018: Stephan T. Lavavej “Class Template Argument Deduction for Everyone”

  Рет қаралды 12,397

CppCon

CppCon

Күн бұрын

Пікірлер: 35
@tourdesource
@tourdesource Жыл бұрын
Quite enlightening talk. Thank you Stephan and CppCon for this one.
@eLBehmo
@eLBehmo 4 жыл бұрын
15:37 - does someone know of a case where type information flows backwards? What does he mean by this?
@davidkatz1017
@davidkatz1017 2 жыл бұрын
If anyone's still interested in the answer: ``` auto a = true ? std::nullopt : std::optional{42}; ``` I'm not sure if this is exactly what Stephan had in mind. The first part of the ternary doesn't tell us the type of the expression (well, it's nullopt_t, but that's not helpful). The second part makes it optional. So type information sort of flows backwards.
@cppsage
@cppsage 6 жыл бұрын
Slide 16! Where is Enterprise? :)
@PixelPulse168
@PixelPulse168 6 жыл бұрын
Well, with great power comes great responsibility.
@origamibulldoser1618
@origamibulldoser1618 5 жыл бұрын
With great power comes great fuck ups
@TsvetanDimitrov1976
@TsvetanDimitrov1976 6 жыл бұрын
We definitely need to have a warning about it if CTAD could potentially select the wrong template specialization.
@juliean123
@juliean123 6 жыл бұрын
nice talk!
@mapron1
@mapron1 6 жыл бұрын
On "Comittee Grill" one of the members (Titus afair) said he regret CTAD exists in standard. Why it could consider evil?
@timseguine2
@timseguine2 6 жыл бұрын
My guess would be because it introduces yet another specialized syntax in order to specify the deduction rules. For me though I see it as necessary for consistency and ease of use with concepts and generalized auto.
@mapron1
@mapron1 6 жыл бұрын
Good point. Though, I don't think comittee member could say "I wish it wouldn't exists" only for "new syntax".
@TheFojar
@TheFojar 6 жыл бұрын
Titus gave his reason for disliking CTAD as that it was rushed into the standard without enough deliberation and tuning. I imagine if it was better-implemented, it wouldn't be as disliked.
@mapron1
@mapron1 6 жыл бұрын
I remember that. But I wa curiuos for objective reasoning, not the process' issues.
@timseguine2
@timseguine2 6 жыл бұрын
I can understand his point of view. I do have the intuition that this could end up like ADL(which is in a lot of cases good) with weird unintended corner cases that unfortunately show up in reasonable usage. I mean C++ syntax is a minefield and this probably didn't make that better.
@anonytube1679
@anonytube1679 6 жыл бұрын
It weirds me out that he says "shared putter, stood vector, int star" instead of: shared pointer, standard vector, int pointer. Who talks like that?
@okaminess
@okaminess 6 жыл бұрын
He's speaking in acronyms.
@ccreutzig
@ccreutzig 4 жыл бұрын
A lot of people in C++ conferences talk like that.
@juliean123
@juliean123 6 жыл бұрын
But i should have logged myself out, or shut down my computer at least before i leave. Nvm i am always hasty and have no focus.
@noxabellus
@noxabellus 6 жыл бұрын
I think we're reaching peak insanity here. You need expert level knowledge to do anything in C++ safely these days. The level of generality in the STL is a cancer spreading across the whole language. I'm not a big fan of Rust but its a good example in this case. It doesn't need any of this shit, because they don't try to make every type work for every situation. They pick a sane subset of problems to solve. If the type you're using doesn't solve the problem you have, you make a new type; you don't stick 15 template parameters on it. If you simply set sane limits, you don't need a whole new syntax to deal with the overly generic nature of everything.
@informant09
@informant09 6 жыл бұрын
Git gud.
@noxabellus
@noxabellus 6 жыл бұрын
@@informant09 I did. Its dealing with other people's lack of understanding that is problematic now
@seditt5146
@seditt5146 5 жыл бұрын
Yeah, its as safe as its always been, its people inventing stuff to fix errors that happen from people that don't know what they are doing which creates more stuff that more people don't know how to use so they need to fix that to make it so more people can use it and that can be safer....... ..er......err..... If youngins would have just git good from the start we would not have most of this shit but instead the belief now is this stuff is what makes you good and that is why so many programs lag these days when computers 20 years ago could have kept up with the same task. Its also why my chrome browser is using like 4 GB of data and climbing for a 5kb web page.
@chevlonmacguinstudios
@chevlonmacguinstudios 6 жыл бұрын
Geez and I thought c parallel programming was crazy, this is messy as fuck completely new layered abstraction over general pragraming.
@LunarLambda
@LunarLambda 6 жыл бұрын
C++ should have type inference, aka almost always auto but without writing "auto", or replace it with something else, like "var v = vector { 1, 2, 3, 4 }; a = array { "hello"s, "world"s }; p = pair { true, 400 };
@sephirostoy
@sephirostoy 6 жыл бұрын
auto is all about type inference. What's wrong with it?
@pitri_hub
@pitri_hub 6 жыл бұрын
I'm glad that auto is there, because I would like to be able to differentiate between the declaration of a variable or if the variable just gets a value. That's what I always hated about languages that can just "use" variables. If you declare it, you explicitly tell the reader "This is the place where I need the variable". It makes the code more expressive. And expressive code is something desirable. If you can just "use" a variable without declaration, you never know if this place was the first usage of the variable without having to search through the whole function. And even if you don't find it in there, who guarantees you that the variable isn't declared outside of the function? Maybe in a class or as a global variable? Just think about it, and the lifetime of variables. Not needing to use auto for a declaration would have major consequences. And I would also like to ask you: What's wrong with auto? Why are you suggesting it being renamed to var or something else?
@alcesmir
@alcesmir 6 жыл бұрын
#define var auto
@sephirostoy
@sephirostoy 6 жыл бұрын
@@alcesmir #define let const auto
@isodoublet
@isodoublet 5 жыл бұрын
"v = vector { 1, 2, 3, 4 };" GTFO with that javascript shit.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 107 М.
CppCon 2018: Jason Turner “Applied Best Practices”
1:03:19
CppCon 2018: Andrei Alexandrescu “Expect the expected”
58:58
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 285 М.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН