From 4722835142752540906
X-Google-Thread: f78e5,4ae4d1cd1dd2d66c
X-Google-NewGroupId: yes
X-Google-Attributes: gid7894ca11fe,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII
Received: by 10.68.129.169 with SMTP id nx9mr1121531pbb.2.1333052281063;
        Thu, 29 Mar 2012 13:18:01 -0700 (PDT)
MIME-Version: 1.0
Path: z9ni16125pbe.0!nntp.google.com!news2.google.com!feed-C.news.volia.net!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.albasani.net!.POSTED!not-for-mail
From: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@googlemail.com>
Newsgroups: comp.std.c++
Subject: Re: Request =?ISO-8859-1?Q?f=F6r_std=3A=3Avector_and_possi?=
 =?ISO-8859-1?Q?bly_others=3A_minimal_initalization?=
Date: Thu, 29 Mar 2012 13:17:58 -0700 (PDT)
Organization: A noiseless patient Spider
Lines: 42
Sender: std-cpp-request@vandevoorde.com
Approved: james.dennett@gmail.com
Message-ID: <jl2deh$has$1@dont-email.me>
References: <abf103e0-7005-47b4-9888-af946353a525@v22g2000vby.googlegroups.com>
 <3008757.1215.1332274822853.JavaMail.geo-discussion-forums@pbjv6>
 <4991d0ff-8c66-41d2-a04d-22a6acce6065@s9g2000pba.googlegroups.com>
 <25560658.357.1332969573044.JavaMail.geo-discussion-forums@ynuu12>
NNTP-Posting-Host: DBpZN7GUJUoN3mMBw7ToD6q+iS05NNnW481mYyA0rk0=
X-Trace: news.albasani.net pd0ORQqR9gryslP0jI72N9D7i86yCPDs9Te6ars08aBaKL5sasSHlbl0Pp1w8ZaQ6QI6WYWXsFD6OSTNa+zPXQ==
X-Complaints-To: abuse@albasani.net
NNTP-Posting-Date: Thu, 29 Mar 2012 20:18:00 +0000 (UTC)
X-Mailer: Perl5 Mail::Internet v2.05
X-Submission-Address: std-cpp-submit@vandevoorde.com
Cancel-Lock: sha1:XoPzL4wfv3c5dhVp7tQqKJVXGcw=
X-Original-Date: Thu, 29 Mar 2012 21:33:45 +0200
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Am 29.03.2012 21:28, schrieb Pedro Lamar�o:
>
> Em sexta-feira, 23 de mar�o de 2012 21h11min22s UTC-3, Kevin McCarty  escreveu:
>
>>  Case 1)  Interfacing with old (C?) code that will initialize a
>>  contiguous block of memory in-place.  One can't always expect that
>>  existing code can be rewritten to take a vector and call push_back or
>>  emplace_back on it.
>>
>>  E.g., supposing the existence of something called std::no_initialize
>>  (whatever that might be)
>>
>>  // some old 3rd-party library function; maybe it calls fread()?
>>  extern "C" initialize_mem(size_t sz, int * mem);
>>
>>  vector<int>    ints(42, std::no_initialize);
>>  initialize_mem(ints.size(), ints.data());
>
>
> In the OP's use case, there is a known amount of "results" for which space must be allocated.
>
> And it is desired to have space allocated, but no constructors run on it.
>
> Isn't uninitialized-land where operator new and std::allocator live? Why not go there?


Yes, this is certainly possible. Just provide an allocator, where
construct (and presumably also destroy) is basically a no-op. I
certainly would not recommend this technique generally, because it
requires a cool head and a stable nervous system ;-)

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                      ]


