It looks verdy difficult
|
public: template <typename TArgument> static void ArgumentInRange(Platform::Exceptions::ExtensionRoots::EnsureAlwaysExtensionRoot root, TArgument argumentValue, Range<TArgument> range, std::string argumentName, std::string message) |
|
{ |
|
auto messageBuilder = [&]() -> std::string { return message; }; |
|
ArgumentInRange(root, argumentValue, range, argumentName, messageBuilder); |
|
} |
|
|
|
public: template <typename TArgument> static void ArgumentInRange(Platform::Exceptions::ExtensionRoots::EnsureAlwaysExtensionRoot root, TArgument argumentValue, Range<TArgument> range, std::string argumentName) |
|
{ |
|
auto messageBuilder = [&]() -> std::string { return std::string("Argument value [").append(Platform::Converters::To<std::string>(argumentValue)).append("] is out of range ").append(Platform::Converters::To<std::string>(range)).append(1, '.'); }; |
|
ArgumentInRange(root, argumentValue, range, argumentName, messageBuilder); |
|
} |
Why do we create lambdas, recursively descend into other functions, sums a bunch of lines to check that an element is in the range? And why do we throw an exception if the element is not in the range, when we can return a boolean value? Can we simplify this?
It looks verdy difficult
Ranges/cpp/Platform.Ranges/EnsureExtensions.h
Lines 33 to 43 in d7b5ac8
Why do we create lambdas, recursively descend into other functions, sums a bunch of lines to check that an element is in the range? And why do we throw an exception if the element is not in the range, when we can return a boolean value? Can we simplify this?