[libcxx-commits] [PATCH] D112362: [libc++][format] Use preferred_name attribute.

Mark de Wever via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Oct 23 05:33:03 PDT 2021


Mordante created this revision.
Mordante added reviewers: ldionne, vitaut.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This was suggested by @vitaut in D110494 <https://reviews.llvm.org/D110494>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112362

Files:
  libcxx/include/__format/format_context.h


Index: libcxx/include/__format/format_context.h
===================================================================
--- libcxx/include/__format/format_context.h
+++ libcxx/include/__format/format_context.h
@@ -70,9 +70,28 @@
 }
 #endif
 
+// TODO FMT Implement [format.context]/4
+// [Note 1: For a given type charT, implementations are encouraged to provide a
+// single instantiation of basic_format_context for appending to
+// basic_string<charT>, vector<charT>, or any other container with contiguous
+// storage by wrapping those in temporary objects with a uniform interface
+// (such as a span<charT>) and polymorphic reallocation. - end note]
+
+using format_context = basic_format_context<back_insert_iterator<string>, char>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>;
+#endif
+
 template <class _OutIt, class _CharT>
 requires output_iterator<_OutIt, const _CharT&>
-class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context {
+class
+    // clang-format off
+    _LIBCPP_TEMPLATE_VIS
+    _LIBCPP_AVAILABILITY_FORMAT
+    _LIBCPP_PREFERRED_NAME(format_context)
+    _LIBCPP_IF_WIDE_CHARACTERS(_LIBCPP_PREFERRED_NAME(wformat_context))
+    // clang-format on
+    basic_format_context {
 public:
   using iterator = _OutIt;
   using char_type = _CharT;
@@ -138,18 +157,6 @@
 #endif
 };
 
-// TODO FMT Implement [format.context]/4
-// [Note 1: For a given type charT, implementations are encouraged to provide a
-// single instantiation of basic_format_context for appending to
-// basic_string<charT>, vector<charT>, or any other container with contiguous
-// storage by wrapping those in temporary objects with a uniform interface
-// (such as a span<charT>) and polymorphic reallocation. - end note]
-
-using format_context = basic_format_context<back_insert_iterator<string>, char>;
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-using wformat_context = basic_format_context<back_insert_iterator<wstring>, wchar_t>;
-#endif
-
 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
 
 #endif //_LIBCPP_STD_VER > 17


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112362.381730.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211023/052d77a6/attachment-0001.bin>


More information about the libcxx-commits mailing list