https://isocpp.org/std/the-standard states that the working draft N4296
contains the C++14 standard plus minor editorial changes.
I noted that N4296 §5.1.3 contains a specification of "Fold expressions". I thought this to be a feature which did not make it to the official C++14 standard.
Are fold expressions part of C++14 or is this addition in N4296 one of those minor editorial changes?
C++17 brought fold expressions to the language. This interesting feature allows to write expressive code, that almost seems magical. Here is a two-posts recap on how fold expressions work (this post) and how they can improve your code (the next post).
Here is a two-posts recap on how fold expressions work (this post) and how they can improve your code (the next post). A fold expression is an instruction for the compiler to repeat the application of an operator over a variadic template pack. Let’s take an example.
With fold expressions, you can directly reduce the parameter pack with the help of the binary operator. Here is the output of the program. Now to the two variations of fold expression that result in four different forms of fold expressions. At first, fold expression can have a default value. That value depends on the binary operator.
(C++11) Reduces ( folds) a parameter pack over a binary operator. ( pack op ... ) any of the following 32 binary operators: + - * / % ^ & | = < > << >> += -= *= /= %= ^= &= |= <<= >>= == != <= >= && || , .* ->*. In a binary fold, both op s must be the same. Note that the open and closing parentheses are part of the fold expression.
N3937 is the C++14 DIS (Draft International Standard). N3936 (no longer publicly available, but can be dug out from the github repo) is N3937 with a different cover.
N4141 is the C++14 IS; it's the DIS plus some editorial changes. It's not publicly available.
N4140 is the pre-Urbana working draft; it's N4141 plus more editorial changes.
N4296 is the post-Urbana working draft. It includes C++17 features voted in at the committee's Urbana meeting.
Fold expressions is a C++17 feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With