|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-11-13 08:38:42
From: "David Abrahams" <david.abrahams_at_[hidden]>
> I'm still having a problem. I think I've whittled it down to the bare
> minimum here:
>
> #include <boost/bind.hpp>
> #include <boost/utility.hpp>
>
> template <class R>
> struct converter
> {
> typedef void const* result_type;
>
> void const* operator()(R const& x) const
> {
> return &x;
> }
> };
> struct Y : boost::noncopyable
> {
> virtual int f(const char*) = 0;
> virtual int g(const char*, const char*) = 0;
> };
> struct X : Y
> {
> int f(const char*);
> int g(const char*, const char*);
> };
> X x;
>
> // OK:
> const void* y = boost::bind(
> converter<int>(),
> boost::bind(
> &Y::f,
> boost::ref(*static_cast<Y*>(&x)), "goodbye")
> )();
>
> // Not OK:
> const void* y1 = boost::bind(
> converter<int>(),
> boost::bind(
> boost::bind(&Y::f, _1, _2), // <== changed this line only
> boost::ref(*static_cast<Y*>(&x)), "goodbye")
> )();
>
> // Motivating Example:
> const void* z = boost::bind(
> converter<int>(),
> boost::bind(
> boost::bind(&Y::g, _1, _2, "hello"),
> boost::ref(*static_cast<Y*>(&x)), "goodbye")
> )();
This works on MSVC 7 for me provided that I use the bind<R> syntax where
appropriate. It indeed fails on bcc32 and g++ 2.95.3; the automatic type
deduction seems broken. I'll investigate.
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk