Quellcode durchsuchen

🧑‍💻 Min and max for base types

Scott Lahteine vor 2 Jahren
Ursprung
Commit
77227f66c2
1 geänderte Dateien mit 12 neuen und 0 gelöschten Zeilen
  1. 12
    0
      Marlin/src/core/types.h

+ 12
- 0
Marlin/src/core/types.h Datei anzeigen

@@ -347,6 +347,10 @@ struct XYval {
347 347
   FI operator T* ()                                     { return pos; }
348 348
   // If any element is true then it's true
349 349
   FI operator bool()                                    { return x || y; }
350
+  // Smallest element
351
+  FI T _min()                                     const { return _MIN(x, y); }
352
+  // Largest element
353
+  FI T _max()                                     const { return _MAX(x, y); }
350 354
 
351 355
   // Explicit copy and copies with conversion
352 356
   FI XYval<T>           copy()                    const { return *this; }
@@ -500,6 +504,10 @@ struct XYZval {
500 504
   FI operator T* ()                                    { return pos; }
501 505
   // If any element is true then it's true
502 506
   FI operator bool()                                   { return NUM_AXIS_GANG(x, || y, || z, || i, || j, || k, || u, || v, || w); }
507
+  // Smallest element
508
+  FI T _min()                                    const { return _MIN(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); }
509
+  // Largest element
510
+  FI T _max()                                    const { return _MAX(NUM_AXIS_LIST(x, y, z, i, j, k, u, v, w)); }
503 511
 
504 512
   // Explicit copy and copies with conversion
505 513
   FI XYZval<T>          copy()                   const { XYZval<T> o = *this; return o; }
@@ -651,6 +659,10 @@ struct XYZEval {
651 659
   FI operator T* ()                                      { return pos; }
652 660
   // If any element is true then it's true
653 661
   FI operator bool()                                     { return 0 LOGICAL_AXIS_GANG(|| e, || x, || y, || z, || i, || j, || k, || u, || v, || w); }
662
+  // Smallest element
663
+  FI T _min()                                      const { return _MIN(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); }
664
+  // Largest element
665
+  FI T _max()                                      const { return _MAX(LOGICAL_AXIS_LIST(e, x, y, z, i, j, k, u, v, w)); }
654 666
 
655 667
   // Explicit copy and copies with conversion
656 668
   FI XYZEval<T>          copy()  const { XYZEval<T> v = *this; return v; }

Laden…
Abbrechen
Speichern