Commit fd5cdfd5476a63f2cd5f764b50c315f040be5efe
Committed by
GitHub
1 parent
584e0c3d
Fix compiler warning C4702 for MSVC-14 (#225)
* Fix compiler warning C4702 for MSVC-14
Showing
1 changed file
with
6 additions
and
9 deletions
include/cxxopts.hpp
| ... | ... | @@ -564,21 +564,20 @@ namespace cxxopts |
| 564 | 564 | } // namespace detail |
| 565 | 565 | |
| 566 | 566 | template <typename R, typename T> |
| 567 | - R | |
| 568 | - checked_negate(T&& t, const std::string&, std::true_type) | |
| 567 | + void | |
| 568 | + checked_negate(R& r, T&& t, const std::string&, std::true_type) | |
| 569 | 569 | { |
| 570 | 570 | // if we got to here, then `t` is a positive number that fits into |
| 571 | 571 | // `R`. So to avoid MSVC C4146, we first cast it to `R`. |
| 572 | 572 | // See https://github.com/jarro2783/cxxopts/issues/62 for more details. |
| 573 | - return static_cast<R>(-static_cast<R>(t-1)-1); | |
| 573 | + r = static_cast<R>(-static_cast<R>(t-1)-1); | |
| 574 | 574 | } |
| 575 | 575 | |
| 576 | 576 | template <typename R, typename T> |
| 577 | - T | |
| 578 | - checked_negate(T&& t, const std::string& text, std::false_type) | |
| 577 | + void | |
| 578 | + checked_negate(R&, T&&, const std::string& text, std::false_type) | |
| 579 | 579 | { |
| 580 | 580 | throw_or_mimic<argument_incorrect_type>(text); |
| 581 | - return t; | |
| 582 | 581 | } |
| 583 | 582 | |
| 584 | 583 | template <typename T> |
| ... | ... | @@ -643,9 +642,7 @@ namespace cxxopts |
| 643 | 642 | |
| 644 | 643 | if (negative) |
| 645 | 644 | { |
| 646 | - value = checked_negate<T>(result, | |
| 647 | - text, | |
| 648 | - std::integral_constant<bool, is_signed>()); | |
| 645 | + checked_negate<T>(value, result, text, std::integral_constant<bool, is_signed>()); | |
| 649 | 646 | } |
| 650 | 647 | else |
| 651 | 648 | { | ... | ... |