Unclear vector<bool> constructor element insertion

L

Luke Allardyce

As seen here
https://groups.google.com/a/isocpp.org/forum/?fromgroups#!topic/std-discussion/J7JKWHr0YRM

It appears that N3691 and later drafts (including the latest N3936) have modified the constructors for vector<bool>

Pre-N3691:
....
explicit vector(size_type n, const bool& value = bool(), const Allocator&= Allocator());
....

Currently:
....
explicit vector(size_type n, const Allocator& = Allocator());
vector(size_type n, const bool& value, const Allocator& = Allocator());
....

The first constructor for the current draft requires that the elements are default-inserted according to [container.requirements.general]:

An element of X is default-inserted if it is initialized by evaluation of the expression allocator_traits<A>::construct(m, p)

vector<bool> does not use allocator_traits::construct to construct these elements however, and it is unclear how they are inserted. Presumably the intent is to insert elements that are zero-initialized (i.e. false) if using the default Allocator, but this doesn't seem to be guaranteed.

Could this be an editing error or does vector<bool> need further clarification?
 
V

Victor Bazarov

As seen here
https://groups.google.com/a/isocpp.org/forum/?fromgroups#!topic/std-discussion/J7JKWHr0YRM

It appears that N3691 and later drafts (including the latest N3936) have modified the constructors for vector<bool>

Pre-N3691:
...
explicit vector(size_type n, const bool& value = bool(), const Allocator& = Allocator());
...

Currently:
...
explicit vector(size_type n, const Allocator& = Allocator());
vector(size_type n, const bool& value, const Allocator& = Allocator());
...

The first constructor for the current draft requires that the elements are default-inserted according to [container.requirements.general]:

An element of X is default-inserted if it is initialized by evaluation of the expression allocator_traits<A>::construct(m, p)

vector<bool> does not use allocator_traits::construct to construct these elements however, and it is unclear how they are inserted. Presumably the intent is to insert elements that are zero-initialized (i.e. false) if using the default Allocator, but this doesn't seem to be guaranteed.

Could this be an editing error or does vector<bool> need further clarification?

Seems like you should post this to comp.std.c++, where the Standard
document and all things related to it are discussed at more detail. The
difference between that newsgroup and this one is that we here discuss
the language _as it is_, and /there/ they discuss it as it should or
ought to be, and also the rationale behind those decisions.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top