 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Scott Meyers Guest
|
Posted: Wed Feb 08, 2006 3:17 pm Post subject: Semantics of tr1::array::data when size is 0? |
|
|
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 ] |
|
| Back to top |
|
 |
sebor@apache.org Guest
|
Posted: Wed Feb 08, 2006 11:38 pm Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
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 ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Thu Feb 09, 2006 12:10 am Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
Scott Meyers wrote:
| Quote: |
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 ] |
|
| Back to top |
|
 |
Howard Hinnant Guest
|
Posted: Sun Feb 12, 2006 3:06 am Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
In article <11uid2ud7jmj411 (AT) corp (DOT) supernews.com>,
Scott Meyers <usenet (AT) aristeia (DOT) com> wrote:
| Quote: | 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 ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Sun Feb 12, 2006 10:29 pm Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
Howard Hinnant wrote:
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 ] |
|
| Back to top |
|
 |
sebor@roguewave.com Guest
|
Posted: Mon Feb 13, 2006 12:13 am Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
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 ] |
|
| Back to top |
|
 |
Howard Hinnant Guest
|
Posted: Mon Feb 13, 2006 8:06 pm Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
In article <1139779927.795010.298760 (AT) z14g2000cwz (DOT) googlegroups.com>,
"sebor (AT) roguewave (DOT) com" <sebor (AT) roguewave (DOT) com> wrote:
| Quote: | 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 ] |
|
| Back to top |
|
 |
sebor@roguewave.com Guest
|
Posted: Thu Feb 16, 2006 5:49 pm Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
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 ] |
|
| Back to top |
|
 |
Guest
|
Posted: Thu Feb 23, 2006 10:01 pm Post subject: Re: Semantics of tr1::array::data when size is 0? |
|
|
sebor (AT) apache (DOT) org wrote:
| Quote: | 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 ] |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|