220 29557 <CAKgx6B+8zzZ131-UZobmUvCgB4YeQ1+wTZadcuT6ieDCofDndg@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: Instantiation of default destructor
Date: Mon, 28 Nov 2016 13:14:13 +0100
Lines: 105
Approved: news@gmane.org
Message-ID: <CAKgx6B+8zzZ131-UZobmUvCgB4YeQ1+wTZadcuT6ieDCofDndg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=94eb2c06105c5269c405425b6b3d
X-Trace: blaine.gmane.org 1480335301 476 195.159.176.226 (28 Nov 2016 12:15:01 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 28 Nov 2016 12:15:01 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCHJ3Z4NUUFBBPV76DAQKGQE4V6HERY@isocpp.org Mon Nov 28 13:14:53 2016
Return-path: <std-proposals+bncBCHJ3Z4NUUFBBPV76DAQKGQE4V6HERY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pg0-f71.google.com ([74.125.83.71])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCHJ3Z4NUUFBBPV76DAQKGQE4V6HERY@isocpp.org>)
	id 1cBKpf-0007EQ-Rc
	for gclcip-std-proposals@m.gmane.org; Mon, 28 Nov 2016 13:14:52 +0100
Original-Received: by mail-pg0-f71.google.com with SMTP id q10sf354713082pgq.7
        for <gclcip-std-proposals@m.gmane.org>; Mon, 28 Nov 2016 04:14:56 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version: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=DYbJa6GQ57/WHSMFXlIOvCw106FyUaVOyponq4fzRy8=;
        b=y/K+4X3IzT5bZ57n+G1hS08/5W4KHH0db4Y6P/upHr0BPf8fLnIv1fP95f2NjuCEUp
         iLVKsnLEdCgq7lp5wGX+w8amG/QlniJBn6XZjXxKeJoRhsRxOPNczGzS07u74Y4zpEpc
         qMQ0pWdCsDEUSzXBb/xkWnCfZ1A5r7f5vwfO/I5BzhPMOxwjKC83/KcnVkiFTYsmynDa
         Zvu+XhJIEWSFSO6wzuJ4ogZCgbRy5h3O9dXH9sDi9QiYAXDTlRKvE6zWmKn958KuEVdJ
         +0ZHgYDSWywf2YOcNGRRLP48Yh+Eux8Uhl81c0c9A/A961oIdyn5XNnQLHBCGv4BqxbH
         +o/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version: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=DYbJa6GQ57/WHSMFXlIOvCw106FyUaVOyponq4fzRy8=;
        b=JYtA49GCNUDmJayWRBb08Waexx7XOgY0OH6gCDgPWoabJnCK0eGP7e++XNtMr06F/9
         tWmDVXnur5R87Uh8W75tGZKviKxZ0U4iJtvvKIUXmkGHFUnvq3s1a/pqbnbh4vFiY6II
         NDrY+YrPxB3zmKGrwPPZInWv5EROyv69Nx2JeylfqwVbddHqQ0QkxHoGawbHkd7Gr7UU
         ch1LDoislzbhFCMvIJsM7k4eMPQhnnR9rGcMAEbTyhY6FsJxUIWbGwPlKkUM8wmnXXaa
         vcu1FlFNGtIzScW2/5bSRF2moyPHRzQhV5mybZSIilnIxyZBi9FVQ+ZiEvKycwXsJjfl
         Y+Cw==
X-Gm-Message-State: AKaTC01segIIZxj2YRwAO09vlPr8MxuZ8FIPppdxH7OrD48KvykJL+xauneHuBojAUHH9A==
X-Received: by 10.99.67.194 with SMTP id q185mr10353643pga.31.1480335295356;
        Mon, 28 Nov 2016 04:14:55 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.107.136.90 with SMTP id k87ls2968453iod.19.gmail; Mon, 28 Nov
 2016 04:14:54 -0800 (PST)
X-Received: by 10.107.189.196 with SMTP id n187mr18266668iof.88.1480335294147;
        Mon, 28 Nov 2016 04:14:54 -0800 (PST)
Original-Received: from mail-io0-x233.google.com (mail-io0-x233.google.com. [2607:f8b0:4001:c06::233])
        by mx.google.com with ESMTPS id 66si18569692itx.49.2016.11.28.04.14.54
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 28 Nov 2016 04:14:54 -0800 (PST)
Received-SPF: pass (google.com: domain of domen.vrankar@gmail.com designates 2607:f8b0:4001:c06::233 as permitted sender) client-ip=2607:f8b0:4001:c06::233;
Original-Received: by mail-io0-x233.google.com with SMTP id c21so220766322ioj.1
        for <std-proposals@isocpp.org>; Mon, 28 Nov 2016 04:14:54 -0800 (PST)
