Util: Change operators to the evaluated order

This commit is contained in:
Riyyi
2021-09-17 19:13:57 +02:00
parent 26ceceeba5
commit cc7252f94d
2 changed files with 7 additions and 5 deletions
+4 -4
View File
@@ -100,12 +100,12 @@ System System::operator|(System rhs)
return rhs; return rhs;
} }
System System::operator||(System rhs) System System::operator&&(System rhs)
{ {
auto lhs = *this; auto lhs = *this;
lhs.exec(); lhs.exec();
if (lhs.m_status == 0) { if (lhs.m_status > 0) {
return lhs; return lhs;
} }
@@ -116,12 +116,12 @@ System System::operator||(System rhs)
return rhs; return rhs;
} }
System System::operator&&(System rhs) System System::operator||(System rhs)
{ {
auto lhs = *this; auto lhs = *this;
lhs.exec(); lhs.exec();
if (lhs.m_status > 0) { if (lhs.m_status == 0) {
return lhs; return lhs;
} }
+3 -1
View File
@@ -29,10 +29,12 @@ public:
System operator()(const std::vector<std::string>& arguments); System operator()(const std::vector<std::string>& arguments);
System operator()(const std::vector<std::string_view>& arguments); System operator()(const std::vector<std::string_view>& arguments);
// Operator order
// + -> | -> && -> ||
System operator+(System rhs); System operator+(System rhs);
System operator|(System rhs); 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<std::string>& arguments); void print(const std::vector<std::string>& arguments);