Boost logo

Boost Users :

From: Surya Kiran Gullapalli (skg_at_[hidden])
Date: 2005-02-09 01:41:50


Hi,
Please find the attached file.
Whats wrong with bind, I'm getting compilation errors .
===================
temp_bind.cpp: In constructor `temp::temp()':
temp_bind.cpp:30: error: no matching function for call to `if_then(const
boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<3, boost::lambda::function_action<3, boost::lambda::detail::unspecified> >, boost::tuples::tuple<bool (temp::*const)(int) const, temp* const, const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> > >, std::basic_ostream<char, std::char_traits<char> >&)'
==================

Surya Kiran Gullapalli
Sr. Development Engineer
Fluent India Pvt. Ltd.,
Pune


#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

#include <boost/lambda/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/if.hpp>

using namespace std ;
using namespace boost::lambda ;

struct temp
{
        temp ()
        {
                vector <int> vi ;
                vi.push_back (0) ;
                vi.push_back (1) ;
                vi.push_back (0) ;
                vi.push_back (1) ;
                vi.push_back (0) ;
                vi.push_back (1) ;
                vi.push_back (0) ;
                vi.push_back (1) ;

                // I want to call is_zero function on every element of the container vi.

                //for_each (vi.begin(), vi.end(),
                // if_then (bind (is_zero, _1), cout << "YES" << '\n')) ;
                for_each (vi.begin(), vi.end(), if_then
                                (bind (&temp::is_zero, this, _1), cout << "YES" << '\n')) ;
        }
        ~temp () {}

        bool is_zero (int i) const { return static_cast<bool>(i); }
} ;
 
int main (void)
{
        temp t ;
}



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