Article View: comp.std.c++
Article #1773Re: Why not A::A(something) : A(other) {} ?
From: John Max Skaller
Date: Tue, 15 Aug 1995 02:42
Date: Tue, 15 Aug 1995 02:42
33 lines
1997 bytes
1997 bytes
In article <DCwops.HEo@world.std.com>, Tom Breton <tob@world.std.com> wrote: >vandevod@ro.cs.rpi.edu (David Vandevoorde) writes: >> Except for the initializer-list, I don't see how factoring out the >> common construction adds significant overhead: > >"Factoring out" is usually proposed as a work-around, but it's not >really a solution. 0) It can't initialize reference or const members. 1) >Conceptually, it's just wrong. A member function should do stuff after >construction, not before construction. Construction should come from >ctors. Actually, ctors are "wrong" themselves. Typcially, you want to compute several values and stuff them into members. Just as you can initialise the stack frame of a function in stages with loops and so-on between initialisations, so too one would like to do this for objects. You can do so -- but only by using assignments. Hm. I wonder how many compilers can optimise default initialisation followed by assignment to copy construction? This should be possible for Standard Library classes like "string" where the semantics are known. -- JOHN (MAX) SKALLER, INTERNET:maxtal@suphys.physics.su.oz.au Maxtal Pty Ltd, 81A Glebe Point Rd, GLEBE Mem: SA IT/9/22,SC22/WG21 NSW 2037, AUSTRALIA Phone: 61-2-566-2189 --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<40isu2$a96@metro.ucc.su.OZ.AU>Path:
arc1-ca.pugleaf.net!in2.uu.net!bounce-backReferences:
<3vu8ve$e6h@usenet.rpi.edu> <DCwops.HEo@world.std.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 15 Aug 95 02:42:30 GMT
Approved: fjh@cs.mu.oz.au
Return-Path: <daemon@ncar.UCAR.EDU>
From: maxtal@Physics.usyd.edu.au (John Max Skaller)
Newsgroups: comp.std.c++
Subject: Re: Why not A::A(something) : A(other) {} ?
X-Original-Date: 12 Aug 1995 18:46:26 GMT
Organization: School of Physics, University of Sydney, Australia
Message-ID: <40isu2$a96@metro.ucc.su.OZ.AU>
References: <3vu8ve$e6h@usenet.rpi.edu> <DCwops.HEo@world.std.com>