Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Template (C++)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Abbreviated function templates ==== Since [[C++20]], using <code>auto</code> or <code>[[concepts (C++)|Concept]] auto</code> in any of the parameters of a [[function declaration]], that declaration becomes an ''abbreviated function template'' declaration.<ref>{{cite web|url=http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1141r1.html|title=P1141R1 - Yet another approach for constrained declarations|access-date=2018-11-11|archive-date=2018-11-11|archive-url=https://web.archive.org/web/20181111133625/http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p1141r1.html|url-status=live}}</ref> Such a declaration declares a function template and one invented template parameter for each placeholder is appended to the template parameter list: <syntaxhighlight lang="cpp"> void f1(auto); // same as template<class T> void f1(T) void f2(C1 auto); // same as template<C1 T> void f2(T), if C1 is a concept void f3(C2 auto...); // same as template<C2... Ts> void f3(Ts...), if C2 is a concept void f4(C2 auto, ...); // same as template<C2 T> void f4(T...), if C2 is a concept void f5(const C3 auto*, C4 auto&); // same as template<C3 T, C4 U> void f5(const T*, U&); </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)