220 41388 <f6ad2ae2-079e-3ecd-b40c-3898319a80c4@gmail.com> article
Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail
From: Andrey Semashev <andrey.semashev@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Improving compile times for non-template
 dependent member functions.
Date: Wed, 23 Jan 2019 19:34:31 +0300
Approved: news@gmane.org
Message-ID: <f6ad2ae2-079e-3ecd-b40c-3898319a80c4@gmail.com>
References: <6a72db2a-932d-4f79-ab68-7c1424e93b9d@isocpp.org>
 <a97e361c-772e-6fb5-5ca8-d72250f45541@gmail.com>
Reply-To: std-proposals@isocpp.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
Content-Transfer-Encoding: quoted-printable
Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226";
	logging-data="61190"; mail-complaints-to="usenet@blaine.gmane.org"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
 Thunderbird/60.0.1
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCXY5TXHWYJRBG5PULRAKGQETKUGSZQ@isocpp.org Wed Jan 23 17:34:36 2019
Return-path: <std-proposals+bncBCXY5TXHWYJRBG5PULRAKGQETKUGSZQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lj1-f198.google.com ([209.85.208.198])
	by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
	(Exim 4.89)
	(envelope-from <std-proposals+bncBCXY5TXHWYJRBG5PULRAKGQETKUGSZQ@isocpp.org>)
	id 1gmLU4-000FoV-9p
	for gclcip-std-proposals@m.gmane.org; Wed, 23 Jan 2019 17:34:36 +0100
Original-Received: by mail-lj1-f198.google.com with SMTP id x18-v6sf808862lji.0
        for <gclcip-std-proposals@m.gmane.org>; Wed, 23 Jan 2019 08:34:36 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1548261276; cv=pass;
        d=google.com; s=arc-20160816;
        b=Ku/rvWrZHB0uSh5ary6U4EKfe8P1kDCqDb9BFwD0+yxL4w9RR15FBH132CqqtvqmB1
         GL58hQreJHAvmvY2xe4NHzgR+pdIRRS5crLlicegZ7pBhl+Yqzfha2aja0rEovn2PmZA
         HNxnpBoP2bBiVFM2jt16NWpAenmmgF7rU0yXqTAvolYfjNhT3NrGdyHmxMWHMXw4CNNH
         PlV3E9NipmNueVnBflamBnuTmnDtxQ+5pPCAlcPU9rtkHloUEfxNcYqlqfpPd4drJlRy
         qWh5PkYcpstnJItFYrWmURnjxSyobu4+SySypoH/4mLR0PUb8sUHZYBVAy4pQYhlyxCC
         KN7A==
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:references:to:from:subject:dkim-signature;
        bh=cYpCicN0RtH/la0Dt/GHjZEzMdoKHIcy+tzmYDEITUU=;
        b=l5YS9KkgFMYB9AkvjFJHG3JMrGGqRnRTQ7o8Ah536y6AX2Fz7YiBgfV0RY8RcBYcJs
         AxxquzVxUOLgFtKqXpWjoJL0vszVxASGkAQCUNtF5rKB733dDVifcgFkF64ZLYPW/uQz
         QdTGdKjGN9cLCXEQj1Zq0cEbmLzuLwbB05E06GnNvEc8kpHIlkk1B0Xrj/tzj45ojK5V
         IfwV3pvPNAefZfDmiYBbKs1KhnMimgCkkdaM5q0x1x0dforNrL9EKwplqAlfmGJ7x6ze
         yn9WCipHzRINdRAbt2tuhJWwDKi0MvCpJZZ9mQ1pw3lDNr772WW3ioNzPS3yjnCZzVIV
         gKpQ==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=N2nlVMnq;
       spf=pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=andrey.semashev@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:from:to:references: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=cYpCicN0RtH/la0Dt/GHjZEzMdoKHIcy+tzmYDEITUU=;
        b=QtQnhs1O/IhAvBHM6w8e/XZKOPqRwXUuFxEWaBZfx5fV/vyMGnnB6TnET8DHi9EhI3
         8UQa2W6s5RXOg8DHodE20APaP2eImzJw84k0PuiRnBsDq10eBBLL7PwM7pExgXqmBqhC
         BpvnB7zq8ruOKW/xQEJDPiEz9I/2l7PTJlwYHbeQFDVgurP8z0NgID25cgRVQqwtuUl/
         kI/7FBBRMa0ZzjpF3OVf0o1c170Im7hP4IBI3AD/54MlghhUPhpdAKmdFBeMHbVPg87Q
         2GFHVQCQNiEeiB4ZDG9BiBb6Bt1OBTiO6Pb3lG6GvKz2fh2RY7P33rwvAmEnxHz+2FHH
         hxZ 
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:from:to:references: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=cYpCicN0RtH/la0Dt/GHjZEzMdoKHIcy+tzmYDEITUU=;
        b=j8iPuv6YQ/IJ/W1oq6sLP7cjlqhkjphZLucZBv1uHomnUw9P2H6HJBQ3Or7JHjyjhq
         /lW9ZSe+bkFr90Pm0vNeNMHh+yDBwjkOn3elSeM5YaHNaAh6hxE1x36b+DuvwnEfsFD3
         7wGH+8saUejDmLmqm1yBhM1WNAqyql6gQGdePNkEkKJTscqLZlwq/AMNEvuPkqxnskL9
         KqKWFmG3FVqxt+rr6MMLTdlQwpTIXaUk7xEYe2pRgKRbWCBEtsTzeqc3UPupEf/Tz6Sd
         C3dHvmAVQi6tZYFe6ROi80r+BVvIDSflH7jgK5xXass 
