Solved

Template in template

Posted on 2002-04-08
3
260 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now