You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a need that I keep running into. In C++26 we're finally getting std::span::at(), and that's nice, but where it really gets interesting is when I need to do a std::string_view::copy() into a std::span<char>. That's an opportunity for a bigger overrun, and there's a bulk discount to be had compared to checking at() for each element.
If I were writing this as a C++ Standard proposal, I'd probably ask for a std::expected return value, so the caller can decide what to do about an overrun without having to catch an exception. Or maybe just separate the bounds check from the actual copying. And then I'd agonise over still having to spell out the code for reporting overruns. It wouldn't save me all that much code.
But in libpqxx I simply want a wrapper for std::string_view::copy() that either returns a std::size_t, or throws a conversion_overrun.
The text was updated successfully, but these errors were encountered:
This is a need that I keep running into. In C++26 we're finally getting
std::span::at()
, and that's nice, but where it really gets interesting is when I need to do astd::string_view::copy()
into astd::span<char>
. That's an opportunity for a bigger overrun, and there's a bulk discount to be had compared to checkingat()
for each element.If I were writing this as a C++ Standard proposal, I'd probably ask for a
std::expected
return value, so the caller can decide what to do about an overrun without having to catch an exception. Or maybe just separate the bounds check from the actual copying. And then I'd agonise over still having to spell out the code for reporting overruns. It wouldn't save me all that much code.But in libpqxx I simply want a wrapper for
std::string_view::copy()
that either returns astd::size_t
, or throws aconversion_overrun
.The text was updated successfully, but these errors were encountered: