Click here to Skip to main content
15,905,073 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: [wtl]CHyperLink bRet = (dwRet > 32); Pin
Michael Dunn8-Apr-05 8:05
sitebuilderMichael Dunn8-Apr-05 8:05 
GeneralRe: [wtl]CHyperLink bRet = (dwRet > 32); Pin
Tommy2d10-Apr-05 8:03
Tommy2d10-Apr-05 8:03 
GeneralCDateTimePickerCtrl - CDateTimeCtrl Pin
The Professor8-Apr-05 1:30
The Professor8-Apr-05 1:30 
QuestionHow to get Application pointer of Word if i have Container(Word) pointer Pin
ajalilqarshi8-Apr-05 0:28
ajalilqarshi8-Apr-05 0:28 
Generalquick bind1st question Pin
marinme6-Apr-05 23:56
marinme6-Apr-05 23:56 
GeneralRe: quick bind1st question Pin
Mike Dimmick7-Apr-05 2:06
Mike Dimmick7-Apr-05 2:06 
Generalusing bind2nd function on map Pin
fordge6-Apr-05 17:24
fordge6-Apr-05 17:24 
GeneralRe: using bind2nd function on map Pin
Stuart Dootson6-Apr-05 21:16
professionalStuart Dootson6-Apr-05 21:16 
Something like this should do the trick

<code>
typedef std::map<int, std::string> MyMap;

bool KeyEquals(MyMap::value_type value, int keyValue)
{
   return value.first == keyValue;
}

std::string blah(MyMap const& theMap, int thing)
{
   MyMap::const_iterator it =
      std::find_if(theMap.begin(), theMap.end(),
                   std::bind2nd(std::ptr_fun(KeyEquals), thing));
   return (it==theMap.end())?std::string():it->second;
}
</code>


PS - try out www.boost.org.Bind. This makes function binding a lot easier. You'd have the code below instead...

std::string blah(MyMap const& theMap, int thing)
{
   MyMap::const_iterator it = 
      std::find_if(theMap.begin(), theMap.end(), 
                   boost::bind(&KeyEquals, _1, thing));
   return (it==theMap.end())?std::string():it->second;
}


i.e. no std::ptr_fun, no having to say that you're binding the second parameter. You can see that the order of the parameters passed to bind matches the function signature order of KeyEquals, with '_1' (a predefined placeholder) denoting that the first (and only, in this case) parameter of the bound function object is the value passed by find_if.

HTH!

Stuart Dootson

'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
GeneralRe: using bind2nd function on map Pin
fordge7-Apr-05 1:23
fordge7-Apr-05 1:23 
GeneralRe: using bind2nd function on map Pin
Stuart Dootson7-Apr-05 2:37
professionalStuart Dootson7-Apr-05 2:37 
Questionmultiple key containers?? Pin
fordge6-Apr-05 17:17
fordge6-Apr-05 17:17 
AnswerRe: multiple key containers?? Pin
Stuart Dootson6-Apr-05 21:18
professionalStuart Dootson6-Apr-05 21:18 
GeneralCCommandBarCtrl menu appears as a toolbar button Pin
Paper#6-Apr-05 13:16
Paper#6-Apr-05 13:16 
GeneralProblem using ATL Object in other ATL Server Pin
andreasf5-Apr-05 20:22
andreasf5-Apr-05 20:22 
GeneralImmediate repainting of a listctrl Pin
Franz Klein5-Apr-05 0:17
Franz Klein5-Apr-05 0:17 
GeneralRe: Immediate repainting of a listctrl Pin
Michael Dunn5-Apr-05 7:14
sitebuilderMichael Dunn5-Apr-05 7:14 
QuestionCan a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
samfromcn4-Apr-05 16:36
samfromcn4-Apr-05 16:36 
AnswerRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
Michael Dunn4-Apr-05 20:12
sitebuilderMichael Dunn4-Apr-05 20:12 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
samfromcn4-Apr-05 21:39
samfromcn4-Apr-05 21:39 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
Stuart Dootson4-Apr-05 21:52
professionalStuart Dootson4-Apr-05 21:52 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
samfromcn4-Apr-05 22:27
samfromcn4-Apr-05 22:27 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
Stuart Dootson4-Apr-05 23:05
professionalStuart Dootson4-Apr-05 23:05 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
samfromcn4-Apr-05 23:28
samfromcn4-Apr-05 23:28 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
Stuart Dootson4-Apr-05 23:43
professionalStuart Dootson4-Apr-05 23:43 
GeneralRe: Can a ConnectionPoint Object have function like &quot;HRESULT Test([in, out] Byte* pData)&quot; Pin
samfromcn5-Apr-05 16:14
samfromcn5-Apr-05 16:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.