Re: Workaround for partial specialization wanted
"Matthias Hofmann" <hofmann@anvil-soft.com> schrieb im Newsbeitrag
news:5qaovmFud3k7U1@mid.individual.net...
I thought I could work around the problem with the following code, but
unfortunately this gives me an "internal compiler error":
class X
{
void* f( void* ptr )
{
return ptr;
}
public:
template <class T> static T* f( X& x, T* ptr )
{
return static_cast<T*>( x.f( ptr ) );
}
};
int main()
{
int i;
X x;
// fatal error C1001: INTERNAL COMPILER ERROR
X::f<int>( x, &i );
return 0;
}
Even installing Service Pack 6 did not help.
I think I finally found a workaround for my problem! :-) The trick is to
use
a friend rather than a static member function:
class X
{
void* f( void* ptr )
{
return ptr;
}
template <class T> friend T* f( X&, T* );
};
template <class T> T* f( X& x, T* ptr )
{
return static_cast<T*>( x.f( ptr ) );
}
int main()
{
int i;
X x;
f<int>( x, &i );
return 0;
}
Together with boost::remove_extent, I think I will now be able to port my
code to Microsoft Visual C++ 6.0! :-)
--
Matthias Hofmann
Anvil-Soft, CEO
http://www.anvil-soft.com - The Creators of Toilet Tycoon
http://www.anvil-soft.de - Die Macher des Klomanagers
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]