Boost logo

Boost Users :

From: Agoston Bejo (gusz1_at_[hidden])
Date: 2004-12-17 16:52:58


Boost 1.32 (I've downloaded it last week or so).

On the bottom you can find the complete program. (In other newsgroups I
often saw people complaining about having to read the whole source code - I
suppose they didn't mean minimal examples, am I right?)

"Peter Dimov" <pdimov_at_[hidden]> wrote in message
news:004001c4e470$902ee900$6601a8c0_at_pdimov...
> Agoston Bejo wrote:
> > [Platform: VC++7.1 (I always forget to mention this, only that's why
> > I added it now.)]
> >
> > Actually what you have suggested is one of the two workarounds I came
> > accross when googling the net.
> > The other one was this (IMHO it would be slightly more elegant if it
> > worked):
> >
> > cout << *find_if(ia, ia+5, boost::not1(
> > make_adaptable<bool, int>(bind(equ, _1, 1)))) << endl;
> >
> > But it generated an error.
>
> Compiles here (but the linker dies with an internal error ;-) ). Which
> version of Boost are you using?
>
> (Please post complete programs in the future. Thanks in advance.)

There it goes:

--------------------------------------------------

// xNot1Bind.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <boost/bind.hpp>
#include <boost/bind/make_adaptable.hpp>
#include <boost/functional.hpp>

using namespace std;
using namespace boost;

bool equ(int i, int j) {
 return i == j;
}

int _tmain(int argc, _TCHAR* argv[])
{
 int ia[] = {1,2,3,4,5};
// cout << *find_if(ia, ia+5, boost::not1(bind(equ, _1, 1))) << endl;
// cout << *find_if(ia, ia+5, bind(
// logical_not<bool>(), bind(equ, _1, 1) ) );
 cout << *find_if(ia, ia+5, boost::not1(
   make_adaptable<bool, int>(bind(equ, _1, 1)))) << endl;
 return 0;
}

-------------------------------------------------


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