From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31230 invoked by alias); 1 May 2015 18:22:27 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 31211 invoked by uid 89); 1 May 2015 18:22:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 01 May 2015 18:22:26 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 2B3A98E688; Fri, 1 May 2015 18:22:25 +0000 (UTC) Received: from localhost (ovpn-116-62.ams2.redhat.com [10.36.116.62]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t41IMOUn026778; Fri, 1 May 2015 14:22:24 -0400 Date: Fri, 01 May 2015 18:22:00 -0000 From: Jonathan Wakely To: Daniel =?iso-8859-1?Q?Kr=FCgler?= Cc: libstdc++ , gcc-patches List Subject: Re: [patch] Implement ISO/IEC TS 18822 C++ File system TS Message-ID: <20150501182223.GI3618@redhat.com> References: <20150430173236.GT3618@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-05/txt/msg00086.txt.bz2 On 01/05/15 19:03 +0200, Daniel Krügler wrote: >b/libstdc++-v3/src/filesystem/path.cc: > >- path::compare(const path& p) const noexcept: > >Shouldn't the implementation of this noexcept function not try to >create copies of path objects? Couldn't _Cmpt just hold references to >_M_pathname? All your other comments are definitely correct and I'll make the relevant fixes soon, but I'm not sure what you mean here, could you clarify? I think it would be possible to implement a path like: class path { using value_type = ...; using string_type = basic_string; struct _Cmpt; using composite_path = pair>; using sub_path = basic_string_view; variant _M_data; enum _Type { ... } _M_type; }; struct _Cmpt : path { // ... }; With the invariant that for all objects of type _Cmpt the variant member holds a string_view that refers to the string_type object in some other path. This would reduce the memory footprint of a path object (but for the new std::string ABI, only if there are path components longer than the SSO small string buffer). Even with that design, paths would still be sizeof(string_type) + sizeof(std::list<_Cmpt>) + sizeof(_Type). Alternatively, it could be done without a variant, just adding a string_view member to the path type, which would make it even larger, but would simplify the implementation.