Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FR: a constructor for delegate with a freestanding function #966

Open
positron96 opened this issue Oct 2, 2024 · 2 comments
Open

FR: a constructor for delegate with a freestanding function #966

positron96 opened this issue Oct 2, 2024 · 2 comments

Comments

@positron96
Copy link

At the moment, you construct a delegate with a freestanding function like this: my_delegate_type::create<my_function>(), and use it like this: add_callback(my_delegate_type::create<my_function>()).

It would be nice to have an implicit constructor for this case, then this ::create distraction could be omitted and simplified to just add_callback(my_function).

As I understand, this syntax is possible for functors and lambdas, but not for freestanding functions. There are probably obstructions to doing this, otherwise you'd probably have implemented it long ago, but my c++-fu is not strong enough to understand it.

@jwellbelove
Copy link
Contributor

I'll take a look to see if it is possible.

@jwellbelove
Copy link
Contributor

I've been doing C++ for over 20 years, and it still manages to surprise me sometimes, especially convoluted template meta-programming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants