C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Semantics of tr1::array::data when size is 0?

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards
View previous topic :: View next topic  
Author Message
Scott Meyers
Guest





PostPosted: Wed Feb 08, 2006 3:17 pm    Post subject: Semantics of tr1::array::data when size is 0? Reply with quote



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





PostPosted: Wed Feb 08, 2006 11:38 pm    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with 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.

---
[ 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





PostPosted: Thu Feb 09, 2006 12:10 am    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote



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





PostPosted: Sun Feb 12, 2006 3:06 am    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote

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





PostPosted: Sun Feb 12, 2006 10:29 pm    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote

Howard Hinnant wrote:

Quote:
In article <11uid2ud7jmj411 (AT) corp (DOT) supernews.com>,
Scott Meyers <usenet (AT) aristeia (DOT) 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 ]
Back to top
sebor@roguewave.com
Guest





PostPosted: Mon Feb 13, 2006 12:13 am    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote

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





PostPosted: Mon Feb 13, 2006 8:06 pm    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote

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





PostPosted: Thu Feb 16, 2006 5:49 pm    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote

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






PostPosted: Thu Feb 23, 2006 10:01 pm    Post subject: Re: Semantics of tr1::array::data when size is 0? Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language, library and standards All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.