Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-08-31 07:28:34


Joaquín Mª López Muñoz wrote:

> > The documentation suggests to use either 'replace', or more efficient
> > 'modify' method. Why can't I do the following:
> >
> > typedef variables_t::nth_index<1>::type index_t;
> > index_t& index = variable_declarations.get<1>();
> > index_t::iterator existing = index.find(vd);
> > const_cast<Variable_declaration&>(*existing)
> > .make_external();
>
> You can do this as long as you're 100% sure there won't be collisions
> or reorderings. This is no different to const_casting away an element in a
> std::set: if you know what you're doing, well, it's OK. That said,
> using replace or modify keeps you on the safe side.

OK. I started to wonder because the method above appears to be much more
efficient than 'replace' and much more simple that 'modify', so I'm about to
use it as default.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk