220 29561 <CAKgx6BK4yf6YexmGyFKPg2cyStMxdNp7-gJQy=cTehbw_xk=aQ@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Domen Vrankar <domen.vrankar@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Instantiation of default destructor
Date: Mon, 28 Nov 2016 20:17:12 +0100
Lines: 139
Approved: news@gmane.org
Message-ID: <CAKgx6BK4yf6YexmGyFKPg2cyStMxdNp7-gJQy=cTehbw_xk=aQ@mail.gmail.com>
References: <CAKgx6B+8zzZ131-UZobmUvCgB4YeQ1+wTZadcuT6ieDCofDndg@mail.gmail.com>
 <CAGg_6+Nkv4oNaA8FuA68VQCEzfqnVM3A1ZBSxt2NOtsUgDB1gQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a114fce3a10dc91054261542d
X-Trace: blaine.gmane.org 1480360679 13928 195.159.176.226 (28 Nov 2016 19:17:59 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 28 Nov 2016 19:17:59 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCHJ3Z4NUUFBBYUF6LAQKGQES4KKTBA@isocpp.org Mon Nov 28 20:17:54 2016
Return-path: <std-proposals+bncBCHJ3Z4NUUFBBYUF6LAQKGQES4KKTBA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f69.google.com ([74.125.83.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCHJ3Z4NUUFBBYUF6LAQKGQES4KKTBA@isocpp.org>)
	id 1cBRR1-0002df-CH
	for gclcip-std-proposals@m.gmane.org; Mon, 28 Nov 2016 20:17:51 +0100
Original-Received: by mail-pg0-f69.google.com with SMTP id q10sf378000192pgq.7
        for <gclcip-std-proposals@m.gmane.org>; Mon, 28 Nov 2016 11:17:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :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=fqi70YNoAcnhgahsjFYBFcxKIve/HM7mnpGrPTQjZz4=;
        b=MsccngRUtYtZ5ugsB84gTX2SDwCFtd6xDEhT3N4JzhXv4QpEqWRRJDddTi8S2LPd6U
         PEmHjNWPHSXFynf3r+G7P/8jQWXGmk5kad96DHkjpt8nOkr6PPAXhnjZaGySis22iymM
         TRUYtV8MXQsvWfaBpadR7z7qUSPzltNOLN5vRmf6V514JLLObRRF9XSwFkJ3uhnb8ER7
         k/FnUX4ho72JKeOVdlJ4A9EIK7QCfR5zOoiLxgyl3NikmfyBexyVVPuL5mQtJohh9xb4
         3Dfd6LJJXdUHHN5xR0Kry1ngSA+w9dCV5z5aL3i8eWgFEoN0EA3yPxozG2d+lU+a/z7f
         pliQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to: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=fqi70YNoAcnhgahsjFYBFcxKIve/HM7mnpGrPTQjZz4=;
        b=E+rPp7OhgFQ69C4vou2KzMuWotTwnLqik5UfuIuI13lUz6AYaO1Dmv30ar53oyNHid
         +j60SzXA4KXA7afUcaU3PjBXA4Em8xNXQIyj8jKgKnG8Ae1VfCEwnOkZaxlBN68MkQO8
         9JsH9h/PQunrnog5BIO7LDScG7qULhBnbFo9B7P8W74oLaaIV1n3kHAUuplxNrRvZsp7
         L2G/UhLLHLWhfM6rJKWE17pnr83af3V5CTok0/qUArv2OR7c22XCopfrGsS8v1ZWyYGL
         Cfwu9LiAMiCm5lNqee+78rcOnqClV+UfdkSVw1b9OcwTvswYpaUjgXX2Ri+v60QB4MH2
         k8PQ==
X-Gm-Message-State: AKaTC02HpBM4hbl8EMSGzKjT2zogDWIcrtL1ig8odZoeOEpr5k7qFKFLX6JBJ8aUQoQ9Eg==
X-Received: by 10.99.164.25 with SMTP id c25mr11131048pgf.114.1480360674849;
        Mon, 28 Nov 2016 11:17:54 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.79.145 with SMTP id c139ls3342829itb.8.gmail; Mon, 28 Nov
 2016 11:17:53 -0800 (PST)
X-Received: by 10.36.66.143 with SMTP id i137mr20274447itb.43.1480360673805;
        Mon, 28 Nov 2016 11:17:53 -0800 (PST)
Original-Received: from mail-io0-x231.google.com (mail-io0-x231.google.com. [2607:f8b0:4001:c06::231])
        by mx.google.com with ESMTPS id j9si19856061itj.82.2016.11.28.11.17.53
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 28 Nov 2016 11:17:53 -0800 (PST)
Received-SPF: pass (google.com: domain of domen.vrankar@gmail.com designates 2607:f8b0:4001:c06::231 as permitted sender) client-ip=2607:f8b0:4001:c06::231;
Original-Received: by mail-io0-x231.google.com with SMTP id m5so109900444ioe.3
        for <std-proposals@isocpp.org>; Mon, 28 Nov 2016 11:17:53 -0800 (PST)
X-Received: by 10.107.20.77 with SMTP id 74mr20110641iou.66.1480360673203;
 Mon, 28 Nov 2016 11:17:53 -0800 (PST)
Original-Received: by 10.50.235.15 with HTTP; Mon, 28 Nov 2016 11:17:12 -0800 (PST)
In-Reply-To: <CAGg_6+Nkv4oNaA8FuA68VQCEzfqnVM3A1ZBSxt2NOtsUgDB1gQ@mail.gmail.com>
X-Original-Sender: Domen.Vrankar@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of
 domen.vrankar@gmail.com designates 2607:f8b0:4001:c06::231 as permitted
 sender) smtp.mailfrom=domen.vrankar@gmail.com;       dmarc=pass (p=NONE
 dis=NONE) header.from=gmail.com
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:29561
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29561>

--001a114fce3a10dc91054261542d
Content-Type: text/plain; charset=UTF-8

2016-11-28 20:03 GMT+01:00 Nevin Liber <nevin@eviloverlord.com>:

> On Mon, Nov 28, 2016 at 6:14 AM, Domen Vrankar <domen.vrankar@gmail.com>
> wrote:
>
>> For me it's not a big deal to write A::~A() = default; in cpp file but
>> still since we've had that debate I was wondering if it would be feasible
>> to change the wording (don't know how much the standard would have to be
>> changed for that) so that implicit default destructor would be added to the
>> code at the point of first constructor implementation (in the above example
>> at the point of A::A(T* ptr_); implementation in .cpp file) and not at the
>> end of the file where the class was declared?
>>
>
> Define "first constructor implementation".
>

//a.h
// guard & include memory
struct B;
struct A
{
  A(int i); // first constructor as it is declared first
  A();
  std::shared_ptr<B> ptr;
};

//a_1.cpp
#include "a.h" // compiler sees the declaration and remembers that it needs
to generate a destructor implementation
#include "b.h"

A::A() {}

// end of file - compiler did not find the implementation of first
constructor so it just wasted space and time checking for the location
during compilation

//a_2.cpp
#include "a.h" // compiler sees the declaration...
#include "b.h"

A::A(int i) {} // implementation of the first constructor so destructor is
generated here as if writing A::~A() = default; after this line


> Different constructors for the same class may be declared in different
> compilation units (different .cpp files).  Right now the implicit ones work
> as if declared "inline", which is what allows class declaration headers to
> be included by multiple .cpp files, as well as making it easier to inline.
> IMHO, changing this is a non-starter.
>

Hm forgot about no longer implicitly inlining drawback/change that my
proposal would cause... This started out as a possibly bad idea but now it
starts to look as a really bad idea :)

