4 ms·
std::span is new enough to not be in muscle memory of C++ programmers. Even the standard library commits a similar sin with `from_chars` and not taking a `stri
by planede 4y ago
std::span is new enough to not be in muscle memory of C++ programmers.
Even the standard library commits a similar sin with `from_chars` and not taking a `string_view`.
- gpderetta 4y agostd::span is new, but I have seen some custom form of it in pretty much every codebase I've worked with for a very long time (and implemented some myself). Like it used be the case for std::string in older codebases.
- pencilguin 4y agostring_view would definitely have been wrong. std::span did not exist in the Standard at the time std::from_chars was adopted. An overload that takes std::span would be easy, and harmless. But as std::from_chars is only ever used from within some other abstraction, any benefit would be minimal.
- planede 4y agoWhy would string_view be wrong there?
- pencilguin 4y agoBecause, then, to parse out a number you would first need to get it into a string.