Browse Source

remove c++17 requirements

pull/2/head
Skycoder42 7 years ago
parent
commit
00a0524bad
  1. 18
      src/mvvmcore/qtmvvmcore_helpertypes.h

18
src/mvvmcore/qtmvvmcore_helpertypes.h

@ -12,14 +12,6 @@
namespace QtMvvm { namespace QtMvvm {
namespace __helpertypes { namespace __helpertypes {
#if __cplusplus >= 201703L
template<typename... T>
using conjunction = std::conjunction<T...>;
#else
template<typename... T>
using conjunction = std::__and_<T...>;
#endif
static const QByteArray InjectablePrefix = QByteArrayLiteral("de.skycoder42.qtmvvm.injectable."); static const QByteArray InjectablePrefix = QByteArrayLiteral("de.skycoder42.qtmvvm.injectable.");
template <typename T> template <typename T>
@ -29,7 +21,7 @@ template <typename T>
struct is_qobj_ptr : public is_qobj<std::remove_pointer_t<T>> {}; struct is_qobj_ptr : public is_qobj<std::remove_pointer_t<T>> {};
template <typename TInterface, typename TService> template <typename TInterface, typename TService>
struct is_valid_interface : public conjunction<std::is_base_of<TInterface, TService>, is_qobj<TService>> {}; struct is_valid_interface : public std::integral_constant<bool, std::is_base_of<TInterface, TService>::value && is_qobj<TService>::value> {};
template <typename TInjectPtr> template <typename TInjectPtr>
inline QByteArray qobject_iid(std::enable_if_t<is_qobj_ptr<TInjectPtr>::value, void*> = nullptr) { inline QByteArray qobject_iid(std::enable_if_t<is_qobj_ptr<TInjectPtr>::value, void*> = nullptr) {
@ -52,7 +44,7 @@ inline QByteArray inject_iid() {
} }
template <typename TFunc, typename T1, typename... TArgs> template <typename TFunc, typename T1, typename... TArgs>
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) {
injectables.append(inject_iid<T1>()); injectables.append(inject_iid<T1>());
auto subFn = [fn](const QObjectList &params, int index, TArgs... tArgs) { auto subFn = [fn](const QObjectList &params, int index, TArgs... tArgs) {
--index; --index;
@ -62,7 +54,7 @@ inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const
} }
template <typename TFunc> template <typename TFunc>
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) { inline std::function<QObject*(QObjectList)> pack_function_imp(const TFunc &fn, QByteArrayList &injectables) {
Q_UNUSED(injectables) Q_UNUSED(injectables)
return [fn](const QObjectList &params) { return [fn](const QObjectList &params) {
return fn(params, params.size()); return fn(params, params.size());
@ -76,7 +68,7 @@ template <typename TClass, typename TRet, typename... TArgs>
struct fn_info<TRet(TClass::*)(TArgs...) const> struct fn_info<TRet(TClass::*)(TArgs...) const>
{ {
template <typename TFunctor> template <typename TFunctor>
static inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack(const TFunctor &fn, QByteArrayList &injectables) { static inline std::function<QObject*(QObjectList)> pack(const TFunctor &fn, QByteArrayList &injectables) {
auto subFn = [fn](const QObjectList &params, int index, TArgs... args) -> QObject* { auto subFn = [fn](const QObjectList &params, int index, TArgs... args) -> QObject* {
Q_UNUSED(params) Q_UNUSED(params)
Q_ASSERT_X(index == 0, Q_FUNC_INFO, "number of params does not equal recursion depth"); Q_ASSERT_X(index == 0, Q_FUNC_INFO, "number of params does not equal recursion depth");
@ -87,7 +79,7 @@ struct fn_info<TRet(TClass::*)(TArgs...) const>
}; };
template <typename TFunc> template <typename TFunc>
inline Q_CONSTEXPR std::function<QObject*(QObjectList)> pack_function(const TFunc &fn, QByteArrayList &injectables) { inline std::function<QObject*(QObjectList)> pack_function(const TFunc &fn, QByteArrayList &injectables) {
return fn_info<TFunc>::pack(fn, injectables); return fn_info<TFunc>::pack(fn, injectables);
} }

Loading…
Cancel
Save