Topic: omission in ISO 14882? default vector constructor ...
Author: jonathan_95060@yahoo.com (Jonathan)
Date: Wed, 5 Sep 2001 16:49:20 GMT Raw View
I'm looking at my copy of ISO 14882:1998(E) and I came across the
following sloppiness (?)
for deques (and lists) the standard explicity says the default
constructor creates an empty deque (or list):
page 472, S23.2.1.1, 1 (deque default ctor effects)
page 476 S23.2.2.1, 1 (list default ctor effects)
I find it quite odd that the behavior for the default vector
constructor is left unspecified:
page 484 S23.2.4.1 (vector default ctor, other ctors)
here the default ctor, "size" ctor, "iterator" ctor and copy ctor are
listed but only the semantics of the copy ctor are defined.
While it is easy to extrapolate from the other containers what the
semantics of the default ctor should be, the standard should
pedantically define each and every method.
On a related note, I just noticed that neither deque, list or vector
explicitly define the semantics for their respective copy
constructors. I would expect them to be defined along with the other
methods, although perhaps in a fashion similar to the definition of
vector.resize() (page 485).
If anyone one can point me at a list of errata for ISO 14882 I'd
appreciate it (I've searched on google but haven't turned anything
up). Perhap the omissions I mention above are already covered in an
errata document.
Cheers,
--jfc
======================================= MODERATOR'S COMMENT:
The "errata" are contained in the Issues List published at the committee's website: http://anubis.dkuug.dk/jtc1/sc22/wg21/
---
[ 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.research.att.com/~austern/csc/faq.html ]
Author: "James Russell Kuyper Jr." <kuyper@wizard.net>
Date: Thu, 6 Sep 2001 07:17:47 GMT Raw View
Jonathan wrote:
>
> I'm looking at my copy of ISO 14882:1998(E) and I came across the
> following sloppiness (?)
>
> for deques (and lists) the standard explicity says the default
> constructor creates an empty deque (or list):
>
> page 472, S23.2.1.1, 1 (deque default ctor effects)
> page 476 S23.2.2.1, 1 (list default ctor effects)
>
> I find it quite odd that the behavior for the default vector
> constructor is left unspecified:
>
> page 484 S23.2.4.1 (vector default ctor, other ctors)
>
> here the default ctor, "size" ctor, "iterator" ctor and copy ctor are
> listed but only the semantics of the copy ctor are defined.
>
> While it is easy to extrapolate from the other containers what the
> semantics of the default ctor should be, the standard should
> pedantically define each and every method.
The general container requirements in Table 65 specify that a
post-conditions of the default constructor is size()==0. Therefore, the
explicit statements for deque<> and list<> are redundant in the case of
the default constructor.
However, those explicit statements also constrain the non-default
constructor that takes one allocator argument. I suppose you could argue
that std::vector(std::allocator<int>) is not constrained to have
size()==0, since Table 65 doesn't apply, and there's no explicit
statement to the contrary.
> On a related note, I just noticed that neither deque, list or vector
> explicitly define the semantics for their respective copy
> constructors. I would expect them to be defined along with the other
> methods, although perhaps in a fashion similar to the definition of
> vector.resize() (page 485).
This is covered by the general container requirements. A post-condition
of the copy constructor of any container is that X(a)==a. The
requirements for a==b, where a and b are containers of the same type,
are:
convertible to bool
== is an equivalence relation
a.size()==b.size() && equal(a.begin(),a.end(),b.begin())
---
[ 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.research.att.com/~austern/csc/faq.html ]
Author: jonathan_95060@yahoo.com (Jonathan)
Date: Fri, 7 Sep 2001 05:46:08 GMT Raw View
"James Russell Kuyper Jr." <kuyper@wizard.net> wrote in message news:<3B96BAB5.14964C99@wizard.net>...
> Jonathan wrote:
> >
> > I'm looking at my copy of ISO 14882:1998(E) and I came across the
> > following sloppiness (?)
> >
> > for deques (and lists) the standard explicity says the default
> > constructor creates an empty deque (or list):
> >
> > page 472, S23.2.1.1, 1 (deque default ctor effects)
> > page 476 S23.2.2.1, 1 (list default ctor effects)
> >
> > I find it quite odd that the behavior for the default vector
> > constructor is left unspecified:
> >
> > page 484 S23.2.4.1 (vector default ctor, other ctors)
> >
> > here the default ctor, "size" ctor, "iterator" ctor and copy ctor are
> > listed but only the semantics of the copy ctor are defined.
> >
> > While it is easy to extrapolate from the other containers what the
> > semantics of the default ctor should be, the standard should
> > pedantically define each and every method.
>
> The general container requirements in Table 65 specify that a
> post-conditions of the default constructor is size()==0. Therefore, the
> explicit statements for deque<> and list<> are redundant in the case of
> the default constructor.
>
> However, those explicit statements also constrain the non-default
> constructor that takes one allocator argument. I suppose you could argue
> that std::vector(std::allocator<int>) is not constrained to have
> size()==0, since Table 65 doesn't apply, and there's no explicit
> statement to the contrary.
Right. Although if the intended behavior of the default ctor across
the various sequence containers is 'size() == 0' then the standard
should document this fact consistently. Either mention explicitly for
each container's ctor or only mention it in the general requirements!
Mentioning this fact haphazdly is confusing.
> > On a related note, I just noticed that neither deque, list or vector
> > explicitly define the semantics for their respective copy
> > constructors. I would expect them to be defined along with the other
> > methods, although perhaps in a fashion similar to the definition of
> > vector.resize() (page 485).
>
> This is covered by the general container requirements. A post-condition
> of the copy constructor of any container is that X(a)==a. The
> requirements for a==b, where a and b are containers of the same type,
> are:
>
> convertible to bool
> == is an equivalence relation
> a.size()==b.size() && equal(a.begin(),a.end(),b.begin())
I'll read over the general container requirements carefully.
Thanks for your help!
Cheers,
--jfc
> ---
> [ 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.research.att.com/~austern/csc/faq.html ]
---
[ 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.research.att.com/~austern/csc/faq.html ]