220 34984 <1643738.UGnyhZm5To@tjmaciei-mobl1> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Thiago Macieira <thiago@macieira.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Contra P0722R0 "destroying operator-delete"
Date: Tue, 17 Oct 2017 11:03:55 -0700
Lines: 62
Approved: news@gmane.org
Message-ID: <1643738.UGnyhZm5To@tjmaciei-mobl1>
References: <89c7d198-0eec-4099-ba31-bad92706ebae@isocpp.org> <CAGL0aWf-x-A5YaYoQYQw+xdokBHxGJ4MgZkc0+-B++5Da+FpOQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Trace: blaine.gmane.org 1508263460 25496 195.159.176.226 (17 Oct 2017 18:04:20 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Tue, 17 Oct 2017 18:04:20 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCB4TK757YBRBEUMTHHQKGQEMQSAINY@isocpp.org Tue Oct 17 20:04:14 2017
Return-path: <std-proposals+bncBCB4TK757YBRBEUMTHHQKGQEMQSAINY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f197.google.com ([209.85.128.197])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCB4TK757YBRBEUMTHHQKGQEMQSAINY@isocpp.org>)
	id 1e4WDc-0003sy-Tq
	for gclcip-std-proposals@m.gmane.org; Tue, 17 Oct 2017 20:03:57 +0200
Original-Received: by mail-wr0-f197.google.com with SMTP id c11sf1177463wrg.10
        for <gclcip-std-proposals@m.gmane.org>; Tue, 17 Oct 2017 11:04:04 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1508263444; cv=pass;
        d=google.com; s=arc-20160816;
        b=Ae3pLPQHcOw0eV5nasSratjH3U1wmz93l4S8bzeYDQEZJT7/apu0iyGOOyi4YcNHzN
         CRLg0w0SCnoJtB7AexEjV5Qgq9MD6MudLJdkcg0LJeP5n0EJHE81jjYlv4R+0FbVg1b/
         WnGj2MmSALjircTdyYS8txmG/cV6M+z36oWRmY/AgB+XSP4oxEwFRX1glEKPLKr0taIV
         fkaXl0QJNIRPPGCywvtjc3NFuLqe61xMHfox3FWuiIGFhXpgbUMk/s4PQn6aJNsnmqCD
         dPMtpDDsnABbDszjMOrPhRzxGB8GL45gAjesOABJjb4auDoR7WfPgq6t17feBI9T8gcm
         b0iA==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-transfer-encoding
         :mime-version:references:in-reply-to:message-id:date:subject:to:from
         :arc-authentication-results:arc-message-signature:dkim-signature
         :arc-authentication-results;
        bh=61IajDSzOvu+mtyek6d3rrMDBGTBdXO8jAsgjmTeEmU=;
        b=wE/3169rxaG4Ykr7MFtskB2lTI1PEuuZwymJ8BvpJhneupNWwngyxeln5pV265QPki
         CMi7MVx+LjIDywSnyGCkjZC18M9yOpl1ajXKKlMoSoW9UGCc2iy3RhO+RP2IY6IjFdlR
         0BVCq96AefjG9ZLZjpnmMUt8rs4ZzSqXPn6bCuk7uHDFhkv2ww6unaZ39x2asliX7qUd
         Nh5D9pkp0Z+EnDEzTUd3sBVBl7Aua89WR9xkxVoDshXievITNa3GS9xyn7Wsw+hriJZ5
         WCO34GqfrkB5uJtV5Dx1c8+jRTRTOU1RFWCO6MKO8+fbNCK9xM9QElRyfHLtxuByug+f
         ggDQ==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) smtp.mailfrom=thiago@macieira.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=from:to:subject:date:message-id:in-reply-to:references:mime-version
         :content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=61IajDSzOvu+mtyek6d3rrMDBGTBdXO8jAsgjmTeEmU=;
        b=z6r7SmyrUFHrg09lCE2WhQAWhXGzlYjJ+DTR7+ZJAn5jDbnkMDAbR//w6ifPeIR0Ah
         pnIEbuyn7oFjRM3/YERxfiIz4djcHYUBMHaPE4b20EoXsW/XlO9hQqF1lKFdpYdICI7J
         Y7hps7ECzHU0rnmN1sfzTkMZ7X3dOfLJpukVG5ti2U+iPcMSA5HObleSz7AGZjyfvV3H
         D4SSyJn9hNp0QnOC+Re1sp7dyEA3WWDS7Epyj2wlBJsdqvNUm0+rlIWdD7M/DCyhF/E5
         gQzuwICcDMxCbvpDVFgQhMhpHIFQ0dRsLt4fKkaZbtKZYkGbVV3o0tRQ0DWsfLkbLLyY
         Mg/w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to
         :references:mime-version:content-transfer-encoding:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=61IajDSzOvu+mtyek6d3rrMDBGTBdXO8jAsgjmTeEmU=;
        b=TxtDTT9aCUOkFnmavKyjrcs+yXoPKlOAcdkkLxMVg+eZI3yorKV4b/4hWZEX4WSp89
         fnESCTFV7rgMqA4tExSflRelFeAIGCBdR4AZlTpBMSM3yLnvnqQycVURu52EgaEI8zrx
         2tCyeS5vJ5ZlSmPwtfkALXsoaYbwBWEWLdI8NuRC4K6f+ZfwUKjo7YcW1Ajqn15RBHa0
         9uTn4PXUMnPmZ8SqhTYOq++4VDWczanowSbUV/LD8BnnZBdsao7pXqKnMnaSWmeyTMRD
         301vXS8J01Xp0bVoTrgn2YMJj6Gb2bONeABfObzRTnS6awnwaOJAb8yJmC0Vx856euNB
         P43 
