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

Compiler warning regarding type definition

P: n/a
DFP
I am posting the gcc 3.3.2 compiler error and the source lines below
them. Please explain this warning and how to fix it.

crt/crtmap.hpp:17: warning: `std::map<K, D, C,
std::allocator<std::pair<const
_Key, _Tp> > >::iterator' is implicitly a typename
crt/crtmap.hpp:17: warning: implicit typename is deprecated, please see the
documentation for details
crt/crtmap.hpp:18: warning: `std::map<K, D, C,
std::allocator<std::pair<const
_Key, _Tp> > >::const_iterator' is implicitly a typename
crt/crtmap.hpp:18: warning: implicit typename is deprecated, please see the
documentation for details

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

Here is the offending code:

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

inline CRTMap(void)
{
}

[...]

Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On Sat, 03 Apr 2004 22:24:08 -0500, DFP <DF*@nospam.net> wrote:
I am posting the gcc 3.3.2 compiler error and the source lines below
them. Please explain this warning and how to fix it.
Isn't this in the FAQ yet? :-)

crt/crtmap.hpp:17: warning: `std::map<K, D, C,
std::allocator<std::pair<const
_Key, _Tp> > >::iterator' is implicitly a typename
crt/crtmap.hpp:17: warning: implicit typename is deprecated, please see the
documentation for details
crt/crtmap.hpp:18: warning: `std::map<K, D, C,
std::allocator<std::pair<const
_Key, _Tp> > >::const_iterator' is implicitly a typename
crt/crtmap.hpp:18: warning: implicit typename is deprecated, please see the
documentation for details

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

Here is the offending code:

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 typename std::map<K,D,C>::iterator iterator;
typedef std::map<K,D,C>::const_iterator const_iterator; //// Line 18

typedef typename std::map<K,D,C>::const_iterator const_iterator;

ISO C++ requires type names (as opposed to other kinds of names) dependent
upon a template parameter to be qualified with the keyword "typename". Some
compilers make do without the 'typename', although the code is not
compliant without it.
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #2

P: n/a
On Sat, 03 Apr 2004 22:24:08 -0500, DFP <DF*@nospam.net> wrote:
I am posting the gcc 3.3.2 compiler error and the source lines below
them. Please explain this warning and how to fix it.
Isn't this in the FAQ yet? :-)

crt/crtmap.hpp:17: warning: `std::map<K, D, C,
std::allocator<std::pair<const
_Key, _Tp> > >::iterator' is implicitly a typename
crt/crtmap.hpp:17: warning: implicit typename is deprecated, please see the
documentation for details
crt/crtmap.hpp:18: warning: `std::map<K, D, C,
std::allocator<std::pair<const
_Key, _Tp> > >::const_iterator' is implicitly a typename
crt/crtmap.hpp:18: warning: implicit typename is deprecated, please see the
documentation for details

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

Here is the offending code:

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 typename std::map<K,D,C>::iterator iterator;
typedef std::map<K,D,C>::const_iterator const_iterator; //// Line 18

typedef typename std::map<K,D,C>::const_iterator const_iterator;

ISO C++ requires type names (as opposed to other kinds of names) dependent
upon a template parameter to be qualified with the keyword "typename". Some
compilers make do without the 'typename', although the code is not
compliant without it.
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
Jul 22 '05 #3

P: n/a
DFP wrote:
typedef std::map<K,D,C>::iterator iterator; //// Line 17
typedef std::map<K,D,C>::const_iterator const_iterator; //// Line 18


"//" is sufficient to mark a comment in C++.

typedef typename std::map<K,D,C>::iterator iterator;
typedef typename std::map<K,D,C>::const_iterator const_iterator;

The rule is that std::map<K,D,C>::iterator is assumed to be the name of
an object unless you say that it's the name of a type.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #4

P: n/a
DFP wrote:
typedef std::map<K,D,C>::iterator iterator; //// Line 17
typedef std::map<K,D,C>::const_iterator const_iterator; //// Line 18


"//" is sufficient to mark a comment in C++.

typedef typename std::map<K,D,C>::iterator iterator;
typedef typename std::map<K,D,C>::const_iterator const_iterator;

The rule is that std::map<K,D,C>::iterator is assumed to be the name of
an object unless you say that it's the name of a type.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.