R
Ruben Campos
¿Is there any way -other than reimplementing- to make a partially or totally
specialized template to be equivalent to a built-in type?
I ask this for apply it over class templates implementing mathematical
entities -as polynomes and vectors- where entities of order equal to 1 are
equivalent to scalar types. For example:
template <typename TScalar, unsigned int N>
class CPolynome
{
// ...
};
template <typename TScalar>
class CPolynome <TScalar, 1>
{
// CPolynome <TScalar, 1> is equivalent to TScalar, but ¿how is it
implemented?
};
I've tried two ways, both wrong:
template <typename TScalar> typedef TScalar CPolynome <TScalar, 1>;
template <typename TScalar> class CPolynome <TScalar, 1> : public TScalar
{ /* ... */ };
The only right way I've found is to provide full implementation to CPolynome
<TScalar, 1> in order to work as the built-in type.
specialized template to be equivalent to a built-in type?
I ask this for apply it over class templates implementing mathematical
entities -as polynomes and vectors- where entities of order equal to 1 are
equivalent to scalar types. For example:
template <typename TScalar, unsigned int N>
class CPolynome
{
// ...
};
template <typename TScalar>
class CPolynome <TScalar, 1>
{
// CPolynome <TScalar, 1> is equivalent to TScalar, but ¿how is it
implemented?
};
I've tried two ways, both wrong:
template <typename TScalar> typedef TScalar CPolynome <TScalar, 1>;
template <typename TScalar> class CPolynome <TScalar, 1> : public TScalar
{ /* ... */ };
The only right way I've found is to provide full implementation to CPolynome
<TScalar, 1> in order to work as the built-in type.