Given the sequence (for example, the string "Xa"), I want to get the next prefix in lexicographic order (for example, "Xb"). The next of "aZ" should be "b"
A motivating use case when this feature is useful is described here .
As I don't want to reinvent the wheel, I wonder if there is any function in C ++ STL or boost that can help to easily define this common function? If not, do you think this feature might be useful?
Notes
- Even if the examples are strings, the function should work for any sequence.
- The lexicographic order must be a parameter of the function template.
From the answers, I conclude that in C ++ / Boost there is nothing that could help to easily define this common function, and also that this function is too specific to be offered for free. I will use a common next_prefix, after which I will ask if you find it useful.
I accepted the only answer that gives some hints on how to do this, even if the proposed implementation is not general.
source
share