Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.std.c++ > #316

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

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From Daniel Krügler<daniel.kruegler@googlemail.com>
Newsgroups comp.std.c++
Subject Re: Allocator-awareness and value-initialization on container elements
Date Sat, 1 Oct 2011 08:12:27 -0700 (PDT)
Organization A noiseless patient Spider
Lines 67
Sender std-cpp-request@vandevoorde.com
Approved stephen.clamage@oracle.com
Message-ID <j650rt$rro$1@dont-email.me> (permalink)
References <710bc167-27dc-4cfb-ada0-5444457f083c@i9g2000yqe.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
X-Trace news.albasani.net MjQH/LfYlB4EY0cxhC8srklJd+VoFOguhKXfy0YC6L9Vdp/X2DI9vpUpjPb4eN19s81Px5DOGnpgmpXHCqmVCQ==
NNTP-Posting-Date Sat, 1 Oct 2011 15:12:30 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="s6l+KmEW/+JVbWV+sogTwXhigrzKho9u9UptiJyvIsAqa6/maXsGfTZR8GqP2viWdc9vmET+y3TeTgXcS3JKEQx/tYt4ueeCdQZn2O/Igj0LszjP1X8+eB3jyy8pXU28"; mail-complaints-to="abuse@albasani.net"
X-Mailer Perl5 Mail::Internet v2.05
X-Submission-Address std-cpp-submit@vandevoorde.com
Cancel-Lock sha1:jQ0rb6WaP2qg0rKIfqr/vrMuJl4=
X-Original-Date Fri, 30 Sep 2011 20:13:21 +0200
Xref x330-a1.tempe.blueboxinc.net comp.std.c++:316

Show key headers only | View raw


Am 30.09.2011 19:36, schrieb Ai Azuma:
>  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).

This is correct.

>  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 completely agree with what you write here. Note that there exists a
new proposal

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3301.pdf

which has basically the same effect, but introduces a separate new term
for allocator-aware containers - DefaultInsertable - which is defined to
be equal to

allocator_traits<A>::construct(m, p);

(Just ignore the 'contruct' typos in the paper). I consider the
introduction of a separate new name (but still easy to recognice with
the good ol' DefaultConstructible requirement set).

In regard to your criticism of the term value-initialization I agree as
well. IMO the proposal should be updated to fix these terms here as well.

HTH&  Greetings from Bremen,

Daniel Krügler




-- 
[ 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                      ]

Back to comp.std.c++ | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Allocator-awareness and value-initialization on container elements Ai Azuma<ai.azuma@gmail.com> - 2011-09-30 10:36 -0700
  Re: Allocator-awareness and value-initialization on container elements Daniel Krügler<daniel.kruegler@googlemail.com> - 2011-10-01 08:12 -0700
    Re: Allocator-awareness and value-initialization on container elements Ai Azuma<ai.azuma@gmail.com> - 2011-10-03 10:12 -0700

csiph-web