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 have a private copy-constructor?(Robert?)


On Mon, 30 Aug 2004, Max Bowsher wrote:

> I can't see why setup's PackageSpecification class has a private
> copy-constructor.
> Am I missing something?

AFAIU from the C++ spec, the copy constructor is needed to pass something
by value.  Making it private disallows passing anything by value, only by
reference.

> The reason why I am suddenly interested is that the C++ standard says that
> this:
>
> foo(SomeClass())
>
> requires SomeClass's copy-constructor to be accessible (bizarre, no?) and g++
> 3.4 has decided to enforce this.

Only if foo()'s signature is

... foo(SomeClass a);

If you declared foo() as

... foo(Someclass const & a);

(see, for example, packagedb::findBinary()), the copy constructor
shouldn't be needed.

> So, unless I can make the copy-constructor public (which I don't want to
> do if doing so risks other problems), I need to rewrite all code like:
>
> do_something(PackageSpecification(somename))
>
> to:
>
> PackageSpecification tmppkgspec(somename);
> do_something(tmppkgspec);
>
> which isn't very nice.

The above is a no-op, since if do_something() takes a PackageSpecification
instance by value, then it would take tmppkgspec by value, and attempt to
copy it, and you're back to the copy constructor problem.

It is *remotely* possible that g++ 3.4 decided to disallow passing newly
created instances by reference, but I haven't used 3.4, so can't say
anything about it.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"Happiness lies in being privileged to work hard for long hours in doing
whatever you think is worth doing."  -- Dr. Jubal Harshaw


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