+ Reply to Thread
Results 1 to 2 of 2

Thread: Can I pass lamda as argument in another user define function?

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    24

    Can I pass lamda as argument in another user define function?

    Can I pass lamda as an argument in another user define function? How can I do this in VS 2010 + VC++? Please give some clue.

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    24
    Yes, you can pass lambda as an argument in another user defined function.

    Example:
    Code:
    void AcceptLambdaAsArgument(std::tr1::function<void(int)> f)
    {
    	f(10) ;
    }
    
    int main()
    {
    	auto fun = [] (int value) 
    					{
    						CString strMessage ;
    						strMessage.Format("%d", value) ;
    						OutputDebugString(strMessage.GetBuffer()) ;
    					} ;
    	AcceptLambdaAsArgument(fun) ;
    
    	return 0 ;
    }

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts