T
Thomas Barnet-Lamb
I have a query concerning the handling of explicit specializations.
Essentially, I want to know whether it is legal to take a template
like
and specialise it in the case X takes some particular value, such as:
Here is a complete example of what I am trying to do
-------------------------------------------------
template<class linktype> typename linktype::mychildset&
GetCList(typename linktype:arent&,linktype* =0);
struct UniqueID
{
typedef int mychildset;
typedef int parent;
};
int k;
template<> UniqueID::mychildset& GetCList<UniqueID>(UniqueID:arent&
par,UniqueID*)
{
return k;
}
int main()
{
return 0;
}
-------------------------------------------------
..NET 2003 will not compile this code, giving the error message
"explicit specialization; 'UniqueID::mychildset
&GetCList<UniqueID>(UniqueID:arent &,UniqueID *)' is not a
specialization of a function template", whereas the original .NET
accepted it. I was wondering whether this was due to enhanced
standards conformance in '03, or whether it might have some other
cause (e.g. a compiler bug). (BTW, I tried the code on
www.comeaucomputing.com, which accepted it.) Any information
gratefully recieved!
Best,
Thomas Barnet-Lamb
Lionhead Studios Ltd.
www.lionhead.com
Essentially, I want to know whether it is legal to take a template
like
template<class X> typename X::A Foo(typename X::B, typename X::C)
and specialise it in the case X takes some particular value, such as:
template<> typename Bar::A Foo<Bar>(typename Bar::B, typename Bar::C)
Here is a complete example of what I am trying to do
-------------------------------------------------
template<class linktype> typename linktype::mychildset&
GetCList(typename linktype:arent&,linktype* =0);
struct UniqueID
{
typedef int mychildset;
typedef int parent;
};
int k;
template<> UniqueID::mychildset& GetCList<UniqueID>(UniqueID:arent&
par,UniqueID*)
{
return k;
}
int main()
{
return 0;
}
-------------------------------------------------
..NET 2003 will not compile this code, giving the error message
"explicit specialization; 'UniqueID::mychildset
&GetCList<UniqueID>(UniqueID:arent &,UniqueID *)' is not a
specialization of a function template", whereas the original .NET
accepted it. I was wondering whether this was due to enhanced
standards conformance in '03, or whether it might have some other
cause (e.g. a compiler bug). (BTW, I tried the code on
www.comeaucomputing.com, which accepted it.) Any information
gratefully recieved!
Best,
Thomas Barnet-Lamb
Lionhead Studios Ltd.
www.lionhead.com