fix(StatixString): add a workaround to deal with int constructors (Windows)

This commit is contained in:
Ronan Abhamon 2018-05-18 18:02:22 +02:00
parent c327a60318
commit 2b34c206bd

View file

@ -111,13 +111,19 @@ namespace Private {
RawStaticString<N> raw;
private:
template<std::size_t... Index, typename Int = int, typename std::enable_if<Int(Value) >= 0, int>::type* = nullptr>
constexpr StaticIntStringHelper (const IndexSequence<Index...> &) :
raw{ char('0' + Value / pow10(N - Index - 2) % 10 )..., '\0' } {}
template<typename T>
static bool testInt (T n) {
// Do not use it directly in the two enable_if below. (MSVC 2015 bug.)
return n < 0;
}
template<std::size_t... Index, typename Int = int, typename std::enable_if<Int(Value) < 0, int>::type* = nullptr>
template<std::size_t... Index, typename Int = int, typename std::enable_if<!testInt<Int>(Value), int>::type* = nullptr>
constexpr StaticIntStringHelper (const IndexSequence<Index...> &) :
raw{ '-', char('0' + abs(Value) / pow10(N - Index - 3) % 10 )..., '\0' } {}
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...> &) :
raw{ '-', char('0' + abs(Value) / pow10(N - Index - 3) % 10)..., '\0' } {}
};
};