Boost logo

Boost :

Subject: Re: [boost] phoenix::bind
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-10-02 12:31:54


AMDG

Peter Dimov wrote:
> My original attempt:
>
> lambda( _f = _1 )[ bind( _f, bind( _f, _1 ) ) ]
>
> made sense to me, and I still don't understand why it doesn't work.

I think it ought to work and I think I understand why it doesn't work.

In the bind statement, if the function object is a reference it does
not strip the reference off before accessing the nested ::template
result<...>::type

Here is a reduced test case

#include <boost/spirit/home/phoenix/core.hpp>
#include <boost/spirit/home/phoenix/bind.hpp>

using namespace boost::phoenix;

using namespace arg_names;

struct square {
    template<class T>
    struct result {
        typedef T type;
    };
    template<class T>
    T operator()(const T& t) const {
        return(t * t);
    }
};

int main() {
    square s;
    double x = 2.0;
    double result = bind(ref(s), _1)(x);
}

In Christ,
Steven Watanabe


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