#include #include #include #include #include #include using namespace std; #define BOOST_LOG_REGISTER_ATTRIBUTE( _name, attr, type ) \ namespace tag\ {\ struct attr\ {\ typedef type value_type;\ \ char const* const name;\ \ typedef attribute_value const& result_type;\ \ template \ attribute_value const&\ operator()(Env const& env) const\ {/*warning: the checking for iterator is ignored for simplicity here */\ return ::boost::fusion::at_c<0>(env.args()).find(_name)->second;\ }\ };\ }\ \ BOOST_PHOENIX_DEFINE_CUSTOM_TERMINAL(\ template <>\ , ::tag::attr\ , mpl::false_\ , ::tag::attr(functional::env(proto::_state))\ )\ \ typedef ::boost::phoenix::actor attr##_type;\ attr##_type attr = {{_name}}; typedef int attribute_value; typedef map< string, attribute_value > attribute_values_view; typedef boost::function< bool (attribute_values_view const&) > filter; enum my_severity { info, warning, error }; BOOST_LOG_REGISTER_ATTRIBUTE("Severity", severity, my_severity) int main(int argc, char *argv[]) { filter flt = severity >= warning; attribute_values_view a; a["Severity"] = warning; cout << flt(a); return EXIT_SUCCESS; }