|
Boost Users : |
Subject: [Boost-users] [fusion] proposal BOOST_FUSION_ADAPT_FUNCTION, BOOST_FUSION_DEFINE_FUNCTION, etc
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-10-15 01:09:44
Hi,
I am using Boost.Fusion lately. Sometimes one has a function with
several parameters,
int f(double d , int i , std::string s){
...bla bla ...
}
the logic of the program says that sometimes that same funcion will be
called by generic code and in such case it is better if "f" where
defined as taking a fusion::vector as argument.
int f(fusion::vector<double, int, std::string>) // another function,
could be an overload even
since there is only one why to define this adaptor function, e.g.
int f(fusion::vector<double, int, std::string> x){
return f(at_c<0>(x), at_c<1>(x), at_c<2>(x));\
}
and it is pretty mechanical. I was wondering if it would be a good
idea to have, with consistency with the BOOST_FUSION_ADAPT_STRUCT,
something called BOOST_FUSION_ADAPT_FUNCTION
BOOST_FUSION_ADAPT_FUNCTION(
int, f,
double,
int,
std::string
)
(or something like that)
that defines the second / fusion-compatible version of f.
It could be even a
BOOST_FUSION_DEFINE_FUNCTION(
int, f,
(double, d),
(int, i),
(std::string, s),
( ... code using variables d, i, s or at_key<d_>, at_key<i_>,
at_key<s_> ... )
)
that defines simultaneously the raw-C function, f(double, int, string)
*and* the fusion friendly version f(vector<...>).
I could probably program these macro for specific cases but not a
general one since I don't know enough macro syntax to make it work.
Do you think it is a good idea or it is already doable with existing
Fusion features?
Thank you,
Alfredo
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