Questions tagged [rtti]

RTTI stands for Run-Time Type Information, it is also known as reflection; it allows access to compile-time data at run-time.

RTTI refers to the ability of the system to report on the dynamic type of an object and to provide information about that type at runtime (as opposed to at compile time). When utilized consistently, it can be a powerful tool to ease the work of the programmer in managing resources, or as the basis for writing reflective code. Further explanation can be found on Wikipedia

824 questions
11
votes
1 answer

How to compile with different compile options for different files in CMAKE?

I have a project like this: |--CMakeLists.txt(1) |--File1.cpp -W -W-all |--Folder1 |--CMakeLists.txt(2) |--File2.cpp -W -W-all -fno-rtti As you can see above, File2.cpp needs to compile with -fno-rtti whereas the other files should compile…
Utkarsh Kumar
  • 567
  • 1
  • 5
  • 17
11
votes
2 answers

TRTTIContext multi-thread issue

Everything I've read indicates that TRTTIContext is thread-safe. However, TRTTIContext.FindType seems to fail (returns nil) occasionally when multithreading. Using a TCriticalSection around it fixes the issue. Note that I'm using XE6, and the…
Griffyn
  • 173
  • 1
  • 11
10
votes
1 answer

Delphi XE: Where is my TValue.Equals()?

It seems that one, in my opinion mandatory method is missing from TValue; TValue.Equals(TValue). So whats a fast and decent way of comparing 2 TValues, preferably without the use of TValue.ToString(), which allows false matches between variants,…
Marius
  • 3,043
  • 1
  • 15
  • 24
10
votes
4 answers

avoiding RTTI in OO design

I recently saw an OO design question on some forum and started thinking of using RTTI. However this must be bad design but I am unable to think of an alternative. Here is the simple question : Create a C++ program for the following scenario using…
vjain27
  • 3,514
  • 9
  • 41
  • 60
10
votes
2 answers

Can RTTI interrogate types from project code at designtime?

I would like to use RTTI to examine the types contained within project source files at designtime rather than runtime. To the best of my knowledge this is unsupported but the discussion in the comments of this question indicate that it is possible…
LachlanG
  • 4,047
  • 1
  • 23
  • 35
10
votes
3 answers

Creating an interface implementer instance at runtime

First, a little explanation about my situation: I have a sample interface which is implemented by different classes, and these classes might not always have a shared ancestor: IMyInterface = interface …
vcldeveloper
  • 7,399
  • 2
  • 33
  • 39
10
votes
4 answers

C++: emulating RTTI

I've got a class hierarchy as this one: class A { } // class AA : A { } // A class AAA : AA { } // / \ class AAB : AA { } …
peoro
  • 25,562
  • 20
  • 98
  • 150
10
votes
5 answers

delphi xe disable RTTI

i have use delphi xe recently but exe size is very big because of rtti(i think) howto remove rtti , and can i make my application size as small as delphi 2009 application(490 kb) without comprssion; and what is the use of rtti
Vibeeshan Mahadeva
  • 7,147
  • 8
  • 52
  • 102
10
votes
3 answers

Why is dynamic_cast evil or not ? Should I use dynamic_cast in this case?

Some say the use of dynamic_cast often means bad design and dynamic_cast can be replaced by virtual functions why is the use of dynamic_cast considered bad design? Suppose I have I function name func(Animal* animal, int animalType) , the…
Gary Gauh
  • 4,984
  • 5
  • 30
  • 43
10
votes
1 answer

std::type_info::hash_code() uniqueness and the meaning of "should"

Is it meant to be guaranteed that same std::type_info::hash_code() values imply same types? Cplusplus.com seems to claim so: This function returns the same value for any two type_info objects that compare equal, and different values for distinct…
Stephen Lin
  • 5,470
  • 26
  • 48
10
votes
7 answers

What is the best way to serialize Delphi application configuration?

I will answer this question myself, but feel free to provide your answers if you are faster than me or if you don't like my solution. I just came up with this idea and would like to have some opinions on that. Goal: a configuration class that is…
jpfollenius
  • 16,456
  • 10
  • 90
  • 156
9
votes
5 answers

When and why is an std::__non_rtti_object exception generated?

I'm using Visual Studio and performing a valid dynamic cast. RTTI is enabled. Edit : Updated the code to be more realistic struct base { virtual base* Clone() { base* ptr = new base; CopyValuesTo( ptr ); return…
Carl
  • 43,122
  • 10
  • 80
  • 104
9
votes
1 answer

How to use SuperObject to invoke methods that uses an Object as parameter in Delphi?

We can use the SuperObject library to invoke methods of a certain object by its name and giving its parameters as a json string using the SOInvoker method like in this answer I'd like to know how do I send a created object as a parameter. I tried to…
Haruki
  • 674
  • 1
  • 9
  • 24
9
votes
1 answer

Enable Delphi XE RTTI only for some classes

I'm trying to have RTTI enabled only for a subset of my classes. The reason is that for those classes for which I want RTTI, I want RTTI on public methods too, but if that is enabled project-wide, then all public methods from all classes get into…
Eric Grange
  • 5,931
  • 1
  • 39
  • 61
9
votes
5 answers

Determining if a derived class overrides a method from a base class

class B { virtual int foo(); }; class D : public B { virtual int foo() { cout<<"D\n"; } }; int B::foo() { /* how do i tell if this->foo() is overridden by a subclass, or if it will */ /* simply recurse into B::foo()? */ …
deltamind106
  • 423
  • 3
  • 11