Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Jacob Carlborg
On 2010-05-23 23.36, Andrei Alexandrescu wrote: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are nonessential. Here they are: 1. Using a class

Re: struct vs. class containers

2010-05-24 Thread Jacob Carlborg
On 2010-05-24 00.06, bearophile wrote: Andrei Alexandrescu: 1. Using a class makes implementing members easier because there's no need to do work through an additional member. With a struct, you need a pimpl approach. For example: struct Array { struct Impl { ... }

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Steven Schveighoffer
On Sun, 23 May 2010 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Andrei Alexandrescu
On 05/24/2010 10:58 AM, Steven Schveighoffer wrote: On Sun, 23 May 2010 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter.

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a

2010-05-24 Thread bearophile
Andrei Alexandrescu: Oh, and the monitor isn't needed so that's an unused word there. I'd forgotten about it. It can be invented some kind of property or pragma for classes, to remove the monitor from all the instances of that class. I don't know if this can be done, if it is useful, and if

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-24 Thread Steven Schveighoffer
On Mon, 24 May 2010 12:18:02 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: On 05/24/2010 10:58 AM, Steven Schveighoffer wrote: On Sun, 23 May 2010 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org wrote: I've thought for a very long time about the class

struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-23 Thread Andrei Alexandrescu
I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are nonessential. Here they are: 1. Using a class makes implementing members easier because there's

Re: struct vs. class containers

2010-05-23 Thread bearophile
Andrei Alexandrescu: 1. Using a class makes implementing members easier because there's no need to do work through an additional member. With a struct, you need a pimpl approach. For example: struct Array { struct Impl { ... } Impl * impl; ...

Re: struct vs. class containers (was: Re: dcollections 1.0 and 2.0a beta released)

2010-05-23 Thread Michel Fortin
On 2010-05-23 17:36:52 -0400, Andrei Alexandrescu seewebsiteforem...@erdani.org said: I've thought for a very long time about the class vs. struct choice in a container, and I came to a startling conclusion: it (almost) doesn't matter. Could be either, and the tradeoffs involved are

Re: struct vs. class containers

2010-05-23 Thread Andrei Alexandrescu
On 05/23/2010 05:06 PM, bearophile wrote: Andrei Alexandrescu: 1. Using a class makes implementing members easier because there's no need to do work through an additional member. With a struct, you need a pimpl approach. For example: struct Array { struct Impl { ... }