Boost logo

Boost :

From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-11-12 16:47:28

Hi All,

    I'm writing a macro-based interface definition language, which I hope to
post soon. For this, I need to be able to detect the presence of member
functions with given name and signature. My current formulation generates code
like the following to test whether a class has a non-const member function named
'one' with the signature char(int, float):

    template<typename T>
    struct has_member_function_one {
        template<typename U, char (U::*MemFun)(int, float)>
        struct one_holder { };

        static ::boost::type_traits::no_type one_tester(...);
        template<typename U>

        static ::boost::type_traits::yes_type one_tester
        ( ::boost::mpl::identity<U>*,
          one_holder<U, &U::one>* = 0 );

        static const bool value =
        sizeof(one_tester((::boost::mpl::identity<T>*)0)) ==

        typedef ::boost::mpl::bool_<value> type;

This works fine on Comeau 4.3.3, Intel 8.0 for Windows, GCC 3.4.1 and VC8.0
(beta). But on VC7.1, it works only if the member function 'one' is not

I've tried Terje Slettebø's operator_concept_traits library, some code posted
long ago by Brock Peabody, but they all use the same technique and fail on

Does anyone have a workaround?

Best Regards,

Boost list run by bdawes at, gregod at, cpdaniel at, john at