magpie/API/helpers.h

16 lines
385 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>
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");
}