Boost logo

Boost :

From: Chris Trengove (trengove_at_[hidden])
Date: 2003-04-01 04:29:32


"David Abrahams" <dave_at_[hidden]> wrote in message
news:u3cl6kg6r.fsf_at_boost-consulting.com...
> Please see if you can come up with a simpler non-specific approach
> which might break cwpro7. That's what I'd like to have in the
> codebase.

I think I have come across an approach which works with BCC, but I'm afraid
it can hardly be called "non-specific". Not being able to use template
syntax with member function pointers is quite a handicap. We end up with
something like

    python::detail::member_function_cast<Target>::stage1(f).stage2(f)

where stage1() is a set of overloaded member functions which merely extract
the class (S) from the member function pointer; eg.

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

Then cast_helper<S,T> derives from

    mpl::if_c<is_base_and_derived<S,T>::value,...,...>

to choose between the two types of cast, which is performed by the stage2()
member function. However, for the base/derived case, we need an additional
full set of overloaded member functions to perform the cast. So the net
effect of this particular compiler bug is that we need to double the work of
Boost.Preprocessor in generating all these overloads!

To add insult to injury, we also have to re-write the test file as well,
using typedefs everywhere. For example, change

    assert_mf_cast<int (Y::*)() const, Y>(&X::f);

to

    typedef int (Y::*mpf1)() const;
    assert_mf_cast<mpf1, Y>(&X::f);

I'm not sure if you'd like to have this in the codebase!

Chris


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