Variant/Any and the never-empty guarantee

I am currently writing an object container similar to boost.any but with an allocator template parameter. That allocator is of a custom type that allows efficient stack allocation like boost.variant. While looking at variant's documentation, I became aware of the problem with operator= and the never-empty guarantee. http://boost.org/doc/html/variant/design.html#variant.design.never-empty However, I think none of the solutions is really satisfying, especially in my case where the allocator is generic and provided by the user and where the types that are to be put in the container aren't known until runtime. Lots of versions would need to be made, indicating whether one or another option is nothrow for the object or the allocator, providing fallback allocators etc. Do you think it is reasonable to simply require a nothrow move constructor for the types which are to be put into my container? I cannot think of a case where move constructors would really want to throw, and swap functions which are similar are usually no-throw. There is also the 'false hopes' solution, which is said to not be allowed by the standard. But realistically, that solution shouldn't cause any problem, since I always see moving as a simple bitwise copy ; unless the object references itself, which would be solved by moving it back anyway. I welcome any critics, ideas and advices about moving, exceptions, and bitwise copy.
participants (1)
-
Mathias Gaunard