|
Boost Users : |
Subject: Re: [Boost-users] [bind] Pointer as third parameter
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2008-12-18 08:18:12
Jean-Pierre Bergamin wrote:
> Dear boost-Users
>
> I'm having problems with calling a function that takes a pointer as the
> third argument through bind.
> I cannot explain, why the code below does not compile with the function
> 'op3' enabled. When changing f3 to void f3(int a, int b, int c) { } it
> also works. I don't see any reasony why this should fail, since f2 also
> works.
>
> Any ideas how to solve this?
>
> // ---------------------------------------
> void f3(int a, int b, int *c) { }
> void f2(int a, int *b) { }
>
> template <typename F> void op3(F f) {
> int a = 1, b = 2, c = 3;
> f(a, b, &c);
> }
>
> template <typename F> void op2(F f) {
> int a = 1, b = 2;
> f(a, &b);
> }
>
> void call() {
> op2(boost::bind(&f2, _1, _2));
> //op3(boost::bind(&f3, _1, _2, _3));
> }
> // ---------------------------------------
Works for me on MSVC 8 w/ 64bit disabled.
> MSVC 8 fails with:
>
> .\test.cpp(19) : error C2664: 'void boost::_bi::bind_t<R,F,L>::operator
> ()<int,int,int*__w64 >(A1 &,A2 &,A3 &) const' : cannot convert parameter
> 3 from 'int *__w64 ' to 'int *__w64 &'
> with
> [
> R=void,
> F=void (__cdecl *)(int,int,int *),
> L=boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::arg<3>>,
> A1=int,
> A2=int,
> A3=int *__w64
> ]
> .\Sleep.cpp(29) : see reference to function template
> instantiation 'void
> op3<boost::_bi::bind_t<R,F,L>>(boost::_bi::bind_t<R,F,L>)' being compiled
> with
> [
> R=void,
> F=void (__cdecl *)(int,int,int *),
> L=boost::_bi::list3<boost::arg<1>,boost::arg<2>,boost::arg<3>>
> ]
Did you try:
void f3(int a, int b, int* __w64 c) { }
Jeff
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