TypeNumber

Files CCore/inc/TypeNumber.h CCore/src/TypeNumber.cpp

TypeNumber is a tool to convert a type into a number. Different types have different associated numbers. This feature can be used for the quick type comparison and the type reporting. To be used with this feature a type must have an associated Unid.


class TypeNumber
 {
   ulen number;

   ....

  public:
   
   ulen get() const { return number; }
   
   bool operator == (TypeNumber obj) const { return number==obj.number; }
   
   bool operator != (TypeNumber obj) const { return number!=obj.number; }
   
   template <class ... TT>
   bool oneOf() const;
 };

TypeNumber is a lightweight type number class. It folds the type number.

get() returns the type number itself.

== and != operators can be used to compare objects.

oneOf() returns true, if the number is a number of one of types from the given type list.


template <class T>
class TypeNumberOf : public TypeNumber
 {
   ....
   
  public:
  
   TypeNumberOf();
 };

And this derived class is a type number constructor for the given type.


TypeNumber<T>()==TypeNumber<S>() iff T==S