There is a complaint that the following function doesn't work because it returns "pointers/iterators to local variables". Is this complaint correct? I can't see this problem...
const Range dummy::foo() const
{
std::vector<Handle> _handles;
_handles.reserve(_collection.size());
for (const auto& pair: _collection)
{
_handles.push_back(pair.first);
}
return _handles;
}
Return type:
using Range = boost::any_range<Handle, boost::forward_traversal_tag, const Handle>;
Thanks for explanations and suggested solutions!