From 8540018056311697248 X-Google-Thread: f78e5,99f1efda99846e15 X-Google-Attributes: gidf78e5,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!peer01.cox.net!cox.net!peer-uk.news.demon.net!kibo.news.demon.net!mutlu.news.demon.net!news.demon.co.uk!demon!stump.algebra.com!devnull From: technews@kangaroologic.com ("Jonathan Turkanis") Newsgroups: comp.std.c++ Subject: Re: Custom allocator for vector Date: Thu, 26 Aug 2004 06:54:59 GMT Lines: 30 Sender: mail2news@demon.net Approved: fjh@cs.mu.oz.au (Fergus Henderson , moderator of comp.std.c++) Message-ID: <2p4rb0FgvscnU1@uni-berlin.de> References: <2ns6efF45gptU1@uni-berlin.de> <5bp3i05gbil94hkm6je61ehubm3jv2om5d@4ax.com> NNTP-Posting-Host: news.news.demon.net X-Trace: news.demon.co.uk 1093503304 25447 158.152.254.254 (26 Aug 2004 06:55:04 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Thu, 26 Aug 2004 06:55:04 +0000 (UTC) X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov) X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Priority: 3 X-Spam-Checker-Version: SpamAssassin 2.64-mulga_r1 (2004-01-11) on mulga.cs.mu.OZ.AU X-Orig-X-Trace: news.uni-berlin.de gqdg264YwxAX9ZuVegnwageRWQihAqUw6q7q+FH3hmXLipiP7b X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,PRIORITY_NO_NAME autolearn=no version=2.64-mulga_r1 X-MSMail-Priority: Normal X-Received: (from fjh@localhost) by mulga.cs.mu.OZ.AU (8.12.10+Sun/8.12.9/Submit) id i7Q6sxEY009511; Thu, 26 Aug 2004 16:54:59 +1000 (EST) X-Path: comp-std-cpp-robomod!not-for-mail X-Delivered-To: std-c++@ucar.edu X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-Newsgroups: comp.std.c++ Xref: g2news1.google.com comp.std.c++:2185 "tom_usenet" wrote: > On Tue, 10 Aug 2004 17:18:53 GMT, alexvn@big-foot.com ("Alex Vinokur") > >The more specific question: do we need construct() and destroy() indeed? For instance, g++ doesn't use them. > > We do need them for special pointer types, yes. e.g. a pointer might > be an int (for an offset), in which case new((void*)anint) T(val) is > just not going to work; the allocator will need something like: > > void myallocator::construct(pointer p, const_reference value) > { > T* ptr = base_address + p; > new ((void*)ptr) value_type(value); > } How does this work if you've used allocate() to allocate memory for an array of T? Jonathan --- [ 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.jamesd.demon.co.uk/csc/faq.html ]