From 47f39334899ef3e743859c5daadafb2997477471 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 19 Mar 2012 09:39:43 +0000 Subject: [PATCH] allow casting bitmasks to their integer type, and make sure that bool(bitmask) is False when all bits are off --- panda/src/putil/bitMask.I | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/panda/src/putil/bitMask.I b/panda/src/putil/bitMask.I index 9c7de08321..53bdbe48fd 100644 --- a/panda/src/putil/bitMask.I +++ b/panda/src/putil/bitMask.I @@ -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 +INLINE BitMask:: +operator WType () const { + return _word; +} + +//////////////////////////////////////////////////////////////////// +// Function: BitMask::operator bool +// Access: Published +// Description: Will return true, unless all bits are off. +//////////////////////////////////////////////////////////////////// +template +INLINE BitMask:: +operator bool () const { + return (_word != 0); +} + //////////////////////////////////////////////////////////////////// // Function: BitMask::get_key // Access: Published