|
Boost : |
Subject: Re: [boost] [optional] generates unnessesary code for trivial types
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2012-02-15 09:36:54
Den 14-02-2012 20:53, Stewart, Robert skrev:
>> Specifically, polymorphic data types are often passed around by
>> pointer to base class instead of reference to base class by most
>> C++ programmers.
>
> Really? I'm certainly not "most C++ programmers" then. If something
> might not exist, I use optional or a pointer, depending. If it is
> required to exist, then I use a reference. I write functions taking
> references, not pointers, when I don't want to deal with the
> possibility of a null pointer. The caller must handle that for me.
Yes, really. Look at Boost.PtrContainers, for instance. They also allow
you to create containers that are validated to contain no nulls.
But we are very often required to use the pointers.
How the object is passed around out-side the container is another matter.
-Thorsten
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk