Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you compile using <a href="http://clang.llvm.org/" rel="nofollow noreferrer">clang</a>, it helpfully reports that (2) and (3) are unusable. The warning for (3), which you expect to be selected, is as follows:</p> <blockquote> <p>warning: class template partial specialization contains a template parameter that can not be deduced; this partial specialization will never be used</p> <pre><code>struct alpha&lt;std::tuple&lt;Args..., T&gt;, T&gt; { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ </code></pre> <p>note: non-deducible template parameter '<code>Args</code>'</p> <pre><code>template&lt;class T, class... Args&gt; ^ </code></pre> </blockquote> <p>Why is <code>Args</code> not deducible? The C++0x FDIS states at §14.8.2.5/9:</p> <blockquote> <p>If the template argument list of [a type that is specified in terms of template parameters] contains a pack expansion that is not the last template argument, the entire template argument list is a non-deduced context.</p> </blockquote> <p>In your specialization, the type <code>std::tuple&lt;Args..., T&gt;</code> is a type that is specified in terms of template parameters <code>Args</code> and <code>T</code>. It contains a pack expansion (<code>Args...</code>), but that pack expansion is not the last template argument (<code>T</code> is the last template argument). Thus, the entire template argument list of the <code>tuple</code> (the entirety of <code>&lt;Args..., T&gt;</code>) is a non-deduced context.</p> <p>The argument list of the <code>std::tuple</code> is the only place in the template specialization's argument list that <code>Args</code> appears; since it is not deducible from there, it is not deducible at all and the specialization will never be used.</p> <p>Matthieu M. <a href="https://stackoverflow.com/questions/6757691/partial-specialization-of-tuple-contents-with-variadic-arguments/6758377#6758377">provides a clever workaround in his answer</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload