C++ question: nesting template classes

I’m trying to create a 2D sparse array with elements of type set<char*> (that’s the STL set class). I’ve got a template class Cell<T> (T is some type) that would be perfect for implementing this.

Both classes work fine on their own, but I can’t compose them. That is, Cell<char*> works, and set<char*> works, but Cell<set<char*>> doesn’t work. And I need Cell<Cell<set<char*>>> to work. Shouldn’t that work? Am I running up against some obscure language constraint?

This is in MS VC6. Switching over to anything other than MS.net would be impractical, cause we’re an MS shop.

Any help would be immensely appreciated.

Forgot to mention the errors I’m getting. The offending line is “Cell<Cell<set<char*>>>* m_SparseTable;”, and I’m getting the following errors:

error C2146: syntax error : missing ‘,’ before identifier ‘m_SparseTable’
error C2065: ‘m_SparseTable’ : undeclared identifier
error C2143: syntax error : missing ‘>’ before ‘;’
error C2208: ‘class Cell’ : no members defined using this type

Cell<set<char*> >
That is, you need a space between successive ‘>’ characters.

If you run them together, it becomes the >> operator, as in
cin >> input1 >> input2;

This is a known limitation of the C++ grammar. The tokenizer is confused about the > signs. Ideally, you want them to be parsed as 3 greater than tokens. However, >> is also a valid operator itself. When you have >>> without any spaces between them, by the longest match rule, they will be interpreted as one “right shift” and one “greater than” instead of 3 greater than.

Solution 1: Insert spaces. For example,

Cell< set<char *> > tbl;

Solution 2: Use typedef.

typedef set<char *> char_set_t;
typedef Cell<char_set_t> char_cell_t;

char_cell_t tbl;

The spaces are easier on me, so that’s what I’ll do. Thanks a bunch.