Fix -Wredundant-move warnings, 2nd try
std::move is redundant when it is used to return a local object from a function (eg return std::move(local)): indeed, returning a local object from a function implicitly moves it. Moreover using std::move this way See https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rf-return-move-local However, in order to avoid -Wreturn-std-move as well, a Base object is move-constructed from Derived when required.
This commit is contained in:
@@ -236,7 +236,7 @@ TopoDS_Shape FaceMakerCheese::makeFace(const std::vector<TopoDS_Wire>& w)
|
||||
builder.Add(comp, aFace);
|
||||
}
|
||||
|
||||
return std::move(comp);
|
||||
return TopoDS_Shape(std::move(comp));
|
||||
}
|
||||
else {
|
||||
return TopoDS_Shape(); // error
|
||||
|
||||
@@ -2222,7 +2222,7 @@ TopoDS_Shape TopoShape::makeHelix(Standard_Real pitch, Standard_Real height,
|
||||
TopoDS_Edge edgeOnSurf = BRepBuilderAPI_MakeEdge(segm , surf);
|
||||
TopoDS_Wire wire = BRepBuilderAPI_MakeWire(edgeOnSurf);
|
||||
BRepLib::BuildCurves3d(wire);
|
||||
return std::move(wire);
|
||||
return TopoDS_Shape(std::move(wire));
|
||||
}
|
||||
|
||||
//***********
|
||||
@@ -2308,7 +2308,7 @@ TopoDS_Shape TopoShape::makeLongHelix(Standard_Real pitch, Standard_Real height,
|
||||
|
||||
TopoDS_Wire wire = mkWire.Wire();
|
||||
BRepLib::BuildCurves3d(wire);
|
||||
return std::move(wire);
|
||||
return TopoDS_Shape(std::move(wire));
|
||||
}
|
||||
|
||||
TopoDS_Shape TopoShape::makeThread(Standard_Real pitch,
|
||||
@@ -2926,9 +2926,10 @@ TopoDS_Shape TopoShape::makeOffset2D(double offset, short joinType, bool fill, b
|
||||
TopoDS_Compound result;
|
||||
BRep_Builder builder;
|
||||
builder.MakeCompound(result);
|
||||
for(TopoDS_Shape &sh : shapesToReturn)
|
||||
for(TopoDS_Shape &sh : shapesToReturn) {
|
||||
builder.Add(result, sh);
|
||||
return std::move(result);
|
||||
}
|
||||
return TopoDS_Shape(std::move(result));
|
||||
}
|
||||
else {
|
||||
return shapesToReturn[0];
|
||||
@@ -3175,7 +3176,7 @@ TopoDS_Shape TopoShape::removeSplitter() const
|
||||
builder.Add(comp, xp.Current());
|
||||
}
|
||||
|
||||
return std::move(comp);
|
||||
return TopoDS_Shape(std::move(comp));
|
||||
}
|
||||
|
||||
return _Shape;
|
||||
|
||||
@@ -542,7 +542,7 @@ TopoDS_Shape PartGui::DlgProjectionOnSurface::create_compound(const std::vector<
|
||||
}
|
||||
}
|
||||
}
|
||||
return std::move(aCompound);
|
||||
return TopoDS_Shape(std::move(aCompound));
|
||||
}
|
||||
|
||||
void PartGui::DlgProjectionOnSurface::show_projected_shapes(const std::vector<SShapeStore>& iShapeStoreVec)
|
||||
|
||||
@@ -1736,7 +1736,7 @@ TopoDS_Shape Area::toShape(CArea &area, short fill, int reorient) {
|
||||
builder.Add(compound,s);\
|
||||
}\
|
||||
if(TopExp_Explorer(compound,TopAbs_EDGE).More())\
|
||||
return std::move(compound);\
|
||||
return TopoDS_Shape(std::move(compound));\
|
||||
return TopoDS_Shape();\
|
||||
}\
|
||||
return mySections[_index]->_op(_index, ## __VA_ARGS__);\
|
||||
@@ -1873,8 +1873,9 @@ TopoDS_Shape Area::makeOffset(int index,PARAM_ARGS(PARAM_FARG,AREA_PARAMS_OFFSET
|
||||
}
|
||||
if(thicken)
|
||||
FC_DURATION_LOG(d,"Thicken");
|
||||
if(TopExp_Explorer(compound,TopAbs_EDGE).More())
|
||||
return std::move(compound);
|
||||
if(TopExp_Explorer(compound,TopAbs_EDGE).More()) {
|
||||
return TopoDS_Shape(std::move(compound));
|
||||
}
|
||||
return TopoDS_Shape();
|
||||
}
|
||||
|
||||
@@ -2261,7 +2262,7 @@ TopoDS_Shape Area::toShape(const CArea &area, bool fill, const gp_Trsf *trsf, in
|
||||
AREA_WARN("FaceMakerBullseye failed: "<<e.what());
|
||||
}
|
||||
}
|
||||
return std::move(compound);
|
||||
return TopoDS_Shape(std::move(compound));
|
||||
}
|
||||
|
||||
struct WireInfo {
|
||||
|
||||
@@ -66,14 +66,18 @@ void ExternalGeometryExtension::Restore(Base::XMLReader &reader)
|
||||
|
||||
std::unique_ptr<Part::GeometryExtension> ExternalGeometryExtension::copy(void) const
|
||||
{
|
||||
std::unique_ptr<ExternalGeometryExtension> cpy = std::make_unique<ExternalGeometryExtension>();
|
||||
auto cpy = std::make_unique<ExternalGeometryExtension>();
|
||||
|
||||
cpy->Ref = this->Ref;
|
||||
cpy->Flags = this->Flags;
|
||||
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
|
||||
#if defined (__GNUC__) && (__GNUC__ <=4)
|
||||
return std::move(cpy);
|
||||
#else
|
||||
return cpy;
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject * ExternalGeometryExtension::getPyObject(void)
|
||||
|
||||
@@ -75,13 +75,17 @@ void SketchGeometryExtension::Restore(Base::XMLReader &reader)
|
||||
|
||||
std::unique_ptr<Part::GeometryExtension> SketchGeometryExtension::copy(void) const
|
||||
{
|
||||
std::unique_ptr<SketchGeometryExtension> cpy = std::make_unique<SketchGeometryExtension>();
|
||||
auto cpy = std::make_unique<SketchGeometryExtension>();
|
||||
|
||||
cpy->Id = this->Id;
|
||||
|
||||
cpy->setName(this->getName()); // Base Class
|
||||
|
||||
#if defined (__GNUC__) && (__GNUC__ <=4)
|
||||
return std::move(cpy);
|
||||
#else
|
||||
return cpy;
|
||||
#endif
|
||||
}
|
||||
|
||||
PyObject * SketchGeometryExtension::getPyObject(void)
|
||||
|
||||
Reference in New Issue
Block a user