QScopedValueRollback Class

template <typename T> class QScopedValueRollback

QScopedValueRollback 클래스는 소멸 시 변수를 이전 값으로 초기화합니다. 더 보기...

Header: #include <QScopedValueRollback>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

공용 함수

상세 설명

QScopedValueRollback 클래스는 try-catch 블록을 작성할 필요 없이 예외가 발생했을 때 상태를 되돌릴 때 사용할 수 있습니다.

또한 재진입 가드와 같이 일시적으로 설정된 변수를 관리하는 데에도 사용할 수 있습니다. 이 클래스를 사용하면 함수가 정상적으로 종료되든, 반환 문에 의해 조기 종료되든, 예외에 의해 종료되든 변수가 재설정됩니다.

템플릿은 할당을 지원하는 유형으로만 인스턴스화할 수 있습니다.

QScopedPointerQScopeGuard참조하세요 .

멤버 함수 문서

[explicit constexpr] QScopedValueRollback::QScopedValueRollback(T &var)

파괴 시 되돌리기 위해 내부에 var 의 이전 값을 저장합니다.

[explicit constexpr] QScopedValueRollback::QScopedValueRollback(T &var, T value)

value 을 변수에 할당하고 파괴 시 되돌리기 위해 내부적으로 이전 값인 var 을 저장합니다.

[constexpr] QScopedValueRollback::~QScopedValueRollback()

관리 변수에 이전 값을 할당합니다. 생성 시점의 값 또는 commit()에 대한 마지막 호출 시점의 값입니다.

[constexpr] void QScopedValueRollback::commit()

관리 변수의 이전 값을 현재 값으로 업데이트합니다.

© 2025 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.