|
Boost : |
From: Anthony Williams (anthony_w.geo_at_[hidden])
Date: 2005-05-13 03:24:39
"Thorsten Ottosen" <nesotto_at_[hidden]> writes:
> "Anthony Williams" <anthony_w.geo_at_[hidden]> wrote in message
> news:y8akdel6.fsf_at_yahoo.com...
> | "Thorsten Ottosen" <nesotto_at_[hidden]> writes:
>
> | > well' that the behavior currently. The string algorithms rely on this
> | > behavior.
> |
> | Which string algorithms exactly? The functions in the standard that deal
> with
> | null-terminated strings all deal with char * and const char *, rather than
> | arrays.
>
> the string algorithms in boost. (probably one of those libararies you never
> use either)
I don't use them, but I did look at the docs and a couple of headers, and
couldn't see anywhere where char arrays were used explicitly --- everything
seemed to be a reference to a container of some type passed as a parameter.
[Aside: I really must familiarize myself with more of the boost libs; the ones
I do use are really handy]
Aha --- the collection traits identify that end(some_char_array) is found
using std::char_traits<char>::length. That makes sense for string algorithms,
and is not the one-less-than-the-array-size you suggested.
I still think that using such a specialized interpretation of char[] when used
with for(:) would be a bad plan. A special case such as this is best
introduced using special case syntax:
char someString[]="fred";
for(char x: nts_array(someString))
doStuff(x);
Anthony
-- Anthony Williams Software Developer
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk