[libcxx-commits] [PATCH] D117606: [libcxx][test] Portably test that `{w, }format_context` is a specialization of `basic_format_context`

Casey Carter via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 18 14:22:16 PST 2022


CaseyCarter created this revision.
CaseyCarter added a reviewer: libc++.
CaseyCarter added a project: libc++.
CaseyCarter requested review of this revision.
Herald added 1 blocking reviewer(s): libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D117606

Files:
  libcxx/test/std/utilities/format/format.formatter/format.context/types.compile.pass.cpp


Index: libcxx/test/std/utilities/format/format.formatter/format.context/types.compile.pass.cpp
===================================================================
--- libcxx/test/std/utilities/format/format.formatter/format.context/types.compile.pass.cpp
+++ libcxx/test/std/utilities/format/format.formatter/format.context/types.compile.pass.cpp
@@ -107,12 +107,21 @@
   test<std::back_insert_iterator<std::basic_string<char32_t>>, char32_t>();
 }
 
-static_assert(std::is_same_v<
-              std::format_context,
-              std::basic_format_context<
-                  std::back_insert_iterator<std::basic_string<char>>, char>>);
+template <class Context, class charT>
+constexpr bool is_basic_format_context_specialization = false;
+template <class It, class charT>
+constexpr bool is_basic_format_context_specialization<std::basic_format_context<It, charT>, charT> = true;
+
+static_assert(is_basic_format_context_specialization<std::format_context, char>);
+LIBCPP_STATIC_ASSERT(
+    std::is_same_v<
+        std::format_context,
+        std::basic_format_context<
+            std::back_insert_iterator<std::basic_string<char>>, char>>);
+
 #ifndef TEST_HAS_NO_WIDE_CHARACTERS
-static_assert(
+static_assert(is_basic_format_context_specialization<std::wformat_context, wchar_t>);
+LIBCPP_STATIC_ASSERT(
     std::is_same_v<
         std::wformat_context,
         std::basic_format_context<


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117606.400984.patch
Type: text/x-patch
Size: 1407 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220118/9995ff17/attachment.bin>


More information about the libcxx-commits mailing list