Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In C++03, template arguments could not have internal linkage:</p> <blockquote> <p><code>[C++03: 14.6.4.2/1]:</code> For a function call that depends on a template parameter, if the function name is an <em>unqualified-id</em> but not a <em>template-id</em>, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2) except that:</p> <ul> <li><strong>For the part of the lookup using unqualified name lookup</strong> (3.4.1), <strong>only function declarations with external linkage from the template definition context are found</strong>.</li> <li>For the part of the lookup using associated namespaces (3.4.2), only function declarations with external linkage found in either the template definition context or the template instantiation context are found.</li> </ul> <p><em>[..]</em></p> </blockquote> <p>This was changed (issue <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#561" rel="nofollow">#561: "Internal linkage functions in dependent name lookup"</a>) in C++11:</p> <blockquote> <p><code>[C++11: C.2.6]:</code> 14.6.4.2 <br/> <strong>Change</strong>: Allow dependent calls of functions with internal linkage <br/> <strong>Rationale:</strong> Overly constrained, simplify overload resolution rules.</p> </blockquote> <p>resulting in:</p> <blockquote> <p><code>[C++11: 14.6.4.2/1]:</code> For a function call that depends on a template parameter, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2, 3.4.3) except that:</p> <ul> <li><strong>For the part of the lookup using unqualified name lookup</strong> (3.4.1) or qualified name lookup (3.4.3), <strong>only function declarations from the template definition context are found.</strong></li> <li>For the part of the lookup using associated namespaces (3.4.2), only function declarations found in either the template definition context or the template instantiation context are found.</li> </ul> <p><em>[..]</em></p> </blockquote> <p>(Spot the missing <em>"with external linkage"</em> qualification.)</p> <p>Since your <code>main()::ComparitorInner&amp;</code> has internal linkage, and the instantiation of <code>std::sort</code> requires this type to be a template parameter (albeit deduced), your code is only valid in C++11.</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.
    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