C++ (@c_plus_plus) header
C++ (@c_plus_plus) profile picture

Twitter link for the official C++ Facebook page

World
Joined September 2009
Photo by C++ (@c_plus_plus)Photo by C++ (@c_plus_plus)Photo by C++ (@c_plus_plus)Photo by C++ (@c_plus_plus)Photo by C++ (@c_plus_plus)
Include

Only show posts containing:

Exclude

Hide posts containing:

Time range
-
Minimum likes
Quick C++ quiz: what does this do? #include <stdio.h> void f(float&&) { puts("float"); } void f(int&&) { puts("int"); } void g(auto &&...v) { (f(v), ...); } int main() { g(1.0f, 2); }
37%Prints "float" then "int"
12%Prints "int" then "float"
26%Order is unspecified
25%Ill-formed or UB
796 votes • Final results
21
27
3
127
Replying to @journeymanped
well, the alternative in the scenarios where it is usually used is to have a full-blown cast. Would you rather your users write an ugly cast in front of a lambda or just explain them the + trick?
2
1
2
New Year Quiz: how many of you C++ buffs know about and used a + in front of a captureless lambda to trigger conversion to function pointer? Like the post if you did! Curious how popular this trick is for surface syntax design of a library...
16
7
1
74
The theoretical foundation of C++ generic programming. Now free elementsofprogramming.com/ (Caveat: not a beginner's tutorial) elementsofprogramming.com/
2
28
2
72