[any] Move semantic

Hi, My current understanding of the new rules of 5 tells me that boost::any isn't "move aware". First, am I correct? Second, I think that adding the move constructor and move operator is trivial. Again, am I correct or is there some tricks to know before adding them? Third, I want to use boost::any in a value-semantic type. Sometime it would keep a unique_ptr. If I understand correctly move semantic and unique_ptr implementation, the current boost::any implementation don't forbid me to use unique_ptr as a value type. Am I correct? Joel Lamotte

On 17 May 2012 03:33, Klaim - Joël Lamotte <mjklaim@gmail.com> wrote: Third, I want to use boost::any in a value-semantic type. Sometime it would
keep a unique_ptr. If I understand correctly move semantic and unique_ptr implementation, the current boost::any implementation don't forbid me to use unique_ptr as a value type.
It currently forbids you because Copyable is a requirement on the value type, and is enforced in boost::any::holder<ValueType>::clone. If you want to hold a move only type, you'll have to have a version of detect it and throw an exception when copying is attempted. -- Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
participants (2)
-
Klaim - Joël Lamotte
-
Nevin Liber