|
Boost Users : |
Subject: [Boost-users] [bind] deduce arguments types
From: Martin Häfner (martinhaefner_at_[hidden])
Date: 2011-08-31 18:15:12
Hi all,
I have written a small grammar for command line parsing where function
binders could be added as actors (callback) of a distinct option. The
simple example below shows that the free function id(...) is called if
the option -i is getting parsed and the bound member function is
called when -j is given:
bool id(int i)
{
return true; /* if id satisfies some preconditions, the parser will
evaluate the result value */
}
struct Id
{
void id(int i)
{
// the parser will not evaluate the 'void' result value
}
};
Id ident;
bool rc = cmdline::Parser<SomePolicyA, SomePolicyB, SomePolicyC>
::parse(argc, argv,
cmdline::Option<'i'>().doc("an integer identifier")) >> id
<= cmdline::Option<'j'>().doc("another integer")) >>
boost:bind(Id::id, &ident, _1)
);
The problem now is that I want to deduce the result type of the given
actor as well as the argument type. Retrieving the result type is
manageable with boost binders but I have no idea how I could retrieve
the argument type in order to do a proper conversion from char* to int
without the usage of make_adaptable<> which breaks the elegance of the
binder usage at this point.
My self-written binder class exposes appropriate typedefs so the
writer of the parser grammar does not have to cope with all that
'magic' template stuff, but I cannot get a working solution for
boost::bind nor do I get a working solution with tr1 binders.
Maybe anybody could help or at least could explain me why the boost
classes do not define these simple typedefs?
Regards,
Martin
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net