Slides for P3774R0
Rename std :: nontype
,
and make it broadly useful
- Document number:
- P3775R0
- Date:
2025-08-12 - 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
Rename std :: nontype
,
and make it broadly useful
P3775R0
Introduction
- P2472R3 added
constructors forstd :: nontype std :: function_ref - merged into P0792R14, plenary-approved Varna 2023 for C++26
possibly obsoleted bystd :: nontype
(P2781R9)std :: constant_wrapper - In C++26
- "non-type template parameter" term was removed by P2841R1 (C++26)
- in Sofia, two plausible directions discussed
- replace
withstd :: nontype std :: constant_wrapper - rename
tostd :: nontype std :: constant_arg - latter option had more consensus
- replace
std :: function_ref
refresher
std :: function_ref
is a "function wrapper"
similar to std :: function
, std :: move_only_function
,
std :: copyable_function
, but without ownership.
std :: function_ref < R ( Args ... ) cv noex >
stores:
—bound-entity
(basically aBoundEntityType
)cv void *
—thunk-ptr R ( * ) ( BoundEntityType , Args ... ) noex
,
,
.
std :: nontype
in std :: function_ref
Alternatives considered
- Low-consensus:
constructor tagstd :: stateless - remove
, revisit in C++29std :: nontype - wait for P1045R1
function parametersconstexpr - expose the
BoundEntityType
- Plausible:
- replace
withstd :: nontype std :: constant_wrapper - rename
(most consensus in Sofia)std :: nontype
- replace
Ⅰ — Nullary functions
Ⅱ — Proper constant wrappers
Ⅲ — Improper constant wrappers
Ⅳ — Surrogate calls
Ⅴ — Function objects
Proposed solution — std :: fn
-
C++26: rename
,std :: nontype fn std :: nontype_t fn_t -
C++26: move decl. from
to<utility> <functional> - C++29: add call operator, extra functionality
Discussion
- Do we agree
should not be used here?std :: constant_wrapper -
Do we agree on the name?
had "consensus"std :: constant_arg
/std :: fn
proposedstd :: fn_t
/std :: const_fn
possible alternativestd :: const_fn_t
/std :: fw
possible alternativestd :: function_wrapper
- Do we agree on moving to
?<functional>