typeinfo

What's the lifetime of the object returned by typeid operator?

回眸只為那壹抹淺笑 提交于 2019-12-12 11:16:58
问题 If I call typeid and retrieve the address of returned type_info : const type_info* info = &( typeid( Something ) ); what's the lifetime of the object returned by typeid and how long will the pointer to that object remain valid? 回答1: However the implementation implements them, the results of typeid expressions are lvalues and the lifetime of the objects that those lvalues refer to must last until the end of the program. From ISO/IEC 14882:2003 5.2.8 [expr.typeid]: The result of a typeid

C++ (ATL) ITypeInfo.GetContainingTypeLib fails when passed live instance of VBA Class

霸气de小男生 提交于 2019-12-11 05:44:56
问题 So I asked this question in a C# context and I have set bounty over there. I have written an equivalent fragment of C++ code (to be housed within an ATL DLL project) to tap C++ developers experience as well. IDispatch has a method called GetTypeInfo() with which one can acquire a pointer to ITypeInfo. ITypeInfo itself has a method called GetContainingTypeLib which gets the containing ITypeLib (as it says). This is useful when given a CoClass instance once can get to all the other CoClasses in

What's the lifetime of memory pointed to typeinfo::name()?

 ̄綄美尐妖づ 提交于 2019-12-10 14:15:35
问题 In C++ I can use typeid operator to retrieve the name of any polymorphic class: const char* name = typeid( CMyClass ).name(); How long will the string pointed to by the returned const char* pointer available to my program? 回答1: As long as the class with rtti exists. So if you deal with single executable - forever. But for classes in a Dynamic Link Librariy it shifts a little. Potentially you can unload it. 回答2: The memory returned by type_info::name() will be available for the application's

Rust library for inspecting .rlib binaries

与世无争的帅哥 提交于 2019-12-10 13:43:39
问题 I'm looking for a way to load and inspect .rlib binaries generated by rustc. I've hunted around the standard library without much luck. My assumption is that an .rlib contains all the type information necessary to statically type check programs that "extern crate" it. rustc::metadata is where my hunt ended. I can't quite figure out if the structures available at this point in the compiler are intended as entry points for users, or if they are solely intermediate abstractions depending on a

c++filt does not demangle typeid name

馋奶兔 提交于 2019-12-10 13:23:09
问题 I am running a code on GCC C++ compiler, to output the type_info::name: #include <iostream> #include <typeinfo> using namespace std; class shape { protected: int color; public: virtual void draw() = 0; }; class Circle: public shape { protected: int color; public: Circle(int a = 0): color(a) {}; void draw(); }; void Circle::draw() { cout<<"color: "<<color<<'\n'; } class triangle: public shape { protected: int color; public: triangle(int a = 0): color(a) {}; void draw(); }; void triangle::draw(

undefined reference to `typeinfo for QCollectio...

不羁的心 提交于 2019-12-09 11:02:38
今天交叉编译qte应用程序时,遇到下面的编译链接问题: /tmp/ccWGP9rp.o:(.rodata._ZTI6QGList[typeinfo for QGList]+0x8): undefined reference to `typeinfo for QCollection' collect2: ld returned 1 exit status make: *** [hello_qt] Error 1s 一开始以为是qte库的裁剪导致部分特性功能的缺失造成了,可是找了半天也没有找到和QCollection相关的特性红,而且按照qconfig-dist.h配置编译qte库后,问题依旧。后来检查编译选项,是缺少编译选项-fno-rtti导致的,加上就好了。编译命令参考: arm-hismall-linux-g++ -ohello_qt hello_qt.cpp -DQWS -pipe -fno-rtti -fno-exceptions 选项简要说明: -pipe 使用管道代替编译中临时文件,在使用非gnu汇编工具的时候,可能有些问题 -fno-rtti 不生成带虚拟函数类的运行时类型识别(Run-Time Type Identification)功能(dynamic_cast and typeid)信息,不使用该功能时,使用该选项可以节省空间。 -fno-exceptions

Does C++11 provide hashing functions for std::type_info?

孤者浪人 提交于 2019-12-06 23:47:39
问题 I'm still working on a good solution to my One-Of-A-Type Container Problem -- and upon reflection I think it would be nice to be able to just use something like a std::map<std::type_info, boost::any> . Unfortunately, std::type_info does not define an operator< , and I think it'd be unreasonable for it to define one. However, it does seem reasonable to define a hash function for it, because you could simply use the singleton address of the std::type_info object as a reasonable "hash".

undefined reference to `typeinfo for class' [duplicate]

拟墨画扇 提交于 2019-12-05 13:28:01
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: g++ undefined reference to typeinfo Undefined symbols “vtable for …” and “typeinfo for…”? I can't use my class. class Accel { public: virtual void initialize(void); virtual void measure(void); virtual void calibrate(void); virtual const int getFlightData(byte); }; class Accel_ad : public Accel { public: Accel_ad() : Accel(){} void initialize(void) {/*code code code...*/} void measure(void) {/*measure code*/}

Does C++11 provide hashing functions for std::type_info?

一曲冷凌霜 提交于 2019-12-05 04:11:34
I'm still working on a good solution to my One-Of-A-Type Container Problem -- and upon reflection I think it would be nice to be able to just use something like a std::map<std::type_info, boost::any> . Unfortunately, std::type_info does not define an operator< , and I think it'd be unreasonable for it to define one. However, it does seem reasonable to define a hash function for it, because you could simply use the singleton address of the std::type_info object as a reasonable "hash". Therefore, you'd be able to put a std::type_info into a std::unordered_map as the key. Does C++11 provide such

C++ template name pretty print

瘦欲@ 提交于 2019-12-04 04:18:33
I have need to print indented template names for debugging purposes. For example, instead of single-line, I would like to indent name like this: boost::phoenix::actor< boost::phoenix::composite< boost::phoenix::less_eval, boost::fusion::vector< boost::phoenix::argument<0>, boost::phoenix::argument<1>, I started writing my own but is getting to be complicated. Is there an existing solution? if there is not one, can you help me to finish up my implementation? I will post it if so. Thanks this is what typeid.name looks like, boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::less