QtTaskTree::ForeverIterator Class
class QtTaskTree::ForeverIteratorFor要素内で使用する無限イテレータ。詳細...
| ヘッダー: | #include <qtasktree.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS TaskTree) target_link_libraries(mytarget PRIVATE Qt6::TaskTree) |
| qmake: | QT += tasktree |
| 以下のように: | Qt 6.11 |
| 継承元: | QtTaskTree::Iterator |
| ステータス: | テクノロジープレビュー |
このクラスはテクノロジープレビュー段階にあり、変更される可能性があります。
注:このクラスのすべての関数は再入可能です。
パブリック関数
関連項目:Iterator 、RepeatIterator 、UntilIterator 、およびListIteratorも参照してください 。
メンバー関数のドキュメント
ForeverIterator::ForeverIterator()
「For (ForeverIterator()) >> Do {}」という構文に対して、終わりのないイテレータを生成します。
注: Do本体で並列モードが指定されている場合は、細心の注意を払ってください 。この場合、QTaskTree は無限個のタスクをインスタンス化してしまう可能性があります。
使用例:
static const intmaxNumber= 10;
const intluckyNumber=QRandomGenerator().global()->bounded(maxNumber);
qDebug() << "Today's lucky number is:" << luckyNumber;
qDebug() << "Let's start the drawing...";
const autoonNumberCheck= [luckyNumber]{
const intdrawnNumber=QRandomGenerator().global()->bounded(maxNumber);
qDebug() << "You have drawn:" << drawnNumber;
boolwon=drawnNumber==luckyNumber;
if(won)
qDebug() << "You have won! Congratulations!";
returnwon;
};
constGroup recipe=For (ForeverIterator())>>Do {
stopOnSuccess,
timeoutTask(1s),
QSyncTask(onNumberCheck)
};QTaskTree によってrecipe が起動された際の、考えられる出力は以下の通りです:
Today's lucky number is: 8
Let's start the drawing...
You have drawn: 2
You have drawn: 2
You have drawn: 6
You have drawn: 7
You have drawn: 9
You have drawn: 8
You have won! Congratulations!© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.