X-Received: by 10.107.62.195 with SMTP id l186mr5228221ioa.1.1480335293571;
 Mon, 28 Nov 2016 04:14:53 -0800 (PST)
Original-Received: by 10.50.235.15 with HTTP; Mon, 28 Nov 2016 04:14:13 -0800 (PST)
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::233 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:29557
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/29557>

--94eb2c06105c5269c405425b6b3d
Content-Type: text/plain; charset=UTF-8

Hi,

In this video [1] <https://www.youtube.com/watch?v=8AjRD6mU96s> (time
57:40) Jason Jurecka was talking about the need to write empty/defaulted
destructor in cpp file if you want to declare a class in header file, use
it in std::unique_ptr and include its declaration only in cpp file:

//a.h
....
class T;

struct A
{
A(T* ptr_); // intentionally before A() constructor - see the question below
A();
std::unique_ptr<T> ptr;
};
....

//a.cpp
#include "a.h"
#include "t.h" // declaration of T class
....
A::A() {}
A::A(T* ptr_) : ptr{ptr_} {}
....

This won't work since default destructor is (if I understood the reason why
Tomasz Wota's example in the comment worked: [2]
<http://melpon.org/wandbox/permlink/k8UpfCT8DlYv1hv3>) implemented at the
end of the compilation unit.

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?

Thanks,
Domen

[1] https://www.youtube.com/watch?v=8AjRD6mU96s
[2] http://melpon.org/wandbox/permlink/k8UpfCT8DlYv1hv3

-- 
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/CAKgx6B%2B8zzZ131-UZobmUvCgB4YeQ1%2BwTZadcuT6ieDCofDndg%40mail.gmail.com.

--94eb2c06105c5269c405425b6b3d
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div><div>Hi,<br><br></div>In this video <a href=3D"https:=
//www.youtube.com/watch?v=3D8AjRD6mU96s">[1]</a> (time 57:40) Jason Jurecka=
 was talking about the need to write empty/defaulted destructor in cpp file=
 if you want to declare a class in header file, use it in std::unique_ptr a=
nd include its declaration only in cpp file:<br><br></div><div>//a.h<br>...=
<br></div><div>class T;<br><br></div><div>struct A<br></div><div>{<br>A(T* =
ptr_); // intentionally before A() constructor - see the question below<br>=
</div><div>A();</div><div>std::unique_ptr&lt;T&gt; ptr;<br></div><div>};<br=
></div><div>...<br><br></div><div>//a.cpp<br></div><div>#include &quot;a.h&=
quot;<br></div><div>#include &quot;t.h&quot; // declaration of T class<br><=
/div><div>...<br></div><div>A::A() {}<br></div><div>A::A(T* ptr_) : ptr{ptr=
_} {}<br></div><div>...<br><br></div><div>This won&#39;t work since default=
 destructor is (if I understood the reason why Tomasz Wota&#39;s example in=
 the comment worked: <a href=3D"http://melpon.org/wandbox/permlink/k8UpfCT8=
DlYv1hv3">[2]</a>) implemented at the end of the compilation unit.<br><br><=
/div><div>For me it&#39;s not a big deal to write A::~A() =3D default; in c=
pp file but still since we&#39;ve had that debate I was wondering if it wou=
ld 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 destructor woul=
d 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 fi=
le) and not at the end of the file where the class was declared?<br><br></d=
iv><div>Thanks,<br></div><div>Domen<br></div><div><br>[1] <a href=3D"https:=
//www.youtube.com/watch?v=3D8AjRD6mU96s">https://www.youtube.com/watch?v=3D=
8AjRD6mU96s</a><br>[2] <a href=3D"http://melpon.org/wandbox/permlink/k8UpfC=
T8DlYv1hv3">http://melpon.org/wandbox/permlink/k8UpfCT8DlYv1hv3</a><br></di=
v></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/CAKgx6B%2B8zzZ131-UZobmUvCgB4YeQ1%2Bw=
TZadcuT6ieDCofDndg%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAKgx6B%2B8zz=
Z131-UZobmUvCgB4YeQ1%2BwTZadcuT6ieDCofDndg%40mail.gmail.com</a>.<br />

--94eb2c06105c5269c405425b6b3d--

.
