This my first attempt at using the boost::mpl library, so I may be off
on the wrong track. If that's the case, please let me know and I'll
come up with a different way to solve my problem. This seemed like a
good practice case though. I'm trying to write a class that can test a
function (eventually any function). The idea is that you specialize
some number of arguments ( up to ten ) and then hand it a function.
Then you feed "test cases" into it, which consist of arguments and an
expected result.
It seemed to me that TMP might be the key avoid having to write the
template class 10 times (once for each number of template parameters).
I thought it would look something like this:
template
class TestScenario
{
typedef boost::mpl::vector TenArgs;
typedef typename boost::mpl::find::type FirstUnusedArg;
typedef typename TenArgs::erase JustTheArgs;
// I know this is non-sense but what should go here?
typedef boost::function2 TestFunctionTS;
.
.
.
So far so good. I have a type that is a vector of the subset of
template arguments that are initialized.
I've thought about maybe trying to use #defines and recursion to create
a template argument string for the boost::function, or something. That
seems totally hideous, likely to fail, and my coworkers wouldn't accept
it as maintainable code anyway just because of the #defines' presence.
Is there an elegant way to go from a vector of types to an argument list
for another template? I would have to use this mechanism to also
specialize various other functions, like the one that accepts sets of
arguments, and some kind of struct for holding those arguments at
run-time.
Thank you,
mike