any icon indicating copy to clipboard operation
any copied to clipboard

Add a template flag which forces the assigned object to be allocated within the any object

Open gloinart opened this issue 4 years ago • 1 comments

Add a templated parameter to the basic_any class which, if true, results of a compile-time error if the basic_any is assigned a too large object.

Example struct Small{int x;}; struct Big{int x, y, z, w;}; auto a = boost::small_any<4, 4, true>{}; a = Small{}; a = Big{}; // static_assert(sizeof(T) <= OptimizeForSize) breaks the compilation

gloinart avatar Sep 21 '21 19:09 gloinart

I think it should be a separate data type. PRs are welcome

apolukhin avatar Sep 02 '22 13:09 apolukhin