C++ Visitor Design Pattern - Part 4 of 4 - std::visit and std::variant version

  Рет қаралды 1,527

Mike Shah

Mike Shah

Күн бұрын

Пікірлер: 11
@__hannibaalbarca__
@__hannibaalbarca__ 3 ай бұрын
Hello, Mike, i m really appreciate that , i m using double visit; with double variant , variant_ptr_solid -> variante_ptr_behavior and it work very well.
@MikeShah
@MikeShah 3 ай бұрын
Cheers!
@machinelearning4611
@machinelearning4611 9 күн бұрын
very well explained
@MikeShah
@MikeShah 9 күн бұрын
Cheers!
@Chupe_chupe
@Chupe_chupe 10 ай бұрын
Great video
@MikeShah
@MikeShah 10 ай бұрын
Cheers!
@bsdooby
@bsdooby 10 ай бұрын
Are the previous examples and this functional-style one really the same? IMHO the actors act on some target objects (the orcs, goblins), and actors are not the state bearers, but the actions that change the state of bespoke objects (?)
@MikeShah
@MikeShah 10 ай бұрын
I probably prefer the previous example as it's easier for me to see where the state holds. That said, we could put the attributes, and have an 'id' in the any of the 'actor types' (which could still be derived types) to access any state that we need. But yes, we're effectively using the variant as a 'target', and can dynamically select the state. I think variant might actuallyl be very useful in a game-like scenario for swapping behaviors for objects in the same hierarchy very quickly -- haven't tried in actual game scenario though with this implementation.
@bsdooby
@bsdooby 10 ай бұрын
@@MikeShah would be interesting to compare performance given that variant type, in a hot loop
@MikeShah
@MikeShah 10 ай бұрын
Agreed!@@bsdooby
@ami6packs
@ami6packs 8 ай бұрын
@@bsdooby std::variant is faster than classical visitor pattern using virtual.
УНО Реверс в Амонг Ас : игра на выбывание
0:19
Фани Хани
Рет қаралды 1,3 МЛН
UFC 287 : Перейра VS Адесанья 2
6:02
Setanta Sports UFC
Рет қаралды 486 М.
The Biggest React Framework You've Never Heard of
20:29
Theo - t3․gg
Рет қаралды 52 М.
Some simple problems solved in C3
20:39
C3Lang
Рет қаралды 2,2 М.
Forget WiFi AGAIN! This Wireless Method is WAY Better?
12:05
GreatScott!
Рет қаралды 26 М.
Why RISC-V Matters
13:42
ExplainingComputers
Рет қаралды 17 М.
nice math olympiad problems || can you solve this exponent equation||
15:06