diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Compat.h | 51 | ||||
-rw-r--r-- | include/Scintilla.h | 2 |
2 files changed, 53 insertions, 0 deletions
diff --git a/include/Compat.h b/include/Compat.h new file mode 100644 index 000000000..712ff1373 --- /dev/null +++ b/include/Compat.h @@ -0,0 +1,51 @@ +// c++11 compatibility with some c++14 features and higher. +// This helps minimize changes from the default branch. + +#ifndef COMPAT_H +#define COMPAT_H + +#ifdef __cplusplus + +#include <cstddef> +#include <memory> +#include <type_traits> +#include <utility> + +namespace Sci { + +// std::make_unique +template<class T> struct _Unique_if { + typedef std::unique_ptr<T> _Single_object; +}; +template<class T> struct _Unique_if<T[]> { + typedef std::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 std::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 std::remove_extent<T>::type U; + return std::unique_ptr<T>(new U[n]()); + } +template<class T, class... Args> + typename _Unique_if<T>::_Known_bound + make_unique(Args&&...) = delete; + +// std::size +template <typename T, size_t N> +constexpr size_t size(const T (&)[N]) noexcept { + return N; +} + +} + +#endif + +#endif
\ No newline at end of file diff --git a/include/Scintilla.h b/include/Scintilla.h index db25b4f17..c2ea775b2 100644 --- a/include/Scintilla.h +++ b/include/Scintilla.h @@ -1266,4 +1266,6 @@ struct SCNotification { #endif +#include "Compat.h" + #endif |