2013/6/1 Vicente J. Botet Escriba <vicente.botet@wanadoo.fr>

I've a clear answer from Howard. See below.

Le 01/06/13 18:29, Howard Hinnant a écrit :

      
The reason F has to be CopyConstructible is not because of the signatures of the constructor and assignment operator.  Both could be F, or F&&, and we appear to have split the difference. :-)

The reason F has to be CopyConstructible is because of function's copy constructor, and because F is type-erased inside of function.  Because F is type-erased, when function is copied, it must copy F using a virtual function call (or via a function pointer).  And because F's copy constructor must be called via a virtual function, F's copy constructor is instantiated whether or not function's copy constructor is instantiated.  And that is why F must be CopyConstructible.

If F was not type-erased inside of function, F would not have to be CopyConstructible until actually copied.



Ah, perfectly clear now. Awesome of you to to share the info.

Regards,
Simon