Skip to content

Add StrongTypedef to bn::base#8288

Open
bdash wants to merge 1 commit into
devfrom
test_strong_typedef
Open

Add StrongTypedef to bn::base#8288
bdash wants to merge 1 commit into
devfrom
test_strong_typedef

Conversation

@bdash

@bdash bdash commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Introduce bn::base::StrongTypedef<T, Tag, Mods...> that can be used to give a primitive type a distinct identity. The wrapped type is not implicitly convertible to or from its underlying type, but its value be accessed explicitly.

The operations available on the new type are opt-in through composable modifiers, such as Equality, Ordered, Hashable, Arithmetic, etc.

The intent is that over time we will move to using strong typedefs to represent instruction indexes, expression indexes, virtual addresses, etc., to prevent unintentionally using values of those types in the wrong contexts.

Introduce `bn::base::StrongTypedef<T, Tag, Mods...>` that can be used to give a
primitive type a distinct identity. The wrapped type is not implicitly convertible
to or from its underlying type, but its value be accessed explicitly.

The operations available on the new type are opt-in through composable modifiers,
such as `Equality`, `Ordered`, `Hashable`, `Arithmetic`, etc.
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.

1 participant