> Would there be a way to use the MPL so that I could avoid
> #define'ed macros for creating these functions?
You don't need MPL to do so.
==========================================================
>
>
> #define MAKE_CHECK_TYPE_FUNCTION(the_type, the_string)\
> bool check_type(const string& str, const the_type& value)\
> {\
> if(str != the_string)\
> {\
> cout << " Wrong type=[" << str << "] T=" <<
> typeid(value).name() << endl;\
> return false;\
> }\
> return true;\
> }
>
> MAKE_CHECK_TYPE_FUNCTION(bool, "b")
> MAKE_CHECK_TYPE_FUNCTION(double, "f")
> MAKE_CHECK_TYPE_FUNCTION(int, "i")
> MAKE_CHECK_TYPE_FUNCTION(string, "s")
>
> ==========================================================
template<typename T>
check_type_func_traits;
template<>
check_type_func_traits<bool> { static std::string type_id = "b" }; //
depends on compiler may require extrnal definition also
template<>
check_type_func_traits<double> { static std::string type_id = "f" };
....
template<typename T>
bool check_type(std::string const& str, const T const& value)
{
if( str != check_type_func_traits<T>::type_id )
{
cout << " Wrong type=[" << str << "] T="
<< typeid(value).name() << endl;
return false;
}
return true;
}
Regards,
You may use some different kind of compile time mapping. But this should
work for you.
Gennadiy.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost