🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2655

Re: Q: RTTI and new??

#2655
From: David Vandevoorde
Date: Mon, 20 Nov 1995 16:34
35 lines
2097 bytes
>>>>> "MG" == Michael R Gile <gilem@rpi.edu> writes:
[...]
MG> as I said below, this is what I currently do. However, the
MG> application which I am working with uses template container
MG> classes.  In order to make these containers, every class of every
MG> derivation tree of which there is a container must include these
MG> clone classes.  This is a definite source for potential errors,
MG> since all you have to do is forget to create the clone member, and
MG> you have a problem.  For my purposes it would be suffient to even
MG> know the size of the type which typeinfo represents.  I just don't
MG> see the point in knowing the type, if you can't do anything with
MG> it but compare it to another object.
[...]

You can always check that the clone() member was successful:

	template<typename T> inline
	T&
	clone(T const& original) {
	    T& duplicate = original.clone();
	    assert(typeid(original) == typeid(duplicate));
	}

BTW, it's not too hard to achieve non-invasive clone-like 
functionality using the `type_info' class (the `before()'
member helps too); you'd still need to register clonable
types with something like:

	register_clonable_type<my_new_type>();

	Daveed

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <VANDEVOD.95Nov19231125@avs.cs.rpi.edu>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <48i6qu$1825@litecdev.eng.rpi.edu> <martelli.816806336@cadlab> <48oeqi$tu3@litecdev.eng.rpi.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: vandevod@cs.rpi.edu (David Vandevoorde)
Newsgroups: comp.std.c++
Subject: Re: Q: RTTI and new??
Date: 20 Nov 1995 16:34:51 GMT
Organization: RPI Computer Science
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <VANDEVOD.95Nov19231125@avs.cs.rpi.edu>
References: <48i6qu$1825@litecdev.eng.rpi.edu> <martelli.816806336@cadlab>
 <48oeqi$tu3@litecdev.eng.rpi.edu>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: avs.cs.rpi.edu
In-Reply-To: gilem@rpi.edu's message of 20 Nov 1995 00:03:59 GMT
Content-Length: 1190
X-Lines: 31
Originator: clamage@taumet