El Dissabte, 1 de juny de 2013, a les 11:13:14, Lindsay Mathieson va escriure: > I'm a bit puzzled by this line from nepomuk feeder (itemqueue.cpp:152): > > const Akonadi::Item &item = mFetchedItemList.takeFirst(); > > takeFirst() returns a Akonadi::Item and removes it from its list. The > returned item is being assigned to a constant *reference*. > > But won't the returned item be immediately destroyed rendering the > reference invalid?
No, because as you well said the function is returning a Akonadi::Item, not a Akonadi::Item reference, so what this is doing is holding a constant reference t a temporary value (that will get destroyed as soon as the function/scope ends) not to the value from the list. So in this case const Akonadi::Item &item = mFetchedItemList.takeFirst(); and const Akonadi::Item item = mFetchedItemList.takeFirst(); are basically the same. Cheers, Albert >> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<