[setup] Why does PackageSpecification have aprivatecopy-constructor? (Robert?)

Max Bowsher maxb@ukf.net
Tue Aug 31 13:28:00 GMT 2004


Robert Collins wrote:
> On Tue, 2004-08-31 at 08:54 +0100, Max Bowsher wrote:
>>> So we have code like that at the moment?
>>
>> Certainly. 4 occurrences in IniDBBuilderPackage.cc and 1 in 
>> package_db.cc.
>
> Eh? I can't find any. We have things like
> setSourcePackage(PackageSpecification(name));

Yes, that's what I'm referring to.

> which at the end of the call chain does:
> _packageversion::setSourcePackageSpecification(PackageSpecification
> const &aSpec)
> {
>   _sourcePackage=aSpec;
> }
>
> which should not invoke the copy contructor. rather it is the assignment
> operator.
>  PackageSpecification &operator= (PackageSpecification const &);
>
> 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.

>
> 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?

> 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?

> However, showing the error you get might be more useful...

PackageSpecification.h: In member function `virtual void 
IniDBBuilderPackage::buildPackage(const String&)':
PackageSpecification.h:70: error: 
`PackageSpecification::PackageSpecification(const PackageSpecification&)' is 
private
IniDBBuilderPackage.cc:80: error: within this context

80:  cp = db.findBinary (PackageSpecification(name));


PackageSpecification.h: In member function `virtual void 
IniDBBuilderPackage::buildPackageSource(const String&, const String&)':
PackageSpecification.h:70: error: 
`PackageSpecification::PackageSpecification(const PackageSpecification&)' is 
private
IniDBBuilderPackage.cc:130: error: within this context

130:  csp = db.findSource (PackageSpecification (cbpv.Name()));


PackageSpecification.h:70: error: 
`PackageSpecification::PackageSpecification(const PackageSpecification&)' is 
private
IniDBBuilderPackage.cc:160: error: within this context

160:  cbpv.setSourcePackageSpecification (PackageSpecification 
(cspv.Name()));


PackageSpecification.h: In member function `virtual void 
IniDBBuilderPackage::buildSourceName(const String&)':
PackageSpecification.h:70: error: 
`PackageSpecification::PackageSpecification(const PackageSpecification&)' is 
private
IniDBBuilderPackage.cc:375: error: within this context

375:      cbpv.setSourcePackageSpecification (PackageSpecification (name));



More information about the Cygwin-apps mailing list