Re: Help: How many explicit specializations required?

From: Nicolas Pavlidis (pavnic_at_sbox.tugraz.at)
Date: 09/16/04


Date: 16 Sep 2004 20:30:32 +0200

coolpint@yahoo.co.uk (CoolPint) writes:

> template <typename T>
> void func(T * const &) // should handle T * as well as const T *
> { cout << "Overloading for Pointers\n"; }
>
> template <>
> void func(char * const &)
> { cout << "specialization: char * \n"; }

This (taken as an example) will not work, spezialization (explicit or
partial) is only possible with clases.
There are two ways you can work around this:
1) Write a class where the function you need is a publc static member,
then you can do this what you want
2) Work with overloadings, this should work fine, because template and
non template functions are overloadable

Or you can still use typetrais and overload the function too for the
spezial int cases which you mentioned, which is IMHO the slightest
effort to reach your aim.

Kind regards,
Nicolas

-- 
|     Nicolas Pavlidis       |       Elvis Presly:    |\ |__      |
|   Student of SE  & KM      |      "Into the goto"   | \|__|     |
|  pavnic@sbox.tugraz.at     |       ICQ #320057056      |        |
|-------------------University of Technology, Graz----------------|