by pjmlp · 4y ago · 0 comments
I only raised the issue, because this is how new programmers keep doing mistakes in C++ when learning the code from others, specially projects that they find are cool to learn from.
As you seem to use best practices in the rest of the code that seemed strange to me.
void engine::callback(std::span<float> output)
{
std::size_t samples = 0;
if (stream_)
{
samples = stream_->read(output.data(), output.size());
if (samples == 0) stream_ = nullptr;
}
auto remaining = output.subspan(samples);
std::fill(remaining.begin(), remaining.end(), 0.f);
}Even the standard library commits a similar sin with `from_chars` and not taking a `string_view`.
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.