Boost logo

Boost :

From: Derek Ross (dross_at_[hidden])
Date: 2003-01-27 12:33:37


Hello,

Would there be a way to use the MPL so that I could avoid
#define'ed macros for creating these functions?

The purpose of these functions is to ensure that the type
of 'value' is in line with the type as specified by the
string 'str'. For example, if 'value' is an int, then
'str' should be "i".

It would be OK if the type string was replaced by a
single char, if that simplified the task.

Thanks,
Derek.

==========================================================

#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")

==========================================================


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk