mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 21:58:08 +00:00
fix(StaticString): add a workaround for MSVC 2015 on int constructor
This commit is contained in:
parent
5b9c76ff31
commit
130d199e6e
1 changed files with 6 additions and 8 deletions
|
|
@ -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' } {}
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue