Skip to content

✨ Add CT_WRAP#243

Merged
bdeane-intel merged 4 commits intointel:mainfrom
elbeno:cx-utils
Jul 10, 2025
Merged

✨ Add CT_WRAP#243
bdeane-intel merged 4 commits intointel:mainfrom
elbeno:cx-utils

Conversation

@elbeno
Copy link
Contributor

@elbeno elbeno commented Jul 3, 2025

Problem:

  • It is useful to have a macro that wraps a potentially-constexpr-usable value in stdx::ct when possible, to preserve its constexpr properties.

Solution:

  • Add CT_WRAP that does this.

Notes:

@elbeno elbeno force-pushed the cx-utils branch 6 times, most recently from 87cd5ae to 97c4bd9 Compare July 9, 2025 00:20
@elbeno elbeno marked this pull request as draft July 9, 2025 12:56
@elbeno elbeno force-pushed the cx-utils branch 2 times, most recently from 9dae98b to 2f97d92 Compare July 9, 2025 17:32
@elbeno elbeno marked this pull request as ready for review July 9, 2025 17:39
elbeno added 4 commits July 9, 2025 19:56
Problem:
- It is useful to have a macro that wraps a potentially-`constexpr`-usable value
  in `stdx::ct` when possible, to preserve its `constexpr` properties.

Solution:
- Add `CT_WRAP` that does this.

Notes:
- See intel/compile-time-init-build#743 for some parts
  of this in CIB; this part probably belongs in stdx.
Problem:
- It's useful to have `map`/`transform` in the preprocessor.

Solution:
- Add `pp_map.hpp`.
Problem:
- We want to not forget to apply `CX_VALUE` to arguments in macros when they are
  usable at compile time.

Solution:
- Add `CX_WRAP` which wrap its argument in a `CX_VALUE` when it's possible to
  do so.
Problem:
- It's easy to call `stdx::ct_format` but forget to preserve the constexpr
  nature of the arguments. Especially with literals, e.g.
  `stdx::ct_format<"{}">(42)` results in a runtime format argument.

Solution:
- Add `STDX_CT_FORMAT` which automatically wraps the arguments so that their
  constexpr nature is preserved where possible. `STDX_CT_FORMAT("{}", 42)` is
  now a compile-time formatting operation.
Copy link
Contributor

@mjcaisse-intel mjcaisse-intel left a comment

Choose a reason for hiding this comment

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

Awesome! Looks great. Can't wait to use this!

@bdeane-intel bdeane-intel merged commit 3641035 into intel:main Jul 10, 2025
42 checks passed
@elbeno elbeno deleted the cx-utils branch October 16, 2025 20:06
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.

3 participants