std::span<T> provides a lightweight, non-owning view over contiguous memory (C arrays, std::vector, std::array, memory-mapped files):
void ProcessSamples(std::span<const float> samples) {
for (float val : samples) {
// Process samples safely
}
}Instead of taking const float* pData, size_t count, std::span encapsulates both the pointer and length in a single object with .subspan(), .data(), and .size(), preventing buffer overruns.