using + template - how has this been resolved?

  • Thread starter Helmut Jarausch
  • Start date
H

Helmut Jarausch

Hi,

there is the following example in Vandevoorde/Josuttis
C++ Templates (7th printing) ch 9.3.4 p 134

template <typename T>
class BXT {
public:
typedef T Mystery;
template<typename U>
struct Magic;
};

template <typename T>
class DXTM : private BXT<T> {
public:
// using BXT<T>::template Magic; // fails
// Most likely this is an oversight in the standard specifications
// and future revisions will probably make the previous construct valid

// using BXT<T>::Magic; // fails
Magic<T>* plink;
};

How has this been resolved?

Many thanks for some info.

Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
 
J

Johannes Schaub (litb)

Helmut said:
Hi,

there is the following example in Vandevoorde/Josuttis
C++ Templates (7th printing) ch 9.3.4 p 134

template <typename T>
class BXT {
public:
typedef T Mystery;
template<typename U>
struct Magic;
};

template <typename T>
class DXTM : private BXT<T> {
public:
// using BXT<T>::template Magic; // fails
// Most likely this is an oversight in the standard specifications
// and future revisions will probably make the previous construct valid

// using BXT<T>::Magic; // fails
Magic<T>* plink;
};

How has this been resolved?

It has not been resolved, and probably won't be resolved. See
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#109
 
J

Johannes Schaub (litb)

Helmut said:
Hi,

there is the following example in Vandevoorde/Josuttis
C++ Templates (7th printing) ch 9.3.4 p 134

template <typename T>
class BXT {
public:
typedef T Mystery;
template<typename U>
struct Magic;
};

template <typename T>
class DXTM : private BXT<T> {
public:
// using BXT<T>::template Magic; // fails
// Most likely this is an oversight in the standard specifications
// and future revisions will probably make the previous construct valid

// using BXT<T>::Magic; // fails
Magic<T>* plink;
};

How has this been resolved?

What I've previously overlooked: I think you *can* say the following,
though. It is the name of a member template. Not the name of a member
template specialization.

using BXT<T>::Magic;

The error is at the point of use, because it does not know whether Magic
refers to a class template or not.

typename DXTM<T>::template Magic<T> *plink;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top