diff options
Diffstat (limited to 'lib/sorting.hpp')
-rw-r--r-- | lib/sorting.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sorting.hpp b/lib/sorting.hpp index 0604aaf..777de00 100644 --- a/lib/sorting.hpp +++ b/lib/sorting.hpp @@ -1,5 +1,6 @@ #pragma once +#include <glm/fwd.hpp> #include <type_traits> template<typename T> struct PtrSorter { @@ -28,3 +29,21 @@ template<typename T, auto M> struct PtrMemberSorter : public PtrSorter<T> { return (*a).*M < b; } }; + +struct CompareBy { + glm::length_t index; + + template<typename T> + auto + operator()(const T & a, const T & b) const + { + return get(a) < get(b); + } + + template<typename T> + auto + get(const T & a) const + { + return a[index]; + } +}; |