Opened 9 years ago

Closed 9 years ago

#9291 closed Bugs (duplicate)

can not compile sink->set_filter(phoenix::bind(&my_filter, ...

Reported by: Johan Lundberg <lundberj@…> Owned by: Andrey Semashev
Milestone: To Be Determined Component: log
Version: Boost 1.54.0 Severity: Regression
Keywords: Cc:

Description

The line

sink->set_filter(phoenix::bind(&my_filter, severity, tag_attr))

from the documentation, here: http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/tutorial/advanced_filtering.html fails to compile.

*How to reproduce*

Find this tutorial (linked from the doc above):

http://www.boost.org/doc/libs/1_54_0/libs/log/example/doc/tutorial_filtering.cpp

Then change '#if 0' to '#if 1' to activate that part of the tutorial and comment out the other definition of init(). I get errors related to phoenix bind on line 155:

sink->set_filter(phoenix::bind(&my_filter, severity, tag_attr));

I can't judge if this is a problem with boost log itself or the documentation/tutorial.

I used boost 1.54 and tried gcc 4.7.2 and 4.8.1, and tried both c++11 and c++98 mode with the same result.

  • Details on the compilation error: I think this is the relevant

part of the error message:

/myboost154/include/boost/phoenix/core/preprocessed/expression_10.hpp:140:17: error: could not convert ‘boost::proto::make_expr<boost::phoenix::detail::tag::function_eval, boost::proto::domainns_::basic_default_domain, boost::phoenix::detail::function_ptr<2, bool, bool (*)(const boost::log::v2_mt_posix::value_ref<severity_level>&, const boost::log::v2_mt_posix::value_ref<std::basic_string<char> >&)>, boost::log::v2_mt_posix::expressions::attribute_keyword<tag::severity>, boost::log::v2_mt_posix::expressions::attribute_keyword<tag::tag_attr>

((* & a0), (* & a1), (* & a2))’

from ‘const type {aka const boost::proto::exprns_::basic_expr<boost::phoenix::detail::tag::function_eval, boost::proto::argsns_::list3<boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::function_ptr<2,bool, bool (*)(const boost::log::v2_mt_posix::value_ref<severity_level>&, const boost::log::v2_mt_posix::value_ref<std::basic_string<char>>&)> >, 0l>, boost::log::v2_mt_posix::expressions::attribute_keyword<tag::severity>, boost::log::v2_mt_posix::expressions::attribute_keyword<tag::tag_attr> >, 3l>}’ to ‘boost::proto::exprns_::basic_expr<boost::proto::tagns_::tag::terminal, boost::proto::argsns_::term<boost::phoenix::detail::function_ptr<2, bool, bool (*)(const boost::log::v2_mt_posix::value_ref<severity_level>&, const boost::log::v2_mt_posix::value_ref<std::basic_string<char> >&)>

, 0l>::proto_child0 {

aka boost::phoenix::detail::function_ptr<2, bool, bool (*)(const boost::log::v2_mt_posix::value_ref<severity_level>&, const boost::log::v2_mt_posix::value_ref<std::basic_string<char>

&)>}’ };

Change History (4)

comment:1 by Andrey Semashev, 9 years ago

(In [86404]) Refs #9291. Corrected the docs wrt the problems of using attribute keywords with phoenix::bind or phoenix::function.

comment:2 by Andrey Semashev, 9 years ago

This is a known problem caused by #7996. The workaround is to explicitly specify the fallback policy in case if the attribute value is missing, for example:

sink->set_filter(phoenix::bind(&my_filter, severity.or_none(), tag_attr.or_none()));

Here or_none means "pass an empty value_ref to my_filter if the attribute value is not found".

I've updated the docs, thanks for the report.

comment:3 by Johan Lundberg <lundberj@…>, 9 years ago

Thank you. Works just fine.

comment:4 by Andrey Semashev, 9 years ago

Resolution: duplicate
Status: newclosed

Duplicates #7996.

Note: See TracTickets for help on using tickets.