Boost logo

Boost Users :

From: Agoston Bejo (gusz1_at_[hidden])
Date: 2004-12-16 19:01:03


Hi!
A small example:

--------------------------------
template<typename T1, typename T2>
bool equ(T1 t1, T2 t2, double threshold) {
 return t1 == t2;
}

int _tmain(int argc, _TCHAR* argv[])
{
 int ia1[] = {1,2,3,4,5};
 cout << *find_if(ia1, ia1+5, bind<bool>(equ<int, int>, _1, 5)) << endl;
// ERROR
 return 0;
}
-----------------------------------
Compiler: VC++7.1

(Intermezzo: another question: why do I have to specify the result type for
bind in this case (bool)? Why can't it deduce it from the template function
declaration: the return type is non-dependent.)

Error message:

c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\boost\bind.hpp(246) : error C2198: 'bool (__cdecl
*)(int,int,double)' : too few arguments for call through pointer-to-function

... and the rest (I suppose they are mainly irrelevant)

        c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\boost\bind\bind_template.hpp(33) : see reference to
function template instantiation 'R boost::_bi::list2<A1,A2>::operator
()<boost::_bi::bind_t<R,F,L>::result_type,bool(__cdecl
*)(T1,T2,double),boost::_bi::list1<int &>>(boost::_bi::type<T>,F,A &)' being
compiled
        with
        [
            R=boost::_bi::bind_t<bool,bool (__cdecl
*)(int,int,double),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int
>::B1,boost::_bi::list_av_2<boost::arg<1>,int>::B2>>::result_type,
            A1=boost::_bi::list_av_2<boost::arg<1>,int>::B1,
            A2=boost::_bi::list_av_2<boost::arg<1>,int>::B2,
            F=bool (__cdecl *)(int,int,double),

L=boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,boost::_bi:
:list_av_2<boost::arg<1>,int>::B2>,
            T1=int,
            T2=int,
            T=boost::_bi::bind_t<bool,bool (__cdecl
*)(int,int,double),boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int
>::B1,boost::_bi::list_av_2<boost::arg<1>,int>::B2>>::result_type,
            A=boost::_bi::list1<int &>
        ]
        c:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\include\algorithm(64) : see reference to function template
instantiation 'boost::_bi::bind_t<R,F,L>::result_type
boost::_bi::bind_t<R,F,L>::operator ()<int>(A1 &)' being compiled
        with
        [
            R=bool,
            F=bool (__cdecl *)(int,int,double),

L=boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1>,int>::B1,boost::_bi:
:list_av_2<boost::arg<1>,int>::B2>,
            A1=int
        ]
        d:\prog\vcpp\Boost\xBindAndDefFuncArg\xBindAndDefFuncArg.cpp(22) :
see reference to function template instantiation '_InIt
std::find_if<int*,boost::_bi::bind_t<R,F,L>>(_InIt,_InIt,_Pr)' being
compiled
        with


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