RE: Avoid typename repetition in template specialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Frank,

> If there would be a way to undefine a typename in the actual namespace this would help a lot in this case.

It would help if there was an "undefine", or at least a way to scope them that would work in this situation.  But there is not, as far as I am aware.

> Is there functionality for this or is there a workaround for my case that occurs to you?

#define T1 PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns >
// use T1
#undef T1

But I strongly dislike the preprocessor, since I much prefer programming in C++ rather than "programming in preprocessor macro magic".

I would use this approach:
typedef PScalar< PColorMatrix< RComplex<REAL64>, Nc> > TScalarMatrix;
typedef PSpinVector< PColorVector< RComplex<REAL64>, Nc>, Ns > TSpinVector;
template<>
inline BinaryReturn< TScalarMatrix , TSpinVector , OpMultiply >::Type_t
operator+(const T1& l, const T2& r )
{
   BinaryReturn< TScalarMatrix , TSpinVector , OpMultiply >::Type_t d;
    // code
   return d;
}

Although TScalarMatrix is probably more semantic detail (and longer to type) than you'd prefer over T1, it avoids the naming collision.

Sincerely,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux