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
lemire
changed the title
Validating conversion functions may return a struct.
Validating conversion functions may return a struct indicating length and success
Mar 20, 2021
I'd see it more like C++ defined for std::from_chars --- struct has a pointer and error code. However, if we want to finally C API and binding to other languages, maybe your idea with plain-old-data is more suitable.
@WojciechMula Alternatively, you can replace the Boolean with an error code (could be an integer type). Then you want to flip the convention around and have it be error with 0 being ok and any non-zero value representing an error code. It allows you to provide fine error reporting. So...
structresult {
int error;
size_t length;
}
but if we are just going to report yes or no, then such an API is a waste of effort and we should go with something simpler.
lemire
changed the title
Validating conversion functions may return a struct indicating length and success
Validating and transcoding conversion functions may return a struct indicating length and success
Jul 12, 2022
@NicolasJiaxin This is something you could work on... The scenario of the validation functions is relatively simple. Of course, there are many different design decisions about how to proceed. Benchmarking could help.
Currently validating conversion functions return a length. This might be better:
with structured binding, you can do...
auto [is_ok, length] = convert()
.The text was updated successfully, but these errors were encountered: