Na tej stronie

Utils::Result Class

template <typename T = void> class Utils::Result

Typ Result<T> służy do zwracania przez funkcję wartości wskazującej na pomyślne zakończenie lub ciągu znaków opisującego błąd. Więcej...

Header: #include <Result>

Szczegółowy opis

Typedef Result jest skrótem dla ` expected<T, QString>`, gdzie w przypadku powodzenia zwracana jest oczekiwana wartość typu ` T `, a w przypadku nieoczekiwanej wartości — komunikat o błędzie dla użytkownika.

Należy używać typu ` Result<> `, gdy nie ma konkretnej wartości sukcesu do zwrócenia ( nie należy używać typu ` Result<bool>`). W takim przypadku, aby zwrócić sukces, należy zwrócić ` Utils::ResultOk `. Można również użyć funkcji pomocniczej ` Utils::makeResult `, aby połączyć przypadki sukcesu i błędu.

Zwróć wartość typu ` Utils::ResultError ` jako klasę pomocniczą dla przypadku błędu.

Zobacz także: Utils::ResultOk, Utils::ResultError oraz Utils::makeResult.

Copyright © The Qt Company Ltd. and other contributors. 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.