X-Gm-Message-State: AMCzsaUfBojR4SqB2dyHy1wHEP0sMmstutepD8aIMXqu1U8ojiHiBTtC
	Hk36n8sBDlNSIOq0mywBNLCVCg==
X-Google-Smtp-Source: ABhQp+ScVxi1UfcaDWPpP6NDdfNoPVAVbThd3bD6k4KQZsGCu7osiDXARXC/xFyTWBHGmtch2+zbuQ==
X-Received: by 10.28.111.213 with SMTP id c82mr553146wmi.25.1508263443625;
        Tue, 17 Oct 2017 11:04:03 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.159.4 with SMTP id i4ls441424wme.3.gmail; Tue, 17 Oct 2017
 11:04:02 -0700 (PDT)
X-Received: by 10.28.212.65 with SMTP id l62mr4032789wmg.77.1508263442299;
        Tue, 17 Oct 2017 11:04:02 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1508263442; cv=none;
        d=google.com; s=arc-20160816;
        b=KO+zx6HpHK9zO2Oly7cL1vGMrGRgn9NDkcNN8n2dgH393310eAGnz+oUFxozDplPPh
         2kWI062biPttqLEMfmDc/cBAiXK9tOgyFx4PTDNt6R0YpqTPhF4bkrN4Q5XJKuDjF/ui
         BTcS0+PXTj6lOnAT6YhbvV/zpiqg0FbcLIhdKH9kDtieVJYixKvUwESnCxBlQBxZaUPH
         gcdlrH32W1yZVpSdgGjFJzcJ3f+sH1OHTC6rZfET5WBQsQ+w/XkQ9n8iph6vpAWj9i0K
         1O/9SFK7yBUB1bnoEwh1lrXGeqWIIbYajLzmXvSbOizha43ynkv4YstzPmPQ5NaBqBVn
         1ovA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:mime-version:references:in-reply-to
         :message-id:date:subject:to:from:arc-authentication-results;
        bh=tJKWsPKDA/y+pxB6rnjNkXOz3a6TZB47eYsmIfoKVgI=;
        b=Bjlm49qw2wT5ALkTp1L+UHaHgYeqjd0ClEoNDSgk6wN3qoQBWXZVHdC0W6FOE6o6RU
         cMJWZBUUVMCrFh1CaKUT+6pxtk0dvnU+A8Y1eZ+DdD1UdS86Wafkw6a6vIQgucFbi023
         2zEAan5eSXI2QAyU4CDT9Y2YgypiidTVS+FY9SwLKMnh+UFy2/N5t5HdT4vpw+sbLlqh
         d5NjkaEY6aFmBVnjPGxGFj+vuQknvLpuPh7mRmj4BSqal5UWNxYAqZZEHHqtnNeoqCIb
         HWklLzzqoFqcsuzmzB4sST1p9PK+/ESXjFvmI1D1aPTU57LDGQHjmgp0jLQUQduT9u/u
         Vg0w==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) smtp.mailfrom=thiago@macieira.org
