Much better to change this to
```
std::unique_ptr<DTSegmentCand> seg{ new DTSegmentCand(pointsSet,s1);
```
Then you don't have to manually deal with memory management on each return statement.