// Copyright (C) 2018 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #pragma once namespace Timeline { template class SafeCastable { public: template bool is() const { return static_cast(this)->classId() == Derived::staticClassId; } template Derived &asRef() { Q_ASSERT(is()); return static_cast(*this); } template const Derived &asConstRef() const { Q_ASSERT(is()); return static_cast(*this); } template Derived &&asRvalueRef() { Q_ASSERT(is()); return static_cast(*this); } }; } // namespace Timeline