From 47f1f81829f8d062cfca8056979d6a77c06cc307 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 <0xFEEDC0DE64@gmail.com> Date: Thu, 14 Dec 2017 00:18:15 +0100 Subject: [PATCH] Added support for cpp11 compilers (only make_unique was missing) --- cpp14polyfills.h | 51 ++++++++++++++++++++++++++++++++++++++++++++ zeiterfassung.pro | 3 ++- zeiterfassungapi.cpp | 3 +++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 cpp14polyfills.h diff --git a/cpp14polyfills.h b/cpp14polyfills.h new file mode 100644 index 0000000..1c482e9 --- /dev/null +++ b/cpp14polyfills.h @@ -0,0 +1,51 @@ +#ifndef CPP14POLYFILLS_H +#define CPP14POLYFILLS_H + +#ifndef CPP14POLYFILLS_INCLUDED +#define CPP14POLYFILLS_INCLUDED + +#if __cplusplus < 201402L + +// std includes +#include +#include +#include +#include +#include + +namespace std { + template struct _Unique_if { + typedef unique_ptr _Single_object; + }; + + template struct _Unique_if { + typedef unique_ptr _Unknown_bound; + }; + + template struct _Unique_if { + typedef void _Known_bound; + }; + + template + typename _Unique_if::_Single_object + make_unique(Args&&... args) { + return unique_ptr(new T(std::forward(args)...)); + } + + template + typename _Unique_if::_Unknown_bound + make_unique(size_t n) { + typedef typename remove_extent::type U; + return unique_ptr(new U[n]()); + } + + template + typename _Unique_if::_Known_bound + make_unique(Args&&...) = delete; +} + +#endif // __cplusplus < 201402L + +#endif // CPP14POLYFILLS_INCLUDED + +#endif // CPP14POLYFILLS_H diff --git a/zeiterfassung.pro b/zeiterfassung.pro index 42e32dd..edb45ac 100755 --- a/zeiterfassung.pro +++ b/zeiterfassung.pro @@ -76,7 +76,8 @@ HEADERS += \ replies/getprojectsreply.h \ replies/getauswertungreply.h \ replies/zeiterfassungreply.h \ - replies/deletetimeassignmentreply.h + replies/deletetimeassignmentreply.h \ + cpp14polyfills.h FORMS += \ mainwindow.ui \ diff --git a/zeiterfassungapi.cpp b/zeiterfassungapi.cpp index 6e95090..c0a86d0 100644 --- a/zeiterfassungapi.cpp +++ b/zeiterfassungapi.cpp @@ -23,6 +23,9 @@ #include "replies/updatetimeassignmentreply.h" #include "replies/userinforeply.h" +//add support for pre cpp14 compilers +#include "cpp14polyfills.h" + ZeiterfassungApi::ZeiterfassungApi(const QString &url, QObject *parent) : QObject(parent), m_url(url),