...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::log::attribute_value_ordering — Ordering predicate, based on attribute values associated with records.
// In header: <boost/log/utility/record_ordering.hpp> template<typename ValueT, typename FunT = less> class attribute_value_ordering : private less { public: // types typedef bool result_type; // Result type. typedef ValueT value_type; // Compared attribute value type. // member classes/structs/unions struct l1_visitor { // types typedef void result_type; // construct/copy/destruct l1_visitor(attribute_value_ordering const &, record_view const &, bool &); // public member functions template<typename LeftT> result_type operator()(LeftT const &) const; }; template<typename LeftT> struct l2_visitor { // types typedef void result_type; // construct/copy/destruct l2_visitor(FunT const &, LeftT const &, bool &); // public member functions template<typename RightT> result_type operator()(RightT const &) const; }; // construct/copy/destruct explicit attribute_value_ordering(attribute_name const &, FunT const & = FunT()); // public member functions result_type operator()(record_view const &, record_view const &) const; };
This predicate allows to order log records based on values of a specifically named attribute associated with them. Two given log records being compared should both have the specified attribute value of the specified type to be able to be ordered properly. As a special case, if neither of the records have the value, these records are considered equivalent. Otherwise, the ordering results are unspecified.