New tinfo mechanism
Dear All, I wish to identify an object by the new tinfo mechanism. I used the naive expression ex_to<basic>(other).return_type_tinfo() However for ncmul, for example, it still returns the type of the first non-commutative factor, not make_return_type_t<ncmul>() as may be expected from basic::return_type_info(). What is most correct way to get the ncmul identified? Many thanks and best wishes, Vladimir -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk -- www: http://maths.leeds.ac.uk/~kisilv/
Hello, On Tue, Oct 21, 2008 at 09:43:02AM +0100, Vladimir V. Kisil wrote:
I wish to identify an object by the new tinfo mechanism. I used the naive expression
ex_to<basic>(other).return_type_tinfo()
\begin{nitpick} I don't quite understand what was wrong with other.return_type_tinfo() \end{nitpick}
However for ncmul, for example, it still returns the type of the first non-commutative factor,
Old RTTI did the same thing.
not make_return_type_t<ncmul>() as may be expected from basic::return_type_info().
I'm very confused. Such a behaviour denies the whole point of RTTI. Why on Earth one would expect it? Anyway, both C++ RTTI ("new tinfo system") and GiNaC's custom RTTI follow the standard (see paragraph 5.2.8, "Type identification"): "2. When typeid is applied to an lvalue expression whose type is a polymorphic class type (10.3), the result refers to a type_info object representing the type of the most derived object (1.8) (that is, the dynamic type) to which the lvalue refers." So your expectation is plain wrong.
What is most correct way to get the ncmul identified?
Could you please be more specific? What does 'identify ncmul' mean? a. Check if the object is ncmul or its derived class. b. Check what is exactly the type of ncmul object. c. Something else. Or even better -- post the fragment of a (pseudo)code, explain what you expect, and what it actually does. Best regards, Alexei -- All science is either physics or stamp collecting.
Dear Alexei,
On Tue, 21 Oct 2008 14:07:27 +0400, Alexei Sheplyakov <varg@theor.jinr.ru> said: AS> Could you please be more specific?
I was looking for a minimal patch to pyGiNaC (yes, I know, you will not approve this activity ;-) to make it working with a present development branch. AS> b. Check what is exactly the type of ncmul object. Using your hint I replace all usages of tinfos with is_exactly_a<T>() function and obtained that I wanted. Many thanks and best wishes, Vladimir -- Vladimir V. Kisil email: kisilv@maths.leeds.ac.uk -- www: http://maths.leeds.ac.uk/~kisilv/
participants (2)
-
Alexei Sheplyakov
-
Vladimir V. Kisil