[GiNaC-devel] tinfo

Christian Bauer cb at cebix.net
Tue Nov 22 09:47:25 CET 2005


Jens Vollinga wrote:
> But tinfo could become a char*, couldn't it?

How about:

typedef const void * tinfo_t;
struct tinfo_static_t {};

class SOMECLASS {
public:
     static const tinfo_static_t tinfo_static;

     SOMECLASS() : tinfo_key(&tinfo_static) {}
     SOMECLASS(tinfo_t ti) : tinfo_key(ti) {}

     tinfo_t tinfo() const { return tinfo_key; }

protected:
     tinfo_t tinfo_key;
};

const tinfo_static_t SOMECLASS::tinfo_static = {};

template<class T>
inline bool is_exactly_a(const SOMECLASS & obj)
{
     return obj.tinfo() == &T::tinfo_static;
}

This looks promising. No explicit specializations of is_exactly_a<> are 
needed any more.

Bye,
Christian

-- 
   / Physics is an algorithm
\/ www.cebix.net



More information about the GiNaC-devel mailing list