Jump to content
  • Advertisement
Sign in to follow this  

[SOLVED]About STL and typedefs...

This topic is 4061 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I'm getting an compile error and I can't figure out why... I know that is something about STL... but the error don't help me much. I wonder if someone know what is that about. The error log: In instantiation of `__gnu_cxx::new_allocator<const char>': 391 instantiated from `std::_Deque_base<const char, std::allocator<const char> >' 75 `const _Tp* __gnu_cxx::new_allocator<_Tp>::address(const _Tp&) const [with _Tp = const char]' and `_Tp* __gnu_cxx::new_allocator<_Tp>::address(_Tp&) const [with _Tp = const char]' cannot be overloaded Here's the source code...
#ifndef _REGEXP_H__
#define _REGEXP_H__

#include <stack>
#include <deque>
#include <string>
#include "State.h"

using namespace std;

class RegExp
    typedef deque< State *> NFA;

        RegExp(string exp);

        void buildNFA();
        void pushToStack( const char input );
        bool popFromStack( NFA &operand);
        bool concatOP();
        bool starOP();
        bool unionOP();
        string insertConcatOP();
        void evaluateExp();

        bool leftHasHigherPrecedence( const char opLeft, const char opRight ) const;
        bool isInput(const char c) const;

        State * getNextState();
        std::vector< State * > epsilonClosure( std::vector< State * > states );


        string exp;

        stack< NFA > operandStack;
        stack< const char > operatorStack;


If I remove the typedef and use deque< State * > instead it will compile until it reaches the line stack< NFA > operandStack at the end... That made me think, is it valid to say stack< deque< State * > > ... ? Thanks in advance. [Edited by - felipedrl on October 29, 2007 7:05:16 PM]

Share this post

Link to post
Share on other sites
I've already solved it... it was a problem in the statement:

stack< const char > operatorStack;

I just put a char and the error is gone now.


Share this post

Link to post
Share on other sites
Haven't had a lot of time to think about it, but maybe this is the problem:

stack< **const** char > operatorStack;

I think the const is preventing you from creating any new entries because the value is immutable.

EDIT: Bah! Just missed my chance to shine!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!