Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 9124

C/C++ • Re: std::variant use in rpicam-apps question

$
0
0
My guess, and it is only a guess because I've never used std::variant<> and I'm too ancient to keep up to date, is this might have something to do with move semantics (aka T&&) which I also have no experience of. I've noticed std::forward<> often pops up which I believe is a mechanism which prevents C++ having to make a copy of a temporary which is going to immediately be thrown away. I *think* it works like this..

Code:

T somevar(somefunc())
..rather than somefunc() returning a temporary result which has to be copied to somevar, std::forward<> moves the temporary into somevar.

You're best off asking this in a dedicated C++ forum. Please follow up here so I know how wide of the mark my guess is! :-)

Statistics: Posted by swampdog — Wed Jul 02, 2025 5:53 pm



Viewing all articles
Browse latest Browse all 9124

Trending Articles