From 347b13ee60ea35b11aff0efa8814f74a7c2e244d Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 12 May 2019 07:51:42 +1000 Subject: [PATCH] coord/comparator: allow delayed and defaulted deduction of arguments --- coord/comparator.hpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/coord/comparator.hpp b/coord/comparator.hpp index 22f3b082..1efd620a 100644 --- a/coord/comparator.hpp +++ b/coord/comparator.hpp @@ -15,6 +15,11 @@ /////////////////////////////////////////////////////////////////////////////// namespace cruft::coord { + /// A StrictWeakOrder over coordinate types. + template + struct ordering; + + /// A StrictWeakOrder over coordinate types. /// /// The comparison operates across successive elements of the two @@ -35,4 +40,18 @@ namespace cruft::coord { return false; } }; + + + /// A StrictWeakOrder over coordinate types. + /// + /// Deduction is deferred until the function is called, in the same way + /// that std::less<> operates. + template <> + struct ordering { + template + bool operator() (CoordT const &a, CoordT const &b) const noexcept + { + return ordering {} (a, b); + } + }; }