TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 227 subscribers
Post #24037 22
Three constant wrappers in C++26?

If my understanding is correct, we will have 3 compile time value wrappers in C++26:

- std::integral_constant
- std::nontype_t
- std::constant_wrapper

Note: I think there's some discussion in renaming nontype_t to something else, like constant_arg_t or fn_t, nevertheless it'll remain separate from constant_wrapper and integral_constant

I think this mess is worse than that of functions (function, move_only_function, copyable_function). With functions, at least the rule of thumb is "avoid function; use the other two". But with the constant wrappers? It seems that each of them has their legit use case and none is getting deprecated.

Which one should be used at function boundary? Some libraries already made the choice of integral_constant such as boost.PFR. Other libraries may make a different choice. And since these three are not inter-convertible, I'm afraid this situation will create more work than needed for library writers and/or users.

https://redd.it/1o4kbpz
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 14, 2026I tested whether a coding agent would use C++23 ranges without being told Blog post: https…
  2. Oct 14, 2026C++ futures part 1: The mental model https://devblogs.microsoft.com/oldnewthing/20261012-0…
  3. Oct 14, 2026C++ futures part 2: The mental model for std::promise, std::packaged_task https://devblogs…
  4. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  5. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  6. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →