Re: Exception
On May 9, 10:19 pm, Nindi <Nind...@yahoo.co.uk> wrote:
[...]
The solution provided on the gotw site requires a heap allocation and
in lots of cases this will be inefficient will it not ?
In most cases, the extra overhead will not even be measurable.
If the program is too slow, and the profiler shows that it is
because of these allocations, then it's time to change. Which
you can normally do fairly simply, because the details are all
hidden within the class.
So as long as you divise a swap function suitable for your
particular class would this not be 'acceptable' ?
That's more or less the point of the GotW. Ideally, every class
would have an appropriate swap function, and you'd use it. (All
of the standard containers have such a swap function, for
example.) Tom Cargill's challenge involved using existing
types, which you couldn't change.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34