Boost logo

Boost :

From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2024-12-06 06:48:07


On Fri, Nov 29, 2024, 17:41 Marcus Tomlinson via Boost <
boost_at_[hidden]> wrote:

> I’m aware that the current implementation of any intentionally avoids copy
> assignments and uses only copy construction for all value updates. I
> believe this is due to the fact that copy assignment isn’t always available
> for all types - understandable.
>

This could be solved via type traits.

My proposal is what if we had a separate “fast-any” type that does utilise
> copy assignment when types match. In my own usage of this new type, I’ve
> found massive (roughly 2x) performance improvement on consecutive
> assignments of the same type.
>
> I’d like to gauge whether there would be any interest in adding such a
> type to the Boost library.
>
> Source code: https://github.com/cross-platform/fast_any

How about just improving the existing boost::any? If the incomming type is
assignable, this is not empty and its type matches the type stored in this,
then call unsafe_any_cast and assing the new value

Could you please provide a PR? Thanks in advance

>
>
> Regards,
> Marcus Tomlinson
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk