Boost logo

Boost :

From: Chris Trengove (trengove_at_[hidden])
Date: 2003-03-27 21:48:28


A question for David Abrahams (or anyone else who might have a bright idea).

I have resolved quite a few of the issues involved in porting Boost.Python
to Borland, but here is one particularly nasty problem. In
member_function_cast.hpp you have code, which after expansion at the hands
of Boost.Preprocessor, gives

template <class T>
struct member_function cast
{
    template <class S,class R>
    static cast_helper<S, R (T::*) ()> stage1(R (S::*)())
    {
        return cast_helper<S, R (T::*)()>();
    }

    // Many more definitions of stage1() with increasing numbers of
parameters (arity).
};

Unfortunately, this runs foul of the infamous BCC "emoticon" bug, whereby
the ")" character (and various others) will terminate the template argument
list. In the above, the compiler therefore sees "cast_helper<S,R
(T::*[end_of_template]". I assume that it is this bug which mandates the
special treatment for BCC in
boost/type_traits/is_member_function_pointer.hpp.

The standard workaround is to use a typedef, which in this case would be

    typedef R (T::*T_mfp)();
    static cast_helper<S,T_mfp> stage1(...)

But of course here we will need separate typedefs for each of the "arities"
of stage1(), and we need to define them so that they are available to the
stage1 template. It seems to me that the function overloading approach being
used here then becomes infeasible.

Any ideas?

Chris


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