Fix compiler warning C4702 for MSVC-14 (#225)
* Fix compiler warning C4702 for MSVC-14
This commit is contained in:
parent
584e0c3dd3
commit
fd5cdfd547
@ -564,21 +564,20 @@ namespace cxxopts
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
R
|
void
|
||||||
checked_negate(T&& t, const std::string&, std::true_type)
|
checked_negate(R& r, T&& t, const std::string&, std::true_type)
|
||||||
{
|
{
|
||||||
// if we got to here, then `t` is a positive number that fits into
|
// if we got to here, then `t` is a positive number that fits into
|
||||||
// `R`. So to avoid MSVC C4146, we first cast it to `R`.
|
// `R`. So to avoid MSVC C4146, we first cast it to `R`.
|
||||||
// See https://github.com/jarro2783/cxxopts/issues/62 for more details.
|
// See https://github.com/jarro2783/cxxopts/issues/62 for more details.
|
||||||
return static_cast<R>(-static_cast<R>(t-1)-1);
|
r = static_cast<R>(-static_cast<R>(t-1)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename R, typename T>
|
template <typename R, typename T>
|
||||||
T
|
void
|
||||||
checked_negate(T&& t, const std::string& text, std::false_type)
|
checked_negate(R&, T&&, const std::string& text, std::false_type)
|
||||||
{
|
{
|
||||||
throw_or_mimic<argument_incorrect_type>(text);
|
throw_or_mimic<argument_incorrect_type>(text);
|
||||||
return t;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -643,9 +642,7 @@ namespace cxxopts
|
|||||||
|
|
||||||
if (negative)
|
if (negative)
|
||||||
{
|
{
|
||||||
value = checked_negate<T>(result,
|
checked_negate<T>(value, result, text, std::integral_constant<bool, is_signed>());
|
||||||
text,
|
|
||||||
std::integral_constant<bool, is_signed>());
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user