Hello,
I'm just discovering Boost, and it looks great. However, I can't get
the following code to work. I use g++ (GCC) 3.4.4 20050721 and boost
1.32 (also tried 1.33). When I try a similar example with mere
integers it works though...
#include <string>
#include <sstream>
#include <iterator>
#include <vector>
#include
#include
using namespace std;
using namespace boost::lambda;
int main() {
vector<string> cols;
cols.push_back("foo");
string prefix = "t1.";
for_each(cols.begin(), cols.end(), _1 = prefix + _1);
cout << cols.front() << endl;
return 0;
}
g++ t.cpp && ./a.out
/usr/include/boost/lambda/detail/operator_lambda_func_base.hpp: In member function `RET boost::lambda::lambda_functor_baseboost::lambda::assignment_action, Args>::call(A&, B&, C&, Env&) const [with RET = std::basic_string&, A = std::basic_string, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, Args = boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type>]':
/usr/include/boost/lambda/detail/lambda_functors.hpp:146: instantiated from `typename T::sig >::type boost::lambda::lambda_functor<Base>::operator()(A&) const [with A = std::basic_string, T = boost::lambda::lambda_functor_baseboost::lambda::assignment_action, boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type> >]'
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_algo.h:158: instantiated from `_Function std::for_each(_InputIterator, _InputIterator, _Function) [with _InputIterator = __gnu_cxx::__normal_iteratorstd::string > >, _Function = boost::lambda::lambda_functorboost::lambda::assignment_action, boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type> > >]'
t.cpp:16: instantiated from here
/usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:237: error: no match for 'operator=' in 'boost::lambda::detail::select [with Arg = boost::lambda::placeholder<1>, A = std::basic_string, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type](((const boost::lambda::lambda_functor >&)(+boost::tuples::get [with int N = 0, HT = boost::lambda::lambda_functor >, TT = boost::tuples::consboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >, boost::tuples::null_type>](((const boost::tuples::cons >, boost::tuples::consboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >, boost::tuples::null_type> >&)((const boost::tuples::cons >, boost::tuples::consboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >, boost::tuples::null_type> >*)((const boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type>*)this)))))), ((std::basic_string&)(+a)), ((const boost::tuples::null_type&)(+b)), ((const boost::tuples::null_type&)(+c)), ((const boost::tuples::null_type&)(+env))) = boost::lambda::detail::select [with Arg = boost::lambda::lambda_functor_baseboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> >, A = std::basic_string, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type](((const boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >&)(+boost::tuples::get [with int N = 1, HT = boost::lambda::lambda_functor >, TT = boost::tuples::consboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >, boost::tuples::null_type>](((const boost::tuples::cons >, boost::tuples::consboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >, boost::tuples::null_type> >&)((const boost::tuples::cons >, boost::tuples::consboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> > >, boost::tuples::null_type> >*)((const boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type>*)this)))))), ((std::basic_string&)(+a)), ((const boost::tuples::null_type&)(+b)), ((const boost::tuples::null_type&)(+c)), ((const boost::tuples::null_type&)(+env)))'
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/basic_string.h:426: note: candidates are: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/basic_string.h:437: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(const _CharT*) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/basic_string.h:451: note: std::basic_string<_CharT, _Traits, _Alloc>& std::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char, _Traits = std::char_traits<char>, _Alloc = std::allocator<char>]
/usr/include/boost/lambda/detail/operator_lambda_func_base.hpp: In member function `RET boost::lambda::lambda_functor_baseboost::lambda::plus_action, Args>::call(A&, B&, C&, Env&) const [with RET = boost::lambda::detail::return_type_deduction_failure >, A = std::basic_string, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, Args = boost::tuples::tuple >, 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, boost::tuples::null_type>]':
/usr/include/boost/lambda/detail/select_functions.hpp:28: instantiated from `typename Arg::sig >::type boost::lambda::detail::select(const boost::lambda::lambda_functor<T>&, A&, B&, C&, Env&) [with Arg = boost::lambda::lambda_functor_baseboost::lambda::plus_action, boost::tuples::tuple >, 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, boost::tuples::null_type> >, A = std::basic_string, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type]'
/usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:237: instantiated from `RET boost::lambda::lambda_functor_baseboost::lambda::assignment_action, Args>::call(A&, B&, C&, Env&) const [with RET = std::basic_string&, A = std::basic_string, B = const boost::tuples::null_type, C = const boost::tuples::null_type, Env = const boost::tuples::null_type, Args = boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type>]'
/usr/include/boost/lambda/detail/lambda_functors.hpp:146: instantiated from `typename T::sig >::type boost::lambda::lambda_functor<Base>::operator()(A&) const [with A = std::basic_string, T = boost::lambda::lambda_functor_baseboost::lambda::assignment_action, boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type> >]'
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../../include/c++/3.4.4/bits/stl_algo.h:158: instantiated from `_Function std::for_each(_InputIterator, _InputIterator, _Function) [with _InputIterator = __gnu_cxx::__normal_iteratorstd::string > >, _Function = boost::lambda::lambda_functorboost::lambda::assignment_action, boost::tuples::tuple >, boost::lambda::lambda_functorboost::lambda::plus_action, boost::tuples::tuple >, 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, 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, boost::tuples::null_type, boost::tuples::null_type> > >]'
t.cpp:16: instantiated from here
/usr/include/boost/lambda/detail/operator_lambda_func_base.hpp:206: error: conversion from `std::basic_string' to non-scalar type `boost::lambda::detail::return_type_deduction_failure >' requested
--
Jean-Louis Leroy
Sound Object Logic
http://www.soundobjectlogic.com