From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e95e8407f65e1cfb X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-06-18 07:49:05 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0902.news.uu.net!not-for-mail Message-ID: <3D0F4876.2010201@mail.com> Date: Tue, 18 Jun 2002 10:49:26 -0400 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Look what I caught! was re:Ada paper critic References: <3d0e5750_2@news.bluewin.ch> <3D0E6D8B.C2EF98D3@san.rr.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Cache-Post-Path: master.nyc.kbcfp.com!unknown@mosquito.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1024411719 8957 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:26242 Date: 2002-06-18T10:49:26-04:00 List-Id: Darren New wrote: > You're probably thinking of what I said, which was that a pointer into an > array is allowed to be increased to point off the end of the array by one > element, but you can't access it. You don't necessarily get to point two > out of bounds, tho. Right, only one past the end is permitted. As you say, this is used in algorithms which march a pointer through an array and find it convenient to post-increment, as in the traditional copying loop of strcpy: strcpy(char *to, char *from) { while (*to++ = *from++); } In C++, this approach has been adopted by the STL algorithms. Whenever they need to operate on a sequence of elements, that sequence is specified by a half-open range of iterators, [begin, end), which mirrors the pointer approach, and in fact pointers are valid iterators, so that STL algorithms can be used on simple arrays. For example, copy is template T copy(T begin, T end, T to) { while (begin != end) *to++ = *begin++; return to; }