Skip to content

Can we simplify this? #45

Description

@poul250

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions