magpie/utils/helpers.h

18 lines
414 B
C
Raw Normal View History

//SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
//SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
#include <QVariant>
#include <stdexcept>
2024-01-20 21:17:21 +00:00
#define UNUSED(X) (void)(X)
template <class T>
const T& qast(const QVariant& variant) {
if (variant.userType() == qMetaTypeId<T>())
return *reinterpret_cast<const T*>(variant.data());
throw std::runtime_error("An usuccessfull qast");
}