|
Boost : |
Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2012-02-14 21:16:42
Thomas Klimpel wrote:
Simonson, Lucanus J wrote:
>> You could say I
>> should have used a reference instead, but it might not have been my
>> pointer to start with.
>???
It might not have been my code to start with.
>> Specifically, polymorphic data types are often passed around by
>> pointer to base class instead of reference to base class by most C++
>> programmers.
>This doesn't convince me. If the pointer can't be zero (and if somebody else owns it), there is no good reason not to use a reference. Well, if the pointer is a class member, using a reference might be impossible.
An std container of references does not compile, a std container of pointers does. In code with dynamic polymorphic type systems pointers get used a lot, and often more than they should.
Regards,
Luke
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk