diff --git a/types/traits.hpp b/types/traits.hpp index 0ddf64b6..f5a9a6c3 100644 --- a/types/traits.hpp +++ b/types/traits.hpp @@ -470,4 +470,32 @@ namespace cruft { template constexpr auto is_tuple_like_v = is_tuple_like::value; -} + + + /////////////////////////////////////////////////////////////////////////// + /// Tests if a type is orderable; ie, if it supports the less than operator + /// + /// We use void_t to detect the presence of an appropriate operator< + template < + typename ValueT, + typename = std::void_t<> + > + struct is_orderable : public std::false_type {}; + + + //------------------------------------------------------------------------- + template + struct is_orderable< + ValueT, + std::void_t< + decltype ( + std::declval () < std::declval () + ) + > + > : std::true_type {}; + + + //----------------------------------------------------------------------------------- + template + constexpr auto is_orderable_v = is_orderable::value; +};