Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-05-06 07:42:51


John Torjo wrote:
> #include <boost/bind.hpp>
> using namespace boost;
> #include <vector>
>
> struct base {
> int i;
> };
>
> struct test : public base {
> // if you uncomment here and comment above, it'll work
> // int i;
> };
>
> int main() {
> typedef std::vector<test> vector;
> vector v;
> // generates compile-time error on vc7.1
> bind<int&>( mem_fn(&test::i), _1) (v.front());
> return 0;
> }

Yes, this is an unfortunate side effect of the current mem_fn implementation
that relies on overloading tricks instead of enable_if + is_base_of for
portability reasons.

> Peter, any workarounds, until its' fixed?

Please use

    int test::* pm = &test::i;
    bind<int&>( mem_fn(pm), _1) (v.front());

if possible.


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