Skip to content

Commit

Permalink
Merge pull request #5 from tirimatangi/empty
Browse files Browse the repository at this point in the history
Add empty()
  • Loading branch information
tirimatangi authored Dec 16, 2021
2 parents 4886b7c + f886476 commit d95f5b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
8 changes: 8 additions & 0 deletions examples/unit-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,14 @@ void test_a()
// auto expr4 = Expression{[i=10](int k) { return i * k ; }};
// auto expr5 = Expression();
}
{
vector<int> e {1,2,3};
auto expr = Expression{[](int i){ return i+1; }, ref(e)};
auto exprexpr = 1.5 * expr + expr;
cout << "e=" << e << ", exprexpr="<<exprexpr() << "empty=" << exprexpr.empty() << "\n";
e.clear();
cout << "e=" << e << ", exprexpr="<<exprexpr() << "empty=" << exprexpr.empty() << "\n";
}
} // test_a


Expand Down
5 changes: 5 additions & 0 deletions include/LazyExpression/LazyExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ class VariadicExpression
return std::get<0>(_args).size();
}

bool empty() const noexcept
{
return size() == 0;
}

// Returns true if argument pack Args... has at least one argument which itself is an expression.
static constexpr bool hasExpressionArguments()
{
Expand Down

0 comments on commit d95f5b4

Please sign in to comment.