-
-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed #264: Wrap BinaryOperators in their according parentheses.
This goes not only for `BinaryOperators`in fold expressions. All expressions with a `BinaryOperator` are now wrapped. While processing #264 there was another error with the `TypePrinter` regarding the lambdas `auto` parameter which is fixed by this patch as well.
- Loading branch information
1 parent
afb2d45
commit bb123e0
Showing
20 changed files
with
384 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// + - * / % ^ & | = < > << >> += -= *= /= %= ^= &= |= <<= >>= == != <= >= && || , .* ->* | ||
|
||
// Tests for some of the 32 operators | ||
|
||
template<typename... Args> | ||
constexpr auto plus(Args... args) { return (... + args); } | ||
|
||
template<typename... Args> | ||
constexpr auto minus(Args... args) { return (... - args); } | ||
|
||
template<typename... Args> | ||
constexpr auto times(Args... args) { return (... * args); } | ||
|
||
template<typename... Args> | ||
constexpr auto div(Args... args) { return (... / args); } | ||
|
||
template<typename... Args> | ||
constexpr auto mod(Args... args) { return (... % args); } | ||
|
||
template<typename... Args> | ||
constexpr auto bitwiseXOr(Args... args) { return (... ^ args); } | ||
|
||
template<typename... Args> | ||
constexpr auto bitwiseAnd(Args... args) { return (... & args); } | ||
|
||
template<typename... Args> | ||
constexpr auto bitwiseOr(Args... args) { return (... | args); } | ||
|
||
|
||
// = | ||
|
||
template<typename... Args> | ||
constexpr auto lt(Args... args) { return (... < args); } | ||
|
||
template<typename... Args> | ||
constexpr auto gt(Args... args) { return (... > args); } | ||
|
||
|
||
template<typename... Args> | ||
constexpr auto logicalAnd(Args... args) { return (... && args); } | ||
|
||
template<typename... Args> | ||
constexpr auto logicalOr(Args... args) { return (... ||args); } | ||
|
||
template<typename... Args> | ||
constexpr auto comma(Args... args) { return (... , args); } | ||
|
||
int main() | ||
{ | ||
static_assert(6 == plus(1,2,3)); | ||
static_assert(1 == minus(6,2,3)); | ||
static_assert(18 == times(3,2,3)); | ||
static_assert(3 == div(18,2,3)); | ||
static_assert(0 == mod(18,4,2)); | ||
static_assert(0b00'011 == bitwiseXOr(0b11'101, 0b11'010, 0b00'100)); | ||
static_assert(0b00'010 == bitwiseAnd(0b11'010, 0b11'010, 0b00'010)); | ||
static_assert(0b11'111 == bitwiseOr(0b11'001, 0b11'010, 0b00'100)); | ||
|
||
// = | ||
|
||
static_assert(false == lt(1,2,0)); | ||
static_assert(false == gt(1,2,1)); | ||
|
||
|
||
static_assert(false == logicalAnd(true, true, true, false)); | ||
static_assert(true == logicalOr(true, true, true, false)); | ||
|
||
static_assert(4 == comma(1,2,3,4)); | ||
|
||
// Verify that we do not introduce parens here. | ||
int x = 4; | ||
x /= 2; | ||
} | ||
|
Oops, something went wrong.