Topic: Defect Report: std::array is a sequence that doesn't satisfy the sequence requirements?


Author: bop@gmb.dk ("Bo Persson")
Date: Wed, 3 Jan 2007 22:27:01 GMT
Raw View
Pete Becker wrote:
> 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                      ]





Author: bop@gmb.dk ("Bo Persson")
Date: Sat, 30 Dec 2006 17:58:10 GMT
Raw View
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                      ]