|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-07-26 16:40:46
"Peter Dimov" <pdimov_at_[hidden]> writes:
>> c:/videobranch\boost\boost\function\function_template.hpp(111) :
>> warning C4172: returning address of local variable or temporary
The first thing for you to know is that vc7.1 gave that warning
erroneously in many cases. In this case, however, it seems correct.
>> When it finally gets around to mentioning a line number in our own
>> source code, the indicated line is the return statement in the above
>> begin() method.
>
> The change that's breaking your code is (unfortunately) in boost::bind, not
> in transform_iterator. In 1.31, boost::bind(&MapType::value_type::second,
> _1) returns a reference. In 1.32, the same construct returns by
> value.
If Nat were using the actual type of the bind expression as the first
argument to transform_iterator, this wouldn't be a problem (except --
not sure if you care -- that it would be returned by value from the
iterator). Presumably, the bind object has an appropriate
non-reference nested result_type.
Nat, what you are doing looks _really_ inefficient. The result of
make_transform_iterator is some iterator type that's very different
from, but convertible to, your const_iterator type. Going through
that extra layer using boost::function means you are doing a lot of
extra copying -- and potentially, dynamic memory allocation --
whenever you ask for an iterator.
HTH,
-- Dave Abrahams Boost Consulting www.boost-consulting.com
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