220 41396 <9c7f6fed-17c2-cd06-1b86-b2a64d12437e@gmail.com> article
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Improving compile times for non-template
 dependent member functions.
Date: Thu, 24 Jan 2019 15:00:45 -0500
Approved: news@gmane.org
Message-ID: <9c7f6fed-17c2-cd06-1b86-b2a64d12437e@gmail.com>
References: <6a72db2a-932d-4f79-ab68-7c1424e93b9d@isocpp.org>
 <7140056.skhr9ZE8Xc@tjmaciei-mobl1>
 <511c9222-ae06-222e-4f1b-c4843b5f83fe@gmail.com>
Reply-To: std-proposals@isocpp.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
	logging-data="118510"; mail-complaints-to="usenet@blaine.gmane.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.4.0
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBB35SVDRAKGQENIH5PBA@isocpp.org Thu Jan 24 21:00:50 2019
Return-path: <std-proposals+bncBC37LBFWUIFBB35SVDRAKGQENIH5PBA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qt1-f198.google.com ([209.85.160.198])
	by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
	(Exim 4.89)
	(envelope-from <std-proposals+bncBC37LBFWUIFBB35SVDRAKGQENIH5PBA@isocpp.org>)
	id 1gmlBB-000Uhq-Di
	for gclcip-std-proposals@m.gmane.org; Thu, 24 Jan 2019 21:00:49 +0100
