N
nudnik
I tried recently to use boost lambda library but I cannot manage to compile following code
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/core.hpp>
using namespace boost::lambda;
#include <iostream>
template <typename F>
void call ( F f ) {
f();
}
int main (int, char**) {
void (*f)();
//call ([] () { std::cout << "hello world\n"; } );
// auto my_lambda_func = [&](int x) {};
f = [] () { std::cout << "hello world\n"; } ;
call (f);
}
What ever compiler I use without switching to c++0x [ -std=c++0x ] complains with following errors:
lambda.cc:21: error: expected primary-expression before ?[? token
lambda.cc:21: error: expected primary-expression before ?]? token
lambda.cc:21: error: expected `;' before ?{? token
and this even with a newer compiler gcc 4.4.x
My command line looks like g++ -I boost_directory -c input.cpp
When I switch to version 4.6.1, compile after removing the lambda includes and add an option -std=c++0x it works out fine.
What mistake did I make ?
#include <boost/lambda/lambda.hpp>
#include <boost/lambda/bind.hpp>
#include <boost/lambda/core.hpp>
using namespace boost::lambda;
#include <iostream>
template <typename F>
void call ( F f ) {
f();
}
int main (int, char**) {
void (*f)();
//call ([] () { std::cout << "hello world\n"; } );
// auto my_lambda_func = [&](int x) {};
f = [] () { std::cout << "hello world\n"; } ;
call (f);
}
What ever compiler I use without switching to c++0x [ -std=c++0x ] complains with following errors:
lambda.cc:21: error: expected primary-expression before ?[? token
lambda.cc:21: error: expected primary-expression before ?]? token
lambda.cc:21: error: expected `;' before ?{? token
and this even with a newer compiler gcc 4.4.x
My command line looks like g++ -I boost_directory -c input.cpp
When I switch to version 4.6.1, compile after removing the lambda includes and add an option -std=c++0x it works out fine.
What mistake did I make ?