From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9660 invoked by alias); 6 Feb 2011 23:01:31 -0000 Received: (qmail 9646 invoked by uid 22791); 6 Feb 2011 23:01:30 -0000 X-SWARE-Spam-Status: No, hits=1.1 required=5.0 tests=AWL,BAYES_00,DNS_FROM_RFC_BOGUSMX,SARE_HEAD_XWORD,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from caprica.metux.de (HELO mailgate.caprica.metux.de) (82.165.128.25) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 06 Feb 2011 23:01:24 +0000 Received: from mailgate.caprica.metux.de (localhost.localdomain [127.0.0.1]) by mailgate.caprica.metux.de (8.14.4/8.14.4) with ESMTP id p16Mw19B016429 for ; Sun, 6 Feb 2011 23:58:03 +0100 Received: (from uucp@localhost) by mailgate.caprica.metux.de (8.14.4/8.14.4/Submit) with UUCP id p16Mw0DY016421 for gcc-help@gcc.gnu.org; Sun, 6 Feb 2011 23:58:00 +0100 Received: (from weigelt@localhost) by nibiru.metux.de (8.12.10/8.12.10) id p16MrLFX029353 for gcc-help@gcc.gnu.org; Sun, 6 Feb 2011 23:53:21 +0100 Date: Mon, 07 Feb 2011 06:41:00 -0000 From: Enrico Weigelt To: gcc-help@gcc.gnu.org Subject: Re: C++ and garbage collection Message-ID: <20110206225318.GA27172@nibiru.local> Reply-To: weigelt@metux.de Mail-Followup-To: gcc-help@gcc.gnu.org References: <20110204194604.GB12837@nibiru.local> <20110205124139.GB29367@nibiru.local> <20110205144610.GA14734@nibiru.local> <87d3n5e1tg.fsf@mid.deneb.enyo.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87d3n5e1tg.fsf@mid.deneb.enyo.de> User-Agent: Mutt/1.4.1i X-Terror: bin laden, kill bush, Briefbombe, Massenvernichtung, KZ, X-Nazi: Weisse Rasse, Hitlers Wiederauferstehung, 42, X-Antichrist: weg mit schaeuble, ausrotten, heiliger krieg, al quaida, X-Killer: 23, endloesung, Weltuntergang, X-Doof: wer das liest ist doof X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-02/txt/msg00128.txt.bz2 * Florian Weimer wrote: > * Enrico Weigelt: > > >> GCC includes a tr1::shared_ptr so there's no extra dependency if you > >> are only planning to use g++, and std::shared_ptr is part of C++0x. > > > > How does that one actually work and what do I have to do to use it ? > > What's the oldest GCC version you're targeting? Quite old, still some 3.x (can have a look when I'm back in office tomorrow ...) > Modern GCC has std::unique_ptr (zero-overhead pointer wrapper with > RAII semantics), std::shared_ptr and std::make_shared (avoiding a > separate allocation using operator new). This should work after some > adjustments, as long as your data structures are acyclic. You just > have to avoid taking short-cuts to optimize things, using references > and plain pointers instead of the std:: wrappers. We make quite heavy use of references. cu -- ---------------------------------------------------------------------- Enrico Weigelt, metux IT service -- http://www.metux.de/ phone: +49 36207 519931 email: weigelt@metux.de mobile: +49 151 27565287 icq: 210169427 skype: nekrad666 ---------------------------------------------------------------------- Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme ----------------------------------------------------------------------