From 18b650bbc8468dcb077ec95e2ca50c9e6bc5e599 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sat, 5 Jul 2014 15:28:36 -0400 Subject: Make Range::InRange a bool --- ponymix.cc | 2 +- pulse.h | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/ponymix.cc b/ponymix.cc index 15e09f3..a620036 100644 --- a/ponymix.cc +++ b/ponymix.cc @@ -554,7 +554,7 @@ static int CommandDispatch(PulseClient& ponymix, int argc, char *argv[]) { } const auto& cmd = string_to_command(opt_action); - if (cmd.second.args.InRange(argc) != 0) { + if (!cmd.second.args.InRange(argc)) { error_wrong_args(cmd.second, cmd.first.c_str()); } diff --git a/pulse.h b/pulse.h index 7c17baf..55b07c3 100644 --- a/pulse.h +++ b/pulse.h @@ -133,11 +133,9 @@ struct Range { return value < min ? min : (value > max ? max : value); } - // Determine if the passed value is within the range. Returns 0 - // on success, else -1 if lower than the minimum, and 1 if higher - // than the maximum. - int InRange(T value) const { - return value < min ? -1 : (value > max ? 1 : 0); + // Determine if the passed value is within the range. + bool InRange(T value) const { + return value >= min && value <= max; } T min; -- cgit v1.2.3