Re: [PATCH] bug 3081: comm layer cleanups for TCP acceptor

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Fri, 21 Jan 2011 13:40:43 -0700

On 01/21/2011 08:55 AM, Amos Jeffries wrote:
>>> Since we have AsyncCall blocking the default constructor from allowing
>>> null calls to be passed around we need to add an explicit constructor in
>>> the particular children which subscription requires copying for.
>>
>>
>> This does not compute for me. A default (parameter-less) constructor,
>> blocked or not, should not affect copy constructors. Can you rephrase
>> what you are trying to avoid or achieve? Or perhaps quote the errors you
>> get when the above explicit copy constructor is removed.
>>
>
> I was thinking AsyncCall(const AsyncCall &); with no definition blocked
> the children default constructors too. Due to the parent not having one
> available to call from the default child constructor.

There are several problems here adding to my confusion:

* The lack of method definition (a.k.a. body or implementation) cannot
prevent anything at compile time -- the method definition might be in
some library. The compiler does not know this until it tries to link an
executable. Thus, definition is a red herring here, and you can ignore
it for the purpose of this discussion.

* Terminology:

- Default constructor for class C has no parameters: C().

- Copy constructor for class C has one specific parameter: C(const C&).

- Implicit constructor is the one generated by the compiler if the class
declaration does not provide an explicit one. Compiler can generate
implicit default constructor, implicit copy constructor, implicit
assignment operator, and implicit destructor.

* All of these implicit members are always generated if not explicitly
provided, except for the default constructor: An implicit default
constructor is generated only if there are no explicit constructors of
any kind. This makes sense: if we said how to create an object of a
class, the compiler must not provide its own creation method as an
alternative!

* A parent copy constructor cannot block child's default constructor.
The two are totally independent: copying and creation are different things.

* Similarly, a parent default constructor cannot block child's copy
constructor.

HTH,

Alex.
Received on Fri Jan 21 2011 - 20:41:07 MST

This archive was generated by hypermail 2.2.0 : Sat Jan 22 2011 - 12:00:05 MST