Re: partial specialization

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Victor Bazarov wrote:

template<>
struct A<double, int>
{
void foo() {}
};

and

template<>
void A<double, int>::foo() {}

(other than syntax, of course)?

The former is specialisation, the latter is a definition.

The former is specialization of A _and_ a definition of A::foo,
specializezed for double and int, the later is a definition of A::foo
specialized for double and int (and implicit specialization of A), yes.
Yet the effect of both is exactly the same...

--

.



Relevant Pages

  • Re: Implementing a templated "round" function?
    ... > int iround{ ... Why do you think the 1st version is integer calculation and is fast? ... At this time my function accepts only double precision floating ... > I could add a specialisation for every combination of S and T, ...
    (comp.lang.cpp)
  • Re: partial specialization
    ... (other than syntax, of course)? ... The former is specialisation, ... specializezed for double and int, the later is a definition of A::foo ... It depends on the contents of struct Adefinition, ...
    (microsoft.public.vc.language)
  • Re: Class templates and friend function templates
    ... friend void process; ... each specialization of the `task' class template has all specializations of the function template `func' as friends. ... It only has one parameter that is distinct, thus implying a kind of partial specialisation of the friend declaration once C is instantiated for a particular type. ...
    (microsoft.public.vc.language)
  • Re: does not compile with "using namespace std"
    ... That means that a specialisation of class Stack for some ... template parameter T will have the following function ... because you haven't provided a definition for the friend operator <<. ...
    (comp.lang.cpp)
  • Re: Determining a variables type
    ... what part of this solution makes use of partial template ... but essentially it boils down to the compiler chooses the most specialised ... This is the part that uses partial specialisation. ...
    (comp.lang.cpp)