|
Boost Users : |
From: Maximilian Wilson (wilson.max_at_[hidden])
Date: 2004-09-01 13:38:54
I am getting another compiler error when trying to use the lambda
library. Current experiment is string extraction. I'm trying to create
a lambda(x) that pushes any char passed to it onto a particular
string.
string s2;
void (std::string::*ft)(char) = &std::string::push_back;
// extract function pointer because push_back is overloaded
char c = 'n';
bind<void>(ft, var(s2), _1, 1)(c);
// should push one 'n' onto the string. However, it doesn't compile
bind<void>(reinterpret_cast<char(std::string::*)(char)>(ft),
var(s2), _1, 1)(c);
// error messages made me think it might be because
push_back returns void
// I know this isn't good practice, but I'm just trying to
figure out what's wrong
// However, this won't compile either.
And then I get this error
/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/detail/actions.hpp:109:
error: no
matching function for call to `boost::lambda::function_adaptor<char
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::*)(char)>::apply(char (std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::*const&)(char), std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, char&, const int&)'
I'm not really sure what the real problem is. Can you tell from
looking at the error message what I should be doing?
Thanks in advance
Max Wilson
(FULL ERROR TEXT FOLLOWS)
/usr/include/boost/lambda/detail/actions.hpp: In static member function `static
RET boost::lambda::function_action<4, T>::apply(A1&, A2&, A3&, A4&) [with
RET = void, A1 = char (std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::*const)(char), A2 = std::basic_string<char,
std::char_traits<char>, std::allocator<char> >, A3 = char, A4 = const int, T
= void]':
/usr/include/boost/lambda/detail/lambda_functor_base.hpp:442:
instantiated from `RET
boost::lambda::lambda_functor_base<boost::lambda::action<4, Act>,
Args>::call(A&, B&, C&, Env&) const [with RET = void, A = char, B =
const boost::tuples::null_type, C = const boost::tuples::null_type,
Env = const boost::tuples::null_type, Act =
boost::lambda::function_action<4, void>, Args =
boost::tuples::tuple<char (std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::*const)(char), const
boost::lambda::lambda_functor<boost::lambda::identity<std::string&> >,
const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >,
const int, 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:151:
instantiated from `typename T::sig<boost::tuples::tuple<A&,
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> >::type
boost::lambda::lambda_functor<Base>::operator()(A&) const [with A =
char, T = boost::lambda::lambda_functor_base<boost::lambda::action<4,
boost::lambda::function_action<4, void> >, boost::tuples::tuple<char
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::*const)(char), const
boost::lambda::lambda_functor<boost::lambda::identity<std::string&> >,
const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >,
const int, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type> >]'
proj1.cpp:180: instantiated from here
/usr/include/boost/lambda/detail/actions.hpp:109: error: no matching function
for call to `boost::lambda::function_adaptor<char (std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::*)(char)>::apply(char
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::*const&)(char), std::basic_string<char, std::char_traits<char>,
std::allocator<char> >&, char&, const int&)'
/usr/include/boost/lambda/detail/actions.hpp:109: error: return-statement with
a value, in function declared with a void return type
bash-2.05b$ g++ proj1.cpp -I /users/user2/ugrad/m/mdw45/boost_1_31_0
/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/detail/actions.hpp: In
static member function `static RET boost::lambda::function_action<4,
T>::apply(A1&, A2&, A3&, A4&) [with RET = void, A1 = char
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::*const)(char), A2 = std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, A3 = char, A4 = const int, T = void]':
/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/detail/lambda_functor_base.hpp:442:
instantiated from `RET
boost::lambda::lambda_functor_base<boost::lambda::action<4, Act>,
Args>::call(A&, B&, C&, Env&) const [with RET = void, A = char, B =
const boost::tuples::null_type, C = const boost::tuples::null_type,
Env = const boost::tuples::null_type, Act =
boost::lambda::function_action<4, void>, Args =
boost::tuples::tuple<char (std::basic_string<char,
std::char_traits<char>, std::allocator<char> >::*const)(char), const
boost::lambda::lambda_functor<boost::lambda::identity<std::string&> >,
const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >,
const int, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type>]'
/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/detail/lambda_functors.hpp:151:
instantiated from `typename T::sig<boost::tuples::tuple<A&,
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> >::type
boost::lambda::lambda_functor<Base>::operator()(A&) const [with A =
char, T = boost::lambda::lambda_functor_base<boost::lambda::action<4,
boost::lambda::function_action<4, void> >, boost::tuples::tuple<char
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::*const)(char), const
boost::lambda::lambda_functor<boost::lambda::identity<std::string&> >,
const boost::lambda::lambda_functor<boost::lambda::placeholder<1> >,
const int, boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type,
boost::tuples::null_type, boost::tuples::null_type> >]'
proj1.cpp:180: instantiated from here
/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/detail/actions.hpp:109:
error: no
matching function for call to `boost::lambda::function_adaptor<char
(std::basic_string<char, std::char_traits<char>, std::allocator<char>
>::*)(char)>::apply(char (std::basic_string<char, std::char_traits<char>,
std::allocator<char> >::*const&)(char), std::basic_string<char,
std::char_traits<char>, std::allocator<char> >&, char&, const int&)'
/users/user2/ugrad/m/mdw45/boost_1_31_0/boost/lambda/detail/actions.hpp:109:
error: return-statement
with a value, in function declared with a void return type
-- Sometimes I think decisions through, weigh the consequences, decide it is not a good idea, but blind myself and make it anyway. I do not think this is a good thing to do, but it might be. Humans are endowed with both reason and emotion for a reason. -Tara Greenwood
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