typedef'd return type for a template class member function

D

david.corby

Hi again everyone!

I was wondering if there is any way to specify a return type for a
template class member function that is typedef'd in the class. I.E...

template <class T> class A {

public:

typedef int TD;

private:

TD b ();

};

template <class T> A<T>::TD b () {

// Do stuff.

}

I know this won't compile, but hopefully you can see what I'm trying to
do. The type TD will only be used in-class. I know I can stick the
typedef outside of the class, but I'd like to not pollute that
namespace.

Is there any way to make this work? I'm fairly certain I've done it on
non-templated classes.

Thanks!
Dave Corby
 
V

Victor Bazarov

I was wondering if there is any way to specify a return type for a
template class member function that is typedef'd in the class. I.E...

template <class T> class A {

public:

typedef int TD;

private:

TD b ();

};

template <class T> A<T>::TD b () {

template said:
// Do stuff.

}

I know this won't compile, but hopefully you can see what I'm trying to
do. The type TD will only be used in-class. I know I can stick the
typedef outside of the class, but I'd like to not pollute that
namespace.

Is there any way to make this work? I'm fairly certain I've done it on
non-templated classes.

'b'a is a member, you need to qualify the name.

V
 
D

david.corby

Oops... yes, of course, my definition was:

template <class T> A<T>::TD A<T>::b () {

// Do stuff.
}

My mistake, but I didn't make it in the case I'm asking about.
 
V

Victor Bazarov

Oops... yes, of course, my definition was:

template <class T> A<T>::TD A<T>::b () {

// Do stuff.
}

My mistake, but I didn't make it in the case I'm asking about.

Now, it's a good time to correct your mistake and post the real code
that doesn't work.

V
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top