[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Use iterator for STL std::map element access.
From: |
Patrick McCarty |
Subject: |
Re: [PATCH] Use iterator for STL std::map element access. |
Date: |
Tue, 30 Mar 2010 15:23:48 -0700 |
On Sun, Mar 28, 2010 at 8:10 PM, Han-Wen Nienhuys <address@hidden> wrote:
> On Sun, Mar 28, 2010 at 8:54 PM, Patrick McCarty <address@hidden> wrote:
>>
>> http://codereview.appspot.com/819041/show
>>
>> Is this the correct way to return an element from a map?
>
> It looks OK. Within google we have a function
>
> template<class T>
> bool FindCopy(T const& container, const T::key_type& key,
> T::value_type * dest)
>
> reduce the boilerplate involved with extracting values from STL maps.
> You could introduce something like that, and rewrite other lookup code
> like that.
Interesting!
I'll push the patch as-is for now, and I'll plan on writing a
convenience template to use when I have a better grasp of how to
implement it.
Thanks,
Patrick