Open poul250 opened 3 years ago
We can write noexcept
The reason lambdas are used is lazy execution. We do not need to calculate the string until the exception is thrown.
This method called Ensure::Always::ArgumentInRange
the reason it exists is to ensure the condition is met. If it is not, the exception is thrown. You can always use range.Contains
method if you would like to check it yourself. This method returns boolean. If you need to throw an exception - use Ensure::Always::ArgumentInRange
, if you don't want to use exceptions, just don't use this method.
The reason lambdas are used is lazy execution. We do not need to calculate the string until the exception is thrown. This method called
Ensure::Always::ArgumentInRange
the reason it exists is to ensure the condition is met. If it is not, the exception is thrown. You can always userange.Contains
method if you would like to check it yourself. This method returns boolean. If you need to throw an exception - useEnsure::Always::ArgumentInRange
, if you don't want to use exceptions, just don't use this method.
Use std::string_view
with static string messages for this
It looks verdy difficult https://github.com/linksplatform/Ranges/blob/d7b5ac881f7e8921520f5264ce04a1d97dfd31c3/cpp/Platform.Ranges/EnsureExtensions.h#L33-L43 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?