Slides for P3740R0
Last chance to fix std :: nontype
- Document number:
- P3753R0
- Date:
2025-06-17 - Audience:
- LEWG
- Project:
- ISO/IEC 14882 Programming Languages — C++, ISO/IEC JTC1/SC22/WG21
- Reply-To:
- Jan Schultke <janschultke@gmail.com>
- Source:
- github.com/Eisenwave/cpp-proposals/blob/master/src/nontype-slides.cow
- →, ↓ : go to the next slide
- ←, ↑ : go to previous slide
Last chance
to fix std :: nontype
P3740R0
Introduction
- P2472R3 added
constructors forstd :: nontype std :: function_ref - merged into P0792R14, plenary-approved Varna 2023 for C++26
possibly obsoleted bystd :: nontype
(P2781R8)std :: constant_wrapper - in LWG 10:30 AM today
- "non-type template parameter" term was removed by P2841R1 (C++26)
Conclusion
History is messy.
may be a bad feature now,
or at least have a terrible name.
std :: function_ref
refresher
is a "function wrapper"
similar to
,
,
, but without ownership.
stores:
—bound-entity
(basically aBoundEntityType
)cv void *
—thunk-ptr R ( * ) ( BoundEntityType , Args ... ) noex
and
for now.
std :: nontype
in std :: function_ref
Proposed alternative: std :: stateless
Alternatives considered
- remove
, revisit in C++29std :: nontype - ... but this feature is too important
- wait for P1045R1
function parametersconstexpr - ... but paper looks abandoned, no C++29 guarantee
- expose the
BoundEntityType - ... but leaking non-portable implementation details
- rename
std :: nontype - ... to what? confusion with
std :: constant_wrapper
- ... to what? confusion with
Why not just use std :: constant_wrapper
already behaves much like the function pointer it wraps.
Therefore:
andF &&
constructors are candidates, but lose in overload resolutionF *
also works instd :: constant_wrapper std :: move_only_function - ... but with totally different meaning?!
reference impl. also supportsstd :: nontype std :: move_only_function - ... which would make a lot more sense
- design still ages poorly given
function parametersconstexpr
Most viable solutions
- use
constructor tag insteadstd :: stateless - use
instead ofstd :: constant_wrapper std :: nontype - rename
std :: nontype - Author's proposal:
/std :: constant_arg std :: constant_arg_t
- Author's proposal: