-
Notifications
You must be signed in to change notification settings - Fork 240
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
Make more zview
constructors noexcept
.
#625
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a silly problem to have. In a way it's good. Sometimes gcc warns (and in my development builds, warnings are errors!) that some `zview` constructors throw no errors, and would I perhaps like to slap a `noexcept` on them? A _fine_ idea, were it not for the facts that (1) `pqxx::zview` extends `std::string_view`, and (2) the corresponding `string_view` constructor does not have the `noexcept`. So... can I make that promise myself? Turns out I can. Looking at gcc's `string_view` implementation I see that it does declare those constructors as `noexcept`. All I had to do was declare my constructors as "`noexcept` provided that `string_view` is okay with it.")
jtv
changed the title
Make more
Make more Jan 14, 2023
zview
constructots noexcept
.zview
constructors noexcept
.
@@ -73,7 +75,8 @@ | |||
* do it many times, it's probably better to create the `zview` once and | |||
* re-use it. | |||
*/ | |||
constexpr zview(char const str[]) : std::string_view{str} {} | |||
constexpr zview(char const str[]) noexcept(noexcept(std::string_view{str})) : |
Check notice
Code scanning / CodeQL
No raw arrays in interfaces
Raw arrays should not be used in interfaces. A container class should be used instead.
std::string_view{text, static_cast<std::size_t>(len)} | ||
{} | ||
|
||
/// Convenience overload: construct using pointer and signed length. | ||
constexpr zview(char text[], std::ptrdiff_t len) : | ||
constexpr zview(char text[], std::ptrdiff_t len) |
Check notice
Code scanning / CodeQL
No raw arrays in interfaces
Raw arrays should not be used in interfaces. A container class should be used instead.
@@ -40,12 +40,14 @@ | |||
constexpr zview() noexcept = default; | |||
|
|||
/// Convenience overload: construct using pointer and signed length. | |||
constexpr zview(char const text[], std::ptrdiff_t len) : | |||
constexpr zview(char const text[], std::ptrdiff_t len) |
Check notice
Code scanning / CodeQL
No raw arrays in interfaces
Raw arrays should not be used in interfaces. A container class should be used instead.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a silly problem to have. In a way it's good. Sometimes gcc
warns (and in my development builds, warnings are errors!) that some
zview
constructors throw no errors, and would I perhaps like to slapa
noexcept
on them?A fine idea, were it not for the facts that (1)
pqxx::zview
extendsstd::string_view
, and (2) the correspondingstring_view
constructordoes not have the
noexcept
. So... can I make that promise myself?Turns out I can. Looking at gcc's
string_view
implementation I seethat it does declare those constructors as
noexcept
. All I had to dowas declare my constructors as "
noexcept
provided thatstring_view
is okay with it.")