summaryrefslogtreecommitdiff
path: root/Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp')
-rw-r--r--Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp23
1 files changed, 16 insertions, 7 deletions
diff --git a/Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp b/Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp
index 8c05ae49834..f606dab4549 100644
--- a/Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp
+++ b/Build/source/texk/dvisvgm/dvisvgm-src/src/Length.hpp
@@ -2,7 +2,7 @@
** Length.hpp **
** **
** This file is part of dvisvgm -- a fast DVI to SVG converter **
-** Copyright (C) 2005-2017 Martin Gieseking <martin.gieseking@uos.de> **
+** Copyright (C) 2005-2018 Martin Gieseking <martin.gieseking@uos.de> **
** **
** This program is free software; you can redistribute it and/or **
** modify it under the terms of the GNU General Public License as **
@@ -28,20 +28,19 @@
#undef IN
#endif
-struct UnitException : MessageException
-{
+struct UnitException : MessageException {
UnitException (const std::string &msg) : MessageException(msg) {}
};
-class Length
-{
+class Length {
public:
enum class Unit {PT, BP, CM, MM, IN, PC, DD, CC, SP};
public:
- Length () : _pt(0) {}
- Length (double val, Unit unit=Unit::PT) {set(val, unit);}
+ constexpr Length () : _pt(0) {}
+ constexpr Length (long double pt) : _pt(static_cast<double>(pt)) {}
+ Length (double val, Unit unit) {set(val, unit);}
Length (double val, const std::string &unitstr) {set(val, unitstr);}
Length (const std::string &lenstr) {set(lenstr);}
void set (double val, Unit unit);
@@ -76,4 +75,14 @@ class Length
double _pt; // length in TeX point units (72.27pt = 1in)
};
+
+constexpr Length operator "" _pt (long double pt) {return Length(pt);}
+constexpr Length operator "" _bp (long double bp) {return Length(bp/Length::pt2bp);}
+constexpr Length operator "" _mm (long double mm) {return Length(mm/Length::pt2mm);}
+constexpr Length operator "" _in (long double in) {return Length(in/Length::pt2in);}
+constexpr Length operator "" _pt (unsigned long long pt) {return Length(static_cast<double>(pt));}
+constexpr Length operator "" _bp (unsigned long long bp) {return Length(static_cast<double>(bp)/Length::pt2bp);}
+constexpr Length operator "" _mm (unsigned long long mm) {return Length(static_cast<double>(mm)/Length::pt2mm);}
+constexpr Length operator "" _in (unsigned long long in) {return Length(static_cast<double>(in)/Length::pt2in);}
+
#endif