diff --git a/src/Base/BaseClassPyImp.cpp b/src/Base/BaseClassPyImp.cpp index f31cc1bf3b..07649044f8 100644 --- a/src/Base/BaseClassPyImp.cpp +++ b/src/Base/BaseClassPyImp.cpp @@ -32,7 +32,7 @@ using namespace Base; // returns a string which represent the object e.g. when printed in python std::string BaseClassPy::representation() const { - return std::string(""); + return {""}; } @@ -62,7 +62,7 @@ PyObject* BaseClassPy::getAllDerivedFrom(PyObject *args) Py::String BaseClassPy::getTypeId() const { - return Py::String(std::string(getBaseClassPtr()->getTypeId().getName())); + return {std::string(getBaseClassPtr()->getTypeId().getName())}; } Py::String BaseClassPy::getModule() const @@ -75,7 +75,7 @@ Py::String BaseClassPy::getModule() const else module.clear(); - return Py::String(module); + return {module}; } PyObject *BaseClassPy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/Base/CoordinateSystemPyImp.cpp b/src/Base/CoordinateSystemPyImp.cpp index cee937a570..d37e4272c1 100644 --- a/src/Base/CoordinateSystemPyImp.cpp +++ b/src/Base/CoordinateSystemPyImp.cpp @@ -35,7 +35,7 @@ using namespace Base; // returns a string which represents the object e.g. when printed in python std::string CoordinateSystemPy::representation() const { - return std::string(""); + return {""}; } PyObject *CoordinateSystemPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper diff --git a/src/Base/DualNumber.h b/src/Base/DualNumber.h index 206dae1f09..61c5d850de 100644 --- a/src/Base/DualNumber.h +++ b/src/Base/DualNumber.h @@ -45,48 +45,48 @@ public: DualNumber(double re, double du = 0.0) : re(re), du(du) {} - DualNumber operator-() const {return DualNumber(-re,-du);} + DualNumber operator-() const {return {-re,-du};} }; inline DualNumber operator+(DualNumber a, DualNumber b){ - return DualNumber(a.re + b.re, a.du + b.du); + return {a.re + b.re, a.du + b.du}; } inline DualNumber operator+(DualNumber a, double b){ - return DualNumber(a.re + b, a.du); + return {a.re + b, a.du}; } inline DualNumber operator+(double a, DualNumber b){ - return DualNumber(a + b.re, b.du); + return {a + b.re, b.du}; } inline DualNumber operator-(DualNumber a, DualNumber b){ - return DualNumber(a.re - b.re, a.du - b.du); + return {a.re - b.re, a.du - b.du}; } inline DualNumber operator-(DualNumber a, double b){ - return DualNumber(a.re - b, a.du); + return {a.re - b, a.du}; } inline DualNumber operator-(double a, DualNumber b){ - return DualNumber(a - b.re, -b.du); + return {a - b.re, -b.du}; } inline DualNumber operator*(DualNumber a, DualNumber b){ - return DualNumber(a.re * b.re, a.re * b.du + a.du * b.re); + return {a.re * b.re, a.re * b.du + a.du * b.re}; } inline DualNumber operator*(double a, DualNumber b){ - return DualNumber(a * b.re, a * b.du); + return {a * b.re, a * b.du}; } inline DualNumber operator*(DualNumber a, double b){ - return DualNumber(a.re * b, a.du * b); + return {a.re * b, a.du * b}; } inline DualNumber operator/(DualNumber a, DualNumber b){ - return DualNumber(a.re / b.re, (a.du * b.re - a.re * b.du) / (b.re * b.re)); + return {a.re / b.re, (a.du * b.re - a.re * b.du) / (b.re * b.re)}; } inline DualNumber operator/(DualNumber a, double b){ - return DualNumber(a.re / b, a.du / b); + return {a.re / b, a.du / b}; } inline DualNumber pow(DualNumber a, double pw){ - return Base::DualNumber(std::pow(a.re, pw), pw * std::pow(a.re, pw - 1.0) * a.du); + return {std::pow(a.re, pw), pw * std::pow(a.re, pw - 1.0) * a.du}; } } //namespace diff --git a/src/Base/DualQuaternion.cpp b/src/Base/DualQuaternion.cpp index e45d663abc..731d074481 100644 --- a/src/Base/DualQuaternion.cpp +++ b/src/Base/DualQuaternion.cpp @@ -28,72 +28,72 @@ Base::DualQuat Base::operator+(Base::DualQuat a, Base::DualQuat b) { - return DualQuat( + return { a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w - ); + }; } Base::DualQuat Base::operator-(Base::DualQuat a, Base::DualQuat b) { - return DualQuat( + return { a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w - ); + }; } Base::DualQuat Base::operator*(Base::DualQuat a, Base::DualQuat b) { - return DualQuat( + return { a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y, a.w * b.y + a.y * b.w + a.z * b.x - a.x * b.z, a.w * b.z + a.z * b.w + a.x * b.y - a.y * b.x, a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z - ); + }; } Base::DualQuat Base::operator*(Base::DualQuat a, double b) { - return DualQuat( + return { a.x * b, a.y * b, a.z * b, a.w * b - ); + }; } Base::DualQuat Base::operator*(double a, Base::DualQuat b) { - return DualQuat( + return { b.x * a, b.y * a, b.z * a, b.w * a - ); + }; } Base::DualQuat Base::operator*(Base::DualQuat a, Base::DualNumber b) { - return DualQuat( + return { a.x * b, a.y * b, a.z * b, a.w * b - ); + }; } Base::DualQuat Base::operator*(Base::DualNumber a, Base::DualQuat b) { - return DualQuat( + return { b.x * a, b.y * a, b.z * a, b.w * a - ); + }; } Base::DualQuat::DualQuat(Base::DualQuat re, Base::DualQuat du) @@ -136,7 +136,7 @@ Base::DualQuat Base::DualQuat::pow(double t, bool shorten) const double le = this->vec().length(); if (le < 1e-12) { //special case of no rotation. Interpolate position - return DualQuat(this->real(), this->dual()*t); + return {this->real(), this->dual()*t}; } double normmult = 1.0/le; @@ -159,8 +159,8 @@ Base::DualQuat Base::DualQuat::pow(double t, bool shorten) const pitch *= t; //back to quaternion - return DualQuat( + return { l * sin(theta/2) + DualQuat(0,0,0,cos(theta/2)), m * sin(theta/2) + pitch / 2 * cos(theta/2) * l + DualQuat(0,0,0,-pitch/2*sin(theta/2)) - ); + }; } diff --git a/src/Base/DualQuaternion.h b/src/Base/DualQuaternion.h index 509a454af2..7ca3b7b1d7 100644 --- a/src/Base/DualQuaternion.h +++ b/src/Base/DualQuaternion.h @@ -60,19 +60,19 @@ public: DualQuat(DualQuat re, DualQuat du); ///returns dual quaternion for identity placement - static DualQuat identity() {return DualQuat(0.0, 0.0, 0.0, 1.0);} + static DualQuat identity() {return {0.0, 0.0, 0.0, 1.0};} ///return a copy with dual part zeroed out - DualQuat real() const {return DualQuat(x.re, y.re, z.re, w.re);} + DualQuat real() const {return {x.re, y.re, z.re, w.re};} ///return a real-only quaternion made from dual part of this quaternion. - DualQuat dual() const {return DualQuat(x.du, y.du, z.du, w.du);} + DualQuat dual() const {return {x.du, y.du, z.du, w.du};} ///conjugate - DualQuat conj() const {return DualQuat(-x, -y, -z, w);} + DualQuat conj() const {return {-x, -y, -z, w};} ///return vector part (with scalar part zeroed out) - DualQuat vec() const {return DualQuat(x,y,z,0.0);} + DualQuat vec() const {return {x,y,z,0.0};} ///magnitude of the quaternion double length() const {return sqrt(x.re*x.re + y.re*y.re + z.re*z.re + w.re*w.re);} @@ -86,7 +86,7 @@ public: ///ScLERP. t=0.0 returns identity, t=1.0 returns this. t can also be outside of 0..1 bounds. DualQuat pow(double t, bool shorten = true) const; - DualQuat operator-() const {return DualQuat(-x, -y, -z, -w);} + DualQuat operator-() const {return {-x, -y, -z, -w};} //DEBUG //void print() const { diff --git a/src/Base/FileInfo.cpp b/src/Base/FileInfo.cpp index 5412fdfcd5..cf527dcea8 100644 --- a/src/Base/FileInfo.cpp +++ b/src/Base/FileInfo.cpp @@ -295,7 +295,7 @@ std::string FileInfo::extension() const { std::string::size_type pos = FileName.find_last_of('.'); if (pos == std::string::npos) - return std::string(); + return {}; return FileName.substr(pos+1); } @@ -303,7 +303,7 @@ std::string FileInfo::completeExtension() const { std::string::size_type pos = FileName.find_first_of('.'); if (pos == std::string::npos) - return std::string(); + return {}; return FileName.substr(pos+1); } diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 29126d0866..8d52860328 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -243,7 +243,7 @@ std::string InterpreterSingleton::runString(const char *sCmd) throw SystemExitException(); else { PyException::ThrowException(); - return std::string(); // just to quieten code analyzers + return {}; // just to quieten code analyzers //throw PyException(); } } @@ -257,7 +257,7 @@ std::string InterpreterSingleton::runString(const char *sCmd) } else { PyErr_Clear(); - return std::string(); + return {}; } } diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index 8591adb9c9..98d1894d48 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -980,16 +980,14 @@ std::string ParameterGrp::GetASCII(const char* Name, const char * pPreset) const // if not return preset if (!pcElem) { if (!pPreset) - return std::string(""); - else - return std::string(pPreset); + return {}; + return {pPreset}; } // if yes check the value and return DOMNode *pcElem2 = pcElem->getFirstChild(); if (pcElem2) - return std::string(StrXUTF8(pcElem2->getNodeValue()).c_str()); - else - return std::string(""); + return {StrXUTF8(pcElem2->getNodeValue()).c_str()}; + return {}; } std::vector ParameterGrp::GetASCIIs(const char * sFilter) const @@ -1517,7 +1515,7 @@ ParameterManager::~ParameterManager() Base::Reference ParameterManager::Create() { - return Base::Reference(new ParameterManager()); + return {new ParameterManager()}; } void ParameterManager::Init() diff --git a/src/Base/PersistencePyImp.cpp b/src/Base/PersistencePyImp.cpp index 56a7dc8620..25a9e03cda 100644 --- a/src/Base/PersistencePyImp.cpp +++ b/src/Base/PersistencePyImp.cpp @@ -37,7 +37,7 @@ using namespace Base; // returns a string which represent the object e.g. when printed in python std::string PersistencePy::representation() const { - return std::string(""); + return {""}; } @@ -48,7 +48,7 @@ Py::String PersistencePy::getContent() const writer.setForceXML(true); getPersistencePtr()->Save(writer); - return Py::String (writer.getString()); + return {writer.getString()}; } Py::Int PersistencePy::getMemSize() const diff --git a/src/Base/Placement.cpp b/src/Base/Placement.cpp index 6cf542d5cc..36bb98c438 100644 --- a/src/Base/Placement.cpp +++ b/src/Base/Placement.cpp @@ -60,7 +60,7 @@ Placement Placement::fromDualQuaternion(DualQuat qq) { Rotation rot(qq.x.re, qq.y.re, qq.z.re, qq.w.re); DualQuat mvq = 2 * qq.dual() * qq.real().conj(); - return Placement(Vector3d(mvq.x.re,mvq.y.re, mvq.z.re), rot); + return {Vector3d(mvq.x.re,mvq.y.re, mvq.z.re), rot}; } Base::Matrix4D Placement::toMatrix() const @@ -217,7 +217,7 @@ Placement Placement::slerp(const Placement & p0, const Placement & p1, double t) { Rotation rot = Rotation::slerp(p0.getRotation(), p1.getRotation(), t); Vector3d pos = p0.getPosition() * (1.0-t) + p1.getPosition() * t; - return Placement(pos, rot); + return {pos, rot}; } Placement Placement::sclerp(const Placement& p0, const Placement& p1, double t, bool shorten) diff --git a/src/Base/PrecisionPyImp.cpp b/src/Base/PrecisionPyImp.cpp index 9b5f03c493..892707df4e 100644 --- a/src/Base/PrecisionPyImp.cpp +++ b/src/Base/PrecisionPyImp.cpp @@ -33,7 +33,7 @@ using Base::PrecisionPy; // returns a string which represents the object e.g. when printed in python std::string PrecisionPy::representation() const { - return std::string(""); + return {""}; } PyObject* PrecisionPy::angular(PyObject *args) diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp index 84d0b4082c..930fadbf5c 100644 --- a/src/Base/QuantityPyImp.cpp +++ b/src/Base/QuantityPyImp.cpp @@ -604,7 +604,7 @@ void QuantityPy::setUnit(Py::Object arg) Py::String QuantityPy::getUserString() const { - return Py::String(getQuantityPtr()->getUserString().toUtf8(),"utf-8"); + return {getQuantityPtr()->getUserString().toUtf8(),"utf-8"}; } Py::Dict QuantityPy::getFormat() const diff --git a/src/Base/Rotation.cpp b/src/Base/Rotation.cpp index 344d513c7b..23c57cbbb1 100644 --- a/src/Base/Rotation.cpp +++ b/src/Base/Rotation.cpp @@ -535,12 +535,12 @@ Rotation Rotation::slerp(const Rotation & q0, const Rotation & q1, double t) double y = scale0 * q0.quat[1] + scale1 * q1.quat[1]; double z = scale0 * q0.quat[2] + scale1 * q1.quat[2]; double w = scale0 * q0.quat[3] + scale1 * q1.quat[3]; - return Rotation(x, y, z, w); + return {x, y, z, w}; } Rotation Rotation::identity() { - return Rotation(0.0, 0.0, 0.0, 1.0); + return {0.0, 0.0, 0.0, 1.0}; } Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdir, const char* priorityOrder) @@ -684,7 +684,7 @@ Rotation Rotation::makeRotationByAxes(Vector3d xdir, Vector3d ydir, Vector3d zdi m[2][i] = finaldirs[i].z; } - return Rotation(m); + return {m}; } void Rotation::setYawPitchRoll(double y, double p, double r) @@ -848,12 +848,12 @@ EulerSequence_Parameters translateEulerSequence (const Rotation::EulerSequence t switch (theSeq) { - case Rotation::Extrinsic_XYZ: return Params (1, F, F, T); - case Rotation::Extrinsic_XZY: return Params (1, T, F, T); - case Rotation::Extrinsic_YZX: return Params (2, F, F, T); - case Rotation::Extrinsic_YXZ: return Params (2, T, F, T); - case Rotation::Extrinsic_ZXY: return Params (3, F, F, T); - case Rotation::Extrinsic_ZYX: return Params (3, T, F, T); + case Rotation::Extrinsic_XYZ: return {1, F, F, T}; + case Rotation::Extrinsic_XZY: return {1, T, F, T}; + case Rotation::Extrinsic_YZX: return {2, F, F, T}; + case Rotation::Extrinsic_YXZ: return {2, T, F, T}; + case Rotation::Extrinsic_ZXY: return {3, F, F, T}; + case Rotation::Extrinsic_ZYX: return {3, T, F, T}; // Conversion of intrinsic angles is made by the same code as for extrinsic, // using equivalence rule: intrinsic rotation is equivalent to extrinsic @@ -861,30 +861,30 @@ EulerSequence_Parameters translateEulerSequence (const Rotation::EulerSequence t // Swapping of angles (Alpha <-> Gamma) is done inside conversion procedure; // sequence of axes is inverted by setting appropriate parameters here. // Note that proper Euler angles (last block below) are symmetric for sequence of axes. - case Rotation::Intrinsic_XYZ: return Params (3, T, F, F); - case Rotation::Intrinsic_XZY: return Params (2, F, F, F); - case Rotation::Intrinsic_YZX: return Params (1, T, F, F); - case Rotation::Intrinsic_YXZ: return Params (3, F, F, F); - case Rotation::Intrinsic_ZXY: return Params (2, T, F, F); - case Rotation::Intrinsic_ZYX: return Params (1, F, F, F); + case Rotation::Intrinsic_XYZ: return {3, T, F, F}; + case Rotation::Intrinsic_XZY: return {2, F, F, F}; + case Rotation::Intrinsic_YZX: return {1, T, F, F}; + case Rotation::Intrinsic_YXZ: return {3, F, F, F}; + case Rotation::Intrinsic_ZXY: return {2, T, F, F}; + case Rotation::Intrinsic_ZYX: return {1, F, F, F}; - case Rotation::Extrinsic_XYX: return Params (1, F, T, T); - case Rotation::Extrinsic_XZX: return Params (1, T, T, T); - case Rotation::Extrinsic_YZY: return Params (2, F, T, T); - case Rotation::Extrinsic_YXY: return Params (2, T, T, T); - case Rotation::Extrinsic_ZXZ: return Params (3, F, T, T); - case Rotation::Extrinsic_ZYZ: return Params (3, T, T, T); + case Rotation::Extrinsic_XYX: return {1, F, T, T}; + case Rotation::Extrinsic_XZX: return {1, T, T, T}; + case Rotation::Extrinsic_YZY: return {2, F, T, T}; + case Rotation::Extrinsic_YXY: return {2, T, T, T}; + case Rotation::Extrinsic_ZXZ: return {3, F, T, T}; + case Rotation::Extrinsic_ZYZ: return {3, T, T, T}; - case Rotation::Intrinsic_XYX: return Params (1, F, T, F); - case Rotation::Intrinsic_XZX: return Params (1, T, T, F); - case Rotation::Intrinsic_YZY: return Params (2, F, T, F); - case Rotation::Intrinsic_YXY: return Params (2, T, T, F); - case Rotation::Intrinsic_ZXZ: return Params (3, F, T, F); - case Rotation::Intrinsic_ZYZ: return Params (3, T, T, F); + case Rotation::Intrinsic_XYX: return {1, F, T, F}; + case Rotation::Intrinsic_XZX: return {1, T, T, F}; + case Rotation::Intrinsic_YZY: return {2, F, T, F}; + case Rotation::Intrinsic_YXY: return {2, T, T, F}; + case Rotation::Intrinsic_ZXZ: return {3, F, T, F}; + case Rotation::Intrinsic_ZYZ: return {3, T, T, F}; default: - case Rotation::EulerAngles : return Params (3, F, T, F); // = Intrinsic_ZXZ - case Rotation::YawPitchRoll: return Params (1, F, F, F); // = Intrinsic_ZYX + case Rotation::EulerAngles : return {3, F, T, F}; // = Intrinsic_ZXZ + case Rotation::YawPitchRoll: return {1, F, F, F}; // = Intrinsic_ZYX }; } diff --git a/src/Base/Stream.cpp b/src/Base/Stream.cpp index c149dfafdb..7eea30139e 100644 --- a/src/Base/Stream.cpp +++ b/src/Base/Stream.cpp @@ -264,7 +264,7 @@ ByteArrayOStreambuf::seekoff(std::streambuf::off_type off, endpos = _buffer->size(); break; default: - return pos_type(off_type(-1)); + return {off_type(-1)}; } if (endpos != curpos) { @@ -272,7 +272,7 @@ ByteArrayOStreambuf::seekoff(std::streambuf::off_type off, endpos = -1; } - return pos_type(endpos); + return {endpos}; } std::streambuf::pos_type @@ -396,7 +396,7 @@ IODeviceOStreambuf::seekoff(std::streambuf::off_type off, endpos = device->size(); break; default: - return pos_type(off_type(-1)); + return {off_type(-1)}; } if (endpos != curpos) { @@ -404,7 +404,7 @@ IODeviceOStreambuf::seekoff(std::streambuf::off_type off, endpos = -1; } - return pos_type(endpos); + return {endpos}; } std::streambuf::pos_type @@ -496,7 +496,7 @@ IODeviceIStreambuf::seekoff(std::streambuf::off_type off, endpos = -1; } - return pos_type(endpos); + return {endpos}; } std::streambuf::pos_type @@ -696,7 +696,7 @@ PyStreambuf::seekoff(PyStreambuf::off_type offset, PyStreambuf::seekdir dir, PyS whence = 2; break; default: - return pos_type(off_type(-1)); + return {off_type(-1)}; } try { @@ -715,7 +715,7 @@ PyStreambuf::seekoff(PyStreambuf::off_type offset, PyStreambuf::seekdir dir, PyS } catch(Py::Exception& e) { e.clear(); - return pos_type(off_type(-1)); + return {off_type(-1)}; } } diff --git a/src/Base/Tools.h b/src/Base/Tools.h index 76a67f9e98..c4eb15ccf7 100644 --- a/src/Base/Tools.h +++ b/src/Base/Tools.h @@ -86,12 +86,12 @@ inline std::ostream& blanksN(std::ostream& os, int n) inline manipulator tabs(int n) { - return manipulator(&tabsN, n); + return {&tabsN, n}; } inline manipulator blanks(int n) { - return manipulator(&blanksN, n); + return {&blanksN, n}; } // ---------------------------------------------------------------------------- @@ -263,7 +263,7 @@ struct BaseExport Tools */ static inline std::string toStdString(const QString& s) { QByteArray tmp = s.toUtf8(); - return std::string(tmp.constData(), static_cast(tmp.size())); + return {tmp.constData(), static_cast(tmp.size())}; } /** diff --git a/src/Base/Tools2D.cpp b/src/Base/Tools2D.cpp index 7bb14cbcca..275e430de8 100644 --- a/src/Base/Tools2D.cpp +++ b/src/Base/Tools2D.cpp @@ -245,7 +245,7 @@ Vector2d Line2d::FromPos (double fDistance) const { Vector2d clDir(clV2 - clV1); clDir.Normalize(); - return Vector2d(clV1.x + (clDir.x * fDistance), clV1.y + (clDir.y * fDistance)); + return {clV1.x + (clDir.x * fDistance), clV1.y + (clDir.y * fDistance)}; } bool Line2d::IntersectAndContain (const Line2d& rclLine, Vector2d &rclV) const diff --git a/src/Base/Tools2D.h b/src/Base/Tools2D.h index 1588e3200b..913fb24883 100644 --- a/src/Base/Tools2D.h +++ b/src/Base/Tools2D.h @@ -229,12 +229,12 @@ inline bool Vector2d::operator== (const Vector2d &v) const inline Vector2d Vector2d::operator+ () const { - return Vector2d(x, y); + return {x, y}; } inline Vector2d Vector2d::operator+ (const Vector2d &v) const { - return Vector2d(x + v.x, y + v.y); + return {x + v.x, y + v.y}; } inline Vector2d& Vector2d::operator+= (const Vector2d &v) @@ -246,12 +246,12 @@ inline Vector2d& Vector2d::operator+= (const Vector2d &v) inline Vector2d Vector2d::operator- () const { - return Vector2d(-x, -y); + return {-x, -y}; } inline Vector2d Vector2d::operator- (const Vector2d &v) const { - return Vector2d(x - v.x, y - v.y); + return {x - v.x, y - v.y}; } inline Vector2d& Vector2d::operator-= (const Vector2d &v) @@ -263,7 +263,7 @@ inline Vector2d& Vector2d::operator-= (const Vector2d &v) inline Vector2d Vector2d::operator* (double c) const { - return Vector2d(c * x, c * y); + return {c * x, c * y}; } inline Vector2d& Vector2d::operator*= (double c) @@ -280,12 +280,12 @@ inline double Vector2d::operator* (const Vector2d &v) const inline Vector2d operator* (double c, const Vector2d &v) { - return Vector2d(c * v.x, c * v.y); + return {c * v.x, c * v.y}; } inline Vector2d Vector2d::operator/ (double c) const { - return Vector2d(x / c, y / c); + return {x / c, y / c}; } inline Vector2d& Vector2d::operator/= (double c) @@ -363,7 +363,7 @@ inline Vector2d Vector2d::Perpendicular(bool clockwise) const inline Vector2d Vector2d::FromPolar(double r, double fi) { - return Vector2d(r * cos(fi), r * sin(fi)); + return {r * cos(fi), r * sin(fi)}; } inline double Vector2d::Distance(const Vector2d& v) const @@ -549,7 +549,7 @@ inline bool BoundBox2d::Contains(const Vector2d &v, double tolerance) const inline Vector2d BoundBox2d::GetCenter() const { - return Vector2d((MinX + MaxX) * 0.5, (MinY + MaxY) * 0.5); + return {(MinX + MaxX) * 0.5, (MinY + MaxY) * 0.5}; } inline void BoundBox2d::SetVoid() diff --git a/src/Base/Type.cpp b/src/Base/Type.cpp index 6a5ee71a42..247d74b0ae 100644 --- a/src/Base/Type.cpp +++ b/src/Base/Type.cpp @@ -125,9 +125,8 @@ string Type::getModuleName(const char* ClassName) std::string::size_type pos = temp.find_first_of("::"); if (pos != std::string::npos) - return string(temp,0,pos); - else - return string(); + return {temp,0,pos}; + return {}; } Type Type::badType() diff --git a/src/Base/TypePyImp.cpp b/src/Base/TypePyImp.cpp index 428914cb8e..35bd7cff24 100644 --- a/src/Base/TypePyImp.cpp +++ b/src/Base/TypePyImp.cpp @@ -245,7 +245,7 @@ PyObject* TypePy::createInstanceByName (PyObject *args) Py::String TypePy::getName() const { - return Py::String(std::string(getBaseTypePtr()->getName())); + return {std::string(getBaseTypePtr()->getName())}; } Py::Long TypePy::getKey() const @@ -263,7 +263,7 @@ Py::String TypePy::getModule() const else module.clear(); - return Py::String(module); + return {module}; } PyObject *TypePy::getCustomAttributes(const char* /*attr*/) const diff --git a/src/Base/Unit.cpp b/src/Base/Unit.cpp index f6fe744224..212e293c47 100644 --- a/src/Base/Unit.cpp +++ b/src/Base/Unit.cpp @@ -258,7 +258,7 @@ QString Unit::getString() const std::stringstream ret; if (isEmpty()) - return QString(); + return {}; if (Sig.Length > 0 || Sig.Mass > 0 || @@ -551,7 +551,7 @@ QString Unit::getTypeString() const if (*this == Unit::YoungsModulus) return QString::fromLatin1("YoungsModulus"); - return QString(); + return {}; } // SI base units diff --git a/src/Base/UnitPyImp.cpp b/src/Base/UnitPyImp.cpp index e97bfaf7bf..3fd9341fc1 100644 --- a/src/Base/UnitPyImp.cpp +++ b/src/Base/UnitPyImp.cpp @@ -213,7 +213,7 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op) Py::String UnitPy::getType() const { - return Py::String(getUnitPtr()->getTypeString().toUtf8(),"utf-8"); + return {getUnitPtr()->getTypeString().toUtf8(),"utf-8"}; } Py::Tuple UnitPy::getSignature() const diff --git a/src/Base/UnitsSchema.h b/src/Base/UnitsSchema.h index e04893772e..2f27921790 100644 --- a/src/Base/UnitsSchema.h +++ b/src/Base/UnitsSchema.h @@ -73,7 +73,7 @@ public: virtual bool isMultiUnitAngle() const {return false;} //return the basic length unit for this schema - virtual std::string getBasicLengthUnit() const { return std::string("mm"); } + virtual std::string getBasicLengthUnit() const { return {"mm"}; } }; diff --git a/src/Base/UnitsSchemaCentimeters.h b/src/Base/UnitsSchemaCentimeters.h index b45805233c..d6020b89bd 100644 --- a/src/Base/UnitsSchemaCentimeters.h +++ b/src/Base/UnitsSchemaCentimeters.h @@ -38,7 +38,7 @@ class UnitsSchemaCentimeters: public UnitsSchema public: QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString) override; - std::string getBasicLengthUnit() const override { return std::string("cm"); } + std::string getBasicLengthUnit() const override { return {"cm"}; } }; } // namespace Base diff --git a/src/Base/UnitsSchemaImperial1.h b/src/Base/UnitsSchemaImperial1.h index 2360bcc90d..7eca980ef8 100644 --- a/src/Base/UnitsSchemaImperial1.h +++ b/src/Base/UnitsSchemaImperial1.h @@ -41,7 +41,7 @@ public: //virtual void setSchemaUnits(void); //virtual void resetSchemaUnits(void); QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString) override; - std::string getBasicLengthUnit() const override { return std::string("in"); } + std::string getBasicLengthUnit() const override { return {"in"}; } }; /** The schema class for the imperial unit system @@ -54,7 +54,7 @@ public: //virtual void setSchemaUnits(void); //virtual void resetSchemaUnits(void); QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString) override; - std::string getBasicLengthUnit() const override { return std::string("in"); } + std::string getBasicLengthUnit() const override { return {"in"}; } }; /** The schema class for the imperial unit system @@ -67,7 +67,7 @@ public: //virtual void setSchemaUnits(void); //virtual void resetSchemaUnits(void); QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString) override; - std::string getBasicLengthUnit() const override { return std::string("ft"); } + std::string getBasicLengthUnit() const override { return {"ft"}; } //return true if this schema uses multiple units for length (ex. Ft/In) bool isMultiUnitLength() const override {return true;} @@ -84,7 +84,7 @@ public: //virtual void setSchemaUnits(void); //virtual void resetSchemaUnits(void); QString schemaTranslate(const Base::Quantity& quant, double &factor, QString &unitString) override; - std::string getBasicLengthUnit() const override { return std::string("ft"); } + std::string getBasicLengthUnit() const override { return {"ft"}; } //return true if this schema uses multiple units for angles (ex. DMS) bool isMultiUnitAngle() const override {return true;}