Deduction guides
@Naios
This is a real quick deduction guide implementation that worked for me but is really raw. I am open to collaboration as I'm not at all familiar with the codebase.
What was a problem?
The code that didn't compile:
fu2::unique_function func = [](int x) -> float { return x / 2.f; };
Now compiles.
How this PR fixes the problem?
fu2::function, fu2::unique_function and fu2::function_view were template aliases which limited the CTAD.
Now all of them are kind of strong typedef'ed with addition of deduction guides.
Check lists (check x in [ ] of list items)
- [ ] Additional Unit Tests were added that test the feature or regression
- [ ] Coding style (Clang format was applied)
Additional Comments (if any)
I would really appreciate some CONTRIBUTING.md or any kind of guidance.
Hi,
thank you for your contribution.
Unfortunately, adding new classes for function, unique_function and function_view that inherit from function_base could cause issues in the constructors or assignment operators of function_base, which are specialized for function_base and not for the new classes.
Is there maybe a different way to implement deduction?
Additionally, the deduction guides would have to be disabled when compiling function2 in C++14 to stay backwards compatible.
I see how it could cause issues, however I think that it wouldn't. All conversion rules still apply to these new classes so nothing changes really, does it?
To stay backwards compatible adding __cpp_deduction_guides check would do