Thanks,
Domen

-- 
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 email 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/CAKgx6BK4yf6YexmGyFKPg2cyStMxdNp7-gJQy%3DcTehbw_xk%3DaQ%40mail.gmail.com.

--001a114fce3a10dc91054261542d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">2016-11-28 20:03 GMT+01:00 Nevin Liber <span dir=3D"ltr">&lt;<a href=3D=
"mailto:nevin@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a=
>&gt;</span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr"><div class=3D"gmail_extra"><span class=3D"gmail-">On Mon, Nov 28, =
2016 at 6:14 AM, Domen Vrankar <span dir=3D"ltr">&lt;<a href=3D"mailto:dome=
n.vrankar@gmail.com" target=3D"_blank">domen.vrankar@gmail.com</a>&gt;</spa=
n> wrote:<br><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" s=
tyle=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);pad=
ding-left:1ex"><div>For me it&#39;s not a big deal to write A::~A() =3D def=
ault; in cpp file but still since we&#39;ve had that debate I was wondering=
 if it would be feasible to change the wording (don&#39;t know how much the=
 standard would have to be changed for that) so that implicit default destr=
uctor would be added to the code at the point of first constructor implemen=
tation (in the above example at the point of A::A(T* ptr_); implementation =
in .cpp file) and not at the end of the file where the class was declared?<=
br></div></blockquote></div><br></span>Define &quot;first constructor imple=
mentation&quot;.</div></div></blockquote><div><br><div>//a.h<br></div><div>=
// guard &amp; include memory<br></div><div>struct B;<br><span class=3D"gma=
il-m_8521159510168511345gmail-">struct A<br>{<br></span></div><div><span cl=
ass=3D"gmail-m_8521159510168511345gmail-">=C2=A0 A(int i); // first constru=
ctor as it is declared first<br></span></div><div><span class=3D"gmail-m_85=
21159510168511345gmail-">=C2=A0 A();<br></span><span class=3D"gmail-m_85211=
59510168511345gmail-">=C2=A0 std::shared</span>_ptr&lt;B&gt; ptr;<br></div>=
};<br><br></div><div>//a_1.cpp<br></div><div>#include &quot;a.h&quot; // co=
mpiler sees the declaration and remembers that it needs to generate a destr=
uctor implementation<br></div><div>#include &quot;b.h&quot;<br><br></div><d=
iv>A::A() {}<br><br></div><div>// end of file - compiler did not find the i=
mplementation of first constructor so it just wasted space and time checkin=
g for the location during compilation<br></div><div><br></div><div>//a_2.cp=
p<br></div><div>#include &quot;a.h&quot; // compiler sees the declaration..=
..<br></div><div>#include &quot;b.h&quot;<br><br></div><div>A::A(int i) {} /=
/ implementation of the first constructor so destructor is generated here a=
s if writing A::~A() =3D default; after this line<br></div><div>=C2=A0</div=
><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border=
-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div cl=
ass=3D"gmail_extra">Different constructors for the same class may be declar=
ed in different compilation units (different .cpp files).=C2=A0 Right now t=
he implicit ones work as if declared &quot;inline&quot;, which is what allo=
ws class declaration headers to be included by multiple .cpp files, as well=
 as making it easier to inline.=C2=A0 IMHO, changing this is a non-starter.=
<br></div></div></blockquote><div><br></div><div>Hm forgot about no longer =
implicitly inlining drawback/change that my proposal would cause... This st=
arted out as a possibly bad idea but now it starts to look as a really bad =
idea :)<br><br></div><div>Thanks,<br></div><div>Domen<br></div></div></div>=
</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAKgx6BK4yf6YexmGyFKPg2cyStMxdNp7-gJQ=
y%3DcTehbw_xk%3DaQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAKgx6BK4yf6Y=
exmGyFKPg2cyStMxdNp7-gJQy%3DcTehbw_xk%3DaQ%40mail.gmail.com</a>.<br />

--001a114fce3a10dc91054261542d--

.
