From c3b032626c841e180e67aed6093397b8caafbd6c Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Thu, 13 Oct 2022 20:00:30 +0100 Subject: Support searching node network by vec3 position --- lib/sorting.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'lib') 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 + template struct PtrSorter { bool operator()(const T & a, const T & b) const @@ -7,3 +9,22 @@ template struct PtrSorter { return *a < *b; } }; + +template struct PtrMemberSorter : public PtrSorter { + using MT = std::decay_t; + using is_transparent = MT; + + using PtrSorter::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; + } +}; -- cgit v1.2.3