public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r9-9474] libstdc++: Define __cpp_lib_constexpr_string macro
Date: Thu, 29 Apr 2021 11:14:11 +0000 (GMT)	[thread overview]
Message-ID: <20210429111411.BC2393A19001@sourceware.org> (raw)

https://gcc.gnu.org/g:cd5a61a33f6223314b14ae1aa2eed09c20ef81e1

commit r9-9474-gcd5a61a33f6223314b14ae1aa2eed09c20ef81e1
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Apr 28 15:56:04 2021 +0100

    libstdc++: Define __cpp_lib_constexpr_string macro
    
    As noted in r11-1339-gb6ab9ecd550227684643b41e9e33a4d3466724d8 we define
    a non-standard __cpp_lib_constexpr_char_traits feature test macro to
    indicate support for P0426R1 and P1032R1. At some point last year the
    __cpp_lib_constexpr_string macro was retconned to indicate support for
    those papers. This adds the new macro (which we didn't previously
    define, because it referred to P0980R1 "Making std::string constexpr"
    which we don't support).
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/basic_string.h (__cpp_lib_constexpr_string): Define.
            * include/std/version (__cpp_lib_constexpr_string): Define.
            * testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc:
            Check for __cpp_lib_constexpr_string.
            * testsuite/21_strings/char_traits/requirements/version.cc: New test.
    
    (cherry picked from commit 3da80ed7efd582575e7850a403ce693ec882d087)

Diff:
---
 libstdc++-v3/include/bits/basic_string.h                 |  3 ++-
 libstdc++-v3/include/std/version                         |  1 +
 .../requirements/constexpr_functions_c++17.cc            |  7 +++++++
 .../21_strings/char_traits/requirements/version.cc       | 16 ++++++++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h b/libstdc++-v3/include/bits/basic_string.h
index cacc31a9aa9..fbca63bb3aa 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -48,11 +48,12 @@
 # include <string_view>
 #endif
 
-
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
+#define __cpp_lib_constexpr_string 201611L
+
 #if _GLIBCXX_USE_CXX11_ABI
 _GLIBCXX_BEGIN_NAMESPACE_CXX11
   /**
diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version
index 0f704c054cf..51cc821558f 100644
--- a/libstdc++-v3/include/std/version
+++ b/libstdc++-v3/include/std/version
@@ -126,6 +126,7 @@
 #define __cpp_lib_chrono 201611
 #define __cpp_lib_clamp 201603
 #define __cpp_lib_constexpr_char_traits 201611
+#define __cpp_lib_constexpr_string 201611L
 #define __cpp_lib_enable_shared_from_this 201603
 #define __cpp_lib_execution 201902L // FIXME: should be 201603L
 #define __cpp_lib_filesystem 201703
diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc
index 92c301b1900..6dd181fd33c 100644
--- a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc
+++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/constexpr_functions_c++17.cc
@@ -73,6 +73,13 @@ template<typename CT>
     return true;
   }
 
+#ifndef __cpp_lib_constexpr_string
+# error Feature-test macro for constexpr char_traits is missing
+#elif __cpp_lib_constexpr_string < 201611
+# error Feature-test macro for constexpr char_traits has the wrong value
+#endif
+
+// We also provide this non-standard macro for P0426R1.
 #ifndef __cpp_lib_constexpr_char_traits
 # error Feature-test macro for constexpr char_traits is missing
 #elif __cpp_lib_constexpr_char_traits != 201611
diff --git a/libstdc++-v3/testsuite/21_strings/char_traits/requirements/version.cc b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/version.cc
new file mode 100644
index 00000000000..073fa36ab18
--- /dev/null
+++ b/libstdc++-v3/testsuite/21_strings/char_traits/requirements/version.cc
@@ -0,0 +1,16 @@
+// { dg-do compile { target c++17 } }
+
+#include <version>
+
+#ifndef __cpp_lib_constexpr_string
+# error Feature-test macro for constexpr char_traits is missing in <version>
+#elif __cpp_lib_constexpr_string < 201611
+# error Feature-test macro for constexpr char_traits has the wrong value in <version>
+#endif
+
+// We also provide this non-standard macro for P0426R1 and P1032R1.
+#ifndef __cpp_lib_constexpr_char_traits
+# error Feature-test macro for constexpr char_traits is missing in <version>
+#elif __cpp_lib_constexpr_char_traits != 201611
+# error Feature-test macro for constexpr char_traits has the wrong value in <version>
+#endif


                 reply	other threads:[~2021-04-29 11:14 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210429111411.BC2393A19001@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@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).