From: Carsten N. <car...@gm...> - 2008-05-14 20:31:29
|
Hi, Gerrit Voss wrote: >>> that does not look right. >>> >>> boost::any const & >>> IOFileTypeBase::getOption(std::string const &name) const >>> { >>> OptionSet::const_iterator oIt = _optStack.top().find(name); >>> >>> oIt->second; >>> } >> why? because it does not check for oIt == _optStack.top().end() ? This >> as well as the corresponding getOptionAs<> are intended for when it is >> known that the option is present - the doxy comment has a warning about >> this. > > no because it does not return anything, the return statement is > missing. doh, I'm blind, sorry. > I wasn't sure if there is just something simple missing or > if there is more to it. Especially as return gIt->second would return > a reference to a temporary. ok, this is admittedly off topic and not really relevant anymore (that code is gone now), but I'm curious: why does this return a reference to a temporary ? std::map<KeyT, ValueT> stores std::pair<KeyT, ValueT> in its internal data structures and the iterator's operator-> returns a pointer to that pair. Where is the temporary ? Anyway, I've updated the patch to take into account the feedback I got (thanks a lot for everybody's input!), please find it attached. I'll commit the patch in the next few days unless there are objections. Thanks, Carsten |