Skip to content

Conversation

@keyansheng
Copy link

No description provided.

A const lvalue reference (const string& initialT) allows an rvalue
reference (initialT + "$") to be passed in, which is now "owned" by
SuffixArray and gets destructed after the SuffixArray constructor exits.

By removing const, only an lvalue reference can be passed in, which is
not "owned" by SuffixArray and does not get destructed after the
SuffixArray constructor exits.

Attempting to pass initialT + "$" to the constructor now results in a
compile-time error, which is good since creating a copy is a bad idea
anyway.

Instead, you can initialT.push_back('$') before calling the
constructor, similar to how the original char* constructor works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant