Boost C++ Libraries: Ticket #7254: Proto expressions are not MPL sequences https://svn.boost.org/trac10/ticket/7254 <p> Proto expressions are not MPL sequences. It is arguably possible to get a MPL sequence by using boost::fusion::result_of::as_vector, but this may have undesirable overhead. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7254 Trac 1.4.3 Eric Niebler Tue, 21 Aug 2012 18:04:28 GMT <link>https://svn.boost.org/trac10/ticket/7254#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7254#comment:1</guid> <description> <p> I've wanted to do this, but there's a snag. MPL sequences use tag dispatching. You can get the tag of an MPL sequence either by specializing <code>mpl::sequence_tag</code> or by having a nested <code>tag</code> typedef in your sequence type. Neither is satisfactory for Proto. </p> <p> Specializing <code>mpl::sequence_tag</code> is a non-starter because any type that uses <code>proto::extends</code> or <code>BOOST_PROTO_EXTENDS</code> can be a Proto expression. This is an open set. </p> <p> Having a nested <code>tag</code> type is a non-starter because expressions are part of end-users' APIs, and Proto shouldn't be claiming such a common identifier for itself. Someone might want <code>e.tag</code> to mean something in their DSL. </p> <p> BTW, Fusion doesn't have this problem because it uses <code>fusion_tag</code> instead of simply <code>tag</code>. </p> <p> I'm open to suggestions. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Mathias Gaunard</dc:creator> <pubDate>Tue, 21 Aug 2012 18:23:15 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7254#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7254#comment:2</guid> <description> <p> I don't mind adding the tag in my expressions myself. </p> <p> But <code>typedef boost::fusion::fusion_sequence_tag tag;</code> doesn't work. </p> <p> It says there is no <code>convert_impl</code> for the proto expression tag. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Wed, 22 Aug 2012 17:14:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7254#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7254#comment:3</guid> <description> <p> The following works just fine for me: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;typeinfo&gt; #include &lt;boost/proto/proto.hpp&gt; #include &lt;boost/fusion/mpl.hpp&gt; #include &lt;boost/mpl/for_each.hpp&gt; #include &lt;boost/mpl/placeholders.hpp&gt; #include &lt;boost/type_traits/remove_reference.hpp&gt; namespace mpl = boost::mpl; namespace proto = boost::proto; namespace fusion = boost::fusion; template&lt;class E&gt; struct my_expr; struct my_domain : proto::domain&lt;proto::generator&lt;my_expr&gt; &gt; {}; template&lt;class E&gt; struct my_expr : proto::extends&lt;E, my_expr&lt;E&gt;, my_domain&gt; { my_expr(E const &amp;e = E()) : proto::extends&lt;E, my_expr&lt;E&gt;, my_domain&gt;(e) {} typedef fusion::fusion_sequence_tag tag; }; struct noop { typedef void result_type; template&lt;typename T&gt; void operator()(T const &amp;) const { std::cout &lt;&lt; typeid(T).name() &lt;&lt; std::endl; } }; int main() { my_expr&lt;proto::terminal&lt;int&gt;::type&gt; i; mpl::for_each&lt;decltype(i + i), boost::remove_reference&lt;mpl::_1&gt; &gt;(noop()); } </pre> </description> <category>Ticket</category> </item> <item> <dc:creator>Mathias Gaunard</dc:creator> <pubDate>Wed, 22 Aug 2012 19:59:29 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7254#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7254#comment:4</guid> <description> <p> Try calling <code>mpl::pop_back</code> on that type, I get the following error: </p> <p> <code>invalid use of incomplete type `struct boost::fusion::extension::convert_impl&lt;boost::proto::tagns_::tag::proto_expr&gt;'</code> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Wed, 22 Aug 2012 20:39:53 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/7254#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7254#comment:5</guid> <description> <p> Interesting. Looks like an undocumented Fusion customization point. I can guess what it's supposed to do, but I'm following up on the boost list about it. At the very least, it's a bug in Fusion's docs. Let's wait and see what Joel says. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Eric Niebler</dc:creator> <pubDate>Tue, 28 Aug 2012 05:55:41 GMT</pubDate> <title>status changed https://svn.boost.org/trac10/ticket/7254#comment:6 https://svn.boost.org/trac10/ticket/7254#comment:6 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> <p> Fixed on trunk in <a class="changeset" href="https://svn.boost.org/trac10/changeset/80273" title="hook undocumented convert Fusion customization point so that mpl ...">[80273]</a>. </p> Ticket Eric Niebler Mon, 03 Sep 2012 01:17:33 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/7254#comment:7 https://svn.boost.org/trac10/ticket/7254#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket