No video

C++ Weekly - Ep 436 - Transforming Lambda Captures

  Рет қаралды 9,219

C++ Weekly With Jason Turner

C++ Weekly With Jason Turner

Күн бұрын

Пікірлер: 27
@fcolecumberri
@fcolecumberri Ай бұрын
This is one of those features I love I can use and I hate the confusing way it is written.
@czarsonxd2093
@czarsonxd2093 Ай бұрын
had no clue about this
@AndiAbrudan
@AndiAbrudan Ай бұрын
Wow, this is more useful than just the casting part. I find working with the expansion operator very cumbersome; maybe because I haven't studied all the rules. But with this syntax, you're moving the expansion at the top of the lambda, and you're free to use `strlike` as a single object inside the body. Awesome video!
@AtomicAndi
@AtomicAndi Ай бұрын
Thanks for pointing that out. The video was maybe not so awesome after all, because I missed the point about the expansion being kind of outside
@majohime
@majohime Ай бұрын
If only I could find more cool variadic templates/fold expressions related stuff like this
@cppweekly
@cppweekly 23 күн бұрын
Upcoming talk at CppCon 2024 will dig into some of this stuff.
Ай бұрын
This is madness!
@BenjaminWheeler0510
@BenjaminWheeler0510 Ай бұрын
I am lost on all the ellipses unfortunately :( which videos do you cover those on again?
@UsernameUsername0000
@UsernameUsername0000 Ай бұрын
Look up parameter pack and then fold expressions.
@ohwow2074
@ohwow2074 Ай бұрын
It's crazy. I have never heard of this particular use of parameter pack expansion. I guess it'll come in handy.
@Rosen2221
@Rosen2221 Ай бұрын
Literally wrote a subsystem for transporting some version information between client and server, which had almost the exact same function and problem as this video. The function in question was just merging single tokens (from constexpr defines, strings at hand in the version constructing class and other string_view like identifier). WIth the lambda capture we can output a total_size from the single tokens (of whatever stringlike type) and create a new string with reserved size onto which to append
@N....
@N.... Ай бұрын
Ahh ok, I see now what you were talking about, that is indeed simpler than the way I suggested, cool!
@ihatelhp
@ihatelhp Ай бұрын
Surely there are reasons why the ... comes before the identifier initializer?
@abhinavk0929
@abhinavk0929 Ай бұрын
...iden is the syntax to inroduce a parameter pack with the name "iden". So 'strlike' is a pack that consists of string_views into the parameter strings.
@PedroOliveira-sl6nw
@PedroOliveira-sl6nw Ай бұрын
What about lifetime of string views? In this simple case it's okay. But imagine that you return the lambda (instead of void function).
@cppweekly
@cppweekly 23 күн бұрын
Yes, that's a potential problem. kzbin.info/www/bejne/mYbZlaeCia-Ym8U
@badassopenpolling
@badassopenpolling Ай бұрын
nice!
@SylphDS
@SylphDS Ай бұрын
I feel like this is the kind of code you can only read for a about a week after you write it, and then if you read it again at any point after that you get instantly lost in the folding expressions. They are not very intuitive.
@diablo384
@diablo384 Ай бұрын
Does the string_view{...input} make another copy in that lambda function? I can't get it.
@cppweekly
@cppweekly 23 күн бұрын
string_view is never a copy, so it's just creating a view (pointer + length) for each string-like thing passed in. This is not 0 cost, necessarily, but it is very low cost. It might incur some strlen calls sometimes, but otherwise should just be copying 2 pointer-sized things per element.
@troylowry4239
@troylowry4239 Ай бұрын
Wtf is going on in the comments
@majohime
@majohime Ай бұрын
At least no bots spouting slurs, still kinda weird
@RomanOrekhov
@RomanOrekhov Ай бұрын
probably the word "captures" triggered the bots
@AtomicAndi
@AtomicAndi Ай бұрын
Weird example. I'd rather have work_with_stringlike take everything by stringview. How would the code look then?
@anon_y_mousse
@anon_y_mousse Ай бұрын
It's this kind of garbage syntax why I've been working on my own language and the issue with strings is why the default string type in my language *is* a string view.
@sigasigasiga
@sigasigasiga Ай бұрын
std::size be like "oh yeah why am i needed anyway"
@N....
@N.... Ай бұрын
The funny thing about slideware is its selective memory since it's trying to be relevant in other contexts too
C++ Weekly - Ep 437 - Pointers To Overloaded Functions
7:55
C++ Weekly With Jason Turner
Рет қаралды 10 М.
C++ Weekly - Ep 332 - C++ Lambda vs std::function vs Function Pointer
16:30
C++ Weekly With Jason Turner
Рет қаралды 32 М.
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 9 МЛН
Logo Matching Challenge with Alfredo Larin Family! 👍
00:36
BigSchool
Рет қаралды 20 МЛН
Bony Just Wants To Take A Shower #animation
00:10
GREEN MAX
Рет қаралды 7 МЛН
SPILLED CHOCKY MILK PRANK ON BROTHER 😂 #shorts
00:12
Savage Vlogs
Рет қаралды 46 МЛН
C++ Weekly - Ep 419 - The Important Parts of C++23
11:50
C++ Weekly With Jason Turner
Рет қаралды 13 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 249 М.
C++ Weekly - Ep 125 - The Optimal Way To Return From A Function
13:10
C++ Weekly With Jason Turner
Рет қаралды 76 М.
The Pointer to Implementation (pImpl) idiom in C++
6:54
platis.solutions
Рет қаралды 14 М.
The Downsides Of C++ | Prime Reacts
21:23
ThePrimeTime
Рет қаралды 133 М.
How Senior Programmers ACTUALLY Write Code
13:37
Thriving Technologist
Рет қаралды 1,5 МЛН
C++ Code Smells - Jason Turner
56:11
NDC Conferences
Рет қаралды 76 М.
C++ Weekly - Ep 435 - Easy GPU Programming With AdaptiveCpp (68x Faster!)
15:30
C++ Weekly With Jason Turner
Рет қаралды 14 М.
How I use C++: a line-by-line code review
1:40:40
strager
Рет қаралды 255 М.
C++ Weekly - Ep 334 - How to Put a Lambda in a Container
11:51
C++ Weekly With Jason Turner
Рет қаралды 16 М.
طردت النملة من المنزل😡 ماذا فعل؟🥲
00:25
Cool Tool SHORTS Arabic
Рет қаралды 9 МЛН