From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id D3AC13858C78 for ; Fri, 17 Feb 2023 12:03:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D3AC13858C78 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x134.google.com with SMTP id t4so482048lfr.7 for ; Fri, 17 Feb 2023 04:03:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=z+rBO66sCW2dQjypN1/YzDNSgeHnN4svNHQw5RpU2dU=; b=R6FKa/M4ab9p1Y4vJ2n8WWvt1LDg1G6JsrN5OeGxeGR2UBmc/9qeZBfQGCP1vVVabk Ys8sDh2O00lclXsTw7Qinnz+M2jaaegrT1y4hPKbMjhZbNKFQ1IKAaMzb8rUX5ryPZCR 7MoJKnSukIAALP0EZtoqD8hy4hoCrXw5W7vSHR5NQmTM1hoVbGY5DBHjOJ6F60cVW47V EoGpfF2KPStwzNOpdkuMq/xzsufXBzoctJ/ORYy9nasd79uF/znCKKUajOnuTEbkTuKc AyzBfodubZq4l2PtmLGkrJml5uqHa+HKWGj6epRYmYyltXLoXYCKOVD+WbDqY9m5otnM E10A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=z+rBO66sCW2dQjypN1/YzDNSgeHnN4svNHQw5RpU2dU=; b=DJ2spSBn5HmNtBPRkHKl/gNfsr21vWFHJjPI5zdzufhzONTP+4asZyh/5efW6EmPnO bZ8dvL7JY+USnaXJJpMLC/l4AcP3kK6S/7ffJmvfvwG+vhGKuhj/6HpchgQawF13qBlW fZzeI6WitPwIWAkqtjnbXMntmKEu750FMD8C1fr7hlOn2Op4w2GT7PO+t8A9whoaYtiA va96Kltb9AdWM039OvpMBEB6zdyDhcZh6HRSo9tNvIIw13poIYba1DCwtp1uWiROm8Rt MpUE4HM+ZIfomYlTBloev5bg6z10xsbM0WfMFuB7soB1dl23IOubK0kvQ1NZoTZqJOG8 hRyg== X-Gm-Message-State: AO0yUKUBwfQYdFjGEjoXp8Naqti58urQ1hwxBx4W2ZR0dTtUdsrjSE50 vWYbte11NNm4ROWzt0CRTwUHJokUEaASEUtxLn8= X-Google-Smtp-Source: AK7set991rYHIpp5Ff0aThfZRgKLbnKj/L80lm+v490W16Z+dd6zPD45vPHrx2q9j6h5zqsag+j3QILYI75ZU8UzdFg= X-Received: by 2002:ac2:530d:0:b0:4d5:ca42:e438 with SMTP id c13-20020ac2530d000000b004d5ca42e438mr325161lfh.1.1676635379980; Fri, 17 Feb 2023 04:02:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Julien D Arques Date: Fri, 17 Feb 2023 13:02:48 +0100 Message-ID: Subject: Re: Tip to reduce manual template declaration? To: Jonathan Wakely Cc: gcc-help Content-Type: multipart/alternative; boundary="0000000000003ddbe205f4e418a4" X-Spam-Status: No, score=0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --0000000000003ddbe205f4e418a4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Yes, Actually the net result is the productivity bump for the devs I pay. Before that the trend was to take a small break. Now, they are focused because the compilation of the whole code is almost instant. I am a business man before being a dev. Every dollar paid must be productive. I don't regret my move but it was painful to do. Le ven. 17 f=C3=A9vr. 2023 =C3=A0 12:39, Jonathan Wakely a =C3=A9crit : > > > On Fri, 17 Feb 2023, 07:24 Julien D Arques via Gcc-help, < > gcc-help@gcc.gnu.org> wrote: > >> Hi, >> I just finished a project that required to generate a static library out >> of >> heavily templated code. >> > > Why? > > >> It has been a productivity nightmare and will be hard to extend if needs >> be. >> Many "extern template XXX" in .hpp and corresponding "template XXX" in >> .cpp >> that killed my day (many possible type combinations). >> > > But why did you do that? > > >> That need may happen again in a future project and I really don't want to >> reiterate what I did. >> >> Maybe modules will help but I need a solution that can be applied now. >> >> Do we have a hack in GCC to avoid this pitfall? >> > > Just don't do it. > > Templates are implicitly instantiated as needed. Why do you need them > defined in the static library, instead of letting users instantiate them = as > needed when compiling the headers? > > If you're doing it to make compiling those headers faster, that's a valid > choice you've made, but you're trading more work for you when creating the > library vs less work for the compiler when using the library. If you choo= se > to do that, then I'm afraid there's no short cut to avoid doing the extra > work. > > One alternative would be to define the entry points to the library API as > non-template functions, and then just let the templates be implicitly > instantiated for the definitions of those functions in the library. But > that would mean designing a different API and that might be just as much > work (if it's even practical to do that). > --0000000000003ddbe205f4e418a4--