Commit 130d199e authored by Ronan's avatar Ronan
Browse files

fix(StaticString): add a workaround for MSVC 2015 on int constructor

parent 5b9c76ff
......@@ -111,18 +111,16 @@ namespace Private {
RawStaticString<N> raw;
private:
template<typename T>
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<std::size_t... Index, typename Int = int, typename std::enable_if<!testInt<Int>(Value), int>::type* = nullptr>
template<std::size_t... Index, typename Int = int, typename std::enable_if<!IsNeg::value, Int>::type* = nullptr>
constexpr StaticIntStringHelper (const IndexSequence<Index...> &) :
raw{ char('0' + Value / pow10(N - Index - 2) % 10)..., '\0' } {}
template<std::size_t... Index, typename Int = int, typename std::enable_if<testInt<Int>(Value), int>::type* = nullptr>
constexpr StaticIntStringHelper (const IndexSequence<Index...> &) :
template<std::size_t... Index, typename Int = int, typename std::enable_if<IsNeg::value, Int>::type* = nullptr>
constexpr StaticIntStringHelper(const IndexSequence<Index...> &) :
raw{ '-', char('0' + abs(Value) / pow10(N - Index - 3) % 10)..., '\0' } {}
};
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment