By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,421 Members | 1,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,421 IT Pros & Developers. It's quick & easy.

Defining iterators

P: n/a
I upgraded to gcc 3.4 and ran into the problem below. I don't understand
it and need to fix this quickly. Any resolutions in changing to code
will be appreciated. I will research this later this week as time allows
but a quick resolution with code example will help a great deal.

Thanks

-------------

crt/crtmap.hpp:17: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:17: error: ISO C++ forbids declaration of `iterator' with
no type

crt/crtmap.hpp:17: error: expected `;' before "iterator"

crt/crtmap.hpp:18: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:18: error: ISO C++ forbids declaration of
`const_iterator' with no type

crt/crtmap.hpp:18: error: expected `;' before "const_iterator"

------

template <class K,class D,class C>
class CRTMap
{

private:
mutable std::map<K,D,C> mymap;
mutable CRTMLock MLock;

public:
typedef std::map<K,D,C>::iterator iterator; // line 17
typedef std::map<K,D,C>::const_iterator const_iterator; // line 18
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Deke wrote:

I upgraded to gcc 3.4 and ran into the problem below. I don't understand
it and need to fix this quickly. Any resolutions in changing to code
will be appreciated. I will research this later this week as time allows
but a quick resolution with code example will help a great deal.

Thanks

-------------

crt/crtmap.hpp:17: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:17: error: ISO C++ forbids declaration of `iterator' with
no type

crt/crtmap.hpp:17: error: expected `;' before "iterator"

crt/crtmap.hpp:18: error: type `std::map<K, D, C,
std::allocator<std::pair<const _Key, _Tp> > >
' is not derived from type `CRTMap<K, D, C>'

crt/crtmap.hpp:18: error: ISO C++ forbids declaration of
`const_iterator' with no type

crt/crtmap.hpp:18: error: expected `;' before "const_iterator"

------

template <class K,class D,class C>
class CRTMap
{

private:
mutable std::map<K,D,C> mymap;
mutable CRTMLock MLock;

public:
typedef std::map<K,D,C>::iterator iterator; // line 17
typedef std::map<K,D,C>::const_iterator const_iterator; // line 18

It's become quite a FAQ that is not yet in The FAQ.

Must use typename with dependent type names:
typedef typename std::map<K,D,C>::iterator iterator; // line 17
typedef typename std::map<K,D,C>::const_iterator const_iterator; // line 18

(the older compiler versions were slacking on the standard)

Denis
Jul 22 '05 #2

P: n/a
"Denis Remezov" <RE*********************@yahoo.removethis.ca> wrote in
message news:40***************@yahoo.removethis.ca...
It's become quite a FAQ that is not yet in The FAQ.

Must use typename with dependent type names:
typedef typename std::map<K,D,C>::iterator iterator; // line 17 typedef typename std::map<K,D,C>::const_iterator const_iterator; // line 18
(the older compiler versions were slacking on the standard)


The standard *did* change underfoot, you know.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.