From 1120019932022082473
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,b3e3d077abe0c9b3
X-Google-Attributes: gidf78e5,public
From: dietmar.kuehl@claas-solutions.de
Subject: Re: Count signature
Date: 1998/05/11
Message-ID: <6j6bro$kok$1@nnrp1.dejanews.com>#1/1
X-Deja-AN: 352157157
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <6j0bmk$m0v@bgtnsc03.worldnet.att.net>
X-Original-Date: Mon, 11 May 1998 08:11:37 GMT
Reply-To: dietmar.kuehl@izb-soft.de
X-Http-User-Agent: Mozilla/4.02 [en] (WinNT; I) via proxy gateway CERN-HTTPD/3.0 libwww/2.17
Organization: Deja News - The Leader in Internet Discussion
X-Article-Creation-Date: Mon May 11 08:11:37 1998 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANVa/++EDnX0m9pzZAQFveQF/UD6BpgKQ8jD4P8uDqfxT8RQ05sGqdgEp oRe/zbVxMlVItV+kKQAghUIbv3KxIvBV =+RI4
Newsgroups: comp.std.c++


Hi,
In article <6j0bmk$m0v@bgtnsc03.worldnet.att.net>,
  Cristian.Georgescu@worldnet.att.net wrote:
> The "count" algorithm as specified by the standard returns the
> result in a parameter passed by reference;
>
> In C++PL 3 page 526 (18.5.3)
> the same count algorithm seems to return the result as the return value
> of the function.
>
> Which information is the newest?

The definition in FDIS (final draft international standard) returns the value.
The orginal definition of 'count()' was not really satisfactory: having to
pass an object to be used as count is inconvenient at best. With the
introduction of 'iterator_traits' a better approach became available: the
'size_type' can be used to store the count and is even guaranteed to have an
appropriate size:

  template <typename It, typename T>
  typename iterator_traits<It>::size_type
  count(It begin, It end, T const &val);

The reason for the original version was simply that at this time there was
apparently no way to determine the size_type associated with the iterator.
Thus, the user was required to pass an object of appropriate type. With
'iterator_traits' the interface could be made safer (ie. the user cannot mess
up the type of the count anymore) and more convenient.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html              ]



