Skip to content
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

fix next_power_of_two and improve generic_string #220

Merged
merged 5 commits into from May 26, 2024

Conversation

freshFruict
Copy link
Contributor

generic_string: add starts_with and ends_with functions

performs a simple way to check if a string has prefix/suffix
add test cases for starts_with and ends_with

fix next_power_of_two function

fix wrong sizeof comparison for 64-bit integers
add sizeof comparisons for 16 and 32-bit integers

@felixguendling
Copy link
Owner

Would it make sense to forward the starts_with and ends_with calls to std::string_view like this?

template <typename T> bool starts_with(T&& t) constexpr { return view().starts_with(t); }
template <typename T> bool ends_with(T&& t) constexpr { return view().ends_with(t); }

If there's an option to maintain less code and still provide the same value, I would prefer that.

Can you please run clang-format?

@freshFruict
Copy link
Contributor Author

I've lessen code. As starts_with and ends_with were added in C++ 20, forwarding calls would break C++ 17 compatibility, so I didn't use them

@felixguendling
Copy link
Owner

felixguendling commented May 13, 2024

/home/runner/work/cista/cista/test/string_test.cc:108: FATAL ERROR: test case CRASHED: SIGABRT - Abort (abnormal termination) signal

Can you please check? :)

Not breaking C++17 compat sounds like a good idea.

@felixguendling felixguendling merged commit 8255bcd into felixguendling:master May 26, 2024
10 checks passed
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.

None yet

2 participants