C++ Weekly - Ep 448 - C++23's forward_like

preview_player
Показать описание
☟☟ Awesome T-Shirts! Sponsors! Books! ☟☟

A robust cross-platform IDE for C and C++, CLion makes your development experience smoother and more productive! The latest version of CLion introduces deep integration with the ReSharper C++/Rider C++ language engine, performance improvements for the debugger, new features for embedded development, enhancements for project models and build tools, and much more! Check out all of the details and give it a try today!

T-SHIRTS AVAILABLE!

WANT MORE JASON?

SUPPORT THE CHANNEL

GET INVOLVED

JASON'S BOOKS

► C++23 Best Practices

► C++ Best Practices

JASON'S PUZZLE BOOKS

► Object Lifetime Puzzlers Book 1

► Object Lifetime Puzzlers Book 2

► Object Lifetime Puzzlers Book 3

► Copy and Reference Puzzlers Book 1

► Copy and Reference Puzzlers Book 2

► Copy and Reference Puzzlers Book 3

► OpCode Puzzlers Book 1


RECOMMENDED BOOKS

AWESOME PROJECTS

O'Reilly VIDEOS

Рекомендации по теме
Комментарии
Автор

I had to rewind. Yes, Jason indeed did not say "more or less equivalent": he said "morally equivalent". I think the term "C++ value system" is taking on whole new meanings.

victotronics
Автор

I love the ending. I know that's not the intended message, but I choose to interpret it that way - "get back as close as possible to C, except always use RAII objects"

TsvetanDimitrov
Автор

Your cartoon character on previews reminds me of charachers from "Dire Straits" musicians, "Money for Nothing" video clip.

josephlagrange
Автор

Can you use deducing this to write all the begin() overloads for a container? I have tried but it seems that it'll have to be more verbose than just writing the overloads manually. Because "begin() const" is supposed to return a pointer to const, not a const pointer, so forward_like doesn't help in this.

rezwanarefin
Автор

I got the forwarding part: we receive the object reference as a forwarding reference, thus the need to 'deforward' the object ref type. But I still don't know why we needed std::forward_like, wouldn't std::forward do the same thing? 🤔

Raspredval
Автор

In the case shown in the video returning would be the same as returning (with the exception of std::forward_like not handling volatile-qualified types) which doesn't make the code any better.

christous
Автор

is this a good use of std::forward_like though? The same could have been achieved using

If value were replaced by a “legacy” member function with no rvalue version, that would have been more interesting.

AlfredoCorrea
Автор

C++ really blows my head sometimes... And not necessarily in a good way

TheMrKeksLp
Автор

This is actually a really neat function. It reads like crap but it looks like i can remove a ton of getter overloads from my code

ruadeil_zabelin
Автор

PSA to never, ever use this in production code 😊

pw
Автор

I am a bit confused why we have this mechanism if the only thing it is capable of is to replace (by complicating the code) a public value? why do we not just use a public value then?

amingholizad
Автор

auto -> decltype(auto) what a cursed thing

xybelis
Автор

i still don't get what this is for

qsvui
Автор

If C++ ever drops the regular syntax for function signatures and forces everyone to use the arrow syntax, I'm going to stop using C++. I can't stand that ugly and unnecessary format, and anyone that tells me that it's somehow easier or in any way better is wrong. If you can't use a placeholder and go back and edit it after you've written the rest of the function, then you need to learn how to use your editor better. And yes, the placeholder should be something invalid so that it won't just compile and give you a silent error later. It should *NOT* be auto.

anon_y_mousse