andrejtonev/cabpp

Using move semantics with multiple constructors

andrejtonev opened this issue · 1 comments

ptrs_.push_back(new T(std::forward<Args>(args)...));

If the T constructor is using move semantics, only the first object will receive the correct arguments.

This goes beyond just the move semantics. Basically any passed argument that gets changed by the constructor will lead to constructor calls with different passed arguments.
One way to solve this would be to force constant references as input types.
In cases where the user needs move semantics or non-const references, they can create the objects independently of CAB and just pass their pointers.