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

Make more zview constructors noexcept. #625

Merged
merged 3 commits into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Use `array_parser` only on comma-separated types, i.e. most of them. (#590)
- Bumping requirements versions: need postgres 10.
- Fix `array_parser` bug when parsing semicolon in an unquoted string.
- Make some `zview` constructors `noexcept` if `string_view` does it.
- Faster text decoding in `stream_from`, and escaping in `stream_to`. (#601)
- At last, streaming throughput is faster (on my system) than a regular query.
- Deprecate `basic_fieldstream` and `fieldstream`.
Expand Down
9 changes: 6 additions & 3 deletions include/pqxx/zview.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ public:
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.
noexcept(noexcept(std::string_view{text, static_cast<std::size_t>(len)})) :
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.
noexcept(noexcept(std::string_view{text, static_cast<std::size_t>(len)})):
std::string_view{text, static_cast<std::size_t>(len)}
{}

Expand Down Expand Up @@ -73,7 +75,8 @@ public:
* 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{str} {}

/// Construct a `zview` from a string literal.
/** A C++ string literal ("foo") normally looks a lot like a pointer to
Expand Down