 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Matthew Guest
|
Posted: Thu Apr 29, 2004 11:47 am Post subject: template error in gcc, not in MSVC7.1 |
|
|
Hi all,
I have run into a problem. I have a project that compiles under MSVC
7.1 but not on gcc 3.1.
I have an abstract base class called Stack which takes a template
parameter to the stack type. It provides iterators and normal stack
functionality.
I want to maintain multiple stacks (with different template types)
within the program. To manage them, I wanted to use a Stack-derived
stack. So I created a StackStack class which is explicitly designed to
hold stack pointers (boost shared_ptrs of stacks, actually).
The code compiles and runs under MSVC 7.1 (.NET 2003), but fails under
gcc. Can you help explain why and what I should do to fix it?
The error I get is:
/ISR_Project/StackBase/StackStack.h:11: error: syntax error before `>' token
Thanks for your help,
Matt.
//////////////////////////
namespace ISR {
template<typename StackType>
class Stack {
public:
typedef typename std::vector<StackType>::iterator iterator;
typedef typename std::vector<StackType>::const_iterator const_iterator;
Stack();
Stack(const std::string& ID) {m_ID = ID;}
virtual ~Stack() {};
.....
};
}
////////////////////////////
#include "Stack.h"
//boost
#include "smart_ptr.hpp"
namespace ISR {
typedef boost::shared_ptr< Stack stackPtr;
class StackStack : public Stack<stackPtr> {
public:
StackStack(const std::string& ID) : Stack<stackPtr>(ID) {};
virtual ~StackStack();
.....
};
}
//////////////
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Bronek Kozicki Guest
|
Posted: Fri Apr 30, 2004 11:22 am Post subject: Re: template error in gcc, not in MSVC7.1 |
|
|
On 29 Apr 2004 07:47:13 -0400, Matthew wrote:
| Quote: | 7.1 but not on gcc 3.1.
typedef boost::shared_ptr< Stack stackPtr;
|
What is did you mean in above line? It's not valid C++. Here is what
Comeau compiler in strict mode is saying about it:
"T306.cpp", line 28: error #761-D: typename may only be used within a template
typedef boost::shared_ptr< Stack stackPtr;
^
"T306.cpp", line 28: error #40: expected an identifier
typedef boost::shared_ptr< Stack stackPtr;
^
B.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
news Guest
|
Posted: Fri Apr 30, 2004 11:25 am Post subject: Re: template error in gcc, not in MSVC7.1 |
|
|
Matthew <mje (AT) mpeavy (DOT) com> writes:
| Quote: | /ISR_Project/StackBase/StackStack.h:11: error: syntax error before `>' token
|
I don't know what file StackStack.h looks like and, in particular, what its
line 11 is, but
| Quote: | typedef boost::shared_ptr< Stack stackPtr;
|
what is this line supposed to mean?
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|