Boost logo

Boost Users :

From: Paul Thompson (friedegg_at_[hidden])
Date: 2003-06-10 06:54:03


Hi all.

I've been using boost::bind to work around deficiencies with
std::mem_fun_ref and std::bind2nd under MSVC6.

I have a class called CDocumentAttachments which had a member
function thus:

    HINSTANCE Execute(LPCTSTR verb) const;

I was using bind with this as follows:

    for_each(filenames.begin(),
             filenames.end(),
             bind(&CDocumentAttachments::Execute, _1, _T("print")));

"filenames" is a const vector of CDocumentAttachments objects.

This worked fine.

A little later on in development, I changed the function signature for
CDocumentAttachments::Execute to:

    HINSTANCE Execute(LPCTSTR verb, bool visible) const;

How will I pass the extra bool to bind? I can't find any examples of
passing more than one parameter to a member function.

I thought about (among many others)

    for_each(filenames.begin(),
             filenames.end(),
             bind(&CDocumentAttachments::Execute, _2, _T("print"),
false));

but the compiler (VC6) complains with two of the following:

k:\vc\include\boost\bind.hpp(760) : error C2679: binary '[' : no
operator
defined which takes a right-hand operand of type 'const class
boost::arg<2>'
(or there is no acceptable conversion)
        k:\vc\include\boost\bind\bind_template.hpp(33) : see
reference to
function template instantiation 'struct HINSTANCE__ *__cdecl
boost::_bi::evaluator3<struct HINSTANCE__ *>::eval(const class
boost::_bi::list3<class boost::arg<2>,class boost::
_bi::value<char *>,class boost::_bi::value<bool> > &,struct
boost::_mfi::cmf2<struct HINSTANCE__ *,class
CDocumentAttachments,char const
*,bool>,class boost::_bi::list1<class CDocumentAttachments const &>
&)'
being compiled

I know I'm being really thick here, and I'm sure there's something
really
obvious that I'm missing, but reading through the documentation hasn't
helped me.

Thank you very much.

Paul

--
Paul Thompson
Programmer
McLellan Software Design Ltd.

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