kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #31266
[PATCH 2/3] vector2d: Fix traits usage and use std::numeric_limits
---
include/math/vector2d.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/math/vector2d.h b/include/math/vector2d.h
index 8bf2da588..d67f9b72f 100644
--- a/include/math/vector2d.h
+++ b/include/math/vector2d.h
@@ -29,8 +29,8 @@
#define VECTOR2D_H_
#include <cmath>
-#include <climits>
#include <iostream>
+#include <limits>
#include <sstream>
#include <math/math_util.h>
@@ -55,8 +55,6 @@ template <>
struct VECTOR2_TRAITS<int>
{
typedef int64_t extended_type;
- static const extended_type ECOORD_MAX = 0x7fffffffffffffffULL;
- static const extended_type ECOORD_MIN = 0x8000000000000000ULL;
};
// Forward declarations for template friends
@@ -74,12 +72,15 @@ std::ostream& operator<<( std::ostream& aStream, const VECTOR2<T>& aVector );
*
*/
template <class T = int>
-class VECTOR2 : public VECTOR2_TRAITS<T>
+class VECTOR2
{
public:
typedef typename VECTOR2_TRAITS<T>::extended_type extended_type;
typedef T coord_type;
+ static constexpr extended_type ECOORD_MAX = std::numeric_limits<extended_type>::max();
+ static constexpr extended_type ECOORD_MIN = std::numeric_limits<extended_type>::min();
+
T x, y;
// Constructors
--
2.14.1
References