From fd5cdfd5476a63f2cd5f764b50c315f040be5efe Mon Sep 17 00:00:00 2001 From: Daniel Gomez Antonio Date: Mon, 14 Sep 2020 19:07:53 -0500 Subject: [PATCH] Fix compiler warning C4702 for MSVC-14 (#225) --- include/cxxopts.hpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index 995b893..e91987d 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -564,21 +564,20 @@ namespace cxxopts } // namespace detail template - R - checked_negate(T&& t, const std::string&, std::true_type) + void + 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 // `R`. So to avoid MSVC C4146, we first cast it to `R`. // See https://github.com/jarro2783/cxxopts/issues/62 for more details. - return static_cast(-static_cast(t-1)-1); + r = static_cast(-static_cast(t-1)-1); } template - T - checked_negate(T&& t, const std::string& text, std::false_type) + void + checked_negate(R&, T&&, const std::string& text, std::false_type) { throw_or_mimic(text); - return t; } template @@ -643,9 +642,7 @@ namespace cxxopts if (negative) { - value = checked_negate(result, - text, - std::integral_constant()); + checked_negate(value, result, text, std::integral_constant()); } else { -- libgit2 0.21.4