20 General utilities library [utilities]

20.14 Function objects [function.objects]

20.14.15 Default functor traits [func.default.traits]

namespace std {
  template <class T = void>
  struct default_order {
    using type = less<T>;
  };
}

The class template default_order provides a trait that users can specialize for user-defined types to provide a strict weak ordering for that type, which the library can use where a default strict weak order is needed. For example, the associative containers ([associative]) and priority_queue ([priority.queue]) use this trait.

Example:

namespace sales {
  struct account {
    int id;
    std::string name;
  };

  struct order_accounts {
    bool operator()(const Account& lhs, const Account& rhs) const {
      return lhs.id < rhs.id;
    }
  };
}

namespace std {
  template<>
  struct default_order<sales::account> {
    using type = sales::order_accounts;
  };
}

 — end example ]