Boost C++ Libraries: Ticket #12092: Request: allow std::tuple typelists in BOOST_AUTO_TEST_CASE_TEMPLATE() https://svn.boost.org/trac10/ticket/12092 <p> At present, <code>BOOST_AUTO_TEST_CASE_TEMPLATE</code> requires a Boost MPL sequence type to specify the list of types. </p> <p> Please may I request that this be extended under &gt;= C++11 compilation to also support a <code>std::tuple&lt;...&gt;</code> type as a way of specifying the types? </p> <p> I think this would be a good addition because I get the sense that <code>std::tuple</code> is increasingly being preferred as a way to specify typelists (because it's standard, because it allows an arbitrary number of types out-of-the-box and because it doesn't use dummy placeholder types for absent types and so generates much simpler compiler errors). </p> <p> Under the covers, this could just be implemented by converting to, say an equivalent<code>boost::mpl::vector</code>. This isn't too onerous under modern C++ : </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="n">Ts</span><span class="o">&gt;</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">Ts</span><span class="p">...</span><span class="o">&gt;</span> <span class="n">mpl_vector_of_tuple_impl_fn</span><span class="p">(</span><span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">tuple</span><span class="o">&lt;</span><span class="n">Ts</span><span class="p">...</span><span class="o">&gt;</span> <span class="o">&amp;</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_tuple_t</span> <span class="o">=</span> <span class="k">decltype</span><span class="p">(</span> <span class="n">mpl_vector_of_tuple_impl_fn</span><span class="p">(</span> <span class="n">std</span><span class="o">::</span><span class="n">declval</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span> <span class="p">)</span> <span class="p">);</span> </pre></div></div><p> ...which can then be used like: </p> <div class="wiki-code"><div class="code"><pre><span class="k">using</span> <span class="n">example_int_char_mpl_vec</span> <span class="o">=</span> <span class="n">mpl_vector_of_tuple_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> </pre></div></div><p> I don't mind if users have to specify a different name (other than <code>BOOST_AUTO_TEST_CASE_TEMPLATE</code>) when using <code>std::tuple</code>. </p> <p> Thanks very much for your time. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/12092 Trac 1.4.3 anonymous Tue, 24 Oct 2017 04:56:25 GMT <link>https://svn.boost.org/trac10/ticket/12092#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12092#comment:1</guid> <description> <p> As a heavy user of BOOST unit test I would love to see this idea implemented. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Wed, 03 Jan 2018 00:20:36 GMT</pubDate> <title>owner, status, milestone changed https://svn.boost.org/trac10/ticket/12092#comment:2 https://svn.boost.org/trac10/ticket/12092#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Gennadiy Rozental</span> to <span class="trac-author">Raffi Enficiaud</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.66.0</span> </li> </ul> Ticket Raffi Enficiaud Wed, 03 Jan 2018 00:47:50 GMT <link>https://svn.boost.org/trac10/ticket/12092#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12092#comment:3</guid> <description> <p> On branch <code>topic/12092-template-test-case-w-tuples</code> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Thu, 18 Jan 2018 13:50:37 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/12092#comment:4 https://svn.boost.org/trac10/ticket/12092#comment:4 <ul> <li><strong>milestone</strong> <span class="trac-field-old">Boost 1.66.0</span> → <span class="trac-field-new">Boost 1.67.0</span> </li> </ul> Ticket Raffi Enficiaud Fri, 19 Jan 2018 13:39:34 GMT <link>https://svn.boost.org/trac10/ticket/12092#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12092#comment:5</guid> <description> <p> On develop </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Mon, 22 Jan 2018 12:55:12 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/12092#comment:6 https://svn.boost.org/trac10/ticket/12092#comment:6 <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> <p> On master </p> Ticket Tony E Lewis <tonyelewis@…> Tue, 23 Jan 2018 14:23:00 GMT <link>https://svn.boost.org/trac10/ticket/12092#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12092#comment:7</guid> <description> <p> Thanks very much for this. </p> <p> As I now understand it, the 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>mpl::vector</code> so that it works from any arbitrary such typelist (including <code>std::tuple</code>) : </p> <div class="wiki-code"><div class="code"><pre><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">U</span><span class="p">,</span> <span class="k">typename</span><span class="p">...</span> <span class="n">Ts</span><span class="o">&gt;</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">Ts</span><span class="p">...</span><span class="o">&gt;</span> <span class="n">mpl_vector_of_typelist_impl_fn</span><span class="p">(</span><span class="k">const</span> <span class="n">U</span><span class="o">&lt;</span><span class="n">Ts</span><span class="p">...</span><span class="o">&gt;</span> <span class="o">&amp;</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">decltype</span><span class="p">(</span> <span class="n">mpl_vector_of_typelist_impl_fn</span><span class="p">(</span> <span class="n">std</span><span class="o">::</span><span class="n">declval</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span><span class="p">()</span> <span class="p">)</span> <span class="p">);</span> </pre></div></div><p> I'm sorry that I didn't suggest this earlier. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Raffi Enficiaud</dc:creator> <pubDate>Wed, 24 Jan 2018 09:07:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12092#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12092#comment:8</guid> <description> <p> That is nice! However I closed this ticket, would you please just create a new one? </p> </description> <category>Ticket</category> </item> <item> <author>Tony E Lewis <tonyelewis@…></author> <pubDate>Wed, 24 Jan 2018 12:29:24 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/12092#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/12092#comment:9</guid> <description> <p> Thanks. I've created <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/13418" title="#13418: Feature Requests: Request: allow general typelist types in BOOST_AUTO_TEST_CASE_TEMPLATE() (closed: fixed)">ticket:13418</a> for this. </p> </description> <category>Ticket</category> </item> </channel> </rss>