Skip to content

🎨 Preserve ct_format string types #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 7, 2025

Conversation

elbeno
Copy link
Contributor

@elbeno elbeno commented Jan 7, 2025

Problem:

  • ct_format produces a type that is either a ct_string or a format_result, which means all client code needs to check that.
  • ct_format works at compile-time but produces a string value that may lose its constexpr nature, so can't be put into a type.

Solution:

  • Always return a format_result (possibly with an empty tuple).
  • Wrap the returned ct_string in a type.

@elbeno elbeno force-pushed the cts-preserve-constexpr branch from d7d1c07 to 9c0e4df Compare January 7, 2025 14:58
elbeno added 2 commits January 7, 2025 08:13
Problem:
- `ct_format` produces a type that is either a `ct_string` or a `format_result`,
  which means all client code needs to check that.
- `ct_format` works at compile-time but produces a string value that may lose
  its `constexpr` nature, so can't be put into a type.

Solution:
- Always return a `format_result` (possibly with an empty tuple).
- Wrap the returned `ct_string` in a type.
Problem:
- `CX_VALUE` is fine, but sometimes you have a compile-time value that is
  perfectly fine as a template argument, and you just want to wrap it in a type.

Solution:
- `ct` provides a way to do that.
@elbeno elbeno force-pushed the cts-preserve-constexpr branch from 9c0e4df to 54c14bd Compare January 7, 2025 15:36
Problem:
- `CX_VALUE` is fine, but sometimes you have a `std::integral_constant` already.

Solution:
- Add compile-time formatting support for such values wrapped in types.
@elbeno elbeno force-pushed the cts-preserve-constexpr branch from 54c14bd to 1180eb1 Compare January 7, 2025 15:44
@lukevalenty lukevalenty enabled auto-merge January 7, 2025 16:55
@lukevalenty lukevalenty merged commit dfc27dd into intel:main Jan 7, 2025
32 checks passed
@elbeno elbeno deleted the cts-preserve-constexpr branch January 7, 2025 23:11
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