Skip to content

Support any signal/slot signature in all interface#130

Open
stijnvanbeek wants to merge 1 commit into
mainfrom
signalslot-signature-support
Open

Support any signal/slot signature in all interface#130
stijnvanbeek wants to merge 1 commit into
mainfrom
signalslot-signature-support

Conversation

@stijnvanbeek

Copy link
Copy Markdown
Contributor

Support for signals/slots with none or multiple arguments throughout the interface:

class SignalTest
{
public:
	SignalTest()
	{
		noArgsSignal.connect(noArgsSlot);
		argsSignal.connect(argsSlot);
		noArgsSignal();
		argsSignal(1, 0.5);
	}

	Signal<> noArgsSignal;
	Signal<int, float> argsSignal;

	Slot<> noArgsSlot = { this, &SignalTest::method };
	void method()
	{
		Logger::info("method");
	}

	Slot<int, float> argsSlot = { this, &SignalTest::method2 };
	void method2(int i, float x)
	{
		Logger::info("method2: %i, %f", i, x);
	}
};

@stijnvanbeek
stijnvanbeek requested a review from cklosters April 23, 2026 08:15

@cklosters cklosters left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very useful, but shouldn't we use perfect forwarding for variadic functions here? Looks like a perfect use case; preserves rvalues and speeds up compilation & binding.

so Args&&... args instead of Args...

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

Successfully merging this pull request may close these issues.

2 participants