comp.lang.ada
 help / color / mirror / Atom feed
From: kcline17@hotmail.com (Kevin Cline)
Subject: Re: worth the hassle?
Date: 22 Jul 2002 22:56:18 -0700
Date: 2002-07-23T05:56:18+00:00	[thread overview]
Message-ID: <ba162549.0207222156.525e9fee@posting.google.com> (raw)
In-Reply-To: RYX_8.20976$927.2872@nwrddc01.gnilink.net

"Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net> wrote in message news:<RYX_8.20976$927.2872@nwrddc01.gnilink.net>...
> "Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
> news:uheirlk4z.fsf@gsfc.nasa.gov...
> > My own opinion is that supporting limited types is a requirement for
> > any general-purpose container.
> >
> > This is probably one reason why Ada will never be as popular as C++;
> > in C++, you don't have to make this kind of decision :).
> 
> Why isn't this a C++ issue as well? Certainly it is possible to declare the
> C++ equivalent of a limited type, i.e. a type for which assignment is not
> available.

It is a C++ issue, but it is now fairly standard practice to write
containers that only require the contained class to have a copy constructor.
The STL is implemented in this way.  The containers allocate raw memory,
and use placement-new and explicit destructor calls to create and
destroy objects, like this:

char* mem = new char[sizeof T];  // get some memory
T* t = new T(mem, *oldT); // copy-construct object on mem
t->~T();                  // destroy object

Not the sort of thing one would want to see sprinkled through
an application, but fine if encapsulated in a container class.



  parent reply	other threads:[~2002-07-23  5:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-07-22 16:56 worth the hassle? chris.danx
2002-07-22 17:17 ` Wes Groleau
2002-07-22 17:45   ` chris.danx
2002-07-22 19:05     ` Wes Groleau
2002-07-22 17:56 ` chris.danx
2002-07-22 18:06   ` Stephen Leake
2002-07-22 21:06     ` chris.danx
2002-07-23 12:16       ` chris.danx
2002-07-23 12:36       ` chris.danx
2002-07-23 15:00       ` Stephen Leake
2002-07-23 15:15         ` chris.danx
2002-07-23 15:36           ` chris.danx
2002-07-23 16:19             ` Peter Hermann
2002-07-23 16:41               ` chris.danx
2002-07-23 17:35               ` Stephen Leake
2002-07-22 17:58 ` Stephen Leake
2002-07-22 18:15   ` Frank J. Lhota
2002-07-22 19:56     ` Stephen Leake
2002-07-23  5:56     ` Kevin Cline [this message]
2002-07-22 18:44   ` chris.danx
2002-07-23  5:39   ` Kevin Cline
2002-07-23 15:05     ` Stephen Leake
2002-07-23 18:34   ` Perhaps we keep lists elements private and adjust the elements to fit? Chad R. Meiners
2002-07-23 19:23     ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox