Hey guys,

I was wondering if there was some sort of MPL Switch concept in the boost library. Before I go any further on that topic, let me first explain what I'm trying to do.

I'm currently using a library that has several functions as follows:

void SetParamFloat( char* name, float value );
void SetParamInt( char* name, int value );
void SetParamString( char* name, char* value );

I'm creating a sort of facade around this library, and as a result I have a function that looks as follows:

template< typename t_type >
void SetParam( char* name, t_type value );

What I need to do is map real types to function pointers, obviously. But I want all of this to be done at compile time, since I have all of the information to do so. My first thought on a solution to this problem was boost::mpl::map, but then I thought to myself: How do I pass function pointers as template arguments? And on top of that, since all of the functions I'd be mapping to types all have different types anyway, creating a functor object for function pointers seems difficult as you would have to do a lot of messy template class specializations. We'd have to wrap the function pointers in functors of some sort because boost::mpl::map requires typed template arguments, instead of non-type template arguments.

This is what brings me to a sort of switch concept. If there was such a concept in the boost library, it might be more likely to hide the boiler plate code required simply to get to the point to where I can start adding items to a boost::mpl::map. I realize there is no boost::switch concept (at least that google shows), but I was wondering if there was something like it. As a pseudo code example, I would want the logic of my new function to work as follows:

template< typename t_type >
void SetParam( char* name, t_type value )
{
    switch( t_type )
    {
    case float:
        {
            SetParamFloat( name, value );
            break;
        }

    case int:
        {
            SetParamInt( name, value );
            break;
        }

    case char*:
        {
            SetParamString( name, value );
            break;
        }
    }
}

Any help is greatly appreciated. I guess what I really need is some guidance on the matter. I strive for a generic way to implement this, but I don't want it to look messy, as most template code has the bad habit of turning out that way.