| Start | ||||||||
|---|---|---|---|---|---|---|---|---|
| Unary Folds Unary folds are used to fold parameter packs (opens new window) over a specific operator. There are 2 kinds of unary folds: Here is an example |
||||||||
| Binary Folds Binary folds are basically unary folds (opens new window), with an extra argument. There are 2 kinds of binary folds: Here is an example: |
||||||||
| Folding over a comma It is a common operation to need to perform a particular function over each element in a parameter pack. With C++11, the best we can do is: But with a fold expression, the above simplifies nicely to: No cryptic boilerplate required. RemarksFold Expressions are supported for the following operators | | | | | | | | | | | | |---|---|---|---|---|---|---|---|---|--- |+|-||/|%|\ˆ|&|||<<|>>|| |+=|-=|=|/=|%=|\ˆ=|&=||=|<<=|>>=|=| |==|!=|<|>|<=|>=|&&||||,|.|->| When folding over an empty sequence, a fold expression is ill-formed, except for the following three operators:
|
Read Article
https://develop.horje.com/learn/1434/reference