sherpa::EnumSet< T > Class Template Reference

Zero-overhead wrapper class for type-preserving bit sets. More...

#include <EnumSet.hxx>


Public Member Functions

 EnumSet ()
 EnumSet (const EnumSet< T > &that)
 EnumSet (const T &that)
bool operator== (const EnumSet< T > &that) const
bool operator!= (const EnumSet< T > &that) const
EnumSet< T > & operator= (const EnumSet< T > &that)
EnumSet< T > & operator|= (const EnumSet< T > &that)
EnumSet< T > & operator &= (const EnumSet< T > &that)
EnumSet< T > & operator^= (const EnumSet< T > &that)
EnumSet operator| (const EnumSet< T > &that) const
EnumSet operator & (const EnumSet< T > &that) const
EnumSet operator^ (const EnumSet< T > &that) const
EnumSet operator~ () const
bool lacks (const EnumSet< T > &that) const
 operator int BoolConversionSupport::* () const

Data Structures

struct  BoolConversionSupport


Detailed Description

template<class T>
class sherpa::EnumSet< T >

Zero-overhead wrapper class for type-preserving bit sets.

This is a simply horrible hack. It started as a workaround for the fact that enums do not provide type-preserving bit sets, because (a|b) yields int rather than the underlying enumeration type. What we do here is to define EnumSet over an underlying arithmetic type. If you instantiate it over an enum, it will only permit initializers over that enum, which will have the desired effect that the enumerands can serve as bit labels for purposes of documentation.

That isn't hard to fix, except that you can run out of enumeration values -- it is surprising how many bit sets turn out to require 33 bits on a 32-bit machine.

DO NOT attempt to instantiate one of these over an underlying integral type. It will produce an error in the template expander because of the non-member overloading of the binary operators on the underlying types! I need to do some template magic to make that overloading more selective, and I haven't had time yet.

Definition at line 69 of file EnumSet.hxx.


Constructor & Destructor Documentation

template<class T>
sherpa::EnumSet< T >::EnumSet (  )  [inline]

Definition at line 92 of file EnumSet.hxx.

template<class T>
sherpa::EnumSet< T >::EnumSet ( const EnumSet< T > &  that  )  [inline]

Definition at line 97 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
sherpa::EnumSet< T >::EnumSet ( const T &  that  )  [inline]

Definition at line 103 of file EnumSet.hxx.


Member Function Documentation

template<class T>
bool sherpa::EnumSet< T >::lacks ( const EnumSet< T > &  that  )  const [inline]

Definition at line 187 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
EnumSet sherpa::EnumSet< T >::operator & ( const EnumSet< T > &  that  )  const [inline]

Definition at line 162 of file EnumSet.hxx.

template<class T>
EnumSet<T>& sherpa::EnumSet< T >::operator &= ( const EnumSet< T > &  that  )  [inline]

Definition at line 137 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
sherpa::EnumSet< T >::operator int BoolConversionSupport::* (  )  const [inline]

Definition at line 231 of file EnumSet.hxx.

template<class T>
bool sherpa::EnumSet< T >::operator!= ( const EnumSet< T > &  that  )  const [inline]

Definition at line 116 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
EnumSet<T>& sherpa::EnumSet< T >::operator= ( const EnumSet< T > &  that  )  [inline]

Definition at line 123 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
bool sherpa::EnumSet< T >::operator== ( const EnumSet< T > &  that  )  const [inline]

Definition at line 110 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
EnumSet sherpa::EnumSet< T >::operator^ ( const EnumSet< T > &  that  )  const [inline]

Definition at line 170 of file EnumSet.hxx.

template<class T>
EnumSet<T>& sherpa::EnumSet< T >::operator^= ( const EnumSet< T > &  that  )  [inline]

Definition at line 144 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
EnumSet sherpa::EnumSet< T >::operator| ( const EnumSet< T > &  that  )  const [inline]

Definition at line 154 of file EnumSet.hxx.

template<class T>
EnumSet<T>& sherpa::EnumSet< T >::operator|= ( const EnumSet< T > &  that  )  [inline]

Definition at line 130 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.

template<class T>
EnumSet sherpa::EnumSet< T >::operator~ (  )  const [inline]

Definition at line 179 of file EnumSet.hxx.

References sherpa::EnumSet< T >::repr.


The documentation for this class was generated from the following file:
Generated on Fri Feb 10 07:59:21 2012 for BitC Compiler by  doxygen 1.4.7