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

is implicitly a typename warning

P: n/a

Hi,
I love short syntax, so I use macros like
FORi(10) t[i]=a[b[i]*i];
(where FORi expands into standard for loop)
and so on.

Yes I know its a bit evil but when later #undef such macros I think they can
be quite usefull and not making any "bad" in rest of code.

Such macro especially would be usefull in iterators, like

for( vector< shared_ptr< map<int,string> > > :: interator it =
tab.begin() ...

Typing the type of vector/container through with we want to iterate each
time is not very comfortable, also making a typedef for each containter
type is not always good.

Therefore I written small macro FORiter(tab) that iterates through an
conatiner providing iterator "ir"
FORiter( tab ) { *it=777; delete *it; }
(yes, I know aobut the foreach function but I dont find it comfortable in
some situations).

--------
The code:

#define FORiter(TAB) for( typeof(TAB.mTyp_Iterator) it = tab.begin();
it!=tab.end(); ++it)

and to have it working I added mTyp_Iterator to my std::vector<> wrapper,

template <class typ>
class cVector : public std::vector<typ> {
public:
static std::vector<typ>::iterator mTyp_Iterator; // XXX
[...]

It works fine in both g++ 3.3 and 3.4, but it gives warnings:

raf256_vector.h:11: warning: `std::vector<typ, std::allocator<_CharT>
::iterator' is implicitly a typename

raf256_vector.h:11: warning: implicit typename is deprecated, please see the
documentation for details

-----
The problem

How can I do code above the c++ and/or gnu g++ way - using some "typename"
afaik?

--
Rafał Maj
Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Raf256 wrote:
#define FORiter(TAB) for( typeof(TAB.mTyp_Iterator) it = tab.begin();
it!=tab.end(); ++it)


errata:

#define FORiter(TAB) for( typeof(TAB.mTyp_Iterator) it = TAB.begin();
it!=TAB.end(); ++it)

--
Rafał Maj
Jul 23 '05 #2

P: n/a
Raf256 wrote:
I love short syntax, so I use macros like
FORi(10) t[i]=a[b[i]*i];
(where FORi expands into standard for loop)
and so on.

Yes I know its a bit evil but when later #undef such macros I think they can
be quite usefull and not making any "bad" in rest of code.

Such macro especially would be usefull in iterators, like

for( vector< shared_ptr< map<int,string> > > :: interator it =
tab.begin() ...

Typing the type of vector/container through with we want to iterate each
time is not very comfortable, also making a typedef for each containter
type is not always good.

Therefore I written small macro FORiter(tab) that iterates through an
conatiner providing iterator "ir"
FORiter( tab ) { *it=777; delete *it; }
(yes, I know aobut the foreach function but I dont find it comfortable in
some situations).

--------
The code:

#define FORiter(TAB) for( typeof(TAB.mTyp_Iterator) it = tab.begin();
it!=tab.end(); ++it)

and to have it working I added mTyp_Iterator to my std::vector<> wrapper,

template <class typ>
class cVector : public std::vector<typ> {
public:
static std::vector<typ>::iterator mTyp_Iterator; // XXX
[...]

It works fine in both g++ 3.3 and 3.4, but it gives warnings:

raf256_vector.h:11: warning: `std::vector<typ, std::allocator<_CharT>
>::iterator' is implicitly a typename

raf256_vector.h:11: warning: implicit typename is deprecated, please see the
documentation for details

-----
The problem

How can I do code above the c++ and/or gnu g++ way - using some "typename"
afaik?


Why do you care? You're using 'typeof', which is non-standard anyway...
Never mind. Change the XXX line to read

static typename std::vector<typ>::iterator mTyp_Iterator;

V
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.