chinmoyr added a comment.
Actually, I like this construct quite a bit. if (!dir.rmdir(itemPath)) { if (auto ret = execWithElevatedPrivilege(RMDIR, itemPath)) { if (!ret.wasCanceled()) { error(KIO::ERR_CANNOT_DELETE, itemPath); } return false; } } But for this to work the class should be something like this class ExecWithElevatedPrivilegeReturnValue { public: static ExecWithElevatedPrivilegeReturnValue success() { return ExecWithElevatedPrivilegeReturnValue{false, false}; } static ExecWithElevatedPrivilegeReturnValue failure() { return ExecWithElevatedPrivilegeReturnValue{true, false}; } static ExecWithElevatedPrivilegeReturnValue canceled() { return ExecWithElevatedPrivilegeReturnValue{true, true}; } operator bool() const { return m_failed; } bool wasCanceled() const { return m_canceled; } private: ExecWithElevatedPrivilegeReturnValue(bool failed, bool canceled) : m_failed(failed), m_canceled(canceled) {} const bool m_failed; const bool m_canceled; }; am I correct? REVISION DETAIL https://phabricator.kde.org/D6829 To: chinmoyr, dfaure, #frameworks Cc: #frameworks