Boost logo

Boost Users :

From: Robert Dailey (rcdailey_at_[hidden])
Date: 2008-03-24 15:23:03


Hi,

I have a simple template function that takes one argument. For example:

template< typename t_type >
void foo( t_type param )
{
}

I want to restrict the type of t_type to a certain subset of types, such as
'char' or 'wchar_t'. If the user passes in any type other than those two
types, the compiler should not be able to find an overload for foo() that
matches the argument types. Note that I would also be using boost::enable_if
to test this condition, however I do not see anything in type_traits or
anywhere else to perform such a test.

I thought of using mpl::vector to create a list of types the function would
take and using enable_if to check if the type is in the container, but this
seems like a lot of work. I want to see if there is a simpler, more compact
solution.

Thanks.



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