Re:C++ patterns for low-latency applications including high-...
by a_t48 on Monday July 08, 2024 @08:51PM
(#40911486)
If you _maybe_ need to share ownership, the second is a little pessimistic - you always increase the ref count.
[ Parent
| on HN ]
Re:C++ patterns for low-latency applications including high-...
by Maxatar on Monday July 08, 2024 @11:18PM
(#40912237)
That is correct and I can see that being a justification for passing a const&, in fact the C++ Core Guidelines agree with you that such a scenario is the only acceptable reason for passing a shared_ptr by const&, although they encourage passing by value, or just passing a const T&.
Re:C++ patterns for low-latency applications including high-...
by a_t48 on Monday July 08, 2024 @11:51PM
(#40912389)
Obviously the correct way is to accept a templated type and use perfect forwarding. /s /s /s /s /s
Re:C++ patterns for low-latency applications including high-...
by worstspotgain on Tuesday July 09, 2024 @12:13AM
(#40912488)
Bonus points for using static_cast<T &&>(p) instead of std::forward<T>(p) ;)