From 7945b3f109773261f89382c32c4ab2e11d833121 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Wed, 6 Nov 2019 05:41:58 -0500 Subject: [PATCH] update libdivide to 3.0 --- third_party/libdivide.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/third_party/libdivide.h b/third_party/libdivide.h index 7969d86..8b22ea5 100644 --- a/third_party/libdivide.h +++ b/third_party/libdivide.h @@ -11,8 +11,8 @@ #ifndef LIBDIVIDE_H #define LIBDIVIDE_H -#define LIBDIVIDE_VERSION "2.0" -#define LIBDIVIDE_VERSION_MAJOR 2 +#define LIBDIVIDE_VERSION "3.0" +#define LIBDIVIDE_VERSION_MAJOR 3 #define LIBDIVIDE_VERSION_MINOR 0 #include @@ -20,6 +20,7 @@ #if defined(__cplusplus) #include #include + #include #else #include #include @@ -1973,16 +1974,16 @@ enum { // The dispatcher selects a specific division algorithm for a given // type and ALGO using partial template specialization. -template struct dispatcher { }; +template struct dispatcher { }; -template<> struct dispatcher { DISPATCHER_GEN(int32_t, s32) }; -template<> struct dispatcher { DISPATCHER_GEN(int32_t, s32_branchfree) }; -template<> struct dispatcher { DISPATCHER_GEN(uint32_t, u32) }; -template<> struct dispatcher { DISPATCHER_GEN(uint32_t, u32_branchfree) }; -template<> struct dispatcher { DISPATCHER_GEN(int64_t, s64) }; -template<> struct dispatcher { DISPATCHER_GEN(int64_t, s64_branchfree) }; -template<> struct dispatcher { DISPATCHER_GEN(uint64_t, u64) }; -template<> struct dispatcher { DISPATCHER_GEN(uint64_t, u64_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(int32_t, s32) }; +template<> struct dispatcher { DISPATCHER_GEN(int32_t, s32_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(uint32_t, u32) }; +template<> struct dispatcher { DISPATCHER_GEN(uint32_t, u32_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(int64_t, s64) }; +template<> struct dispatcher { DISPATCHER_GEN(int64_t, s64_branchfree) }; +template<> struct dispatcher { DISPATCHER_GEN(uint64_t, u64) }; +template<> struct dispatcher { DISPATCHER_GEN(uint64_t, u64_branchfree) }; // This is the main divider class for use by the user (C++ API). // The actual division algorithm is selected using the dispatcher struct @@ -2026,9 +2027,11 @@ public: return div.divide(n); } #endif + private: // Storage for the actual divisor - dispatcher div; + dispatcher::value, + std::is_signed::value, sizeof(T), ALGO> div; }; // Overload of operator / for scalar division @@ -2058,12 +2061,9 @@ T& operator/=(T& n, const divider& div) { } #endif -#if __cplusplus >= 201103L || \ - (defined(_MSC_VER) && _MSC_VER >= 1800) - // libdivdie::branchfree_divider - template - using branchfree_divider = divider; -#endif +// libdivdie::branchfree_divider +template +using branchfree_divider = divider; } // namespace libdivide