Re: How to discover argument and result types from lambda for
constructing std::function?
On 2012-02-07 01:00, Frank Birbacher wrote:
template<class Ret, class C, class... Args> struct
deduce_function<Ret (C::*)(Args......) const> { typedef
std::function<Ret(Args......)> type; };
Wow, what does that do? I haven't yet come across a double ellipsis. I
can think of template template parameters, but a concrete function
type cannot have such arguments, does it? Please provide an example
that invokes this specialization.
It just captures function types with ellipses, e.g. consider printf's
function type (modulo linkage) void(const char*, ...). Or expressed as a
lambda expression
[](const char*, ...) { }
But I was over-engineering here, std::function does not promise to hold
such entities, given it's specification to solely match
template<class R, class... ArgTypes>
class function<R(ArgTypes...)>;
I'm considering making the example complete and providing it to
Boost.Function. Would you agree on this?
Sure.
Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]