From -3393141639609016645 X-Google-Thread: 109fba,4a997c219a86e9e9 X-Google-Thread: f78e5,4a997c219a86e9e9 X-Google-Attributes: gid109fba,gidf78e5,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!news.glorb.com!proxad.net!news.cs.univ-paris8.fr!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull From: daniel_t@earthlink.net ("Daniel T.") Newsgroups: comp.lang.c++,comp.std.c++ Subject: Re: Boost algorithm ll::accumulate question Date: Sun, 28 Jan 2007 05:24:07 GMT Organization: EarthLink Inc. -- http://www.EarthLink.net Lines: 36 Sender: mail2news@demon.net Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: References: <1169906041.610594.260620@k78g2000cwa.googlegroups.com> NNTP-Posting-Host: news.news.demon.net X-Trace: news.demon.co.uk 1169961867 18102 158.152.254.254 (28 Jan 2007 05:24:27 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Sun, 28 Jan 2007 05:24:27 +0000 (UTC) X-Original-To: std-c++@mailman.ucar.edu X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-User-Agent: MT-NewsWatcher/3.5.2 (PPC Mac OS X) X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au X-Received: (from fjh@localhost) by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id l0S5O7ld015232; Sun, 28 Jan 2007 16:24:07 +1100 (EST) X-Path: comp-std-cpp-robomod!not-for-mail X-NNTP-Posting-Date: Sat, 27 Jan 2007 21:12:38 PST X-Delivered-To: std-c++@mailman.ucar.edu X-Authentication-Warning: mulga.csse.unimelb.edu.au: fjh set sender to devnull@stump.algebra.com using -f X-Newsgroups: comp.lang.c++,comp.std.c++ Xref: g2news2.google.com comp.lang.c++:76163 comp.std.c++:5467 In article <1169906041.610594.260620@k78g2000cwa.googlegroups.com>, "Henrique A. Menarin" wrote: > I want to create a function _and so that I could write > > vector asserts; > //... > bool b = _and(asserts); > > and it "anded" all the elements in the vector. I implemented it like > this: > > > using namespace boost::lambda; > > boost::function(bool (vector)) _and; > _and = bind(ll::accumulate(), > bind(call_begin(), _1), > bind(call_end(), _1), > true, > protect(_1 && _2)); > > But there is an error with the lambda function protect(_1 && _2). > Does anyone knows what is wrong in this expression? > This syntax is valid for creating similar functions for adding and > multiplying numbers. Use std::bitset and you can just call "none()". It will return true if any value in the bitset is true. --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]