Issue 3563: Supporting typedefs for _var types? (cxx_revision) Source: Triodia Technologies Pty Ltd (Mr. Michi Henning, michi(at)triodia.com) Nature: Uncategorized Issue Severity: Summary: quite some time ago, we added the _var_type and _ptr_type definitions to proxies to make it easier to write templates. Similarly, we have the _whatever_seq typedefs for recursive structs and unions, to avoid problems with anonymous types. What's missing at the moment is a similar feature for _var types. When I'm writing a template that does it's job in terms of _var types, I also quite often want to do something to the underlying target type of the _var. However, I can't do that unless I pass in an extra template parameter (which, in turn, doesn't always work if I also want to use STL standard binders and such...) So, why not add a typedef for the target type to every _var type? Resolution: Revised Text: Actions taken: April 14, 2000: duplicate -- closed Discussion: End of Annotations:===== Date: Fri, 14 Apr 2000 15:16:51 +1000 (EST) From: Michi Henning Reply-To: C++ Revision Task Force To: C++ Revision Task Force cc: issues@omg.org Subject: Supporting typedefs for _var types? Message-ID: Organization: Object Oriented Concepts MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-UIDL: >?D!!+ND!!I'N!!LNR!! Hi, quite some time ago, we added the _var_type and _ptr_type definitions to proxies to make it easier to write templates. Similarly, we have the _whatever_seq typedefs for recursive structs and unions, to avoid problems with anonymous types. What's missing at the moment is a similar feature for _var types. When I'm writing a template that does it's job in terms of _var types, I also quite often want to do something to the underlying target type of the _var. However, I can't do that unless I pass in an extra template parameter (which, in turn, doesn't always work if I also want to use STL standard binders and such...) So, why not add a typedef for the target type to every _var type? Something like: class whatever_var { public: typedef whatever * target_type; // ... }; That way, if I have a template with a template parameter T, I can use T::target_type inside the implementation of the template to generically get at whatever type the _var points at. This is definitely backward compatible, and has no run-time overhead. Opinions? Cheers, Michi. -- Michi Henning +61 7 3891 5744 Object Oriented Concepts +61 4 1118 2700 (mobile) Suite 4, 904 Stanley St +61 7 3891 5009 (fax) East Brisbane 4169 michi@ooc.com.au AUSTRALIA http://www.ooc.com.au/staff/michi-henning.html Sender: jbiggar@corvette.floorboard.com Message-ID: <38F74646.B72F28AB@floorboard.com> Date: Fri, 14 Apr 2000 09:24:38 -0700 From: Jonathan Biggar X-Mailer: Mozilla 4.7 [en] (X11; U; SunOS 5.6 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: C++ Revision Task Force Subject: Re: Supporting typedefs for _var types? References: Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii X-UIDL: #=Wd9Ma1e9o[R!!lG > Hi, > > quite some time ago, we added the _var_type and _ptr_type > definitions > to proxies to make it easier to write templates. Similarly, we have > the _whatever_seq typedefs for recursive structs and unions, to > avoid > problems with anonymous types. > > What's missing at the moment is a similar feature for _var types. > When I'm writing a template that does it's job in terms of _var > types, > I also quite often want to do something to the underlying target > type > of the _var. However, I can't do that unless I pass in an extra > template > parameter (which, in turn, doesn't always work if I also want to use > STL standard binders and such...) > > So, why not add a typedef for the target type to every _var type? > Something like: > > class whatever_var { > public: > typedef whatever * target_type; > // ... > }; > > That way, if I have a template with a template parameter T, I can > use > T::target_type inside the implementation of the template to > generically get > at whatever type the _var points at. > > This is definitely backward compatible, and has no run-time > overhead. Seems reasonable, although I think your example is wrong. Shouldn't it be: typedef whatever target_type; instead? If the typedef is not a pointer, it is easy to name the pointer type, but if the typedef is a pointer type, it's not possible to name the pointed to type. -- Jon Biggar Floorboard Software jon@floorboard.com jon@biggar.org Date: Sat, 15 Apr 2000 06:04:31 +1000 (EST) From: Michi Henning To: Jonathan Biggar cc: C++ Revision Task Force Subject: Re: Supporting typedefs for _var types? In-Reply-To: <38F74646.B72F28AB@floorboard.com> Message-ID: Organization: Object Oriented Concepts MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-UIDL: @*Y!!GG8!!F(Ae9IA_!! On Fri, 14 Apr 2000, Jonathan Biggar wrote: > Seems reasonable, although I think your example is wrong. Shouldn't it > be: > > typedef whatever target_type; > > instead? > > If the typedef is not a pointer, it is easy to name the pointer type, > but if the typedef is a pointer type, it's not possible to name the > pointed to type. Sure. That was just an example. Obviously, the definition of target_type would have to different (and hopefully correct) for each _var type... ;-) Cheers, Michi. -- Michi Henning +61 7 3891 5744 Object Oriented Concepts +61 4 1118 2700 (mobile) Suite 4, 904 Stanley St +61 7 3891 5009 (fax) East Brisbane 4169 michi@ooc.com.au AUSTRALIA http://www.ooc.com.au/staff/michi-henning.html