The "null" ButtonHandle and TypeHandle now evaluate to false

This commit is contained in:
rdb 2014-07-29 11:15:12 +00:00
parent 82e4500d2a
commit 24d705b031
4 changed files with 26 additions and 2 deletions

View File

@ -275,6 +275,17 @@ none() {
return _none; return _none;
} }
////////////////////////////////////////////////////////////////////
// Function: TypeHandle::operator bool
// Access: Published
// Description: TypeHandle::none() evaluates to false, everything
// else evaluates to true.
////////////////////////////////////////////////////////////////////
INLINE TypeHandle::
operator bool () const {
return (_index != 0);
}
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: get_best_parent_from_Set // Function: get_best_parent_from_Set
// Access: Published // Access: Published
@ -295,4 +306,3 @@ INLINE int TypeHandle::get_best_parent_from_Set(const std::set< int > &legal_va
} }
return -1; return -1;
} }

View File

@ -146,6 +146,7 @@ PUBLISHED:
INLINE int get_index() const; INLINE int get_index() const;
INLINE void output(ostream &out) const; INLINE void output(ostream &out) const;
INLINE static TypeHandle none(); INLINE static TypeHandle none();
INLINE operator bool () const;
private: private:
int _index; int _index;

View File

@ -152,3 +152,14 @@ INLINE ButtonHandle ButtonHandle::
none() { none() {
return _none; return _none;
} }
////////////////////////////////////////////////////////////////////
// Function: ButtonHandle::operator bool
// Access: Published
// Description: ButtonHandle::none() evaluates to false, everything
// else evaluates to true.
////////////////////////////////////////////////////////////////////
INLINE ButtonHandle::
operator bool () const {
return (_index != 0);
}

View File

@ -51,6 +51,8 @@ PUBLISHED:
INLINE void output(ostream &out) const; INLINE void output(ostream &out) const;
INLINE static ButtonHandle none(); INLINE static ButtonHandle none();
INLINE operator bool () const;
private: private:
int _index; int _index;
static ButtonHandle _none; static ButtonHandle _none;