P4010R0 — Funnel Shift Operations (8 items) SG6, LEWG
Daniel Towner
This paper proposes adding funnel shift operations (funnel_shift_left and funnel_shift_right) to the C++ standard library's header. Funnel shifts concatenate two integer values, shift the result, and extract bits from it, generalizing bit rotation and mapping directly to hardware instructions such as x86 SHLD/SHRD and ARM EXTR. The proposal covers both scalar and SIMD interfaces, constrained to unsigned integer types, with preconditions requiring the shift count to be in [0, N) without implicit modular reduction.

References — Anthropic Citations API

[1]
"Returns: (low >> r) | (high << ((N - r) % N)). and Remarks: funnel_shift_right(high, low, 0) returns low."
[2]
"Returns: (high << r) | (low >> ((N - r) % N)). and Remarks: funnel_shift_left(high, low, 0) returns high."
[3] chars 12051–12141
"funnel_shift_right(high, low, s) is equivalent to (low >> r) | (high << ((N - r) % N)). "
[4] chars 12141–12231
"funnel_shift_left(high, low, s) is equivalent to (high << r) | (low >> ((N - r) % N)). "
[5] chars 7589–7727
"Well-defined shift semantics: Right shifts on signed integers have implementation-defined behavior in C++ (arithmetic vs. logical shift). "
[6] chars 20263–20567
"``` template constexpr V funnel_shift_left(const V& high, const V& low, S s) noexcept; template constexpr V funnel_shift_right(const V& high, const V& low, S s) noexcept; ``` Constraints: The..."
[6] chars 18186–18220
"S models integral ([concepts]). "
[6] chars 18597–18631
"S models integral ([concepts]). "
Summary: P4010R0 proposes std::funnel_shift_left and std::funnel_shift_right operations for unsigned integer types, extracting N bits from a 2N-bit concatenation of two values shifted by a given amount. The proposal includes both scalar and SIMD interfaces and provides proposed wording for inclusion in .
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.