Original-Received: by mail-qt1-f198.google.com with SMTP id q3sf7955441qtq.15
        for <gclcip-std-proposals@m.gmane.org>; Thu, 24 Jan 2019 12:00:49 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1548360048; cv=pass;
        d=google.com; s=arc-20160816;
        b=PXV/O4Fgap/mNQ/1nlttr4Ff/AteujQYwQxYctgjA2Hpl6/U/EWZ+n5ixOJcftzsMF
         je9ufMgTcGTfHIFkvEgwpKR4JFRLBNwpuGRBlKI46n95OymsTPCmPmds2FzqewRTUp+R
         KrPp/5o6pXZrnCSIlTwjqrPXwTWAqED7PEPTTvMCMqFpf+f1zNug2XjRe8x7DU3emPoR
         1p3qTGEzLDIROmARLdZ49LnBy4qrRtlTb6QFTU1QdGsrViowd6XjMQ/pIxpFXcl8WXie
         AaYu43lq/ZiFo/5FRdmZ8RFlDU568c/e+VLlWc4mKkDkVlmy0vycC9zmrVsoPHI8H9/U
         +VWg==
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
         :content-language:in-reply-to:mime-version:user-agent:date
         :message-id:openpgp:from:references:to:subject:dkim-signature;
        bh=QPXuABH1i9xLNnIblTd5W9mAlA5U8pWKrq3lyp2Fq9E=;
        b=HLygJ5ABcooS7s/qsKsTjEUDMnt6RuuNx2mmDEK91S5ENZVrXPo9uQciLiFoQ+gUyN
         gSrccFEwciuAYuX0qhF4QE6GLwQ10OfqDLI6Ko57UK+poIZ9mUM9z9vrAwCyVttZxhBa
         529707hsaq02+t1/SrsWUgvpL29Iujdi42pPB6WWH8SLWnQ0CpgRE++fVFiKnRU+1FLS
         QI7dnHd1Su18HWlP7mtpCmKRZgfo5VaHNHoQsOFnlcdAMXAmy3STicYKrzno75pXvC0p
         LHFqaiwk04KJYjYreVaCtyta9QrHs3piEUNPIlb/UOktcdAllHGO1xwKPg+dSN+M+sYH
         wFxA==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b="CY//QryN";
       spf=pass (google.com: domain of mwoehlke.floss@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=mwoehlke.floss@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:openpgp:message-id:date:user-agent
         :mime-version:in-reply-to:content-language: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=QPXuABH1i9xLNnIblTd5W9mAlA5U8pWKrq3lyp2Fq9E=;
        b=jv5FuGoQSp7EQ9Nt06+eTv0Ns0jgaOonQt6o7lmiJ2mH/pdN4PDQvWuZYnPgMaHYa5
         0i61fRBEKSurN0Agk5g/u3j+ZzSwS4uxSs7zlah0U6bA2EExCFhKz50Yrt0O9jfAJLDX
         oqXV4NVxh/TlHbdtiIF4pXGtJRAhH1VxUaTgPB8sho8zTXEnnBlonAeHhfK8wMK2HR9q
         1A3KaSl0oryxy0F0tJOMjY8nqCSS7REhLsUSONtYXxOYzHQReIaml+OWvvqQGwtz0tCy
         9zKlkiA3g6Xtp1tHKK1mHCP2B+qnfovGxCTSm1W8X+DbppEb7vRrvlWkgDfZXoAQlx6/
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:openpgp:message-id
         :date:user-agent:mime-version:in-reply-to:content-language
         :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=QPXuABH1i9xLNnIblTd5W9mAlA5U8pWKrq3lyp2Fq9E=;
        b=rkVxJL7uAf+Gu5Ou8rxc5u2sFeuv++YfblwyDixOIDAurJI1bT3cGztldJpjzj1am8
         yKUykBRBlCEHXbBHQdsG0xjW/4clgFnHP/xwXisA0ietc0AUcV2W3PSLOZUArvrA5NW7
         W+RgdYd0eOMcgbmhBeZu9RMzgPIF+38jeYAW/Bq+AfvnsF6VLKJetYTVzB0TUZ2T7IgZ
         NoqGvos3PSKek8d+xGhPQzDvsZJhMo/T0++nkO6vFgfmZI3gWHe8msAKLzt+hM6tL5W/
         GE7ez3nWmPU7Si/lgbuBXIYjzye2B3PhKX6 
X-Gm-Message-State: AJcUukfHVCb5wk+Y7mVN5D6b2Bm0iy8eClhughMzMM0jPH5d4OHccjHQ
	RCp+IwGEk1UU3FxaSQe1o5fDGA==
X-Google-Smtp-Source: ALg8bN5HQk8GFtPFKDjFIKWSDAjof16GxvrejX7Bo7cB6wc/ZOnmvBVm9G/DhhtnGNUVQBPajSEr8g==
X-Received: by 2002:a0c:98c6:: with SMTP id g6mr5234630qvd.46.1548360047838;
        Thu, 24 Jan 2019 12:00:47 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a0c:f348:: with SMTP id e8ls2925881qvm.2.gmail; Thu, 24 Jan
 2019 12:00:47 -0800 (PST)
X-Received: by 2002:a0c:93e2:: with SMTP id g31mr7465156qvg.194.1548360046916;
        Thu, 24 Jan 2019 12:00:46 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1548360046; cv=none;
        d=google.com; s=arc-20160816;
        b=mcU1SMT9Eit+NZn7RlMZHBYFZuMlgPlRhUJckggy+9ewQdX9w/AYzLiBT0rqDyrAwA
         1PTblfWPijMCUDnwPIDpVuvTU9OuIfe0UnUH1R+JMqbixD25Mqpb72bDZsLKD34SiMDN
         LLOohRmWnWd7d+ieqmLJE0ygVuSEgZvs/VuaXfnqEnijpiWxg1HsTFklzhmPyMNAXXd9
         VF+hBySK4U4h3W79aILUtQlMcri04gbffNKpEkpDnlFrY0aeDoivqN3erx1WBsEemgCm
         qyD7SRRqTd6VyJZ5zY+anUcg3mD1tlP/0cmuBC0yP8aF9i8m4ooBLKZ6WEdsYoFKufR6
         1TAw==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:openpgp:from:references:to:subject
         :dkim-signature;
        bh=ifB/JAOFYPbEruVKEAEgaIYyd1IlKRBZyoT3Lbt96ZQ=;
        b=w5BjCPwl2OrOf62NMya+d8xai8ymYS/56gSuZXTQ0gzu/w5APJ17mZnHfmMU+qX629
         S61Scg9YOQEavinTlt0UmI2cHcUKChNFYis5HIa7n0ndHghlRQlveoww+ZmPqQp6pkjz
         8XpClTNJEbTaOr0uVzJZcLlRwNEYYcPkBt6rMdwDeoyGEx30JHOK0S/shZQcQb1oIVkd
         ePh8LHPsLTqSFYBf8MDvK9wlqbBvC82nU9QmODJoX5coc93+G8ErNx0wWFJg4v7yS51L
         BRtl9ILXAngn/MsIxI0PixSNR4SCGlAKg/aK/0IvAUTtx5pnGg0eXtunJn/6PcOeaCl/
         J5Dg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b="CY//QryN";
       spf=pass (google.com: domain of mwoehlke.floss@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=mwoehlke.floss@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id v5sor123116538qto.3.2019.01.24.12.00.46
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Thu, 24 Jan 2019 12:00:46 -0800 (PST)
Received-SPF: pass (google.com: domain of mwoehlke.floss@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:aed:3b25:: with SMTP id p34mr8081685qte.310.1548360046491;
        Thu, 24 Jan 2019 12:00:46 -0800 (PST)
Original-Received: from gryphon.kitware.com (tripoint.kitware.com. [66.194.253.20])
        by smtp.googlemail.com with ESMTPSA id o22sm35536401qkk.93.2019.01.24.12.00.45
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Thu, 24 Jan 2019 12:00:45 -0800 (PST)
Openpgp: preference=signencrypt
In-Reply-To: <511c9222-ae06-222e-4f1b-c4843b5f83fe@gmail.com>
Content-Language: en-US
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b="CY//QryN";       spf=pass
 (google.com: domain of mwoehlke.floss@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=mwoehlke.floss@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE 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:41396
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41396>

On 23/01/2019 11.30, Andrey Semashev wrote:
> On 1/23/19 7:20 PM, Thiago Macieira wrote:
>> On Wednesday, 23 January 2019 07:58:54 PST p groarke wrote:
>>> template <class T>
>>> struct test {
>>> =C2=A0=C2=A0=C2=A0=C2=A0 int val() const;
>>>
>>> private:
>>> =C2=A0=C2=A0=C2=A0=C2=A0 int val_ { 42 };
>>> =C2=A0=C2=A0=C2=A0=C2=A0 T t;
>>> };
>>
>> Explain how, given the above, the compiler can decide whether test::val(=
)
>> depends on T or not.
>>
>> Remember: this is all the compiler sees when compiling other
>> translation units
>> that include this header.
>=20
> It doesn't need to know that. When val() is ODR-used, the compiler will
> simply leave a reference to the val symbol to be resolved by the linker.

Er... that works today (since C++98 even). It requires explicit template
instantiation, though.

You would need a way to tell the compiler a) to assume that val() will
not be dependent, and b) that a definition is non-dependent.

> The question is really whether the compiler that sees the implementation
> of val() should emit its compiled body. Currently it doesn't, presumably
> due to the reason I described in my reply.

The point (b) above would take care of this.

It might look something like:

  // .h
  template <class T>
  struct test {
    int val() const =3D template<...>;
    //...
  };

  // .cpp
  template <>
  test<...>::val() const // non-dependent specialization
  { ... }

The `=3D template<...>` tells the compiler that, if it hasn't seen
otherwise (e.g. a specialization), calls to test<T>::val should be
replaced with calls to the non-type-dependent symbol test<...>::val
(which is also declared by the same syntax). The latter syntax for
defining said symbol will of course always generate code. Note,
additionally, that the template parameter is unavailable in the
definition of this member, so anything that would depend on it
(including class statics, I suppose) is an error.

(Straw syntax, of course...)

--=20
Matthew

--=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/9c7f6fed-17c2-cd06-1b86-b2a64d12437e%40gmail.com=
..

.
