Solved

Template in template

Posted on 2002-04-08
3
267 Views
Last Modified: 2010-04-02
Hi, I've run into a Visual C++ 6.0 compiler problem, that I'm not able to workaround anymore.

Using STL, an example of the problem is having a vector of lists:

std::vector<std::list<int>>

That's too much for the compiler. My easy workaround was to do a typedef std::list<int> IntList, and then compile:

std::vector<IntList>

However, I'm now making my code more general using templates. So the int in the example has turned into SomeType:

template<class SomeType>
[...]
std::vector<std::list<SomeType>>

and now my typedef trick doesn't work anymore...

How do I solve this problem? Or who knows a workaround that honors the generalization purpose (obviously I don't want to make implementations for each of the SomeType types)?

TIA
0
Comment
Question by:vendrig
[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
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 150 total points
ID: 6925583
Make it read

std::vector<std::list<int>

Note the blank. The compiler misinterprets that as the ">>" operator.
0
 
LVL 86

Expert Comment

by:jkr
ID: 6925592
BTW - this behaviour is called the "Max Munch" principle, see also http://www.gotw.ca/gotw/078.htm ("Who Is Max Munch, and What's He Doing In My C++ Compiler?"), where your problem  is described in detail...
0
 
LVL 2

Author Comment

by:vendrig
ID: 6925626
Thank you for your quick response:-)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

734 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