allow casting bitmasks to their integer type, and make sure that bool(bitmask) is False when all bits are off

This commit is contained in:
rdb 2012-03-19 09:39:43 +00:00
parent 8ba7b5d0de
commit 47f3933489

View File

@ -821,6 +821,29 @@ operator >>= (int shift) {
_word >>= shift;
}
////////////////////////////////////////////////////////////////////
// Function: BitMask::operator WType
// Access: Published
// Description: Used to cast this BitMask back into the
// underlying integer type.
////////////////////////////////////////////////////////////////////
template<class WType, int nbits>
INLINE BitMask<WType, nbits>::
operator WType () const {
return _word;
}
////////////////////////////////////////////////////////////////////
// Function: BitMask::operator bool
// Access: Published
// Description: Will return true, unless all bits are off.
////////////////////////////////////////////////////////////////////
template<class WType, int nbits>
INLINE BitMask<WType, nbits>::
operator bool () const {
return (_word != 0);
}
////////////////////////////////////////////////////////////////////
// Function: BitMask::get_key
// Access: Published