Original-Received: from gondolin.macieira.info (gondolin.macieira.info. [2a01:4f8:d13:f81:21c:14ff:fe01:12a3])
        by mx.google.com with ESMTP id q22si7996996wrc.186.2017.10.17.11.04.02
        for <std-proposals@isocpp.org>;
        Tue, 17 Oct 2017 11:04:02 -0700 (PDT)
Received-SPF: pass (google.com: domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3 as permitted sender) client-ip=2a01:4f8:d13:f81:21c:14ff:fe01:12a3;
Original-Received: from tjmaciei-mobl1.localnet (jfdmzpr03-ext.jf.intel.com [134.134.139.72])
	by gondolin.macieira.info (Postfix) with ESMTPSA id 2CDB911B47B
	for <std-proposals@isocpp.org>; Tue, 17 Oct 2017 11:04:00 -0700 (PDT)
In-Reply-To: <CAGL0aWf-x-A5YaYoQYQw+xdokBHxGJ4MgZkc0+-B++5Da+FpOQ@mail.gmail.com>
X-Original-Sender: thiago@macieira.org
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of thiago@macieira.org designates 2a01:4f8:d13:f81:21c:14ff:fe01:12a3
 as permitted sender) smtp.mailfrom=thiago@macieira.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:34984
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/34984>

On ter=C3=A7a-feira, 17 de outubro de 2017 10:02:11 PDT 'Richard Smith' via=
 ISO C++=20
Standard - Future Proposals wrote:
> Please read to the end of the paper; that alternative is discussed and we
> explain why it is not entirely satisfactory.

And I agree. My first reaction was, "why not just add a class operator dele=
te",=20
which is answered in the paper.

I like the idea of the destroying operator delete.

Can we have a constructing operator new too? That is, the dual of what the=
=20
paper proposes. That would allow for the object to have a public constructo=
r=20
too. This has been a request in QObject for some time, but we have never fo=
und=20
a satisfactory (i.e., non-hacky or inefficient) solution.

Almost all class types using private implementations would benefit from thi=
s.=20
Take this from actual code <https://code.woboq.org/qt5/qtbase/src/corelib/
kernel/qobject.cpp.html#_ZN7QObjectC1EPS_>:

QObject::QObject(QObject *parent)
    : d_ptr(new QObjectPrivate)

You'll find that QObject is roughly even divided between stack / member obj=
ects=20
and those created with new QObject (or one of the derived classes).

It would be grand to have:

QObject *QObject::operator new(/* implicit size */)
{
    size_t full_size =3D sizeof(QObject) + sizeof(QObjectPrivate);
    auto obj =3D static_cast<QObject *>(::operator new(full_size));
    auto d =3D reinterpret_cast<QObjectPrivate *>(obj + 1);
    // call a private or protected constructor
    return new (obj) QObject(InPlaceTag{}, d);
}

Coupled with a member operator delete (not necessarily the destroying delet=
e),=20
the only other things we need is 1 bit indicating that the main class does =
not=20
own the private object and should not delete it.

--=20
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1643738.UGnyhZm5To%40tjmaciei-mobl1.

.
