Hacker ApprovedDepartments

std::span

Hacker Approved

Array view in Developer tools

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.

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.

21 people gave an opinion

recommend it
15
criticize it
6
approval share
71%
Each figure is one person. RecommendsCriticizes

Recommended in 4 of 13 months

  1. November 2025: recommended
  2. December 2025: recommended
  3. January 2026: not recommended
  4. February 2026: not recommended
  5. March 2026: not recommended
  6. April 2026: not recommended
  7. May 2026: recommended
  8. June 2026: recommended
  9. July 2026: not recommended
  10. August 2026: not recommended
  11. September 2026: not recommended
  12. October 2026: not recommended
  13. November 2026: not recommended (month in progress)

Why it carries the badge

  • 15 people recommend itNeeds 10 or more, met.
  • 2.5 recommenders for every criticNeeds 2 to 1 or better, met.
  • Recommended in 4 of 13 monthsNeeds 4 or more, met.

The same three rules apply to every product, and the badge can’t be bought. How the badge works

What people say about it

The reasons people give, with the number of comments that give each one. Open a reason to read what they said.

Why people recommend it

Each mark is one comment

  • Keeps pointer and length together

    “C++'s std::span was very convenient for fixing the issue by letting the buffer pointer and length be kept together”

    Comment from 4 Nov 2025 in “This week in 1988, Robert Morris unleashed his eponymous worm”

    “It bind both value together and guarantee that you do not mess with the size of your buffer.”

    Comment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

    “what you gain with span, in that the pointer and the length are joined together”

    Comment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”
  • Recommended for new C++20 projects

    “I now use it consistently in all new projects where I can afford to mandate C++20.”

    Comment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

    “I use std::span and std::expected in every project I can”

    Comment from 15 Nov 2025 in “Rust in Android: move fast and fix things”

    “Just use compiler option -std=c++20 and use std::span.”

    Comment from 2 May 2026 in “Lib0xc: A set of C standard library-adjacent APIs for safer systems programming”
  • Preferred over raw pointers

    “That's why C++ Core Guidelines recommend to use std::span.”

    Comment from 10 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

    “std::string_view or std::span should be used instead”

    Comment from 25 May 2026 in “C constructs that still don't work in C++”

What people warn about

Each mark is one comment

  • Not bounds checked, seen as dangerous

    “a type which was standardized to be pointlessly dangerous”

    Comment from 10 Oct 2026 in “`123456' password used in Danish CPR data breach”

    “std span is not bounds checked.”

    Comment from 2 May 2026 in “Lib0xc: A set of C standard library-adjacent APIs for safer systems programming”
  • Slows builds and performance on MSVC

    “Sadly the MSVC ABI makes std::span and std::string_view a pessimisation”

    Comment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

    “Span will increase compilation time for no useful reason.”

    Comment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

What people said

23 of the 24 comments that mention it, newest first. Each links to the original comment.

“a type which was standardized to be pointlessly dangerous”

CriticizesComment from 10 Oct 2026 in “`123456' password used in Danish CPR data breach”

“but not for std::span (until C++26) for reasons I cannot understand”

CriticizesComment from 26 Jul 2026 in “Memory Safety Absolutists”

“tying the pointer and length together reduces chances for variable confusion”

RecommendsComment from 10 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“That's why C++ Core Guidelines recommend to use std::span.”

RecommendsComment from 10 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“Span lets you use a ranged for loop to iterate over the contents without worrying about exceeding the bounds”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“Span will increase compilation time for no useful reason.”

CriticizesComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“it doesn't make the feature itself bad”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“is such a life saver in these situations”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“It bind both value together and guarantee that you do not mess with the size of your buffer.”

MixedComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“Sadly the MSVC ABI makes std::span and std::string_view a pessimisation”

CriticizesComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“For me, a bag of bytes is `std::span`.”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“std::span solves two problems here.”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“I agree with you about std::span”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“I now use it consistently in all new projects where I can afford to mandate C++20.”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“what you gain with span, in that the pointer and the length are joined together”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“A truly zero-cost abstraction which effectively saves you from a lot of troubles.”

RecommendsComment from 9 Jun 2026 in “The beauty and simplicity of the good old C-style void* in C++”

“std::string_view or std::span should be used instead”

RecommendsComment from 25 May 2026 in “C constructs that still don't work in C++”

“std span is not bounds checked.”

CriticizesComment from 2 May 2026 in “Lib0xc: A set of C standard library-adjacent APIs for safer systems programming”

“Just use compiler option -std=c++20 and use std::span.”

RecommendsComment from 2 May 2026 in “Lib0xc: A set of C standard library-adjacent APIs for safer systems programming”

“I'm sure std::span is great, but I like mine better :)”

CriticizesComment from 19 Feb 2026 in “-fbounds-safety: Enforcing bounds safety for C”

“In these applications, size and T are fixed”

RecommendsComment from 4 Dec 2025 in “Checked-size array parameters in C”

“I use std::span and std::expected in every project I can”

RecommendsComment from 15 Nov 2025 in “Rust in Android: move fast and fix things”

“C++'s std::span was very convenient for fixing the issue by letting the buffer pointer and length be kept together”

RecommendsComment from 4 Nov 2025 in “This week in 1988, Robert Morris unleashed his eponymous worm”

Counts come from 1,795,640 Hacker News comments, November 2025 to November 2026. How we count. Report a mistake.