X-Gm-Message-State: AJcUukfJqLu1WwFDRXqKjMKOtFX70CzInrXSgmvZvKj2E5hCbrMwxF+a
	NldPogDfcc8gywXeg+YQYiMotQ==
X-Google-Smtp-Source: ALg8bN4/3rQLmQxgIgoDMoQWvYN06dh+LI/C14qoB/KjAri6IkTWKFEIrC8MzTrKjuOidTVMsCyVgQ==
X-Received: by 2002:a19:f202:: with SMTP id q2mr254713lfh.8.1548261275819;
        Wed, 23 Jan 2019 08:34:35 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a19:2d4f:: with SMTP id t15ls304013lft.2.gmail; Wed, 23 Jan
 2019 08:34:34 -0800 (PST)
X-Received: by 2002:a19:d58e:: with SMTP id m136mr2570387lfg.70.1548261273998;
        Wed, 23 Jan 2019 08:34:33 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1548261273; cv=none;
        d=google.com; s=arc-20160816;
        b=SDVhMWKWtS4pZIL7Iqzf4oDb39e5Gvz5zER0WJ3cHbLFJA7kFdlIS7paLCL+HoqlHd
         vcss6qyvZF5CBTr+GfJR/jNZWNwyvMzUfy4i0oJEiQXr+3u/O/6YY4J1HS1V0JclL3fw
         7xKm9KkdGxOsIOpTzVP6TD/sUw9dpnHlIOtZ9RuuhyotICFhbhvRCN6ukycuiqQ8YEFO
         y/VKdqBQoF3v4uwnsR9jJ2PHUe15tgXvy72xVKMZ8BzuoaLMNO0Rv/aUJqRUmREaMmH/
         fUCKlrbdCZbf04oRd21WYgvaIzP/21q5RIvyEgQ5ElvruQChgjpXeAWOE3oZiXerePkF
         drLw==
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:references:to:from:subject
         :dkim-signature;
        bh=apN90Jjroa8lSWcS9IxG3R9i7zeBIB5Gq1nS0W7twQA=;
        b=aTXEyOEyob25cvgKCqOH6lLMbrZJUSz2k1adCT3ZMoKbX+Cn29DwA1GjfQzSroo/Wd
         8zIzoA2PJ/eMqEr+g393GVUK5TC1CB90UuOIaD9rAhuGpWlS+ZkchcD153lapvEKrpBb
         xUAnb4ZlcEkKH0CtBcH3F75dKvOacLg89gKz64K12V+mdKvMBgCyGk38uIaiOj80aJNr
         L7iX7k21OV2io6GcDLjq/8T3uR5kwBxPlJ7D5i8lXOSVgwUZ2t82d2YsgQNdehnZHHDF
         e5gPbdP+ITOJxQuh6SsU2kMPJlKr0ZklJ09kdL+gaA743zb69G/SZ4mN6qr/2iU1GA4/
         vAeg==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=N2nlVMnq;
       spf=pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=andrey.semashev@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 p8-v6sor2658312ljj.23.2019.01.23.08.34.33
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Wed, 23 Jan 2019 08:34:33 -0800 (PST)
Received-SPF: pass (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 2002:a2e:5418:: with SMTP id i24-v6mr2562012ljb.51.1548261273347;
        Wed, 23 Jan 2019 08:34:33 -0800 (PST)
Original-Received: from [192.168.1.2] (broadband-37-110-31-10.ip.moscow.rt.ru. [37.110.31.10])
        by smtp.googlemail.com with ESMTPSA id x24-v6sm637195ljc.54.2019.01.23.08.34.32
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Wed, 23 Jan 2019 08:34:32 -0800 (PST)
In-Reply-To: <a97e361c-772e-6fb5-5ca8-d72250f45541@gmail.com>
Content-Language: ru
X-Original-Sender: andrey.semashev@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=N2nlVMnq;       spf=pass
 (google.com: domain of andrey.semashev@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=andrey.semashev@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:41388
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41388>

On 1/23/19 7:11 PM, Andrey Semashev wrote:
> On 1/23/19 6:58 PM, p groarke wrote:
>> I'll take a wild guess this has already been asked, thought-of or=20
>> written about, but lets ask anyways. I'm curious why one cannot write=20
>> the implementation of non-template dependent member function in a=20
>> compile unit, in the hopes of improving compile times.
>>
>> For example :
>>
>> .h
>>
>> |
>> template<classT>
>> structtest {
>> intval()const;
>>
>> private:
>> intval {42};
>> =C2=A0=C2=A0 =C2=A0 T t;
>> };
>> |
>>
>>
>> .cpp
>>
>> |
>> // I do not depend on T, can implement in compile unit.
>> // Declaration semantics unimportant.
>> inttest::val()const{
>> returnval;
>> }
>> |
>>
>>
>> I remember a cppcon talk from Ubisoft, where they bypass this issue by=
=20
>> inheriting a base class with non-template dependent behavior=20
>> implemented in their compile unit. Template dependent behavior is=20
>> implemented in the header of the derived class.
>> Why not offer this compilation behavior out-of-the-box?
>=20
> I assume, the main reason is that because the method is not instantiated=
=20
> until it is ODR-used (e.g. called). This is a useful property, which, in=
=20
> fact, may improve compile times if the method body causes a lot of other=
=20
> template instantiations or expensive code generation.

Also, even if val's body does not depend on template parameters of its=20
class, it is still dependent. test<T>::val are distinct functions for=20
different Ts. There are also template specializations to consider.

--=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/f6ad2ae2-079e-3ecd-b40c-3898319a80c4%40gmail.com=
..

.
