How to use std::span from C++20 -- Bartlomiej Filipek
In this article, we’ll look at std::span which is more generic than string_view and can help work with arbitrary contiguous collections.
How to use std::span from C++20
by Bartlomiej Filipek
From the article:
Here’s an example that illustrates the primary use case for
std::span:In traditional C (or low-level C++), you’d pass an array to a function using a pointer and a size like this:
void process_array(int* arr, std::size_t size) { for(std::size_t i = 0; i < size; ++i) { // do something with arr[i] } }
std::spansimplifies the above code:void process_array(std::span<int> arr_span) { for(auto& elem : arr_span) { // do something with elem } }The need to pass a separate size variable is eliminated, making your code less error-prone and more expressive.

A new episode of the series about SObjectizer and message passing:
How do you untie the knotty problem of complexity? Lucian Radu Teodorescu shows us how to divide and conquer difficult problems.
A new episode of the series about SObjectizer and message passing:
In this blog post, we’ll look at several different view/reference types introduced in Modern C++. The first one is
The Visual C++ team attended CppCon 2023, the largest in-person C++ conference, in Aurora, Colorado from October 2-6th. There were over 700 attendees from the C++ community, and we really enjoyed getting a chance to meet all of you and talk about your unique backgrounds and C++ experiences.
A new episode of the series about SObjectizer and message passing:
In this post we talk about how data structure data layout effects software performance and how, by modifying it, we can speed up the access and modification of the data structure.
A report out from this week's ISO C++ standards committee meeting, which just ended: