-
Notifications
You must be signed in to change notification settings - Fork 516
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
Add support for string_view #298
Comments
IMHO the benefits of string_view are not many for SQLiteCpp. Most strings it receives from callers are passed on to sqlite3 which requires C-style zero-terminated strings. This means for each string_view passed in, a copy of the string needs to be allocated and padded with a null-byte (since string_views will usually not be null-terminated). Note that if the caller already has a std::string, passing string_views is actually worse than passing in the std::string by const-ref, because the c_str() member function of std::string is non-allocating in practical implementations. So with a string_view you force an extra allocation. This means in the case of SQLiteCpp, string_views are only useful to hide the extra allocations needed in any case when passing in a substring inside a larger memory area. |
@pylorak I believe you're not quite right. SQLite3 documentation says:
I.e. it is perfectly fine to not terminate them, and therefore using Furthermore, the same applies to queries. It is quite common to have fixed queries in an application. Now with C++17 literals you could do something like |
Not sure if this is possible, but it would be nice to have string_view support in calls to
bind()
The text was updated successfully, but these errors were encountered: