id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 5227,find_ptr wrapper for map::find,olafvdspek@…,Marshall Clow,"Hi, Would it be possible to include this handy wrapper for (unordered) map::find? {{{ #include #include #include using namespace std; template typename T::mapped_type* find_ptr(T& c, U v) { typename T::iterator i = c.find(v); return i == c.end() ? NULL : &i->second; } template const typename T::mapped_type* find_ptr(const T& c, U v) { typename T::const_iterator i = c.find(v); return i == c.end() ? NULL : &i->second; } int main() { typedef boost::unordered_map very_long_type_name_t; very_long_type_name_t very_long_name; very_long_name[1] = ""one""; very_long_type_name_t::iterator i = very_long_name.find(1); if (i != very_long_name.end()) cout << i->second << ""\n""; if (very_long_type_name_t::mapped_type* i = find_ptr(very_long_name, 1)) cout << *i << ""\n""; /* very_long_type_name_t::iterator i = very_long_name.find(1); if (i != very_long_name.end()) cout << i->second << ""\n""; if (very_long_type_name_t::mapped_type* i = find_ptr(very_long_name, 1)) cout << *i << ""\n""; auto i = very_long_name.find(1); if (i != very_long_name.end()) cout << i->second << ""\n""; if (auto i = find_ptr(very_long_name, 1)) cout << *i << ""\n""; */ } }}}",Feature Requests,new,Boost 1.52.0,algorithm,Boost 1.46.0,Problem,,,