# std::span

15 Hacker News commenters recommended std::span and 6 criticized it, November 2025 to November 2026. It was recommended in 4 of 13 months. It meets the Hacker Approved badge rule.

**Verdict:** Lets people keep a buffer pointer and its length together, reducing size mistakes, and is available in C++20. Common caveat: it is not bounds checked.

## Why people recommend it

- Keeps pointer and length together (4 comments): "C++'s std::span was very convenient for fixing the issue by letting the buffer pointer and length be kept together" ([source](https://news.ycombinator.com/item?id=45816352)) "It bind both value together and guarantee that you do not mess with the size of your buffer." ([source](https://news.ycombinator.com/item?id=48459555)) "what you gain with span, in that the pointer and the length are joined together" ([source](https://news.ycombinator.com/item?id=48459174))
- Recommended for new C++20 projects (3 comments): "I now use it consistently in all new projects where I can afford to mandate C++20." ([source](https://news.ycombinator.com/item?id=48459267)) "I use std::span and std::expected in every project I can" ([source](https://news.ycombinator.com/item?id=45934751)) "Just use compiler option -std=c++20 and use std::span." ([source](https://news.ycombinator.com/item?id=47983682))
- Preferred over raw pointers (2 comments): "That's why C++ Core Guidelines recommend to use std::span." ([source](https://news.ycombinator.com/item?id=48472234)) "std::string_view or std::span should be used instead" ([source](https://news.ycombinator.com/item?id=48263918))

## What people warn about

- Not bounds checked, seen as dangerous (2 comments): "a type which was standardized to be pointlessly dangerous" ([source](https://news.ycombinator.com/item?id=50031596)) "std span is not bounds checked." ([source](https://news.ycombinator.com/item?id=47986435))
- Slows builds and performance on MSVC (2 comments): "Sadly the MSVC ABI makes std::span and std::string_view a pessimisation" ([source](https://news.ycombinator.com/item?id=48459535)) "Span will increase compilation time for no useful reason." ([source](https://news.ycombinator.com/item?id=48461665))

## Cite as

Hacker Approved, "std::span", https://hackerapproved.com/p/std-span/ (counts from 1,795,640 Hacker News comments, November 2025 to November 2026).
