aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src/bbox.hh
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-05-26 16:15:36 -0400
committerErik Schnetter <schnetter@gmail.com>2013-05-26 16:18:25 -0400
commitfa57059414919bea3cd6d7d62b69dc733f8b8f6d (patch)
treea7db559a64f53e5f36008a3d57dcbebac3915a74 /Carpet/CarpetLib/src/bbox.hh
parent62d962f1a5140c37b494ab08174d1d5f42a52e8a (diff)
CarpetLib: Use C++ standard methods to compare containers
Remove CarpetLib's "equals" method. Implement equal_to, less, greater, greater_equal, less_equal, not_equal for vect and bbox classes.
Diffstat (limited to 'Carpet/CarpetLib/src/bbox.hh')
-rw-r--r--Carpet/CarpetLib/src/bbox.hh61
1 files changed, 61 insertions, 0 deletions
diff --git a/Carpet/CarpetLib/src/bbox.hh b/Carpet/CarpetLib/src/bbox.hh
index 2847576b5..85af2fcd3 100644
--- a/Carpet/CarpetLib/src/bbox.hh
+++ b/Carpet/CarpetLib/src/bbox.hh
@@ -3,6 +3,7 @@
#include <cassert>
#include <cstdlib>
+#include <functional>
#include <iostream>
#include <limits>
@@ -271,4 +272,64 @@ inline ostream& operator<< (ostream& os, const bbox<T,D>& b) {
+// Comparison
+
+namespace std {
+ // ==
+ template<typename T, int D>
+ struct equal_to<bbox<T,D> >: binary_function<bbox<T,D>, bbox<T,D>, bool>
+ {
+ bool operator()(const bbox<T,D>& x, const bbox<T,D>& y) const;
+ };
+
+ // <
+ template<typename T, int D>
+ struct less<bbox<T,D> >: binary_function<bbox<T,D>, bbox<T,D>, bool>
+ {
+ bool operator()(const bbox<T,D>& x, const bbox<T,D>& y) const;
+ };
+
+ // >
+ template<typename T, int D>
+ struct greater<bbox<T,D> >: binary_function<bbox<T,D>, bbox<T,D>, bool>
+ {
+ bool operator()(const bbox<T,D>& x, const bbox<T,D>& y) const
+ {
+ return less<bbox<T,D> >()(y, x);
+ }
+ };
+
+ // >=
+ template<typename T, int D>
+ struct greater_equal<bbox<T,D> >: binary_function<bbox<T,D>, bbox<T,D>, bool>
+ {
+ bool operator()(const bbox<T,D>& x, const bbox<T,D>& y) const
+ {
+ return not less<bbox<T,D> >()(x, y);
+ }
+ };
+
+ // <=
+ template<typename T, int D>
+ struct less_equal<bbox<T,D> >: binary_function<bbox<T,D>, bbox<T,D>, bool>
+ {
+ bool operator()(const bbox<T,D>& x, const bbox<T,D>& y) const
+ {
+ return not greater<bbox<T,D> >()(x, y);
+ }
+ };
+
+ // !=
+ template<typename T, int D>
+ struct not_equal_to<bbox<T,D> >: binary_function<bbox<T,D>, bbox<T,D>, bool>
+ {
+ bool operator()(const bbox<T,D>& x, const bbox<T,D>& y) const
+ {
+ return not equal_to<bbox<T,D> >()(x, y);
+ }
+ };
+}
+
+
+
#endif // BBOX_HH