Skip to content

✨ Add indexing for type_map - #427

Open
elbeno wants to merge 1 commit into
intel:mainfrom
elbeno:type-map-indexing
Open

elbeno wants to merge 1 commit into
intel:mainfrom
elbeno:type-map-indexing

Conversation

@elbeno

@elbeno elbeno commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Problem:

  • Having to type out stdx::type_lookup_t<M, K> (or any of its variations for type-value combinations) is cumbersome, especially if you have a nested map type.

Solution:

  • Provide operator[] for looking up types and operator() for looking up values. (Providing both in one operator would be much more complex, if at all possible/nice.)

Note:

  • In the case where an incomplete type is the key or value in a type_map, the argument/return types can be type_identity<T>.
  • Because operator() takes a (non-constexpr) argument, conventional use is to pass this as an integral_constant or cts_t: something that exposes a constexpr static value.

Problem:
- Having to type out `stdx::type_lookup_t<M, K>` (or any of its variations for
  type-value combinations) is cumbersome, especially if you have a nested map
  type.

Solution:
- Provide `operator[]` for looking up types and `operator()` for looking up
  values. (Providing both in one operator would be much more complex, if at all
  possible/nice.)

Note:
- In the case where an incomplete type is the key or value in a `type_map`, the
  argument/return types can be `type_identity<T>`.
- Because `operator()` takes a (non-constexpr) argument, conventional use is to
  pass this as an `integral_constant` or `cts_t`: something that exposes a
  `constexpr static` `value`.
@elbeno
elbeno force-pushed the type-map-indexing branch from a494d8b to 2e12ef1 Compare October 9, 2026 21:15

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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant