2

In the chapter N3797::14/4 [temp] (emphasis mine)

A template name has linkage (3.5). A non-member function template can have internal linkage; any other template name shall have external linkage. Specializations (explicit or implicit) of a template that has internal linkage are distinct from all specializations in other translation units.

was mentioned about implicit specialization. As far as I understand from the context, that concept is different from the template explicit specialization which has

template < > declaration

grammar. So, I'm guessing that implicit specialization has something to do with a partial class template specialization. Unfortunately, I couldn't normative reference defining the implicit specialization concept in the current working draft.

manuell
  • 7,528
  • 5
  • 31
  • 58

2 Answers2

2

There is no normative term called "implicit specialization".
However, I believe that in this context, it means the complement of "explicit specialization": Every specialization that was not explicitly specialized by the user, in other (normative) words, instantiated specializations.
Consider that there are

  • Explicit specializations
  • Implicit instantiations
  • Explicit instantiations

Specializations instantiated through the latter two one could refer to as "implicit specializations".

Columbo
  • 60,038
  • 8
  • 155
  • 203
  • Well, if we apply explicit specialization to a template will the coresponding class/function definition be put into a compiled object file? –  Feb 23 '15 at 08:33
  • Just to clarafy, I think if we apply a partial specialization for a class template, any class definition won't be put into an object file unless it's instantiated (implcitly/ explcitily). Am i right? –  Feb 23 '15 at 08:35
  • @DmitryFucintv A partial specialization is a template, and if it isn't instantiated, then it will remain as effectless with respect to the program as uninstantiated primary templates are. – Columbo Feb 23 '15 at 08:46
0

The term isn't used much in the Standard, but we can deduce what it means from §14.5.5.3 - reproduced below - which I've broken into paragraphs (A), (B) and (C) for ease of reference (boldfacing mine):

(A) If a member template of a class template is partially specialized, the member template partial specializations are member templates of the enclosing class template; if the enclosing class template is instantiated (14.7.1, 14.7.2), a declaration for every member template partial specialization is also instantiated as part of creating the members of the class template specialization.

(B) If the primary member template is explicitly specialized for a given (implicit) specialization of the enclosing class template, the partial specializations of the member template are ignored for this specialization of the enclosing class template.

(C) If a partial specialization of the member template is explicitly specialized for a given (implicit) specialization of the enclosing class template, the primary member template and its other partial specializations are still considered for this specialization of the enclosing class template. [ Example:

template<class T> struct A {
    template<class T2> struct B {}; // #1
    template<class T2> struct B<T2*> {}; // #2
};
template<> template<class T2> struct A<short>::B {}; // #3

A<char>::B<int*> abcip; // uses #2
A<short>::B<int*> absip; // uses #3
A<char>::B<int> abci; // uses #1

-- end example]

Repeating (B) with my cross-references to the example in parentheses:

"if the primary member template (i.e. #1) is explicitly specialised (as at #3) for a given (implicit) specialisation of the enclosing class template (A), the partial specialisations of the member template (#2) are ignored for this specialisation of the enclosing class template".

We see the specialisation at #3 results in the ignoring of #2 for absip;. We can therefore conclude that the following line...

template<> template<class T2> struct A<short>::B {}; // #3

...performs an implicit specialisation of the enclosing class template, namely A<short>.

So, implicit specialisation is when specialisation of a member function implicitly involves specialisation of the class template that it's a member of. Put another way, the class template A didn't require a separate earlier specialisation for short before the member template at #1 was specialised, because it could be specialised implicitly.

Community
  • 1
  • 1
Tony Delroy
  • 102,968
  • 15
  • 177
  • 252