Boost logo

Boost Users :

Subject: [Boost-users] [phoenix] another problem with member_variable bind
From: Christian Henning (chhenning_at_[hidden])
Date: 2008-11-07 15:50:51


Hi there, I'm trying to multiply a factor to my probabilities by using
the std::transform algorithm. But it results in a compiler error.

#include <boost/spirit/include/phoenix_algorithm.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/spirit/include/phoenix_container.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_scope.hpp>
#include <boost/spirit/include/phoenix_statement.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>

#include <algorithm>
#include <iostream>
#include <fstream>
#include <vector>

struct point
{
    double _prob;
    double _x;
};

int _tmain(int argc, _TCHAR* argv[])
{
    using namespace std;
    using namespace boost::phoenix;
    using namespace boost::phoenix::arg_names;

    vector< int > ints;

    // works
    std::transform( ints.begin()
             , ints.end()
             , ints.begin()
             , arg1 + 1
             );

    vector< point > points;

    // doesn't work
    std::transform( points.begin()
                  , points.end()
                  , points.begin()
                  , bind( &point::_prob, arg1 ) * val( 2.0 )
                  );

    return 0;
}

The error is:

error C2679: binary '=' : no operator found which takes a right-hand
operand of type 'double' (or there is no acceptable conversion)

Regards,
Christian


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net