Topic: Allocator-awareness and value-initialization on container elements


Author: Ai Azuma<ai.azuma@gmail.com>
Date: Fri, 30 Sep 2011 10:36:03 -0700 (PDT)
Raw View
Hi, folks.

I found that the word "value-initialized" is used in the Effects
paragraph of the following constructors and member functions;

   explicit deque::deque(size_type n);
   void deque::resize(size_type sz);
   explicit forward_list::forward_list(size_type n);
   forward_list::resize(size_type sz);
   explicit list::list(size_type n);
   void list::resize(size_type sz);
   explicit vector::vector(size_type n);
   void vector::resize(size_type sz);

Here, I interpret the meaning of "value-initialization" as defined in
(8.5).

However, as far as I understand correctly, the actual semantics should
be emplace construction from zero argument,
i.e., `std::allocator_traits<allocator_type>::construct(a, p)', where
a is a value of the allocator type and
p is a pointer to the place at which a new element is constructed.
This expression may not value-initialize the element but invoke a
constructor other than the default one.
For example, consider the case where the allocator type is
`std::scoped_allocator_adaptor'.

Therefore, the word "value-initialized" should not be used in these
Effects paragraphs.
In addition, the wording like "EmplaceConstructible from zero
argument" should be used
in the corresponding Requires paragraphs instead of
"DefaultConstructible."

I would like to hear from experts. Thank you in advance for your help.


--
[ comp.std.c++ is moderated.  To submit articles, try posting with your ]
[ newsreader.  If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html                      ]