mph icon indicating copy to clipboard operation
mph copied to clipboard

Is there a string size limitation when creating the lookup table?

Open FranciscoThiesen opened this issue 5 months ago • 2 comments

Hi, @krzysztof-jusiak

This is a really cool library! When reading the code I was left with 2 questions:

  • Is there a limitation on the string sizes that we pass to the lookup table? This is relevant for the use case that I am working with. And if there is such a limitation, is there a way to specify a fallback logic for when the limit is surpassed?
  • Is there any harm/slow-down at not passing a <key, value> pair and using just a list of keys? Like for example:
constexpr auto dict = std::array<std::string_view, 3>{
    "make"sv,
    "model"sv,
    "year"sv
};

int main() {
    static_assert(mph::find<dict>("make") == true);
    static_assert(mph::find<dict>("model") == true);
    static_assert(mph::find<dict>("year") == true);
    static_assert(mph::find<dict>("unknown") == false);
}

Thanks, Francisco

FranciscoThiesen avatar Sep 09 '24 22:09 FranciscoThiesen