From: David Abrahams (dave_at_[hidden])
Date: 2003-04-03 22:51:40
"Chris Trengove" <trengove_at_[hidden]> writes:
> "David Abrahams" <dave_at_[hidden]> wrote in message
>> 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
> 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.
What do you mean by that? Are you describing some Borland bug?
> We end up with something like
> 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
> 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!
Ouch. So you are describing a compiler bug :(.
> 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);
> typedef int (Y::*mpf1)() const;
> assert_mf_cast<mpf1, Y>(&X::f);
Is this what you meant by "not being able to use template syntax with
member function pointers?"
> I'm not sure if you'd like to have this in the codebase!
I'm willing to jump through one or two hoops to get Borland support.
In this case, the extra PP generation should be a special case for
Borland, and all member_function_cast invocations should be wrapped
up in a macro like BOOST_PYTHON_MEMBER_FUNCTION_CAST(target, f) which
hides the horribility from users.
How does that sound?
-- Dave Abrahams Boost Consulting www.boost-consulting.com