Namespaces
Variants
Views
Actions

Talk:cpp/language/fold

From cppreference.com

operator ~ is not binary; it is unary. What is it doing here? --Dannyu NDos (talk) 00:28, 17 January 2015 (PST)

no idea how it snuck in there. Thanks, edited out. --Cubbi (talk) 06:09, 17 January 2015 (PST)

[edit] pack and init can't be any expression

They must be cast-expressions. Expressing that in words is somewhat annoying, though. (Is that what "Precedence of this operator relative to either pack or init expressions is the highest (equivalent to unary operators)") is trying to express?) T. Canens (talk) 12:46, 23 November 2015 (PST)

yes, that's what I was trying to express with that phrasing: since binary ops cannot appear at the top level of a cast-expression, it looks as if the expression is parenthesized (at least the way I see it: pack +  ... + a + b parses as if pack + ... + (a + b) --Cubbi (talk) 13:18, 23 November 2015 (PST)
...and it looks like I was wrong, as clang tells me
main.cpp:5:28: error: expression not permitted as operand of fold expression
    return (args + ... + 1 + 2);
                         ~~^~~
                         (   )

so yes, needs to be fixed --Cubbi (talk) 13:21, 23 November 2015 (PST)

[edit] At the top level

What does, "at the top level", mean in, "has an operator with precedence below cast at the top level"? RobStewart (talk) 10:04, 13 December 2023 (PST)

SO covered that bit in some more detail here: https://stackoverflow.com/questions/38298565 --Cubbi (talk) 11:11, 13 December 2023 (PST)