]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Use if-constexpr in std::__try_use_facet [PR113099]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 3 Jan 2024 12:23:32 +0000 (12:23 +0000)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 5 Jan 2024 10:23:35 +0000 (10:23 +0000)
As noted in the PR, we can use if-constexpr for the explicit
instantantiation definitions that are compiled with -std=gnu++11. We
just need to disable the -Wc++17-extensions diagnostics.

libstdc++-v3/ChangeLog:

PR libstdc++/113099
* include/bits/locale_classes.tcc (__try_use_facet): Use
if-constexpr for C++11 and up.

libstdc++-v3/include/bits/locale_classes.tcc

index 2a6176fb4de45b21d03ca1a8c39c297fcc3d5c23..63097582decfe8c016933624a3fb7f6a99549a97 100644 (file)
@@ -87,6 +87,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
                                __s2.data(), __s2.data() + __s2.length()) < 0);
     }
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wc++17-extensions"
   template<typename _Facet>
     inline const _Facet*
     __try_use_facet(const locale& __loc) _GLIBCXX_NOTHROW
@@ -97,7 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // We know these standard facets are always installed in every locale
       // so dynamic_cast always succeeds, just use static_cast instead.
 #define _GLIBCXX_STD_FACET(...) \
-      if _GLIBCXX17_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \
+      if _GLIBCXX_CONSTEXPR (__is_same(_Facet, __VA_ARGS__)) \
        return static_cast<const _Facet*>(__facets[__i])
 
       _GLIBCXX_STD_FACET(ctype<char>);
@@ -145,6 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return static_cast<const _Facet*>(__facets[__i]);
 #endif
     }
+#pragma GCC diagnostic pop
 
   /**
    *  @brief  Test for the presence of a facet.