Saturday 15 March 2014

c++ - Why is the typeid name of this factory function built CRTP class not as expected? -


I have a factory function that makes an example of an object class. Object class gets from std :: enable_shared_from_this The factory function creates an interim class that receives the object to create it.

When I output type object.name () to the object class, I get an unexpected result.

The full example is here and it has been tested with GCC-4.9.2 and Claig-3.5:

There is a factory function:

  Classroom ObjectBuilder {Public: Template & lt; Typename t, typename ... Args & gt; Fixed std :: shared_ptr & lt; T & gt; Make-Object (erg & amp; algs) {Structure Access: Public T} (Access (RGS & AG ... Algés): T (STD :: Forward & Lt; ARGEE & gt; (RGS) ... ) {// blank}}; // call t producer std :: shared_ptr & lt; T & gt; Ob = std :: make_shared & lt; Login & gt; (Std :: forward & lt; Ergas & gt; (Args) ...); Return ob; }}; Template & lt; Typename t, typename ... Args & gt; Fixed std :: shared_ptr & lt; T & gt; Make_object (Args & ... args) {Return ObjectBuilder :: make_object & lt; T & gt; (Std :: forward & lt; Ergas & gt; (Args) ...); }  

Here is an object class:

  class object: public std :: enable_shared_from_this & lt; Object & gt; {Friends Class Object Builder; Public: Virtual ~ Object () {} std :: type_info const & amp; GetTypeInfo () {return typeid (* this); }  Protected Object() {} };  

Creating an object and output it to its typical name:

  std :: shared_ptr  GetTypeInfo () .name ()) & lt; & Lt; Std :: endl;  

I hope to output one:

  ObjectBuilder :: make_object & lt; Object & gt; () :: Access  

Instead of a digital output:

  std :: shared_ptr  

Why is there a std :: shared_ptr in the beginning? What does this represent?

Besides an interesting / maybe related side note: TIFF is capable of reducing production, but GCC is not. The condensate output is:

  ZN13 objectbuilder 11 mace_object Ii object IEEEEST10 shaver_ctic IT_EDpOT0_E6 access  


No comments:

Post a Comment