Skip to content

feat(buffer): support C++20 std::span overloads - #1760

Open
dave-365 wants to merge 1 commit into
nodejs:mainfrom
dave-365:feat/cpp20-std-span
Open

dave-365 wants to merge 1 commit into
nodejs:mainfrom
dave-365:feat/cpp20-std-span

Conversation

@dave-365

@dave-365 dave-365 commented Nov 4, 2026

Copy link
Copy Markdown

Fixes #1747

Description

This PR introduces C++20 std::span overloads for buffer-like types (Buffer<T>, ArrayBuffer, and TypedArrayOf<T>), allowing developers to pass bounds-carrying handles directly without manually managing separate raw pointers and length parameters:

  • Added Buffer<T>::New, Buffer<T>::NewOrCopy, and Buffer<T>::Copy overloads accepting std::span.
  • Added ArrayBuffer::New overloads accepting std::span.
  • Added .Span() accessors to Buffer<T>, ArrayBuffer, and TypedArrayOf<T>.
  • All std::span APIs are conditionally compiled under #if defined(__cpp_lib_span).
  • Completely preserves ABI compatibility and backward compatibility for C++ < 20.
  • Added comprehensive unit tests in test/buffer.cc and test/array_buffer.cc.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Need Triage

Development

Successfully merging this pull request may close these issues.

Support C++20 span types

1 participant