StringZilla icon indicating copy to clipboard operation
StringZilla copied to clipboard

Bug: compilation error on `partition` with single char argument

Open toge opened this issue 1 year ago • 4 comments

Describe the bug

I met compilation error on following code in README.md

auto parts = haystack.partition(':'); // Matching a character

It seem to be caused by the lack of overload function definition following:

partition_type partition(char pattern) const noexcept { return partition_(char_set{pattern}, 1); }

Steps to reproduce

#include "stringzilla/stringzilla.hpp"

int main() {
  auto haystack = ashvardanian::stringzilla::string_view{"a:b:c"};
  auto [before, match, after] = haystack.partition(':');
}

OS: Fedora Linux 40

Expected behavior

Same as haystack.partition(ashvardanian::stringzilla::char_set(";"))

StringZilla version

3.9.6

Operating System

Fedora Linux 40

Hardware architecture

x86

Which interface are you using?

C++ bindings

Contact Details

No response

Are you open to being tagged as a contributor?

  • [X] I am open to being mentioned in the project .git history as a contributor

Is there an existing issue for this?

  • [X] I have searched the existing issues

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

toge avatar Sep 27 '24 05:09 toge

Thank you, @toge! If it’s missing, it’s worth adding, but should use the substring search under the hood, as opposed to character-set search.

ashvardanian avatar Sep 27 '24 14:09 ashvardanian

@ashvardanian Thank you for your advice! I understand the solution you suggested.

Could you update examples in README.md? I think we should avoid a situation where someone tries to compile the sample code and it fails.

toge avatar Sep 27 '24 17:09 toge

Merging a patch now, but there is more functionality in the C++ layer that I forgot to implement:

using sz::string::cap;
using sz::string::unchecked;

I'm not sure if those are needed though. What do you think, @toge?

ashvardanian avatar Sep 27 '24 22:09 ashvardanian

@ashvardanian Thank you for your quick response!

It would be helpful to have it implemented. For the “fast string processing” feature of Stringzilla, I would be happy to have a wider range of string processing within Stringzilla.

toge avatar Sep 28 '24 02:09 toge