BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Partial template specialization

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
opb
Guest





PostPosted: Sun Jun 05, 2005 4:14 pm    Post subject: Partial template specialization Reply with quote



Hi!

Why can I compile this in BuilderX, but not in BCB6?
And is there a solution to this?



template <typename T, unsigned int N>
class RefArray
{

RefArray<T,N>(T * pElements)
{
}
};

template <typename T>
class RefArray<T,1>
{
RefArray <T,1>(T* pElements)
{
}

};


Back to top
Thomas Maeder [TeamB]
Guest





PostPosted: Sun Jun 05, 2005 5:51 pm    Post subject: Re: Partial template specialization Reply with quote



"opb" <brunstad (AT) online (DOT) no> writes:

Quote:
Why can I compile this in BuilderX, but not in BCB6?

It seems that a problem with non-type template parameters was fixed
from C++ Builder 6 to C++BuilderX.


Quote:
And is there a solution to this?

template <typename T, unsigned int N
class RefArray
{

RefArray {
}
};

template <typename T
class RefArray {
RefArray {
}
};

My first shot would be to try substituting the unsigned int parameter
by a type parameter. Something like:

template <unsigned int N>
struct IntToType
{
enum
{
value = N
};
};


template <typename T, typename IntToTypeInstance>
class RefArray
{
RefArray(T * pElements)
{
}
};

template <typename T>
class RefArray<T, IntToType<1> >
{
RefArray(T* pElements)
{
}
};

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.