Skip to content

Constrain code unit adaptors to same-width integral and byte sources - #262

Merged
ednolan merged 1 commit into
mainfrom
enolan_castconversion2
Sep 22, 2026
Merged

ednolan merged 1 commit into
mainfrom
enolan_castconversion2

Conversation

@ednolan

@ednolan ednolan commented Sep 22, 2026

Copy link
Copy Markdown
Member

Per SG16 feedback, replace the convertible_to constraint on as_charT with a rule that accepts a source type U if it is Char itself, or if it is std::byte or a non-bool integral type with sizeof(U) == sizeof(Char). The exposition-only functor now performs the cast with static_cast.

This rejects narrowing and widening conversions, conversions between distinct charN_t types, floating-point and bool sources, enumerations other than std::byte, and class types, while accepting std::byte and same-width integer buffers.

Add a design discussion section with rationale, alternatives, and a conversion table, and add unit tests covering the accept/reject matrix and the static_cast semantics for byte and signed sources.

Per SG16 feedback, replace the convertible_to constraint on as_charT with
a rule that accepts a source type U if it is Char itself, or if it is
std::byte or a non-bool integral type with sizeof(U) == sizeof(Char).
The exposition-only functor now performs the cast with static_cast.

This rejects narrowing and widening conversions, conversions between
distinct charN_t types, floating-point and bool sources, enumerations
other than std::byte, and class types, while accepting std::byte and
same-width integer buffers.

Add a design discussion section with rationale, alternatives, and a
conversion table, and add unit tests covering the accept/reject matrix
and the static_cast semantics for byte and signed sources.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ednolan
ednolan merged commit 2d22c29 into main Sep 22, 2026
56 checks passed
@ednolan
ednolan deleted the enolan_castconversion2 branch September 22, 2026 12:09
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 99.762%. remained the same — enolan_castconversion2 into main

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants