Тёмный
No video :(

C++ Weekly - Ep 436 - Transforming Lambda Captures 

C++ Weekly With Jason Turner
Подписаться 112 тыс.
Просмотров 9 тыс.
50% 1

Опубликовано:

 

21 авг 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 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 24 дня назад
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 24 дня назад
Yes, that's a potential problem. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-cUvdtLTJeec.html
@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 24 дня назад
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
Далее
ОБЗОР ПОДАРКОВ 🎁 | WICSUR #shorts
00:55
الذرة أنقذت حياتي🌽😱
00:27
Просмотров 13 млн
researchers find an unfixable bug in EVERY ARM cpu
9:48
The Pointer to Implementation (pImpl) idiom in C++
6:54
CONSTANTS in C++
8:31
Просмотров 26 тыс.
why do header files even exist?
10:53
Просмотров 392 тыс.
C++ Weekly - Ep 419 - The Important Parts of C++23
11:50
How Linux Kernel Prints Text on Screen
12:46
Просмотров 63 тыс.
ОБЗОР ПОДАРКОВ 🎁 | WICSUR #shorts
00:55