C++ Weekly - Ep 266 - C++20's std::shift_left and std::shift_right

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

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

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

Does this happen because the algorithm applies std::move to the vector elements? Thanks:)

nikita-wyzx
Автор

The example doesn’t show that shift_left returns an end iterator and shift_right a begin iterator, which you need to erase the elements you moved from.

headlibrarian
Автор

Will you make a video about the new thread synchronisation stuff from C++20? Like waitable atomics, semaphores etc.

chachasenri
Автор

Ooh a printed copy of the book? Awesome!

superscatboy
Автор

it's either Minecraft Jason, or Money For Nothing (Checks For Free) Jason! (Kinda dates me doesn't it?)

treyquattro
Автор

This is a question that I've been unshure about: is it ok to implement operators for std-templates like std::vector<int> or std::variant<...>? Do they need to be in a namespace? It would be a good topic for a video.

I wrote the following code in some project

using my_type = std::variant
<
type_a,
type_b,
type_c
>;

std::ostream& operator<<(std::ostream& out, my_type const& m)
{
std::visit([&](auto const& m1)
{
out << m1;
}, m);
return out;
}

cmdlp