Opened 9 years ago

Closed 9 years ago

#9171 closed Feature Requests (fixed)

Boost.Type_Erasure should be move-aware regarding construction.

Reported by: rivorus@… Owned by: Steven Watanabe
Milestone: To Be Determined Component: type_erasure
Version: Boost 1.54.0 Severity: Problem
Keywords: Cc:

Description

boost::type_erasure::any does not perform move-construction of the contained object during construction of the encapsulating any due to boost::type_erasure::detail::storage's constructor template not using perfect forwarding. This is particularly a problem because it means that you cannot construct an any with a move-only type, which has come up in practice. Similarly, it would be nice to have a "make_any" function template that is able to do completely in-place construction of the contained object.

Change History (2)

comment:1 by Deniz Bahadir <D.Bahadir@…>, 9 years ago

I would also very much appreciate if the concept of move_constructible could be added to Boost.Type_Erasure. At least for C++11. However, maybe it is also possible to implement it for C++03, too, by using Boost.Move?

I actually found this (http://thread.gmane.org/gmane.comp.lib.boost.devel/243109) conversation between Christophe Henry and Steven Watanabe in which Christophe shows a possible implementation of move_constructible concept.
However, it does not seem to work (at least for GCC 4.8 with C++11 enabled).

(PS: In my special case I would like to type-erase a class which has a std::unique_ptr member.)

comment:2 by Steven Watanabe, 9 years ago

Resolution: fixed
Status: newclosed

It seems to be fixed now.

Note: See TracTickets for help on using tickets.