CAF requires that each message type be regular. This means that it must provide a copy constructor that std::unique_ptr does not have. Therefore, the compiler complains.
Messages have an implementation of copy to write. You can copy one message cheaply, as it just hits the link counter inside. At any time, you can const-access message elements. The "write" part of the copy-to-write part only works if the link count is greater than 1 and you are requesting non-constant access. At this point, the runtime invokes the copy constructor of the contained type to create a new message.
If the CAF unconditionally executes this copy, regardless of the reference count, then it would be impossible to effectively support the programming of the data stream when the actor receives the message, changes its contents and proceeds to the next step.
Think of messages as containers of pointers: contained elements are allocated in free storage. Storing a pointer in a message is usually a design flaw. Double packaging also requires excessive distribution of the dispenser.
Since you can flexibly crop messages, you do not need to create a single message and then use the contained value in different contexts.
source share