--- a/src/main.h Sun Jan 19 14:25:57 2020 +0200 +++ b/src/main.h Wed Jan 22 00:23:29 2020 +0200 @@ -37,6 +37,10 @@ struct Id { unsigned int value; + constexpr bool operator<(linetypes::Id other) const + { + return this->value < other.value; + } }; } @@ -44,3 +48,30 @@ { return static_cast<std::size_t>(x); } + +inline QString operator""_q(const char* string, const unsigned long int length) +{ + Q_UNUSED(length) + return QString{string}; +} + +inline QPointF pointToPointF(const QPoint& point) +{ + return {static_cast<qreal>(point.x()), static_cast<qreal>(point.y())}; +} + +inline QPoint pointFToPoint(const QPointF& point) +{ + return {static_cast<int>(std::round(point.x())), static_cast<int>(std::round(point.y()))}; +} + +/** + * \brief Hints to the specified vector that a certain amount of new elements are going to be added. + * \param vector vector to consider + * \param amount amount of new elements to expect + */ +template<typename T> +void reserveMore(std::vector<T>& vector, std::size_t amount) +{ + vector.reserve(vector.size() + amount); +}