Currently the iterator type for OwnPtrVec is just T**, this makes mutating algorithms unnecessarily dangerous, giving access directly to the stored pointer.
Alternative:
Return some sort of a proxy which is (move?) assignable/constructable from (but not to) std::unique_ptr. When assigned from unique_ptr de-allocates old object and releases the unique_ptr.
Something like this should be possible:
class AstNode;
ut::OwnVecPtr<AstNode> nodes;
std::transform(nodes.begin(), nodes.end(), nodes.begin(), [](auto node){
if (foo)
return node;
else
return std::make_unique<AstNode>(bar);
});
Possibly may require std::make_move_iterator?
Currently the iterator type for
OwnPtrVecis justT**, this makes mutating algorithms unnecessarily dangerous, giving access directly to the stored pointer.Alternative:
Return some sort of a proxy which is (move?) assignable/constructable from (but not to)
std::unique_ptr. When assigned fromunique_ptrde-allocates old object andreleases theunique_ptr.Something like this should be possible:
Possibly may require
std::make_move_iterator?