Opened 5 years ago

#13114 new Feature Requests

Multiple signatures for function

Reported by: stinkingmadgod@… Owned by: Douglas Gregor
Milestone: To Be Determined Component: function
Version: Boost 1.63.0 Severity: Not Applicable
Keywords: Cc:

Description

I am not familiar with boost, just wanted to suggest the possibility of having function take multiple signatures

function<void (int), int (double)> f;

This is compatible with std::function, but unknown feasibility for boost::function in its current form.

The key idea is to recursively implement operator() from the argument list

template<typename Ret, typename... Args, typename... Fns>
struct erasure_base<Ret (Args...), Fns...> : erasure_base<Fns...>
{
    virtual Ret operator()(Args&&...) = 0;
    using erasure_base<Fns...>::operator();
};

Attached file is a proof-of-concept implementation of such functionality.

Attachments (1)

function.hpp (4.6 KB ) - added by stinkingmadgod@… 5 years ago.
Proof-of-concept for function taking multiple signatures

Download all attachments as: .zip

Change History (1)

by stinkingmadgod@…, 5 years ago

Attachment: function.hpp added

Proof-of-concept for function taking multiple signatures

Note: See TracTickets for help on using tickets.