Skip to content

Commit

Permalink
Constexpr workaround
Browse files Browse the repository at this point in the history
MSVC 2015 Update 3 doesn't yet like the auto const variable in a
constexpr function, removed the variable.
  • Loading branch information
hsutter committed Sep 29, 2016
1 parent 7aff8ad commit 4799f66
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions util.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

// This project requires GSL, see: https://github.com/microsoft/gsl
#include <gsl/gsl>
#include "gsl/gsl"
#include <limits>
#include <type_traits>

Expand All @@ -49,10 +49,9 @@ bool operator>=(const Type& that) const { return compare3(that) >= 0; }
template<class Target, class Value>
constexpr bool in_representable_range(Value const& value) {
using C = std::common_type_t<Target, Value>;
auto const cvalue = static_cast<C>(value);
return cvalue <= static_cast<C>(std::numeric_limits<Target>::max()) &&
(!std::is_signed<C>::value || static_cast<C>(std::numeric_limits<Target>::min()) <= cvalue) &&
(C{} < cvalue) == (Value{} < value);
return static_cast<C>(value) <= static_cast<C>(std::numeric_limits<Target>::max()) &&
(!std::is_signed<C>::value || static_cast<C>(std::numeric_limits<Target>::min()) <= static_cast<C>(value)) &&
(C{} < static_cast<C>(value)) == (Value{} < value);
}

#endif

0 comments on commit 4799f66

Please sign in to comment.