Boost C++ Libraries: Ticket #7996: phoenix::bind does not protoify the bound arguments https://svn.boost.org/trac10/ticket/7996 <p> I have a problem with Boost.Phoenix v3 bind implementation when used with attribute keywords from Boost.Log. For some reason phoenix::bind does not apply proto::detail::protoify to the bound arguments which breaks compilation of some formatting expressions in Boost.Log. </p> <p> Here's an example: </p> <pre class="wiki">#include &lt;boost/phoenix.hpp&gt; #include &lt;boost/log/trivial.hpp&gt; #include &lt;boost/log/expressions.hpp&gt; #include &lt;boost/log/utility/value_ref.hpp&gt; namespace logging = boost::log; namespace expr = boost::log::expressions; namespace phoenix = boost::phoenix; // Custom severity level formatting function std::string severity_level_as_urgency( logging::value_ref&lt; logging::trivial::severity_level, logging::trivial::tag::severity &gt; const&amp; level) { if (!level || level.get() == logging::trivial::info) return "normal"; logging::trivial::severity_level lvl = level.get(); if (lvl &lt; logging::trivial::info) return "low"; else return "critical"; } int main(int, char*[]) { logging::formatter fmt = expr::stream &lt;&lt; boost::phoenix::bind(&amp;severity_level_as_urgency, logging::trivial::severity); return 0; } </pre><p> The example creates a formatter function object that should call severity_level_as_urgency function to convert the severity level to string and put its result into a stream. </p> <p> trivial::severity is a keyword of type expr::attribute_keyword&lt; ... &gt;. Keywords themselves should never actually be embedded into phoenix expressions, instead I have attribute_actor that implements all the necessary work to extract attribute values. I have specialized proto::detail::protoify template for attribute_keyword (including references and reference_wrappers thereof) so that it is automatically converted to attribute_actor whenever it participates in expressions. But it doesn't work with the above code, Boost.Phoenix embeds attribute_keyword as is into the expression. This results in the error I attached to the ticket. </p> <p> I realize that proto::detail::protoify is not for public use and may not be intended for my use case but I did not find any other way to implement what I described. Anyway, I think bind should treat bound arguments as child subexpressions and protoify them. </p> <p> To compile the test code you will have to checkout Boost.Log from SVN: </p> <pre class="wiki">svn co https://boost-log.svn.sourceforge.net/svnroot/boost-log/branches/bleeding-edge -r 822 boost-log </pre><p> Then the relevant directories have to be linked/copied into the Boost tree. </p> <p> PS: The issue came from the mailing list: </p> <p> <a class="ext-link" href="http://lists.boost.org/Archives/boost/2013/02/200701.php"><span class="icon">​</span>http://lists.boost.org/Archives/boost/2013/02/200701.php</a> </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7996 Trac 1.4.3 Andrey Semashev Wed, 06 Feb 2013 18:11:12 GMT attachment set https://svn.boost.org/trac10/ticket/7996 https://svn.boost.org/trac10/ticket/7996 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">build_error.txt</span> </li> </ul> <p> Compilation error </p> Ticket Thomas Heller Fri, 08 Feb 2013 21:06:53 GMT <link>https://svn.boost.org/trac10/ticket/7996#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:1</guid> <description> <p> Hi Andrey, </p> <p> I am not sure what the problem here *exactly* is. I just checked the code of phoenix bind and all other phoenix expressions, they never use boost::proto::detail::protoify, the use the regular and document boost::proto::make_expr functionality. I am not sure who to blame here. However i think it rather is Boost.Log in this case, as phoenix uses official and document functions of proto. This means i needed to change every phoenix expression in order to work with boost.log which uses an undocument private function out of the detail namespace of a library. </p> <p> That being said, this would probably need closer investigation. I will try to take a close look next week. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Fri, 08 Feb 2013 22:04:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7996#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:2</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7996#comment:1" title="Comment 1">theller</a>: </p> <p> I'm by far not an expert in Boost.Proto but as far as I understand protoify is used internally by Boost.Proto to envelop objects participating in template expressions into Boost.Proto expression tree structures. In particular this is done to all terminals, and this behavior is used by Boost.Log to transparently convert all attribute_keywords to attribute_actors. </p> <p> Boost.Phoenix doesn't use protoify directly, but it does so through some public interface of Boost.Proto (which is probably make_expr, I don't know for sure). My guess is that phoenix::bind doesn't treat the bound arguments the same way Boost.Phoenix treats other terminals in template expressions. This results in bound arguments not being enveloped into Boost.Proto terminal structures and consequently it doesn't invoke protoify and breaks Boost.Log. </p> <p> I will be happy to use a public interface of Boost.Proto or Boost.Phoenix to achieve what I need. I just didn't find such an interface. Please, tell me if there is one. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Andrey Semashev</dc:creator> <pubDate>Sun, 22 Sep 2013 18:58:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7996#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:3</guid> <description> <p> Any updates about this problem? </p> </description> <category>Ticket</category> </item> <item> <author>John Fletcher <J.P.Fletcher@…></author> <pubDate>Tue, 04 Feb 2014 20:55:14 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7996#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:4</guid> <description> <p> I am going to start to look at this problem. My first reaction is that if Thomas did not know an answer, and he wrote version 3 of phoenix to use proto, then I am going to have to do quite a lot of digging to find this one. John </p> </description> <category>Ticket</category> </item> <item> <author>John Fletcher <J.P.Fletcher@…></author> <pubDate>Tue, 04 Feb 2014 23:23:54 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7996#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:5</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7996#comment:4" title="Comment 4">John Fletcher &lt;J.P.Fletcher@…&gt;</a>: </p> <blockquote class="citation"> <p> I am going to start to look at this problem. My first reaction is that if Thomas did not know an answer, and he wrote version 3 of phoenix to use proto, then I am going to have to do quite a lot of digging to find this one. John </p> </blockquote> <p> This is not working. </p> </description> <category>Ticket</category> </item> <item> <author>John Fletcher <J.P.Fletcher@…></author> <pubDate>Tue, 04 Feb 2014 23:24:43 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7996#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:6</guid> <description> <p> Sorry, response on the wrong item. </p> </description> <category>Ticket</category> </item> <item> <author>John Fletcher <J.P.Fletcher@…></author> <pubDate>Fri, 07 Feb 2014 15:39:40 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7996#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:7</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/7996#comment:6" title="Comment 6">John Fletcher &lt;J.P.Fletcher@…&gt;</a>: </p> <blockquote class="citation"> <p> Sorry, response on the wrong item. </p> </blockquote> <p> It was "this is not working" which was on the wrong bug trac. I have yet to start on this one. John </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Smithd413</dc:creator> <pubDate>Thu, 17 Jul 2014 10:36:00 GMT</pubDate> <title>severity, component, version, milestone, owner, type changed https://svn.boost.org/trac10/ticket/7996#comment:8 https://svn.boost.org/trac10/ticket/7996#comment:8 <ul> <li><strong>severity</strong> <span class="trac-field-old">Problem</span> → <span class="trac-field-new">Not Applicable</span> </li> <li><strong>component</strong> <span class="trac-field-old">phoenix</span> → <span class="trac-field-new">xpressive</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost Release Branch</span> → <span class="trac-field-new">Boost.Build-M3</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Website 1.X</span> </li> <li><strong>owner</strong> changed from <span class="trac-author">Thomas Heller</span> to <span class="trac-author">Eric Niebler</span> </li> <li><strong>type</strong> <span class="trac-field-old">Bugs</span> → <span class="trac-field-new">Library Submissions</span> </li> </ul> <p> Thanks so much for sharing this excellent info! I'm seeking forward to see much more posts! beececefeeeeeeec </p> Ticket Andrey Semashev Thu, 17 Jul 2014 11:36:25 GMT severity, component, version, milestone, owner, type changed https://svn.boost.org/trac10/ticket/7996#comment:9 https://svn.boost.org/trac10/ticket/7996#comment:9 <ul> <li><strong>severity</strong> <span class="trac-field-old">Not Applicable</span> → <span class="trac-field-new">Problem</span> </li> <li><strong>component</strong> <span class="trac-field-old">xpressive</span> → <span class="trac-field-new">phoenix</span> </li> <li><strong>version</strong> <span class="trac-field-old">Boost.Build-M3</span> → <span class="trac-field-new">Boost Release Branch</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">Website 1.X</span> → <span class="trac-field-new">To Be Determined</span> </li> <li><strong>owner</strong> changed from <span class="trac-author">Eric Niebler</span> to <span class="trac-author">Thomas Heller</span> </li> <li><strong>type</strong> <span class="trac-field-old">Library Submissions</span> → <span class="trac-field-new">Bugs</span> </li> </ul> Ticket John Fletcher <J.P.Fletcher@…> Thu, 17 Jul 2014 21:09:48 GMT <link>https://svn.boost.org/trac10/ticket/7996#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7996#comment:10</guid> <description> <p> Andy My apologies I have never got around to looking at this one. John </p> </description> <category>Ticket</category> </item> </channel> </rss>