Browse Source

Util: Change operators to the evaluated order

master
Riyyi 3 years ago
parent
commit
cc7252f94d
  1. 8
      src/util/system.cpp
  2. 4
      src/util/system.h

8
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;
}

4
src/util/system.h

@ -29,10 +29,12 @@ public:
System operator()(const std::vector<std::string>& 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);
void print(const std::vector<std::string>& arguments);

Loading…
Cancel
Save