On 11 nov. 2013, at 13:50, Giuseppe D'Angelo <giuseppe.dang...@kdab.com> wrote:

> Il 11/11/2013 13:37, Samuel Gaist ha scritto:
>> Hi,
>> 
>> I have been experiencing a strange behavior with QStringList and the order 
>> of execution of takeFirst.
>> 
>> The following code:
>> 
>> QString line = file.readLine();  // line contains "46 71\n"
>> QStringList lineData = line.split(); // lineData contains ("46", "71\n")
>> qDebug() << lineData.takeFirst() << lineData.takeFirst();
> 
> I've already explained this in the past but I can't find the relevant email. 
> This last line is parsed as
> 
>> operator<<( operator<<( qDebug(), lineData.takeFirst() ) , 
>> lineData.takeFirst() )
> 
> (operator<< is left associative).
> 
> Take the outer operator<<. C++ does not define the order of evaluating its 
> parameters. That means that either lineData.takeFirst() can be called before 
> evaluating the inner operator<<, or vice-versa. Depending on what the 
> compiler chooses to do, you'll have a different result.
> 

Ok, with that and the explanation of Thiago, it's crystal clear. Thanks !

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to