Home » U++ Library support » U++ Callbacks and Timers » [REQUEST]: Allow callback() template to work also with non-void and non-bool return types. 
	| 
		
 |  
	
		
		
			| Re: [REQUEST]: Allow callback() template to work also with non-void and non-bool return types. [message #48775 is a reply to message #48764] | 
			Wed, 13 September 2017 19:15   | 
		 
		
			
				
				
				  | 
					
						  
						mirek
						 Messages: 14271 Registered: November 2005 
						
					 | 
					Ultimate Member  | 
					 | 
		 
		 
	 | 
 
	
		Oblivion wrote on Tue, 12 September 2017 00:49Hello, 
 
It seems that callback() template function isn't working with return types other than bool or void.  
Is this intentional? Or is it possible to replace it with a more flexible one? 
 
If so, maybe  the below template function can do the job (IF I am not missing something here).  
 
template<typename Res, typename... ArgTypes>
Function<Res(ArgTypes...)> callback(Res (*fn)(ArgTypes...))
{
	return [=](ArgTypes... args) { return (*fn)(args...); };
}
 
 
Best regards, 
Oblivion 
  
 
Callback is deprecated. Use Function.
		
		
		[Updated on: Wed, 13 September 2017 19:15] Report message to a moderator  
 |  
	| 
		
	 | 
 
 
 |   
Goto Forum:
 
 Current Time: Tue Nov 04 12:08:17 CET 2025 
 Total time taken to generate the page: 0.03990 seconds 
 |