Topic: Semantics of tr1::array::data when size is 0?
Author: u.int.32.t@gmail.com
Date: Thu, 23 Feb 2006 16:01:30 CST Raw View
sebor@apache.org wrote:
> IIRC, the semantics should be the same as begin() and end() in that
> case. I.e., data() should return a unique (but not derefernceable)
> pointer. I'm not sure why it's not specified in the text; it should be.
If tr1::array is supposed to behave like an array, shouldn't a 0 size
be a compile error?
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: howard.hinnant@gmail.com (Howard Hinnant)
Date: Mon, 13 Feb 2006 19:13:15 GMT Raw View
In article <1139779927.795010.298760@z14g2000cwz.googlegroups.com>,
"sebor@roguewave.com" <sebor@roguewave.com> wrote:
> Why did we leave it unspecified when begin() and end() are?
>From the current resolution of lwg 519 it looks to me like all of
begin(), end() and data() are unspecified, except that begin() == end().
I believe the rationale is so that an implementation can be as efficient
as possible. An invariant is that the client can not dereference any of
these entities, and nothing more is assumed.
-Howard
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: "sebor@roguewave.com" <sebor@roguewave.com>
Date: Thu, 16 Feb 2006 11:49:41 CST Raw View
begin() and end() are specified to return a *unique* value. Assuming
that means a value distinct from any other object's begin() and end(),
why not specify the same thing for data()? Wouldn't returning this be
just as efficient as returning 0?
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: howard.hinnant@gmail.com (Howard Hinnant)
Date: Sun, 12 Feb 2006 01:20:42 GMT Raw View
In article <11uid2ud7jmj411@corp.supernews.com>,
Scott Meyers <usenet@aristeia.com> wrote:
> So what are the semantics of tr1::array<T, 0>::data, and where is this
> specified?
Purposefully unspecified:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#519
-Howard
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: petebecker@acm.org (Pete Becker)
Date: Sun, 12 Feb 2006 22:29:00 GMT Raw View
Howard Hinnant wrote:
> In article <11uid2ud7jmj411@corp.supernews.com>,
> Scott Meyers <usenet@aristeia.com> wrote:
>
>
>>So what are the semantics of tr1::array<T, 0>::data, and where is this
>>specified?
>
>
> Purposefully unspecified:
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-active.html#519
>
Not purposefully. Accidentally. The DR is intended to clear this up.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: "sebor@roguewave.com" <sebor@roguewave.com>
Date: Sun, 12 Feb 2006 18:13:38 CST Raw View
Why did we leave it unspecified when begin() and end() are?
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: Scott Meyers <usenet@aristeia.com>
Date: Wed, 8 Feb 2006 09:17:26 CST Raw View
What are the semantics of tr1::array::data when the size of the array is zero?
The June 2005 TR1 draft (n1836) doesn't seem to say, nor is there any
information on this topic in clause 23.1 of the 2003 standard, which TR1 refers
to. 21.3.6 says that string::data returns a non-null pointer for a zero-length
string, but Nicolai Josuttis' implementation of tr1::array
(http://www.josuttis.com/cppcode/array.hpp.html) has array::data return NULL
when size is zero. (This is relevant only because a comment in the source file
says it was updated to bring it into sync with TR1.)
So what are the semantics of tr1::array<T, 0>::data, and where is this specified?
Thanks,
Scott
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: "sebor@apache.org" <sebor@apache.org>
Date: Wed, 8 Feb 2006 17:38:20 CST Raw View
IIRC, the semantics should be the same as begin() and end() in that
case. I.e., data() should return a unique (but not derefernceable)
pointer. I'm not sure why it's not specified in the text; it should be.
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: petebecker@acm.org (Pete Becker)
Date: Wed, 8 Feb 2006 23:40:07 GMT Raw View
Scott Meyers wrote:
>
> So what are the semantics of tr1::array<T, 0>::data, and where is this
> specified?
>
That's Issue 8.6 in N1809.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]