P2964R2 — User-defined element types in std::simd through trait-based vectorizable definition (13 items) LEWG
Daniel Towner, Ruslan Arutyunyan
This paper proposes extending std::simd to support user-defined element types by replacing the current closed list of vectorizable types (arithmetic types and std::complex) with a trait-based definition based on trivial copyability, power-of-2 size, and alignment constraints. The change enables type-safe strong typedefs, enumerations, std::byte, and domain-specific numeric types to be used as simd element types while maintaining full backward compatibility and identical semantics for existing types. Implementation experience with Clang 20 and Intel oneAPI 2025.0 demonstrates that leading compilers can generate assembly identical to built-in arithmetic types for user-defined types through element-wise inference.

References — Anthropic Citations API

[1]
"(!promotable_type && requires(T a, T b) { BinaryOp{}(a, b) -> std::same_as; });"
[2]
"concept supported-unary-op = and concept supported_binary_op ="
[3]
"( promotable_type && requires(T a, T b) { BinaryOp{}(a, b); }) || (!promotable_type && requires(T a, T b) { BinaryOp{}(a, b) -> std::same_as; });"
[4]
"constexpr rebind_t>"
[5]
"requires(T a) { { UnaryOp{}(a) } -> same_as; }; and requires(T a, T b) { BinaryOp{}(a, b) -> std::same_as; }"
[6]
"supported-binary-op is true, where Op is the corresponding standard transparent function object"
[7]
"Exclusion with this constrain is likely to be rare in practice"
[8]
"A type T is a now vectorizable if:"
[9]
"trait-based constraints that handle all existing types while naturally extend support to enumerations"
[10]
"allowing static_castto use whichever is available"
[11]
"The core idea of our proposal is to change definition of a vectorizable type"
[12]
"concept supported-unary-op = ... promotable-type ? requires(T a) { UnaryOp{}(a); } : requires(T a) { { UnaryOp{}(a) } -> same_as; }; vs. concept supported_binary_op = ( promotable_type &&..."
Summary: This paper proposes replacing the closed list of vectorizable types in std::simd with a trait-based mechanism, allowing user-defined types (structs, enums, std::byte) to opt in to SIMD operations by specializing simd_traits. It introduces exposition-only concepts and modifies operator constraints to support this extensibility.
Pipeline: Discovery (Anthropic Opus + Citations API) → Verification Gate (OpenRouter Opus) → Report Writer (OpenRouter Opus)
Provenance: All references are machine-verified character positions from the Anthropic Citations API — deterministic, exact substrings, not model-generated quotes.