Skip to content

✨ Add indexing for type_map - #427

Merged
elbeno merged 1 commit into
intel:mainfrom
elbeno:type-map-indexing
Oct 12, 2026
Merged

elbeno merged 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

@lukevalenty lukevalenty left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was thinking it would be better to have something like a static template member so <...> can be used...but it's not a clear win. i like the new functionality (err, API)!

@elbeno
elbeno merged commit 4a3e797 into intel:main Oct 12, 2026
27 checks passed
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