|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-10-09 19:32:03
Thorsten Ottosen <nesotto_at_[hidden]> writes:
>> ptr_map<>::insert(key, value) function is taking first argument by non-const
>> reference. Is it missing 'const' there?
>
> No, its an exception-safety issue. if evaluating the first expression could
> throw, we could leak.
Could you please explain what you're saying? On the surface, that
sounds like a flawed rationale on many levels. The arguments to a
function can be evaluated in any order -- they can even be
interleaved. Taking a parameter by non-const reference does nothing
to prevent the corresponding expression from throwing. Is this
another example of false user protection?
-- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk