[Qt-interest] foreach and two template arguments
Schimkowitsch Robert
Robert.Schimkowitsch at andritz.com
Mon Aug 22 11:19:12 CEST 2011
Thanks.
I must have made some syntactical error, which did not allow me to make
the typedef.
Kind regards
Robert Schimkowitsch
-----Original Message-----
From: qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.com
[mailto:qt-interest-bounces+robert.schimkowitsch=andritz.com at qt.nokia.co
m] On Behalf Of Thiago Macieira
Sent: Monday, August 22, 2011 10:21 AM
To: qt-interest at qt.nokia.com
Subject: Re: [Qt-interest] foreach and two template arguments
On Monday, 22 de August de 2011 09:52:25 Schimkowitsch Robert wrote:
> Just out of curiosity (I have bypassed my actual problem using a
> Java-style iterator), is there ANY way I could write the following
const
> foreach-loop:
Yes.
> Q_FOREACH(const CGlib_GridData<valueT, deltaT>& gridData, m_GridData)
typedef CGlib_GridData<valueT, deltaT> Item;
Q_FOREACH(const Item &gridDate, m_gridData)
> -) I did not manage to create a typedef, because I do not yet have
> concrete types I could set as template arguments
Looks like you do. You pasted them above: valueT and deltaT.
> -) Declaring the loop variable before the Q_FOREACH is not allowed
> -) The preprocessor interprets the commas in the Q_FOREACH macro, so I
> get a syntax error the way it's written right now.
There are two other solutions:
1) #define comma ,
2) forgo Q_FOREACH and use the iterators directly. This produces
slightly more
efficient code.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
#####################################################################################
This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.
Thank You.
#####################################################################################
More information about the Qt-interest-old
mailing list