This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [setup] Why does PackageSpecification haveaprivatecopy-constructor? (Robert?)


Robert Collins wrote:
On Tue, 2004-08-31 at 14:27 +0100, Max Bowsher wrote:
Robert Collins wrote:


which is public, and should be usable.

See: http://gcc.gnu.org/bugs.html#cxx_rvalbind


I agree with you, but the C++ Standard and GCC 3.4 disagree with both of
us.

Eek.

Indeed :-)


gcc 3.x have all honoured the privateness of Foo aFoo(Foo());, and
whatever warning you are getting is probably correct.

As to the privateness of the copy constructor, I didn't comment it, but
neither did I implement it: thats an idiom I use, to cause compiler
errors when someone tries to do something that they aren't meant to.

Why is this something that isn't meant to happen?

Because I hadn't written an explicit copy-constructor.


You could certainly make it public and implement it if you choose.

Do I need to implement it? AFAICS the implicit copy-constructor should be ok - am I wrong?

the implicit one will work, but an explicit one would be good practice here IMO. Thats because we have a pointer (_operator) that isn't actually foreign storage, and explicitly copying the pointer, not the contents may make the intent clear.

Mmm. I'm not keen on having an explicit constructor doing exactly what the
implicit one would do. I thing that would prove quite confusing for any new
people trying to understand the code - I know it would be quite puzzling for me, met without context.


Also, gcc might do better optimizing away a non-existent constructor than an explicit one - though I don't have any supporting evidence, it seems plausible.

Unless we add explicit copy-constructors to every single class, I'd rather just leave it out and let the compiler handle things implicitly? It seems cleaner to me.

That's what I'll commit for now, on the premise that removing the private copy-constructor is a step in the right direction, whether we end up with it explicit or implicit.

Max.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]