From 130d199e6e25d49ae6211705eddf0bedf42dc914 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 21 May 2018 11:53:19 +0200 Subject: [PATCH] fix(StaticString): add a workaround for MSVC 2015 on int constructor --- include/linphone/utils/static-string.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/include/linphone/utils/static-string.h b/include/linphone/utils/static-string.h index de5bae91f..bbc421e06 100644 --- a/include/linphone/utils/static-string.h +++ b/include/linphone/utils/static-string.h @@ -111,18 +111,16 @@ namespace Private { RawStaticString raw; private: - template - static constexpr bool testInt (T n) { - // Do not use it directly in the two enable_if below. (MSVC 2015 bug.) - return n < 0; - } + // Workaround for MSVC 2015. + // See: https://stackoverflow.com/questions/41593649/why-wont-visual-studio-let-me-use-a-templatized-constexpr-function-in-enable-i/41597153 + struct IsNeg { static const bool value = Value < 0; }; - template(Value), int>::type* = nullptr> + template::type* = nullptr> constexpr StaticIntStringHelper (const IndexSequence &) : raw{ char('0' + Value / pow10(N - Index - 2) % 10)..., '\0' } {} - template(Value), int>::type* = nullptr> - constexpr StaticIntStringHelper (const IndexSequence &) : + template::type* = nullptr> + constexpr StaticIntStringHelper(const IndexSequence &) : raw{ '-', char('0' + abs(Value) / pow10(N - Index - 3) % 10)..., '\0' } {} }; };