public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Arsen Arsenović" <arsen@aarsen.me>
To: gcc-patches@gcc.gnu.org
Cc: libstdc++@gcc.gnu.org, "Arsen Arsenović" <arsen@aarsen.me>
Subject: [PATCH] libstdc++: Make placeholders inline when inline variables are available
Date: Thu, 20 Oct 2022 16:58:53 +0200	[thread overview]
Message-ID: <20221020145849.2459976-1-arsen@aarsen.me> (raw)

This slightly lowers the dependency of generated code on libstdc++.so.

libstdc++-v3/ChangeLog:

	* include/std/functional: Make placeholders inline, if possible.
---
 libstdc++-v3/include/std/functional | 66 ++++++++++++++++-------------
 1 file changed, 37 insertions(+), 29 deletions(-)

diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional
index d22acaa3cb8..b396e8dbbdc 100644
--- a/libstdc++-v3/include/std/functional
+++ b/libstdc++-v3/include/std/functional
@@ -285,35 +285,43 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
    * simplify this with variadic templates, because we're introducing
    * unique names for each.
    */
-    extern const _Placeholder<1> _1;
-    extern const _Placeholder<2> _2;
-    extern const _Placeholder<3> _3;
-    extern const _Placeholder<4> _4;
-    extern const _Placeholder<5> _5;
-    extern const _Placeholder<6> _6;
-    extern const _Placeholder<7> _7;
-    extern const _Placeholder<8> _8;
-    extern const _Placeholder<9> _9;
-    extern const _Placeholder<10> _10;
-    extern const _Placeholder<11> _11;
-    extern const _Placeholder<12> _12;
-    extern const _Placeholder<13> _13;
-    extern const _Placeholder<14> _14;
-    extern const _Placeholder<15> _15;
-    extern const _Placeholder<16> _16;
-    extern const _Placeholder<17> _17;
-    extern const _Placeholder<18> _18;
-    extern const _Placeholder<19> _19;
-    extern const _Placeholder<20> _20;
-    extern const _Placeholder<21> _21;
-    extern const _Placeholder<22> _22;
-    extern const _Placeholder<23> _23;
-    extern const _Placeholder<24> _24;
-    extern const _Placeholder<25> _25;
-    extern const _Placeholder<26> _26;
-    extern const _Placeholder<27> _27;
-    extern const _Placeholder<28> _28;
-    extern const _Placeholder<29> _29;
+#if __cpp_inline_variables
+#  define _GLIBCXX_PLACEHOLDER inline
+#else
+#  define _GLIBCXX_PLACEHOLDER extern
+#endif
+
+    _GLIBCXX_PLACEHOLDER const _Placeholder<1> _1;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<2> _2;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<3> _3;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<4> _4;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<5> _5;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<6> _6;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<7> _7;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<8> _8;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<9> _9;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<10> _10;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<11> _11;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<12> _12;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<13> _13;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<14> _14;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<15> _15;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<16> _16;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<17> _17;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<18> _18;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<19> _19;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<20> _20;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<21> _21;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<22> _22;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<23> _23;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<24> _24;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<25> _25;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<26> _26;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<27> _27;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<28> _28;
+    _GLIBCXX_PLACEHOLDER const _Placeholder<29> _29;
+
+#undef _GLIBCXX_PLACEHOLDER
   }
 
   /**
-- 
2.38.1


             reply	other threads:[~2022-10-20 15:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-20 14:58 Arsen Arsenović [this message]
2022-10-28 14:56 ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221020145849.2459976-1-arsen@aarsen.me \
    --to=arsen@aarsen.me \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).