diff options
Diffstat (limited to 'Carpet/CarpetLib/src/bbox.hh')
-rw-r--r-- | Carpet/CarpetLib/src/bbox.hh | 61 |
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 |