Added support for cpp11 compilers (only make_unique was missing)

This commit is contained in:
0xFEEDC0DE64
2017-12-14 00:18:15 +01:00
parent 9481bba965
commit 47f1f81829
3 changed files with 56 additions and 1 deletions

51
cpp14polyfills.h Normal file
View File

@@ -0,0 +1,51 @@
#ifndef CPP14POLYFILLS_H
#define CPP14POLYFILLS_H
#ifndef CPP14POLYFILLS_INCLUDED
#define CPP14POLYFILLS_INCLUDED
#if __cplusplus < 201402L
// std includes
#include <memory>
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
namespace std {
template<class T> struct _Unique_if {
typedef unique_ptr<T> _Single_object;
};
template<class T> struct _Unique_if<T[]> {
typedef unique_ptr<T[]> _Unknown_bound;
};
template<class T, size_t N> struct _Unique_if<T[N]> {
typedef void _Known_bound;
};
template<class T, class... Args>
typename _Unique_if<T>::_Single_object
make_unique(Args&&... args) {
return unique_ptr<T>(new T(std::forward<Args>(args)...));
}
template<class T>
typename _Unique_if<T>::_Unknown_bound
make_unique(size_t n) {
typedef typename remove_extent<T>::type U;
return unique_ptr<T>(new U[n]());
}
template<class T, class... Args>
typename _Unique_if<T>::_Known_bound
make_unique(Args&&...) = delete;
}
#endif // __cplusplus < 201402L
#endif // CPP14POLYFILLS_INCLUDED
#endif // CPP14POLYFILLS_H

View File

@@ -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 \

View File

@@ -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),