Boost logo

Boost Users :

From: Flex Ferrum (flex_ferrum_at_[hidden])
Date: 2006-09-20 13:11:34


Hello.

David Walthall wrote:

> Flex Ferrum wrote:
> > map<int,int> m;
> > vector<int> a,b;
> > std::transform(a.begin(), a.end(), std::back_inserter(b), var(m)[_1]);

> Is this a case where transform is not appropriate? My understanding is
> that the operation supplied to transform must not have any side effects,
> and here m may be modified by operator[]. Does this count as a side effect?

Yes, of course, map::operator[] _can_ have side effects. But if author
of such code absolutely sure what each value from source vector
has corresponded map entry then map::operator[] will not have side
effects and will suitable for transormation operation.

____________
Best Regards
Flex


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net