 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Bo Persson Guest
|
Posted: Sat Dec 30, 2006 11:58 pm Post subject: Defect Report: std::array is a sequence that doesn't satisfy |
|
|
This is based on the current draft, N2134.
The <array> header is given under 23.2 Sequences. Paragraph 23.2.1/3 says
"Unless otherwise specified, all array operations are as described in 23.1".
However, array isn't mentioned at all in section 23.1. In particular, Table
82 "Sequence requirements" lists several operations (insert, erase, clear)
that std::array does not have in 23.2.1.
Also, Table 83 "Optional sequence operations" lists several operations that
std::array does have, but array isn't mentioned.
Bo Persson
---
[ 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.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Tue Jan 02, 2007 6:19 pm Post subject: Re: Defect Report: std::array is a sequence that doesn't sat |
|
|
Bo Persson wrote:
| Quote: | This is based on the current draft, N2134.
The <array> header is given under 23.2 Sequences. Paragraph 23.2.1/3 says
"Unless otherwise specified, all array operations are as described in 23.1".
|
That's followed by a list of what the operations are, mostly without
explicit descriptions of what those operations do. It's the
specifications of those operations that come from 23.1, just as the
specifications for various operations for other container types come
from 23.1.
| Quote: | However, array isn't mentioned at all in section 23.1. In particular, Table
82 "Sequence requirements" lists several operations (insert, erase, clear)
that std::array does not have in 23.2.1.
Also, Table 83 "Optional sequence operations" lists several operations that
std::array does have, but array isn't mentioned.
|
Right: array isn't mentioned in 23.1. Its specification comes from 23.2
and the pieces of 23.1 that are pulled in by reference (such as begin(),
end(), etc.). Similarly, specifications for other container types come
from their specific sections and the pieces of 23.1 that are pulled in
by reference. This gets a bit muddled because 23.1 intermixes advice and
specification. Ignore the advice. What's left is a set of abstract
specifications, used by each of the separate container specifications to
describe some of their details.
--
-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
---
[ 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.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Bo Persson Guest
|
Posted: Thu Jan 04, 2007 4:27 am Post subject: Re: Defect Report: std::array is a sequence that doesn't sat |
|
|
Pete Becker wrote:
| Quote: | Bo Persson wrote:
This is based on the current draft, N2134.
The <array> header is given under 23.2 Sequences. Paragraph
23.2.1/3 says "Unless otherwise specified, all array operations
are as described in 23.1".
That's followed by a list of what the operations are, mostly without
explicit descriptions of what those operations do. It's the
specifications of those operations that come from 23.1, just as the
specifications for various operations for other container types come
from 23.1.
However, array isn't mentioned at all in section 23.1. In
particular, Table 82 "Sequence requirements" lists several
operations (insert, erase, clear) that std::array does not have in
23.2.1. Also, Table 83 "Optional sequence operations" lists several
operations that std::array does have, but array isn't mentioned.
Right: array isn't mentioned in 23.1. Its specification comes from
23.2 and the pieces of 23.1 that are pulled in by reference (such
as begin(), end(), etc.). Similarly, specifications for other
container types come from their specific sections and the pieces of
23.1 that are pulled in by reference. This gets a bit muddled
because 23.1 intermixes advice and specification. Ignore the
advice. What's left is a set of abstract specifications, used by
each of the separate container specifications to describe some of
their details.
|
But table 82 still specifies what a sequence should provide. Table 83 lists
'optional sequence operations' seemingly indicating that operations in table
82 are not optional at all. Right?
If we go further back to 23.1/1, it says: "Containers are objects that store
other objects. They control allocation and deallocation of these objects
through constructors, destructors, insert and erase operations".
It doesn't say here either that a container can choose to not support some
of the operations.
Further, in table 80 one requirement is that a default constructed container
X u;
has a post-condition of u.size() == 0. This is not true if X is
std::array<int, 5>.
I believe it is a bit inconsistent to have a sequence that is not really a
sequence, and not really a container (right now forgetting about
vector<bool> . At least I feel that there ought to be some rules on when
and how it is allowed to deviate.
Bo Persson
---
[ 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.comeaucomputing.com/csc/faq.html ] |
|
| Back to top |
|
 |
Pete Becker Guest
|
Posted: Fri Jan 05, 2007 4:27 pm Post subject: Re: Defect Report: std::array is a sequence that doesn't sat |
|
|
Bo Persson wrote:
| Quote: |
If we go further back to 23.1/1, it says: "Containers are objects that store
other objects. They control allocation and deallocation of these objects
through constructors, destructors, insert and erase operations".
It doesn't say here either that a container can choose to not support some
of the operations.
|
What you have demonstrated is that array does not meet the requirements
for a container. It is what it is, nothing more.
--
-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
---
[ 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.comeaucomputing.com/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
|
|