MCPcopy Create free account
hub / github.com/CLIUtils/CLI11 / DeltaRange

Method DeltaRange

examples/custom_validator.cpp:16–27  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 T center_point;
15 T delta;
16 DeltaRange(const T &center, const T &range)
17 : CLI::Validator(
18 [this](const std::string &value) -> std::string {
19 T newValue;
20 auto result = CLI::detail::lexical_cast(value, newValue);
21 if(!(result && this->check(newValue))) {
22 return std::string("value not within range");
23 }
24 return std::string{};
25 },
26 "RANGE"),
27 center_point(center), delta(range) {}
28
29 CLI11_NODISCARD bool check(const T &test) const {
30 return (test >= (center_point - delta)) && (test <= (center_point + delta));

Callers

nothing calls this directly

Calls 2

checkMethod · 0.95
lexical_castFunction · 0.70

Tested by

no test coverage detected