-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
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?
Metadata
Metadata
Assignees
Labels
No labels