/************************************************************************ ** ** @file qoverload.h ** @author Roman Telezhynskyi ** @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 ** 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 . ** *************************************************************************/ #ifndef QOVERLOAD_H #define QOVERLOAD_H #include #if QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #if defined(Q_COMPILER_VARIADIC_TEMPLATES) template struct QNonConstOverload { template Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) { return ptr; } template static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...)) Q_DECL_NOTHROW -> decltype(ptr) { return ptr; } }; template struct QConstOverload { template Q_DECL_CONSTEXPR auto operator()(R (T::*ptr)(Args...) const) const Q_DECL_NOTHROW -> decltype(ptr) { return ptr; } template static Q_DECL_CONSTEXPR auto of(R (T::*ptr)(Args...) const) Q_DECL_NOTHROW -> decltype(ptr) { return ptr; } }; template struct QOverload : QConstOverload, QNonConstOverload { using QConstOverload::of; using QConstOverload::operator(); using QNonConstOverload::of; using QNonConstOverload::operator(); template Q_DECL_CONSTEXPR auto operator()(R (*ptr)(Args...)) const Q_DECL_NOTHROW -> decltype(ptr) { return ptr; } template 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 Q_CONSTEXPR Q_DECL_UNUSED QOverload qOverload = {}; template Q_CONSTEXPR Q_DECL_UNUSED QConstOverload qConstOverload = {}; template Q_CONSTEXPR Q_DECL_UNUSED QNonConstOverload qNonConstOverload = {}; #endif #endif // Q_COMPILER_VARIADIC_TEMPLATES #endif // QT_VERSION < QT_VERSION_CHECK(5, 7, 0) #endif // QOVERLOAD_H