|
Boost : |
From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 1999-09-01 06:19:52
Kevlin Henney wrote:
>
> Greg Colvin wrote:
> [...]
> Anyway, I prefer the string to be an optional second argument:
> assertion (x ? t(3) : 3434==i+j, "must fobnicate before we tweak");
should be frobnicate, BTW
> Yup. This approach can also be extended to deal w/ exception
> parameterisation:
>
> assertion(x ? t(3) : 3434==i+j, logic_error("must fobnicate before we
> tweak"));
Objects of type string and logic_error will be created
for each assertion, even when ckecking is disabled.
The string will:
- compute the length of "must fobnicate before we tweak"
(about 30 steps)
- call allocator<whatever>::allocate (say 30)
- copy the string
logic_error will then make a copy of the string
The destructor will:
- if the string is ref-counted, decrement the ref count,
check its value
- call allocator<whatever>::desallocate
logic_error will have to free its copy of the string
This at least involves a strlen, a memcpy, a malloc,
and a free (or equivalent functions).
Where efficiency counts, in a loop, this is absolutely
unacceptable.
-- Valentin Bonnard
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk