Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Callbacks and Timers » [REQUEST]: Allow callback() template to work also with non-void and non-bool return types.
[REQUEST]: Allow callback() template to work also with non-void and non-bool return types. [message #48764] Tue, 12 September 2017 00:49 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1093
Registered: August 2007
Senior Contributor
Hello,

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


[Updated on: Tue, 12 September 2017 01:01]

Report message to a moderator

 
Read Message
Read Message
Previous Topic: THISBACK and inheritance
Next Topic: How to properly set a timer
Goto Forum:
  


Current Time: Sun Apr 28 14:58:23 CEST 2024

Total time taken to generate the page: 0.04479 seconds