I just tried to do:
Code:
boost::bind(&Input<std::string>::ReadFunction, InputClass),
While
InputClass is: Input InputClass,
Input is a template class: template<typename StrT> class Input,
and ReadFunction is a member function of the class that takes one parameter: void ReadFunction(StrT& RawInput)
The idea is to pass the bound boost object to a member function of the class, like so:
Code:
if ( InputClass.ReadData
(
ConvertedInput,
boost::bind(&Input<std::string>::ReadFunction, InputClass),
&boost::lexical_cast<DataT, std::string>
) )
And allow the class to call the boost object as if it were a global function or a functor:
Code:
InputFunction(RawInput);
But clearly I am missing something, because I am getting a compile error in boost::bind:
3>d:\w00t\documents\visual studio 2008\projects\boost\boost\mem_fn.hpp(342) : error C2298: 'return' : illegal operation on pointer to member function expression
3> d:\w00t\documents\visual studio 2008\projects\boost\boost\mem_fn.hpp(341) : while compiling class template member function 'void (&boost::_mfi::dm<R,T>::operator ()(T *) const)'
3> with
3> [
3> R=void (std::string &),
3> T=Input::Input<std::string>
3> ]
3> d:\w00t\documents\visual studio 2008\projects\boost\boost\bind\bind_template.hpp(3 44) : see reference to class template instantiation 'boost::_mfi::dm<R,T>' being compiled
3> with
3> [
3> R=void (std::string &),
3> T=Input::Input<std::string>
3> ]
3> d:\w00t\documents\visual studio 2008\projects\temp\temp3.cpp(154) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
3> with
3> [
3> R=void (&)(std::string &),
3> F=boost::_mfi::dm<void (std::string &),Input::Input<std::string>>,
3> L=boost::_bi::list1<boost::_bi::value<Input::Input <std::string> >>
3> ]
3> d:\w00t\documents\visual studio 2008\projects\temp\temp3.cpp(216) : see reference to function template instantiation 'void Input::Read<int,const char[19],const char[40],boost::basic_format<Ch>,Input::Validate::Max>(Dat aT &,StrT1 (&),StrT2 (&),const StrT3 &,Validator)' being compiled
3> with
3> [
3> Ch=char,
3> DataT=int,
3> StrT1=const char [19],
3> StrT2=const char [40],
3> StrT3=boost::basic_format<char>,
3> Validator=Input::Validate::Max
3> ]
Function and code where this goes wrong:
Code:
R const & operator()(T const & t) const
{
return (t.*f_);
}
Any ideas what's wrong?