Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
src_corelib_tools_qscopeguard.cpp
Go to the documentation of this file.
1// Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Sérgio Martins <sergio.martins@kdab.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QScopeGuard>
5
7
8//! [0]
10{
11 // The lambda will be executed right before your function returns
12 auto cleanup = qScopeGuard([] { /* code you want executed goes HERE; */ });
13
14 if (v == -1)
15 return;
16
18
19 if (v2 == -1)
20 return;
21
22 //...
23}
24//! [0]
int code_that_might_throw_exceptions()
void myComplexCodeWithMultipleReturnPoints(int v)
[0]