boost::lambda bind expressions can't get bind to string's empty() to work

Posted by navigator on Stack Overflow See other posts from Stack Overflow or by navigator
Published on 2010-05-08T16:42:51Z Indexed on 2010/05/08 16:48 UTC
Read the original article Hit count: 352

Filed under:
|
|

Hi,

I am trying to get the below code snippet to compile. But it fails with:

error C2665: 'boost::lambda::function_adaptor::apply' : none of the 8 overloads could convert all the argument types. Sepcifying the return type when calling bind does not help.

Any idea what I am doing wrong?

Thanks.

#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <string>
#include <map>

int main()
{

    namespace bl = boost::lambda;
    typedef std::map<int, std::string> types;
    types keys_and_values;
    keys_and_values[ 0 ] = "zero";
    keys_and_values[ 1 ] = "one";
    keys_and_values[ 2 ] = "Two";

    std::for_each(
        keys_and_values.begin(),
        keys_and_values.end(),
        std::cout <<  bl::constant("Value empty?: ") << std::boolalpha <<  
                        bl::bind(&std::string::empty,
                                bl::bind(&types::value_type::second, _1)) << "\n");




    return 0;
}

© Stack Overflow or respective owner

Related posts about boost

Related posts about lambda