Reputation: 2784
In C++ you would overload operator bool() const
. In Python, you would override __bool__()
.
What can I do in D to achieve the same result? I can't find any examples on this.
Upvotes: 3
Views: 95
Reputation: 25605
Look for "Boolean Operations" on this page: http://dlang.org/operatoroverloading.html
You implement a member function like:
bool opCast(T : bool)() {
return bool_result;
}
Upvotes: 4