coord/comparator: allow delayed and defaulted deduction of arguments

This commit is contained in:
Danny Robson 2019-05-12 07:51:42 +10:00
parent 6d48e5a8e5
commit 347b13ee60

View File

@ -15,6 +15,11 @@
///////////////////////////////////////////////////////////////////////////////
namespace cruft::coord {
/// A StrictWeakOrder over coordinate types.
template <typename CoordT = void>
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<void> {
template <typename CoordT>
bool operator() (CoordT const &a, CoordT const &b) const noexcept
{
return ordering<CoordT> {} (a, b);
}
};
}