|
Boost : |
From: Jody Hagins (jody-boost-011304_at_[hidden])
Date: 2005-02-15 14:39:38
On Tue, 15 Feb 2005 13:54:27 -0500
David Abrahams <dave_at_[hidden]> wrote:
>
> I wish people would stop calling it that. It's easy, but it's
> overkill.
I got the term from "Exceptional C++" where Herb Sutter calls it "the
operator()= canonical form." I am certainly open to alternatives
(especially since I didn't invent the term ;-).
> > I know it is has a little more overhead
>
> Yes.
Sure. The same could be said of shared_ptr and many other useful,
well-established, tools and techniques that help the programmer write
more correct code.
IMO, this "operator=() canonical form" is by far the best initial
solution for any non-trivial class. Make sure your copy-ctor and swap
do the right thing (which you have to do anyway), and you are set. It
is simple, elegant, and in most cases has fairly small overhead. It
also helps emphasize correctness first.
If the performance becomes a noticable problem, then attack it, but by
then you will already have several tests for correctness and
performance, which means that any problems in the changed implementation
will be detected quickly. As always, a comment about the performance
needs of the code is nice, as it prevents others from changing the
performance characteristics later.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk