-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make find() constexpr in C++11 #48
Comments
I'd like to do so, can you hint on an implementation? |
@martinmoene : Is the naive implementation not ok for the constexpr case? |
@martinmoene : See #49 . |
@eyalroz thanks for your input! It helps to get me going :) |
commit d934b1ac5b8c4ad30222d5fa89d610f74e1b005a Author: Eyal Rozenberg <[email protected]> Date: Sat Feb 12 21:10:58 2022 +0200 Naive implementation of a `constexpr` alternative to `std::search()` for pairs of `basic_string_view`s, using the `basic_string_view::starts_with()` method.
@martinmoene : Do you think we could possibly use an immediately-invoked lambda instead of the function call? |
Not immediately ;) Can you explain what the driving idea behind that is? In C++14, one can create a recursive lambda, but not immediately invoke it. |
Right, we wouldn't be able to recurse. I just wanted to avoid the separate function outside the class, if it's only used in one place. |
Currently, the
find()
method of basic_string_view is nssv_constexpr14. It seems to me it should be possible to make it constexpr since C++11 with tail-recursion iteration.The text was updated successfully, but these errors were encountered: