87 lines
3.1 KiB
C++
87 lines
3.1 KiB
C++
/************************************************************************
|
|
**
|
|
** @file qoverload.h
|
|
** @author Roman Telezhynskyi <dismine(at)gmail.com>
|
|
** @date 12 1, 2018
|
|
**
|
|
** @brief
|
|
** @copyright
|
|
** This source code is part of the Valentina project, a pattern making
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
** Copyright (C) 2018 Valentina project
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
|
**
|
|
** Valentina is free software: you can redistribute it and/or modify
|
|
** it under the terms of the GNU General Public License as published by
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
** (at your option) any later version.
|
|
**
|
|
** Valentina is distributed in the hope that it will be useful,
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
** GNU General Public License for more details.
|
|
**
|
|
** You should have received a copy of the GNU General Public License
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
**
|
|
*************************************************************************/
|
|
#ifndef QOVERLOAD_H
|
|
#define QOVERLOAD_H
|
|
|
|
#include <QtGlobal>
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
|
#if defined(Q_COMPILER_VARIADIC_TEMPLATES)
|
|
|
|
template <typename... Args>
|
|
struct QNonConstOverload
|
|
{
|
|
template <typename R, typename T>
|
|
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
|
|
{ return ptr; }
|
|
|
|
template <typename R, typename T>
|
|
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
|
|
{ return ptr; }
|
|
};
|
|
|
|
template <typename... Args>
|
|
struct QConstOverload
|
|
{
|
|
template <typename R, typename T>
|
|
Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr)
|
|
{ return ptr; }
|
|
|
|
template <typename R, typename T>
|
|
static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr)
|
|
{ return ptr; }
|
|
};
|
|
|
|
template <typename... Args>
|
|
struct QOverload : QConstOverload<Args...>, QNonConstOverload<Args...>
|
|
{
|
|
using QConstOverload<Args...>::of;
|
|
using QConstOverload<Args...>::operator();
|
|
using QNonConstOverload<Args...>::of;
|
|
using QNonConstOverload<Args...>::operator();
|
|
|
|
template <typename R>
|
|
Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr)
|
|
{ return ptr; }
|
|
|
|
template <typename R>
|
|
static Q_DECL_CONSTEXPR auto of(R (*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr)
|
|
{ return ptr; }
|
|
};
|
|
|
|
#if defined(__cpp_variable_templates) && __cpp_variable_templates >= 201304 // C++14
|
|
template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QOverload<Args...> qOverload = {};
|
|
template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QConstOverload<Args...> qConstOverload = {};
|
|
template <typename... Args> Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload<Args...> qNonConstOverload = {};
|
|
#endif
|
|
|
|
#endif // Q_COMPILER_VARIADIC_TEMPLATES
|
|
#endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0)
|
|
|
|
#endif // QOVERLOAD_H
|