[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

typedef for a template class with a template class as param

Posted on 2004-09-01
4
Medium Priority
?
216 Views
Last Modified: 2010-04-01
Good Morning,

I would like to know if there is a way that I can create a typedef for a template class that has another template in it with a variable type parameter.

for example

template<class T> class Outer{...};
template<class T> class Inner{...};

typedef Outer< Inner<class T> > NewClass;

NewClass<int> getClass() {
}

I have tried this with GCC and it tells me the "NewClass" type is not a template, therefore I cannot pass a parameter to it.

I do not want to use the proprocessor.

Thank you,
- Dave
0
Comment
Question by:illusioned
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 1000 total points
ID: 11952644
You can't - see e.g. http://www.gotw.ca/gotw/079.htm ("Template Typedef") - the key sentence is "the code in question above isn't legal for a simple reason: Today's C++ doesn't support template typedefs.". The article also offers an alternative solution.
0
 
LVL 4

Expert Comment

by:havman56
ID: 11952847

This works fine on MSC

template<class T>
class Outer{

      public:
      void getClass();
      
};

template<class T>
class Inner{
      };


template <class T>
void Outer<T>:: getClass()
{


}


main()
{
      typedef Outer< Inner <int> > NewClass;

      NewClass  obj;
      obj.getClass();

}
0
 

Author Comment

by:illusioned
ID: 11953289
Thanks JKR.  

From other things that I have read this may be appearing in standard C++ in the future.  In light of this, I may end up using the preprocessor just so that I won't have to change my code when it is supported by GCC (it may even be now, but I am going to stick with GCC 3.2.3).


Thank you for the help.
- Dave
0
 
LVL 86

Expert Comment

by:jkr
ID: 11959253
You're most welcome :o)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question