Boost C++ Libraries: Ticket #12887: I had a problem with boost.log when set the filter with & operator https://svn.boost.org/trac10/ticket/12887 <p> First I defined keyword: </p> <p> BOOST_LOG_ATTRIBUTE_KEYWORD(attr_appenders, "Appenders", uint64) </p> <p> Then I set the filter like this: </p> <blockquote> <p> void _onSetFilter(<a class="missing wiki">SinkTypePtr</a> sink) const { </p> <blockquote> <p> uint64 mask = 0x01ul &lt;&lt; _id; sink-&gt;set_filter(attr_appenders &amp; mask); </p> </blockquote> <p> } </p> </blockquote> <p> and the error info: /usr/local/include/boost/log/sinks/basic_sink_frontend.hpp:90:18: required from ‘void boost::log::v2_mt_posix::sinks::basic_sink_frontend::set_filter(const FunT&amp;) [with FunT = boost::phoenix::actor&lt;boost::proto::exprns_::basic_expr&lt;boost::proto::tagns_::tag::bitwise_and, boost::proto::argsns_::list2&lt;boost::log::v2_mt_posix::expressions::attribute_actor&lt;long unsigned int, boost::log::v2_mt_posix::fallback_to_none, tag::attr_appenders, boost::phoenix::actor&gt;, boost::phoenix::actor&lt;boost::proto::exprns_::basic_expr&lt;boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term&lt;long unsigned int&gt;, 0l&gt; &gt; &gt;, 2l&gt; &gt;]’ /home/yuwenyong/ClionProjects/tinycore/src/tinycore/logging/appender.h:111:47: required from here /usr/local/include/boost/proto/transform/default.hpp:150:9: error:no match for ‘operator&amp;’ (operand types are ‘boost::log::v2_mt_posix::value_ref&lt;long unsigned int, tag::attr_appenders&gt;’ and ‘const long unsigned int’) </p> <blockquote> <p> BOOST_PROTO_BINARY_DEFAULT_EVAL(&amp;, bitwise_and, make, make) </p> </blockquote> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12887 Trac 1.4.3 anonymous Wed, 08 Mar 2017 03:48:15 GMT component changed; owner set https://svn.boost.org/trac10/ticket/12887#comment:1 https://svn.boost.org/trac10/ticket/12887#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Andrey Semashev</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">log</span> </li> </ul> Ticket Andrey Semashev Wed, 08 Mar 2017 09:16:48 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12887#comment:2 https://svn.boost.org/trac10/ticket/12887#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> The problem is that the operator is applied to an instance of <code>boost::log::value_ref</code>, which is basically an optional reference to the actual attribute value. <code>operator&amp;</code> cannot be applied to it because the reference can be empty (e.g. if the log record does not contain the attribute), and in this case the operator cannot return any meaningful result. </p> <p> Currently, your best solution is to write your own filter function that will first test if the attribute value is found and then apply <code>operator&amp;</code>. </p> <pre class="wiki">bool my_filter(boost::log::value_ref&lt;uint64, tag::attr_appenders&gt; const&amp; appenders) { uint64 mask = 0x01ul &lt;&lt; _id; if (appenders) return (appenders.get() &amp; mask) != 0; else return false; // the default } sink-&gt;set_filter(boost::phoenix::bind(&amp;my_filter, attr_appenders.or_none())); </pre> Ticket anonymous Wed, 08 Mar 2017 09:20:09 GMT status changed; resolution deleted https://svn.boost.org/trac10/ticket/12887#comment:3 https://svn.boost.org/trac10/ticket/12887#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">wontfix</span> </li> </ul> Ticket Andrey Semashev Wed, 08 Mar 2017 09:31:50 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/12887#comment:4 https://svn.boost.org/trac10/ticket/12887#comment:4 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">wontfix</span> </li> </ul> <p> I'm not planning to fix it, since the error is the consequence of the library design. </p> <p> Please, don't reopen, unless you have a suggested way to fix the problem. </p> Ticket