From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2008-06-07 06:36:34
Giovanni Piero Deretta wrote:
> I see two completely orthogonal fuctionalities here:
> 1- type erasure with multiple signatures of a single function object
> 2- aggregating different function objects in a single polymorphic
> function object *without* any type erasure at all.
That's what I've been saying for quite a while. MSF tries to do both,
but should only provide the first.
The second should be another tool, like egg::overload.
That kind of tool needs a lot of work alone.
I personally do not find egg::overload very satisfying. Lots of macros,
separate type definition and usage...
A solution like
more elegant to me.
The problem being that it's not really possible, because the reflection
mechanism used by function objects doesn't allow rewriting their
signatures to forward to them.
Ideally, a system that works even with polymorphic functions would be
best, and if it doesn't require enumerating the signatures (they could
be deduced) even better.
By the way, is it possible to deduce the constraints of an argument type
and apply concept checking with SFINAE within a lambda expression DSEL?
Imagine if it was possible to write
auto f = overload(
_1 + 42,
_1 + 42 would be a function object similar to
auto concept IntAddable<typename T>
/* don't really know how return type is to be specified */
auto foo(T&& t) -> decltype(t + 42)
return t + 42;
and f would be something like
auto f(T&& t) -> decltype(t + 42)
return t + 42;
auto f(...) -> decltype(0)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk