From -6705251982977827811
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!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: alfps@start.no ("Alf P. Steinbach")
Newsgroups: comp.lang.c++,comp.std.c++
Subject: Re: Boost algorithm ll::accumulate question
Date: Sun, 28 Jan 2007 05:23:38 GMT
Lines: 43
Sender: mail2news@demon.net
Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++)
Message-ID: <522o0gF1n2flqU1@mid.individual.net>
References: <1169906041.610594.260620@k78g2000cwa.googlegroups.com>
NNTP-Posting-Host: news.news.demon.net
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.demon.co.uk 1169961827 18075 158.152.254.254 (28 Jan 2007 05:23:47 GMT)
X-Complaints-To: abuse@demon.net
NNTP-Posting-Date: Sun, 28 Jan 2007 05:23:47 +0000 (UTC)
X-Original-To: std-c++@mailman.ucar.edu
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
X-User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051201 Thunderbird/1.5 Mnenhy/0.7.3.0
X-Orig-X-Trace: individual.net QjXepLgx1Fhtcp2OFOiviQfOqDugp9dfE+j7E4hUgzCyg1z75W
X-Virus-Scanned: amavisd-new at csse.unimelb.edu.au
X-Originating-IP: 130.133.1.2
X-Received: (from fjh@localhost)
	by mulga.csse.unimelb.edu.au (8.13.8+Sun/8.13.8/Submit) id l0S5NcdE015133;
	Sun, 28 Jan 2007 16:23:38 +1100 (EST)
X-Path: comp-std-cpp-robomod!not-for-mail
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++:76162 comp.std.c++:5466

* Henrique A. Menarin:
> I want to create a function _and so that I could write
> 
> vector<bool> 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<boost>)) _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.

The type 'boost' seems to be undefined.

Why don't you write a simple for-loop?  And if for some obscure reason a 
loop is out of the question, why don't you just use std::accumulate?  Is 
this perhaps HOMEWORK?

-- 
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

---
[ 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                      ]



