Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-12-17 06:57:28


Agoston Bejo wrote:
> 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.)

'equ' takes three arguments, but you are passing two, _1 and 5. The <bool>
silences the error that bind would have reported because of this and
postpones it until an actuall call is made to equ with two arguments.


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