V
Vaclav Haisman
Hi,
today a guy came to #C++@IRCNet and during discusion he showed this piece of
code:
template<bool tswitch=false>
class clstmp
{
public:
int val;
inline clstmp()
{
ctor_clstmp<tswitch>();
}
template<bool> inline void ctor_clstmp();
template<> inline void ctor_clstmp<false>()
{
val = 1;
}
template<> inline void ctor_clstmp<true>()
{
val = 2;
}
};
It does compile with VS.NET 7.1 compiler even with MS extensions disabled.
It doesn't compile with recent GCC 3.5 fresh from CVS and neither with
Comeau's web test drive compiler. Now I would like to hear ruling on whether
it is valid C++ code or not.
V.H.
today a guy came to #C++@IRCNet and during discusion he showed this piece of
code:
template<bool tswitch=false>
class clstmp
{
public:
int val;
inline clstmp()
{
ctor_clstmp<tswitch>();
}
template<bool> inline void ctor_clstmp();
template<> inline void ctor_clstmp<false>()
{
val = 1;
}
template<> inline void ctor_clstmp<true>()
{
val = 2;
}
};
It does compile with VS.NET 7.1 compiler even with MS extensions disabled.
It doesn't compile with recent GCC 3.5 fresh from CVS and neither with
Comeau's web test drive compiler. Now I would like to hear ruling on whether
it is valid C++ code or not.
V.H.