Click here to Skip to main content
16,010,876 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
sashaf23-Sep-03 2:29
sashaf23-Sep-03 2:29 
GeneralRe: DECLARE_CLASSFACTORY_SINGLETON Problem Pin
Braulio Dez23-Sep-03 2:46
Braulio Dez23-Sep-03 2:46 
GeneralWell... it can be possible but then you are making something wrong... Pin
Braulio Dez23-Sep-03 3:18
Braulio Dez23-Sep-03 3:18 
GeneralRe: Well... it can be possible but then you are making something wrong... Pin
umarcool23-Sep-03 5:42
umarcool23-Sep-03 5:42 
GeneralUsing for_each with a map Pin
John M. Drescher20-Sep-03 9:53
John M. Drescher20-Sep-03 9:53 
GeneralRe: Using for_each with a map Pin
ZoogieZork20-Sep-03 12:11
ZoogieZork20-Sep-03 12:11 
GeneralRe: Using for_each with a map Pin
John M. Drescher20-Sep-03 18:40
John M. Drescher20-Sep-03 18:40 
GeneralRe: Using for_each with a map Pin
Phil Martin23-Sep-03 20:26
professionalPhil Martin23-Sep-03 20:26 
One way to do it is to just write a small wrapper function around ResumeThread that takes a std::pair instead of just a HANDLE

void myResumeThread(const std::pair<HANDLE, int> &pair) {
  ::ResumeThread(pair.first);
}

int main(int argc, char* argv[])
{
  std::map<HANDLE, int> blah;

  std::for_each(blah.begin(), blah.end(), myResumeThread);
}

Another alternative, is if you find yourself doing it alot, is to write a really small class to do the wrapping automagically (Which is probably similar to what the other STL implementations would do anyway, but I'm not sure, since I just made this up) :
template <class T, class PAIR>
class FirstWrapper {
public:
  FirstWrapper(T f) {
    func = f;
  }

  void operator()(const PAIR &p) {
    func(p.first);
  }

  T func;
};

template <class T, class CONTAINER>
FirstWrapper<T,CONTAINER::value_type> makeFirstWrapper(T func, const CONTAINER &cont) {
  return FirstWrapper<T,CONTAINER::value_type>(func);
}

int main(int argc, char* argv[])
{
  std::map<HANDLE, int> blah;

  std::for_each(blah.begin(), blah.end(), makeFirstWrapper(::ResumeThread, blah));
}

The above code just makes an adhoc function wrapper around whatever function call you need.

The STL extensions suggested in the other post are more flexible, but this would do for this purpose.


Phil
GeneralRe: Using for_each with a map Pin
John M. Drescher24-Sep-03 3:51
John M. Drescher24-Sep-03 3:51 
Generaldcom local server marshalling. Pin
umarcool19-Sep-03 2:30
umarcool19-Sep-03 2:30 
GeneralRe: dcom local server marshalling. Pin
Gary R. Wheeler20-Sep-03 5:29
Gary R. Wheeler20-Sep-03 5:29 
GeneralProblem with remote server Pin
umarcool21-Sep-03 19:14
umarcool21-Sep-03 19:14 
GeneralRe: Problem with remote server Pin
Gary R. Wheeler22-Sep-03 14:15
Gary R. Wheeler22-Sep-03 14:15 
GeneralRe: Problem with remote server Pin
umarcool23-Sep-03 5:44
umarcool23-Sep-03 5:44 
GeneralATL COM Pin
Binayak18-Sep-03 13:07
Binayak18-Sep-03 13:07 
GeneralRe: ATL COM Pin
Braulio Dez22-Sep-03 5:15
Braulio Dez22-Sep-03 5:15 
QuestionHow do you catch Dialog Boxes from a Browser Help Object (BHO) Pin
RickGavin18-Sep-03 7:26
RickGavin18-Sep-03 7:26 
GeneralATL 7.0 COM Object Deployment Pin
Braulio Dez18-Sep-03 4:36
Braulio Dez18-Sep-03 4:36 
QuestionHow to release memory? when calling COM with param type BSTR* from VB exe application Pin
doisy18-Sep-03 2:30
doisy18-Sep-03 2:30 
AnswerRe: How to release memory? when calling COM with param type BSTR* from VB exe application Pin
Braulio Dez18-Sep-03 4:41
Braulio Dez18-Sep-03 4:41 
AnswerRe: How to release memory? when calling COM with param type BSTR* from VB exe application Pin
Tom Welch18-Sep-03 5:15
Tom Welch18-Sep-03 5:15 
GeneralOffice::CommandBarControl problem Pin
dorutzu17-Sep-03 4:19
dorutzu17-Sep-03 4:19 
GeneralAn Outlook Addin issue Pin
dorutzu16-Sep-03 12:06
dorutzu16-Sep-03 12:06 
GeneralRe: An Outlook Addin issue Pin
Stuart Dootson16-Sep-03 14:53
professionalStuart Dootson16-Sep-03 14:53 
GeneralRe: An Outlook Addin issue Pin
dorutzu16-Sep-03 23:55
dorutzu16-Sep-03 23:55 

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.