Implement MethodDelegate for automatic type deduction from method pointers #32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a new
MethodDelegateclass that addresses issue #27 by providing automatic type deduction from member function pointers, enabling a more convenient syntax for creating delegates.Key Features
✅ Automatic Type Deduction: Uses member function pointer as template parameter to automatically deduce class type, return type, and argument types
✅ Convenient Syntax: Instead of:
You can now write:
MethodDelegate<&Object::Method> memberMethod(std::make_shared<Object>());✅ Backward Compatibility: Existing
Delegate<ReturnType(Args...)>syntax continues to work unchanged✅ Seamless Conversion:
MethodDelegatecan be implicitly converted to traditionalDelegatewhen neededImplementation Details
MemberFunctionTraits: Template helper that extracts type information from member function pointersMethodDelegate<method>: New class template that takes a member function pointer as a non-type template parameterExample Usage
Test Coverage
The implementation includes comprehensive tests covering:
Test plan
🤖 Generated with Claude Code
Resolves #27