public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* RE: error: 'cit' was not declared in this scope
@ 2009-12-29 19:49 Gerry Sweeney
  2009-12-29 20:45 ` John S. Fine
  0 siblings, 1 reply; 8+ messages in thread
From: Gerry Sweeney @ 2009-12-29 19:49 UTC (permalink / raw)
  To: gcc-help

Hi,

I am trying to port some code from VC9 to Linux using "gcc (Ubuntu 
4.4.1-4ubuntu8) 4.4.1" and I am getting an error with GCC that I don't get 
when compiling under VC9.

test.cpp: In member function 'const Value& enums_map<Key, 
Value>::operator[](const Key&) const':
test.cpp:30: error: expected ';' before 'cit'
test.cpp:31: error: 'cit' was not declared in this scope

The problem is I need to create a local variable of type <the base 
class>::const_iterator but I cant work out how I can do this. As I 
mentioned, the code below works when compiling under VC9 but not with g++. I 
can't work out how to solve this problem, could anyone help? This is the 
code sample (just compiling with "g++ test.cpp"

---------------------------------<snip>-------------------------------------
#include <stdio.h>
#include <string>
#include <iostream>
#include <tr1/regex>
#include <inttypes.h>
#include <stdarg.h>

#include <map>


// Just the std::map, plus a const version of operator[] which returns a 
const reference to a const member template<typename Key, typename Value> 
class enums_map : public std::map<Key, Value> {
        typedef std::map<Key, Value> base_type;

public:
        enums_map()
                : default_value_()
        {
        }

        enums_map(const Value& default_value)
                : default_value_(default_value)
        {
        }

        const Value& operator[] (const Key& key) const
        {
                base_type::const_iterator cit = base_type::find(key);
                if (cit == base_type::end())
                        return default_value_;
                else
                        return cit->second;
        }

        using base_type::operator[];

private:
        const Value default_value_;
};
---------------------------------<snip>-------------------------------------

Any help very much appreciated

Thanks,

Gerry



^ permalink raw reply	[flat|nested] 8+ messages in thread
[parent not found: <E2A1DD3AE3471D42B24E218A48E0D89D0187585B@exch2.internal.hornbill.com>]

end of thread, other threads:[~2010-01-06 15:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-29 19:49 error: 'cit' was not declared in this scope Gerry Sweeney
2009-12-29 20:45 ` John S. Fine
2009-12-30  3:49   ` Gerry Sweeney
2009-12-30 13:51     ` Andrew Haley
2009-12-30 23:59       ` John S. Fine
2010-01-06 15:35         ` Ian Lance Taylor
     [not found] <E2A1DD3AE3471D42B24E218A48E0D89D0187585B@exch2.internal.hornbill.com>
2009-12-29 17:30 ` Gerry Sweeney
2009-12-29 18:11   ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).