enum names inside a templated class

H

Hicham Mouline

hi,

template <int T>
struct C {
typedef typename Traits<T>::E1 E1;
....
static void f();
};

template<>
void C<t1>::f()
{
// E1 is an enum { x1, x2... } in this case
// I wanted to use x1 x2 ... without scoping
// 1. unqualified x1 fails
// 2. E1::x1 is a non standard extension of msvc
// C<t1>::x1 is too verbose
}

is there a simpler way?

regards,
 
H

Hicham Mouline

Hicham Mouline said:
hi,

template <int T>
struct C {
typedef typename Traits<T>::E1 E1;
...
static void f();
};

template<>
void C<t1>::f()
{
// E1 is an enum { x1, x2... } in this case
// I wanted to use x1 x2 ... without scoping
// 1. unqualified x1 fails
// 2. E1::x1 is a non standard extension of msvc
// C<t1>::x1 is too verbose
}

is there a simpler way?

regards,

effectively, I have 12 x enum names. Repeating C<t1>::x1 ... C<t1>::x12
very tedious

Can I use the "using" keyword?

rds,
 
V

Victor Bazarov

Hicham said:
effectively, I have 12 x enum names. Repeating C<t1>::x1 ... C<t1>::x12
very tedious

Can I use the "using" keyword?

What's stopping you from trying?

V
 
J

James Kanze

I'm not sure of the context. With C, C::x12 should be
sufficient. And IIRC an explicit instantiation is considered
"inside" C.

Otherwise... Since you don't seem to mind E1::x1, a typedef for
What's stopping you from trying?

But he'd still have to have 12 using, one for each enum value.
The basic problem is that the enum values are dependent names,
and he needs some simple way of making the compiler realize
this.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top