Boost C++ Libraries: Ticket #13418: Request: allow general typelist types in BOOST_AUTO_TEST_CASE_TEMPLATE() https://svn.boost.org/trac10/ticket/13418 <p> In <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12092" title="#12092: Feature Requests: Request: allow std::tuple typelists in BOOST_AUTO_TEST_CASE_TEMPLATE() (closed: fixed)">ticket:12092</a> I requested that <code>BOOST_AUTO_TEST_CASE_TEMPLATE()</code> be generalised to allow users to specify the typelist as a <code>std::tuple</code> of types, as well as a <code>boost::mpl::vector</code>. You added this feature - thanks very much. </p> <p> As discussed in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12092#comment:7" title="#12092: Feature Requests: Request: allow std::tuple typelists in BOOST_AUTO_TEST_CASE_TEMPLATE() (closed: fixed)">ticket:12092#comment:7</a>, since I made the original request, I've come to realise that TMP gurus avoid using <code>std::tuple</code> as a typelist because it has complex guts that needlessly eat up compiler-time for each instantiation. Instead, I think they typically just use an arbitrary empty template struct, eg: </p> <div class="wiki-code"><div class="code"><pre><span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span><span class="p">...</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">my_typelist_wrapper</span> <span class="p">{};</span> <span class="k">using</span> <span class="n">a_typelist</span> <span class="o">=</span> <span class="n">my_typelist_wrapper</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span><span class="o">&gt;</span><span class="p">;</span> </pre></div></div><p> With this in mind, it might be nice to consider finessing the conversion to <code>boost::mpl::vector</code> so that it works from any arbitrary such typelist (including <code>std::tuple</code>). Here's an illustrative implementation of the idea (which I've slightly tweaked since <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/12092#comment:7" title="#12092: Feature Requests: Request: allow std::tuple typelists in BOOST_AUTO_TEST_CASE_TEMPLATE() (closed: fixed)">ticket:12092#comment:7</a> so that if the metafunction is called with anything other than a single, valid typelist, it will return a dummy type with a descriptive name which will hopefully make the compiler errors more helpful): </p> <div class="wiki-code"><div class="code"><pre><span class="k">struct</span> <span class="n">arg_type_is_not_single_valid_typelist</span> <span class="k">final</span> <span class="p">{</span> <span class="n">arg_type_is_not_single_valid_typelist</span><span class="p">()</span> <span class="o">=</span> <span class="k">delete</span><span class="p">;</span> <span class="o">~</span><span class="n">arg_type_is_not_single_valid_typelist</span><span class="p">()</span> <span class="o">=</span> <span class="k">delete</span><span class="p">;</span> <span class="n">arg_type_is_not_single_valid_typelist</span><span class="p">(</span><span class="k">const</span> <span class="n">arg_type_is_not_single_valid_typelist</span> <span class="o">&amp;</span><span class="p">)</span> <span class="o">=</span> <span class="k">delete</span><span class="p">;</span> <span class="n">arg_type_is_not_single_valid_typelist</span> <span class="o">&amp;</span> <span class="k">operator</span><span class="o">=</span><span class="p">(</span><span class="k">const</span> <span class="n">arg_type_is_not_single_valid_typelist</span> <span class="o">&amp;</span><span class="p">)</span> <span class="o">=</span> <span class="k">delete</span><span class="p">;</span> <span class="p">};</span> <span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span><span class="p">...</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">mpl_vector_of_typelist_impl</span> <span class="p">{</span> <span class="k">using</span> <span class="n">type</span> <span class="o">=</span> <span class="n">arg_type_is_not_single_valid_typelist</span><span class="p">;</span> <span class="p">};</span> <span class="k">template</span> <span class="o">&lt;</span><span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span><span class="p">...</span><span class="o">&gt;</span> <span class="k">class</span> <span class="nc">T</span><span class="p">,</span> <span class="k">typename</span><span class="p">...</span> <span class="n">Us</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">mpl_vector_of_typelist_impl</span><span class="o">&lt;</span> <span class="n">T</span><span class="o">&lt;</span> <span class="n">Us</span><span class="p">...</span> <span class="o">&gt;</span> <span class="o">&gt;</span> <span class="p">{</span> <span class="k">using</span> <span class="n">type</span> <span class="o">=</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="n">Us</span><span class="p">...</span><span class="o">&gt;</span><span class="p">;</span> <span class="p">};</span> <span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span> <span class="n">T</span><span class="o">&gt;</span> <span class="k">using</span> <span class="n">mpl_vector_of_typelist_t</span> <span class="o">=</span> <span class="k">typename</span> <span class="n">mpl_vector_of_typelist_impl</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;::</span><span class="n">type</span><span class="p">;</span> </pre></div></div><p> Here are some simple usage examples: </p> <div class="wiki-code"><div class="code"><pre> <span class="k">template</span> <span class="o">&lt;</span><span class="k">typename</span><span class="p">...</span><span class="o">&gt;</span> <span class="k">struct</span> <span class="n">my_typelist_wrapper</span> <span class="p">{};</span> <span class="k">static_assert</span><span class="p">(</span> <span class="n">std</span><span class="o">::</span><span class="n">is_same</span><span class="o">&lt;</span> <span class="n">mpl_vector_of_typelist_t</span><span class="o">&lt;</span> <span class="n">my_typelist_wrapper</span><span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">&gt;</span> <span class="o">&gt;::</span><span class="n">value</span><span class="p">,</span> <span class="s">&quot;&quot;</span> <span class="p">);</span> <span class="k">static_assert</span><span class="p">(</span> <span class="n">std</span><span class="o">::</span><span class="n">is_same</span><span class="o">&lt;</span> <span class="n">mpl_vector_of_typelist_t</span><span class="o">&lt;</span> <span class="n">std</span><span class="o">::</span><span class="n">tuple</span> <span class="o">&lt;</span> <span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">&gt;</span> <span class="o">&gt;</span><span class="p">,</span> <span class="n">boost</span><span class="o">::</span><span class="n">mpl</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="p">,</span> <span class="kt">char</span> <span class="o">&gt;</span> <span class="o">&gt;::</span><span class="n">value</span><span class="p">,</span> <span class="s">&quot;&quot;</span> <span class="p">);</span> <span class="k">static_assert</span><span class="p">(</span> <span class="n">std</span><span class="o">::</span><span class="n">is_same</span><span class="o">&lt;</span> <span class="n">mpl_vector_of_typelist_t</span><span class="o">&lt;</span> <span class="kt">int</span> <span class="o">&gt;</span><span class="p">,</span> <span class="n">arg_type_is_not_single_valid_typelist</span> <span class="o">&gt;::</span><span class="n">value</span><span class="p">,</span> <span class="s">&quot;&quot;</span> <span class="p">);</span> </pre></div></div> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13418 Trac 1.4.3 Raffi Enficiaud Thu, 21 Jun 2018 23:32:16 GMT <link>https://svn.boost.org/trac10/ticket/13418#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13418#comment:1</guid> <description> <p> Well, I am not sure that <code>mpl::vector</code> can handle, especially because a <a class="ext-link" href="https://www.boost.org/doc/libs/1_67_0/libs/mpl/doc/refmanual/variadic-sequence.html"><span class="icon">​</span>preprocessor value</a> that is limiting the variadicity is involved. </p> <p> I suggest this instead: I will keep the <code>std::tuple</code> internally, and slightly improve the API such that constructing a <code>std::tuple</code> is not needed (and instead any variadic template would do). </p> <p> What do you think? </p> <p> The argument checking is definitely a good thing to have, and you will have a more general API. It will not be faster in terms of compilation machinery since it will still involve <code>std::tuple</code>, at least internally. </p> </description> <category>Ticket</category> </item> <item> <author>Tony Lewis <TonyELewis@…></author> <pubDate>Sat, 23 Jun 2018 13:11:42 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13418#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13418#comment:2</guid> <description> <p> Thanks for the reply. </p> <p> Ah sorry - I think I was assuming that you're currently still using <code>boost::mpl::vector</code> internally but AFAIU, you're saying you use <code>std::tuple</code>. </p> <p> <sub>(I'm a bit surprised because I thought the library supported pre-C++11 so would need to convert everything to a pre-C++11 typelist. Is that incorrect?)</sub> </p> <p> Anyway, the thing I'm specifically requesting in this ticket is that <code>BOOST_AUTO_TEST_CASE_TEMPLATE()</code> accept arbitrary type lists (<code>boost::mpl::vector</code>, <code>std::tuple</code> or the user's own typelist type). </p> <p> I'm not making any requests about how you store the typelist internally (though if you don't have to support pre-C++11 and are already using <code>std::tuple</code>, it's possible you'd enjoy reduced compilation times by moving to <code>template &lt;typename...&gt; your_own_typelist;</code>). </p> <p> So yes: the thing you're proposing is exactly what I'm requesting. Thanks very much. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Mon, 04 Mar 2019 21:44:19 GMT</pubDate> <title>keywords, owner changed https://svn.boost.org/trac10/ticket/13418#comment:3 https://svn.boost.org/trac10/ticket/13418#comment:3 <ul> <li><strong>keywords</strong> 1.70 target added; mpl test typelist template c++11 tuple tmp metaprogramming removed </li> <li><strong>owner</strong> changed from <span class="trac-author">Gennadiy Rozental</span> to <span class="trac-author">Raffi Enficiaud</span> </li> </ul> <p> In branch <code>topic/GH-141-mp11-hana-typelist</code> </p> Ticket Raffi Enficiaud Thu, 07 Mar 2019 21:44:17 GMT status, milestone changed; resolution set https://svn.boost.org/trac10/ticket/13418#comment:4 https://svn.boost.org/trac10/ticket/13418#comment:4 <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">fixed</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.69</span> </li> </ul> <p> In master, rev <code>622a035e34af52ab68c3817645aefd4c6a1da0e5</code>. Should be in 1.70 release. </p> Ticket