summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2022-10-13 20:00:30 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2022-10-13 20:00:30 +0100
commitc3b032626c841e180e67aed6093397b8caafbd6c (patch)
tree96ce5b0a3998325bffd7f79cdef059f4971919dc /lib
parentAdd candidateNodeAt, returns a network node why may not be part of the network (diff)
downloadilt-c3b032626c841e180e67aed6093397b8caafbd6c.tar.bz2
ilt-c3b032626c841e180e67aed6093397b8caafbd6c.tar.xz
ilt-c3b032626c841e180e67aed6093397b8caafbd6c.zip
Support searching node network by vec3 position
Diffstat (limited to 'lib')
-rw-r--r--lib/sorting.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/sorting.hpp b/lib/sorting.hpp
index 6b9be6a..0604aaf 100644
--- a/lib/sorting.hpp
+++ b/lib/sorting.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include <type_traits>
+
template<typename T> struct PtrSorter {
bool
operator()(const T & a, const T & b) const
@@ -7,3 +9,22 @@ template<typename T> struct PtrSorter {
return *a < *b;
}
};
+
+template<typename T, auto M> struct PtrMemberSorter : public PtrSorter<T> {
+ using MT = std::decay_t<decltype((*T {}).*M)>;
+ using is_transparent = MT;
+
+ using PtrSorter<T>::operator();
+
+ bool
+ operator()(const MT & a, const T & b) const
+ {
+ return a < (*b).*M;
+ }
+
+ bool
+ operator()(const T & a, const MT & b) const
+ {
+ return (*a).*M < b;
+ }
+};