[prev in list] [next in list] [prev in thread] [next in thread] 

List:       boost
Subject:    Re: [boost] [1.34.0beta] many, many warnings... :(
From:       <joaquin () tid ! es>
Date:       2007-05-05 17:27:25
Message-ID: f99fc0b8809b.809bf99fc0b8 () tid ! es
[Download RAW message or body]

----- Mensaje original -----
De=3A Jeff Garland =3Cjeff=40crystalclearsoftware=2Ecom=3E
Fecha=3A S=E1bado=2C Mayo 5=2C 2007 6=3A10 pm
Asunto=3A Re=3A =5Bboost=5D =5B1=2E34=2E0beta=5D many=2C many warnings=2E=
=2E=2E =3A(
Para=3A boost=40lists=2Eboost=2Eorg

=3E Jonathan Franklin wrote=3A
=3E =3E Interesting=2E  I=27m obviously flaunting my ignorance=2C but I d=
idn=27t =

=3E =3E realize that inheriting from a class sans virtual dtor was ever
=3E =3E a Good Thing=2E  I=27ll have to read up on the issues WRT
=3E is=5Fpolymorphic=2E
=3E =

=3E I find inheriting without virtual functions quite useful=2E  The =

=3E main reason for the virtual destructor rule goes back to Scott
=3E Meyers Effective C++=2E  He points out that if you have
=3E Base =3C-- Derived and you call delete Base* the destructor of
=3E Derived is not called=2E In general=2C it=27s hard to ensure your =

=3E derived classes won=27t need the destructor called and hence the =

=3E rule=2E =

=3E However=2C if Derived happens to have a trivial/empty destructor =

=3E then=2C really there=27s no reason to call it=2E

I agree and disagree with your previous exposition =3A)

I think deriving without virtual constructors is fine in those
contexts when the user is not expected to delete passed
objects=2C which are by far the most usual=2E Almost every
function of the form

  void foo(=5Bconst=5D T=26 t)

won=27t certainly try to delete t=2C so it=27s fine to pass an
use here an object of some class derived from T (like in
your super=5Fstring case=2E) =


IMHO the contexts in which objects are passed around
without ownership transfer are overwhelmingly more numerous
than those where transfer is done=2C so I think this =22don=27t
derive without virtual dtor=22 is somewhat overrated=2E There=27s
the special case when the base is abstract or has some
virtual function=3A here it is more likely that the class was
designed with ownership transer via pointers in mind=2C and
the rule would be more sensible=2E But then again=2C a great
many classes don=27t have any virtual member function=2C
much more so in the template-dominated C++ of our days=2E

What I don=27t agree with you in is your claim that
=22if Derived happens to have a trivial/empty destructor =

then=2C really there=27s no reason to call it=2E=22 If my
memory serves me well=2C deleting a Derived object through
its Base non-virtual dtor is illegal according to the
standard=2C regardless of whether D=27s dtor is trivial or
not=2E You=27re merely being lucky with the actual behavior
exhibited by compilers=2E

Joaqu=EDn M L=F3pez Mu=F1oz
Telef=F3nica=2C Investigaci=F3n y Desarrollo

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic