~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/find_ptr.h

  • Committer: Olaf van der Spek
  • Date: 2011-02-23 00:39:48 UTC
  • mto: (2197.1.2 build) (2209.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2198.
  • Revision ID: olafvdspek@gmail.com-20110223003948-u7hv60z4avbxwr83
Add find_ptr

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
 
 
3
template <class T, class U>
 
4
typename T::mapped_type* find_ptr(T& c, U v)
 
5
{
 
6
        typename T::iterator i = c.find(v);
 
7
        return i == c.end() ? NULL : &i->second;
 
8
}
 
9
 
 
10
template <class T, class U>
 
11
const typename T::mapped_type* find_ptr(const T& c, U v)
 
12
{
 
13
        typename T::const_iterator i = c.find(v);
 
14
        return i == c.end() ? NULL : &i->second;
 
15
}