Angus Leeming <[EMAIL PROTECTED]> writes: | class Mover {...}; | class SpecialisedMover : public Mover {...}; > | class Movers { | public: | /// @c returns the Mover registered for format @c fmt. | Mover const & operator()(std::string const & fmt) const | { | SpecialsMap::const_iterator const it = specials_.find(fmt); | return (it == specials_.end()) ? default_ : it->second; | } > | private: | typedef std::map<std::string, SpecialisedMover> SpecialsMap; | SpecialsMap specials_; | Mover default_; | }; > | MSVC warns that Movers::operator() is "returning address of local variable | or temporary". I guess that the code is indeed unsafe if it->second is a | copy of the data in the store.
This warning does not seem quite right to me... Are you saying that this would work correctly if we returned specials_[it->first] instead? Something is rotten there. | Should I change the function signature? Let's understand this first. -- Lgb