From cc7252f94daa1875ff130b1cd60e3d0f5d3b12de Mon Sep 17 00:00:00 2001 From: Riyyi Date: Fri, 17 Sep 2021 19:13:57 +0200 Subject: [PATCH] Util: Change operators to the evaluated order --- src/util/system.cpp | 8 ++++---- src/util/system.h | 4 +++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/util/system.cpp b/src/util/system.cpp index 6f39c66..b8c1246 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -100,12 +100,12 @@ System System::operator|(System rhs) return rhs; } -System System::operator||(System rhs) +System System::operator&&(System rhs) { auto lhs = *this; lhs.exec(); - if (lhs.m_status == 0) { + if (lhs.m_status > 0) { return lhs; } @@ -116,12 +116,12 @@ System System::operator||(System rhs) return rhs; } -System System::operator&&(System rhs) +System System::operator||(System rhs) { auto lhs = *this; lhs.exec(); - if (lhs.m_status > 0) { + if (lhs.m_status == 0) { return lhs; } diff --git a/src/util/system.h b/src/util/system.h index 796ac1c..768ea2d 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -29,10 +29,12 @@ public: System operator()(const std::vector& arguments); System operator()(const std::vector& arguments); + // Operator order + // + -> | -> && -> || System operator+(System rhs); System operator|(System rhs); - System operator||(System rhs); System operator&&(System rhs); + System operator||(System rhs); void print(const std::vector& arguments);