Import Cobalt 24.master.0.1032339
diff --git a/third_party/llvm-project/libcxx/include/__format/buffer.h b/third_party/llvm-project/libcxx/include/__format/buffer.h
new file mode 100644
index 0000000..60c1f80
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/buffer.h
@@ -0,0 +1,504 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_BUFFER_H
+#define _LIBCPP___FORMAT_BUFFER_H
+
+#include <__algorithm/copy_n.h>
+#include <__algorithm/fill_n.h>
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__algorithm/ranges_copy_n.h>
+#include <__algorithm/transform.h>
+#include <__algorithm/unwrap_iter.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/enable_insertable.h>
+#include <__format/format_to_n_result.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/concepts.h>
+#include <__iterator/incrementable_traits.h>
+#include <__iterator/iterator_traits.h>
+#include <__iterator/wrap_iter.h>
+#include <__utility/move.h>
+#include <cstddef>
+#include <string_view>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+/// A "buffer" that handles writing to the proper iterator.
+///
+/// This helper is used together with the @ref back_insert_iterator to offer
+/// type-erasure for the formatting functions. This reduces the number to
+/// template instantiations.
+template <__fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __output_buffer {
+public:
+ using value_type = _CharT;
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit __output_buffer(_CharT* __ptr, size_t __capacity, _Tp* __obj)
+ : __ptr_(__ptr),
+ __capacity_(__capacity),
+ __flush_([](_CharT* __p, size_t __n, void* __o) { static_cast<_Tp*>(__o)->__flush(__p, __n); }),
+ __obj_(__obj) {}
+
+ _LIBCPP_HIDE_FROM_ABI void __reset(_CharT* __ptr, size_t __capacity) {
+ __ptr_ = __ptr;
+ __capacity_ = __capacity;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return std::back_insert_iterator{*this}; }
+
+ // Used in std::back_insert_iterator.
+ _LIBCPP_HIDE_FROM_ABI void push_back(_CharT __c) {
+ __ptr_[__size_++] = __c;
+
+ // Profiling showed flushing after adding is more efficient than flushing
+ // when entering the function.
+ if (__size_ == __capacity_)
+ __flush();
+ }
+
+ /// Copies the input __str to the buffer.
+ ///
+ /// Since some of the input is generated by std::to_chars, there needs to be a
+ /// conversion when _CharT is wchar_t.
+ template <__fmt_char_type _InCharT>
+ _LIBCPP_HIDE_FROM_ABI void __copy(basic_string_view<_InCharT> __str) {
+ // When the underlying iterator is a simple iterator the __capacity_ is
+ // infinite. For a string or container back_inserter it isn't. This means
+ // adding a large string the the buffer can cause some overhead. In that
+ // case a better approach could be:
+ // - flush the buffer
+ // - container.append(__str.begin(), __str.end());
+ // The same holds true for the fill.
+ // For transform it might be slightly harder, however the use case for
+ // transform is slightly less common; it converts hexadecimal values to
+ // upper case. For integral these strings are short.
+ // TODO FMT Look at the improvements above.
+ size_t __n = __str.size();
+
+ __flush_on_overflow(__n);
+ if (__n <= __capacity_) {
+ _VSTD::copy_n(__str.data(), __n, _VSTD::addressof(__ptr_[__size_]));
+ __size_ += __n;
+ return;
+ }
+
+ // The output doesn't fit in the internal buffer.
+ // Copy the data in "__capacity_" sized chunks.
+ _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
+ const _InCharT* __first = __str.data();
+ do {
+ size_t __chunk = _VSTD::min(__n, __capacity_);
+ _VSTD::copy_n(__first, __chunk, _VSTD::addressof(__ptr_[__size_]));
+ __size_ = __chunk;
+ __first += __chunk;
+ __n -= __chunk;
+ __flush();
+ } while (__n);
+ }
+
+ /// A std::transform wrapper.
+ ///
+ /// Like @ref __copy it may need to do type conversion.
+ template <__fmt_char_type _InCharT, class _UnaryOperation>
+ _LIBCPP_HIDE_FROM_ABI void __transform(const _InCharT* __first, const _InCharT* __last, _UnaryOperation __operation) {
+ _LIBCPP_ASSERT(__first <= __last, "not a valid range");
+
+ size_t __n = static_cast<size_t>(__last - __first);
+ __flush_on_overflow(__n);
+ if (__n <= __capacity_) {
+ _VSTD::transform(__first, __last, _VSTD::addressof(__ptr_[__size_]), _VSTD::move(__operation));
+ __size_ += __n;
+ return;
+ }
+
+ // The output doesn't fit in the internal buffer.
+ // Transform the data in "__capacity_" sized chunks.
+ _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
+ do {
+ size_t __chunk = _VSTD::min(__n, __capacity_);
+ _VSTD::transform(__first, __first + __chunk, _VSTD::addressof(__ptr_[__size_]), __operation);
+ __size_ = __chunk;
+ __first += __chunk;
+ __n -= __chunk;
+ __flush();
+ } while (__n);
+ }
+
+ /// A \c fill_n wrapper.
+ _LIBCPP_HIDE_FROM_ABI void __fill(size_t __n, _CharT __value) {
+ __flush_on_overflow(__n);
+ if (__n <= __capacity_) {
+ _VSTD::fill_n(_VSTD::addressof(__ptr_[__size_]), __n, __value);
+ __size_ += __n;
+ return;
+ }
+
+ // The output doesn't fit in the internal buffer.
+ // Fill the buffer in "__capacity_" sized chunks.
+ _LIBCPP_ASSERT(__size_ == 0, "the buffer should be flushed by __flush_on_overflow");
+ do {
+ size_t __chunk = _VSTD::min(__n, __capacity_);
+ _VSTD::fill_n(_VSTD::addressof(__ptr_[__size_]), __chunk, __value);
+ __size_ = __chunk;
+ __n -= __chunk;
+ __flush();
+ } while (__n);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush() {
+ __flush_(__ptr_, __size_, __obj_);
+ __size_ = 0;
+ }
+
+private:
+ _CharT* __ptr_;
+ size_t __capacity_;
+ size_t __size_{0};
+ void (*__flush_)(_CharT*, size_t, void*);
+ void* __obj_;
+
+ /// Flushes the buffer when the output operation would overflow the buffer.
+ ///
+ /// A simple approach for the overflow detection would be something along the
+ /// lines:
+ /// \code
+ /// // The internal buffer is large enough.
+ /// if (__n <= __capacity_) {
+ /// // Flush when we really would overflow.
+ /// if (__size_ + __n >= __capacity_)
+ /// __flush();
+ /// ...
+ /// }
+ /// \endcode
+ ///
+ /// This approach works for all cases but one:
+ /// A __format_to_n_buffer_base where \ref __enable_direct_output is true.
+ /// In that case the \ref __capacity_ of the buffer changes during the first
+ /// \ref __flush. During that operation the output buffer switches from its
+ /// __writer_ to its __storage_. The \ref __capacity_ of the former depends
+ /// on the value of n, of the latter is a fixed size. For example:
+ /// - a format_to_n call with a 10'000 char buffer,
+ /// - the buffer is filled with 9'500 chars,
+ /// - adding 1'000 elements would overflow the buffer so the buffer gets
+ /// changed and the \ref __capacity_ decreases from 10'000 to
+ /// __buffer_size (256 at the time of writing).
+ ///
+ /// This means that the \ref __flush for this class may need to copy a part of
+ /// the internal buffer to the proper output. In this example there will be
+ /// 500 characters that need this copy operation.
+ ///
+ /// Note it would be more efficient to write 500 chars directly and then swap
+ /// the buffers. This would make the code more complex and \ref format_to_n is
+ /// not the most common use case. Therefore the optimization isn't done.
+ _LIBCPP_HIDE_FROM_ABI void __flush_on_overflow(size_t __n) {
+ if (__size_ + __n >= __capacity_)
+ __flush();
+ }
+};
+
+/// A storage using an internal buffer.
+///
+/// This storage is used when writing a single element to the output iterator
+/// is expensive.
+template <__fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __internal_storage {
+public:
+ _LIBCPP_HIDE_FROM_ABI _CharT* __begin() { return __buffer_; }
+
+ static constexpr size_t __buffer_size = 256 / sizeof(_CharT);
+
+private:
+ _CharT __buffer_[__buffer_size];
+};
+
+/// A storage writing directly to the storage.
+///
+/// This requires the storage to be a contiguous buffer of \a _CharT.
+/// Since the output is directly written to the underlying storage this class
+/// is just an empty class.
+template <__fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __direct_storage {};
+
+template <class _OutIt, class _CharT>
+concept __enable_direct_output = __fmt_char_type<_CharT> &&
+ (same_as<_OutIt, _CharT*>
+#ifndef _LIBCPP_ENABLE_DEBUG_MODE
+ || same_as<_OutIt, __wrap_iter<_CharT*>>
+#endif
+ );
+
+/// Write policy for directly writing to the underlying output.
+template <class _OutIt, __fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __writer_direct {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __writer_direct(_OutIt __out_it)
+ : __out_it_(__out_it) {}
+
+ _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() { return __out_it_; }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT*, size_t __n) {
+ // _OutIt can be a __wrap_iter<CharT*>. Therefore the original iterator
+ // is adjusted.
+ __out_it_ += __n;
+ }
+
+private:
+ _OutIt __out_it_;
+};
+
+/// Write policy for copying the buffer to the output.
+template <class _OutIt, __fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __writer_iterator {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __writer_iterator(_OutIt __out_it)
+ : __out_it_{_VSTD::move(__out_it)} {}
+
+ _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && { return std::move(__out_it_); }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ __out_it_ = std::ranges::copy_n(__ptr, __n, std::move(__out_it_)).out;
+ }
+
+private:
+ _OutIt __out_it_;
+};
+
+/// Concept to see whether a \a _Container is insertable.
+///
+/// The concept is used to validate whether multiple calls to a
+/// \ref back_insert_iterator can be replace by a call to \c _Container::insert.
+///
+/// \note a \a _Container needs to opt-in to the concept by specializing
+/// \ref __enable_insertable.
+template <class _Container>
+concept __insertable =
+ __enable_insertable<_Container> && __fmt_char_type<typename _Container::value_type> &&
+ requires(_Container& __t, add_pointer_t<typename _Container::value_type> __first,
+ add_pointer_t<typename _Container::value_type> __last) { __t.insert(__t.end(), __first, __last); };
+
+/// Extract the container type of a \ref back_insert_iterator.
+template <class _It>
+struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container {
+ using type = void;
+};
+
+template <__insertable _Container>
+struct _LIBCPP_TEMPLATE_VIS __back_insert_iterator_container<back_insert_iterator<_Container>> {
+ using type = _Container;
+};
+
+/// Write policy for inserting the buffer in a container.
+template <class _Container>
+class _LIBCPP_TEMPLATE_VIS __writer_container {
+public:
+ using _CharT = typename _Container::value_type;
+
+ _LIBCPP_HIDE_FROM_ABI explicit __writer_container(back_insert_iterator<_Container> __out_it)
+ : __container_{__out_it.__get_container()} {}
+
+ _LIBCPP_HIDE_FROM_ABI auto __out_it() { return std::back_inserter(*__container_); }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ __container_->insert(__container_->end(), __ptr, __ptr + __n);
+ }
+
+private:
+ _Container* __container_;
+};
+
+/// Selects the type of the writer used for the output iterator.
+template <class _OutIt, class _CharT>
+class _LIBCPP_TEMPLATE_VIS __writer_selector {
+ using _Container = typename __back_insert_iterator_container<_OutIt>::type;
+
+public:
+ using type = conditional_t<!same_as<_Container, void>, __writer_container<_Container>,
+ conditional_t<__enable_direct_output<_OutIt, _CharT>, __writer_direct<_OutIt, _CharT>,
+ __writer_iterator<_OutIt, _CharT>>>;
+};
+
+/// The generic formatting buffer.
+template <class _OutIt, __fmt_char_type _CharT>
+requires(output_iterator<_OutIt, const _CharT&>) class _LIBCPP_TEMPLATE_VIS
+ __format_buffer {
+ using _Storage =
+ conditional_t<__enable_direct_output<_OutIt, _CharT>,
+ __direct_storage<_CharT>, __internal_storage<_CharT>>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it)
+ requires(same_as<_Storage, __internal_storage<_CharT>>)
+ : __output_(__storage_.__begin(), __storage_.__buffer_size, this), __writer_(_VSTD::move(__out_it)) {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit __format_buffer(_OutIt __out_it) requires(
+ same_as<_Storage, __direct_storage<_CharT>>)
+ : __output_(_VSTD::__unwrap_iter(__out_it), size_t(-1), this),
+ __writer_(_VSTD::move(__out_it)) {}
+
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) { __writer_.__flush(__ptr, __n); }
+
+ _LIBCPP_HIDE_FROM_ABI _OutIt __out_it() && {
+ __output_.__flush();
+ return _VSTD::move(__writer_).__out_it();
+ }
+
+private:
+ _LIBCPP_NO_UNIQUE_ADDRESS _Storage __storage_;
+ __output_buffer<_CharT> __output_;
+ typename __writer_selector<_OutIt, _CharT>::type __writer_;
+};
+
+/// A buffer that counts the number of insertions.
+///
+/// Since \ref formatted_size only needs to know the size, the output itself is
+/// discarded.
+template <__fmt_char_type _CharT>
+class _LIBCPP_TEMPLATE_VIS __formatted_size_buffer {
+public:
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return __output_.__make_output_iterator(); }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(const _CharT*, size_t __n) { __size_ += __n; }
+
+ _LIBCPP_HIDE_FROM_ABI size_t __result() && {
+ __output_.__flush();
+ return __size_;
+ }
+
+private:
+ __internal_storage<_CharT> __storage_;
+ __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};
+ size_t __size_{0};
+};
+
+/// The base of a buffer that counts and limits the number of insertions.
+template <class _OutIt, __fmt_char_type _CharT, bool>
+ requires(output_iterator<_OutIt, const _CharT&>)
+struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base {
+ using _Size = iter_difference_t<_OutIt>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
+ : __writer_(_VSTD::move(__out_it)), __max_size_(_VSTD::max(_Size(0), __max_size)) {}
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ if (_Size(__size_) <= __max_size_)
+ __writer_.__flush(__ptr, _VSTD::min(_Size(__n), __max_size_ - __size_));
+ __size_ += __n;
+ }
+
+protected:
+ __internal_storage<_CharT> __storage_;
+ __output_buffer<_CharT> __output_{__storage_.__begin(), __storage_.__buffer_size, this};
+ typename __writer_selector<_OutIt, _CharT>::type __writer_;
+
+ _Size __max_size_;
+ _Size __size_{0};
+};
+
+/// The base of a buffer that counts and limits the number of insertions.
+///
+/// This version is used when \c __enable_direct_output<_OutIt, _CharT> == true.
+///
+/// This class limits the size available to the direct writer so it will not
+/// exceed the maximum number of code units.
+template <class _OutIt, __fmt_char_type _CharT>
+ requires(output_iterator<_OutIt, const _CharT&>)
+class _LIBCPP_TEMPLATE_VIS __format_to_n_buffer_base<_OutIt, _CharT, true> {
+ using _Size = iter_difference_t<_OutIt>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer_base(_OutIt __out_it, _Size __max_size)
+ : __output_(_VSTD::__unwrap_iter(__out_it), __max_size, this),
+ __writer_(_VSTD::move(__out_it)),
+ __max_size_(__max_size) {
+ if (__max_size <= 0) [[unlikely]]
+ __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void __flush(_CharT* __ptr, size_t __n) {
+ // A __flush to the direct writer happens in the following occasions:
+ // - The format function has written the maximum number of allowed code
+ // units. At this point it's no longer valid to write to this writer. So
+ // switch to the internal storage. This internal storage doesn't need to
+ // be written anywhere so the __flush for that storage writes no output.
+ // - Like above, but the next "mass write" operation would overflow the
+ // buffer. In that case the buffer is pre-emptively switched. The still
+ // valid code units will be written separately.
+ // - The format_to_n function is finished. In this case there's no need to
+ // switch the buffer, but for simplicity the buffers are still switched.
+ // When the __max_size <= 0 the constructor already switched the buffers.
+ if (__size_ == 0 && __ptr != __storage_.__begin()) {
+ __writer_.__flush(__ptr, __n);
+ __output_.__reset(__storage_.__begin(), __storage_.__buffer_size);
+ } else if (__size_ < __max_size_) {
+ // Copies a part of the internal buffer to the output up to n characters.
+ // See __output_buffer<_CharT>::__flush_on_overflow for more information.
+ _Size __s = _VSTD::min(_Size(__n), __max_size_ - __size_);
+ std::copy_n(__ptr, __s, __writer_.__out_it());
+ __writer_.__flush(__ptr, __s);
+ }
+
+ __size_ += __n;
+ }
+
+protected:
+ __internal_storage<_CharT> __storage_;
+ __output_buffer<_CharT> __output_;
+ __writer_direct<_OutIt, _CharT> __writer_;
+
+ _Size __max_size_;
+ _Size __size_{0};
+};
+
+/// The buffer that counts and limits the number of insertions.
+template <class _OutIt, __fmt_char_type _CharT>
+ requires(output_iterator<_OutIt, const _CharT&>)
+struct _LIBCPP_TEMPLATE_VIS __format_to_n_buffer final
+ : public __format_to_n_buffer_base< _OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>> {
+ using _Base = __format_to_n_buffer_base<_OutIt, _CharT, __enable_direct_output<_OutIt, _CharT>>;
+ using _Size = iter_difference_t<_OutIt>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __format_to_n_buffer(_OutIt __out_it, _Size __max_size)
+ : _Base(_VSTD::move(__out_it), __max_size) {}
+ _LIBCPP_HIDE_FROM_ABI auto __make_output_iterator() { return this->__output_.__make_output_iterator(); }
+
+ _LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __result() && {
+ this->__output_.__flush();
+ return {_VSTD::move(this->__writer_).__out_it(), this->__size_};
+ }
+};
+} // namespace __format
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_BUFFER_H
diff --git a/third_party/llvm-project/libcxx/include/__format/concepts.h b/third_party/llvm-project/libcxx/include/__format/concepts.h
new file mode 100644
index 0000000..fe4a7b9
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/concepts.h
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_CONCEPTS_H
+#define _LIBCPP___FORMAT_CONCEPTS_H
+
+#include <__concepts/same_as.h>
+#include <__concepts/semiregular.h>
+#include <__config>
+#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
+#include <__type_traits/is_specialization.h>
+#include <__utility/pair.h>
+#include <tuple>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+/// The character type specializations of \ref formatter.
+template <class _CharT>
+concept __fmt_char_type =
+ same_as<_CharT, char>
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+ || same_as<_CharT, wchar_t>
+# endif
+ ;
+
+// The output iterator isn't specified. A formatter should accept any
+// output_iterator. This iterator is a minimal iterator to test the concept.
+// (Note testing for (w)format_context would be a valid choice, but requires
+// selecting the proper one depending on the type of _CharT.)
+template <class _CharT>
+using __fmt_iter_for = _CharT*;
+
+template <class _Tp, class _CharT>
+concept __formattable =
+ (semiregular<formatter<remove_cvref_t<_Tp>, _CharT>>) &&
+ requires(formatter<remove_cvref_t<_Tp>, _CharT> __f,
+ const formatter<remove_cvref_t<_Tp>, _CharT> __cf,
+ _Tp __t,
+ basic_format_context<__fmt_iter_for<_CharT>, _CharT> __fc,
+ basic_format_parse_context<_CharT> __pc) {
+ { __f.parse(__pc) } -> same_as<typename basic_format_parse_context<_CharT>::iterator>;
+ { __cf.format(__t, __fc) } -> same_as<__fmt_iter_for<_CharT>>;
+ };
+
+# if _LIBCPP_STD_VER > 20
+template <class _Tp, class _CharT>
+concept formattable = __formattable<_Tp, _CharT>;
+
+// [tuple.like] defines a tuple-like exposition only concept. This concept is
+// not related to that. Therefore it uses a different name for the concept.
+//
+// TODO FMT Add a test to validate we fail when using that concept after P2165
+// has been implemented.
+template <class _Tp>
+concept __fmt_pair_like = __is_specialization_v<_Tp, pair> ||
+ // Use a requires since tuple_size_v may fail to instantiate,
+ (__is_specialization_v<_Tp, tuple> && requires { tuple_size_v<_Tp> == 2; });
+
+# endif //_LIBCPP_STD_VER > 20
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_CONCEPTS_H
diff --git a/third_party/llvm-project/libcxx/include/__format/enable_insertable.h b/third_party/llvm-project/libcxx/include/__format/enable_insertable.h
new file mode 100644
index 0000000..71b4252
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/enable_insertable.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
+#define _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+/// Opt-in to enable \ref __insertable for a \a _Container.
+template <class _Container>
+inline constexpr bool __enable_insertable = false;
+
+} // namespace __format
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_ENABLE_INSERTABLE_H
diff --git a/third_party/llvm-project/libcxx/include/__format/escaped_output_table.h b/third_party/llvm-project/libcxx/include/__format/escaped_output_table.h
new file mode 100644
index 0000000..bd2994b
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/escaped_output_table.h
@@ -0,0 +1,1038 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// WARNING, this entire header is generated by
+// utils/generate_escaped_output_table.py
+// DO NOT MODIFY!
+
+// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
+//
+// See Terms of Use <https://www.unicode.org/copyright.html>
+// for definitions of Unicode Inc.'s Data Files and Software.
+//
+// NOTICE TO USER: Carefully read the following legal agreement.
+// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
+// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
+// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
+// TERMS AND CONDITIONS OF THIS AGREEMENT.
+// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
+// THE DATA FILES OR SOFTWARE.
+//
+// COPYRIGHT AND PERMISSION NOTICE
+//
+// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
+// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of the Unicode data files and any associated documentation
+// (the "Data Files") or Unicode software and any associated documentation
+// (the "Software") to deal in the Data Files or Software
+// without restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, and/or sell copies of
+// the Data Files or Software, and to permit persons to whom the Data Files
+// or Software are furnished to do so, provided that either
+// (a) this copyright and permission notice appear with all copies
+// of the Data Files or Software, or
+// (b) this copyright and permission notice appear in associated
+// Documentation.
+//
+// THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+//
+// Except as contained in this notice, the name of a copyright holder
+// shall not be used in advertising or otherwise to promote the sale,
+// use or other dealings in these Data Files or Software without prior
+// written authorization of the copyright holder.
+
+#ifndef _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
+#define _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
+
+#include <__algorithm/ranges_upper_bound.h>
+#include <__config>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+namespace __escaped_output_table {
+
+/// The entries of the characters to escape in format's debug string.
+///
+/// Contains the entries for [format.string.escaped]/2.2.1.2.1
+/// CE is a Unicode encoding and C corresponds to either a UCS scalar value
+/// whose Unicode property General_Category has a value in the groups
+/// Separator (Z) or Other (C) or to a UCS scalar value which has the Unicode
+/// property Grapheme_Extend=Yes, as described by table 12 of UAX #44
+///
+/// Separator (Z) consists of General_Category
+/// - Space_Separator,
+/// - Line_Separator,
+/// - Paragraph_Separator.
+///
+/// Other (C) consists of General_Category
+/// - Control,
+/// - Format,
+/// - Surrogate,
+/// - Private_Use,
+/// - Unassigned.
+///
+/// The data is generated from
+/// - https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt
+/// - https://www.unicode.org/Public/UCD/latest/ucd/extracted/DerivedGeneralCategory.txt
+///
+/// The table is similar to the table
+/// __extended_grapheme_custer_property_boundary::__entries
+/// which explains the details of these classes. The only difference is this
+/// table lacks a property, thus having more bits available for the size.
+///
+/// The data has 2 values:
+/// - bits [0, 10] The size of the range, allowing 2048 elements.
+/// - bits [11, 31] The lower bound code point of the range. The upper bound of
+/// the range is lower bound + size.
+inline constexpr uint32_t __entries[893] = {
+ 0x00000020,
+ 0x0003f821,
+ 0x00056800,
+ 0x0018006f,
+ 0x001bc001,
+ 0x001c0003,
+ 0x001c5800,
+ 0x001c6800,
+ 0x001d1000,
+ 0x00241806,
+ 0x00298000,
+ 0x002ab801,
+ 0x002c5801,
+ 0x002c802d,
+ 0x002df800,
+ 0x002e0801,
+ 0x002e2001,
+ 0x002e3808,
+ 0x002f5803,
+ 0x002fa810,
+ 0x0030800a,
+ 0x0030e000,
+ 0x00325814,
+ 0x00338000,
+ 0x0036b007,
+ 0x0036f805,
+ 0x00373801,
+ 0x00375003,
+ 0x00387001,
+ 0x00388800,
+ 0x0039801c,
+ 0x003d300a,
+ 0x003d900d,
+ 0x003f5808,
+ 0x003fd802,
+ 0x0040b003,
+ 0x0040d808,
+ 0x00412802,
+ 0x00414806,
+ 0x0041f800,
+ 0x0042c804,
+ 0x0042f800,
+ 0x00435804,
+ 0x00447810,
+ 0x00465038,
+ 0x0049d000,
+ 0x0049e000,
+ 0x004a0807,
+ 0x004a6800,
+ 0x004a8806,
+ 0x004b1001,
+ 0x004c0800,
+ 0x004c2000,
+ 0x004c6801,
+ 0x004c8801,
+ 0x004d4800,
+ 0x004d8800,
+ 0x004d9802,
+ 0x004dd002,
+ 0x004df000,
+ 0x004e0805,
+ 0x004e4801,
+ 0x004e6800,
+ 0x004e780c,
+ 0x004ef000,
+ 0x004f1003,
+ 0x004ff004,
+ 0x00502000,
+ 0x00505803,
+ 0x00508801,
+ 0x00514800,
+ 0x00518800,
+ 0x0051a000,
+ 0x0051b800,
+ 0x0051d003,
+ 0x00520817,
+ 0x0052e800,
+ 0x0052f806,
+ 0x00538001,
+ 0x0053a800,
+ 0x0053b80b,
+ 0x00542000,
+ 0x00547000,
+ 0x00549000,
+ 0x00554800,
+ 0x00558800,
+ 0x0055a000,
+ 0x0055d002,
+ 0x00560807,
+ 0x00565000,
+ 0x00566802,
+ 0x0056880e,
+ 0x00571003,
+ 0x00579006,
+ 0x0057d007,
+ 0x00582000,
+ 0x00586801,
+ 0x00588801,
+ 0x00594800,
+ 0x00598800,
+ 0x0059a000,
+ 0x0059d002,
+ 0x0059f001,
+ 0x005a0805,
+ 0x005a4801,
+ 0x005a680e,
+ 0x005af000,
+ 0x005b1003,
+ 0x005bc00a,
+ 0x005c2000,
+ 0x005c5802,
+ 0x005c8800,
+ 0x005cb002,
+ 0x005cd800,
+ 0x005ce800,
+ 0x005d0002,
+ 0x005d2802,
+ 0x005d5802,
+ 0x005dd004,
+ 0x005e0000,
+ 0x005e1802,
+ 0x005e4800,
+ 0x005e6802,
+ 0x005e8814,
+ 0x005fd805,
+ 0x00602000,
+ 0x00606800,
+ 0x00608800,
+ 0x00614800,
+ 0x0061d002,
+ 0x0061f002,
+ 0x00622812,
+ 0x0062d801,
+ 0x0062f001,
+ 0x00631003,
+ 0x00638006,
+ 0x00640800,
+ 0x00646800,
+ 0x00648800,
+ 0x00654800,
+ 0x0065a000,
+ 0x0065d002,
+ 0x0065f800,
+ 0x00661000,
+ 0x00662801,
+ 0x00664800,
+ 0x00666010,
+ 0x0066f800,
+ 0x00671003,
+ 0x00678000,
+ 0x0067a00d,
+ 0x00686800,
+ 0x00688800,
+ 0x0069d801,
+ 0x0069f000,
+ 0x006a0804,
+ 0x006a4800,
+ 0x006a6800,
+ 0x006a8003,
+ 0x006ab800,
+ 0x006b1003,
+ 0x006c0001,
+ 0x006c2000,
+ 0x006cb802,
+ 0x006d9000,
+ 0x006de000,
+ 0x006df001,
+ 0x006e3808,
+ 0x006e9005,
+ 0x006ef806,
+ 0x006f8001,
+ 0x006fa80b,
+ 0x00718800,
+ 0x0071a00a,
+ 0x00723807,
+ 0x0072e024,
+ 0x00741800,
+ 0x00742800,
+ 0x00745800,
+ 0x00752000,
+ 0x00753000,
+ 0x00758800,
+ 0x0075a008,
+ 0x0075f001,
+ 0x00762800,
+ 0x00763808,
+ 0x0076d001,
+ 0x0077001f,
+ 0x0078c001,
+ 0x0079a800,
+ 0x0079b800,
+ 0x0079c800,
+ 0x007a4000,
+ 0x007b6811,
+ 0x007c0004,
+ 0x007c3001,
+ 0x007c6830,
+ 0x007e3000,
+ 0x007e6800,
+ 0x007ed824,
+ 0x00816803,
+ 0x00819005,
+ 0x0081c801,
+ 0x0081e801,
+ 0x0082c001,
+ 0x0082f002,
+ 0x00838803,
+ 0x00841000,
+ 0x00842801,
+ 0x00846800,
+ 0x0084e800,
+ 0x00863000,
+ 0x00864004,
+ 0x00867001,
+ 0x00924800,
+ 0x00927001,
+ 0x0092b800,
+ 0x0092c800,
+ 0x0092f001,
+ 0x00944800,
+ 0x00947001,
+ 0x00958800,
+ 0x0095b001,
+ 0x0095f800,
+ 0x00960800,
+ 0x00963001,
+ 0x0096b800,
+ 0x00988800,
+ 0x0098b001,
+ 0x009ad804,
+ 0x009be802,
+ 0x009cd005,
+ 0x009fb001,
+ 0x009ff001,
+ 0x00b40000,
+ 0x00b4e802,
+ 0x00b7c806,
+ 0x00b89002,
+ 0x00b8b008,
+ 0x00b99001,
+ 0x00b9b808,
+ 0x00ba900d,
+ 0x00bb6800,
+ 0x00bb880e,
+ 0x00bda001,
+ 0x00bdb806,
+ 0x00be3000,
+ 0x00be480a,
+ 0x00bee802,
+ 0x00bf5005,
+ 0x00bfd005,
+ 0x00c05804,
+ 0x00c0d005,
+ 0x00c3c806,
+ 0x00c42801,
+ 0x00c54800,
+ 0x00c55804,
+ 0x00c7b009,
+ 0x00c8f803,
+ 0x00c93801,
+ 0x00c96003,
+ 0x00c99000,
+ 0x00c9c806,
+ 0x00ca0802,
+ 0x00cb7001,
+ 0x00cba80a,
+ 0x00cd6003,
+ 0x00ce5005,
+ 0x00ced802,
+ 0x00d0b801,
+ 0x00d0d802,
+ 0x00d2b000,
+ 0x00d2c008,
+ 0x00d31000,
+ 0x00d32807,
+ 0x00d3980c,
+ 0x00d45005,
+ 0x00d4d005,
+ 0x00d57055,
+ 0x00d9a006,
+ 0x00d9e000,
+ 0x00da1000,
+ 0x00da6802,
+ 0x00db5808,
+ 0x00dbf802,
+ 0x00dd1003,
+ 0x00dd4001,
+ 0x00dd5802,
+ 0x00df3000,
+ 0x00df4001,
+ 0x00df6800,
+ 0x00df7802,
+ 0x00dfa007,
+ 0x00e16007,
+ 0x00e1b004,
+ 0x00e25002,
+ 0x00e44806,
+ 0x00e5d801,
+ 0x00e6400a,
+ 0x00e6a00c,
+ 0x00e71006,
+ 0x00e76800,
+ 0x00e7a000,
+ 0x00e7c001,
+ 0x00e7d804,
+ 0x00ee003f,
+ 0x00f8b001,
+ 0x00f8f001,
+ 0x00fa3001,
+ 0x00fa7001,
+ 0x00fac000,
+ 0x00fad000,
+ 0x00fae000,
+ 0x00faf000,
+ 0x00fbf001,
+ 0x00fda800,
+ 0x00fe2800,
+ 0x00fea001,
+ 0x00fee000,
+ 0x00ff8001,
+ 0x00ffa800,
+ 0x00fff810,
+ 0x01014007,
+ 0x0102f810,
+ 0x01039001,
+ 0x01047800,
+ 0x0104e802,
+ 0x0106083e,
+ 0x010c6003,
+ 0x01213818,
+ 0x01225814,
+ 0x015ba001,
+ 0x015cb000,
+ 0x01677802,
+ 0x0167a004,
+ 0x01693000,
+ 0x01694004,
+ 0x01697001,
+ 0x016b4006,
+ 0x016b880e,
+ 0x016cb808,
+ 0x016d3800,
+ 0x016d7800,
+ 0x016db800,
+ 0x016df800,
+ 0x016e3800,
+ 0x016e7800,
+ 0x016eb800,
+ 0x016ef820,
+ 0x0172f021,
+ 0x0174d000,
+ 0x0177a00b,
+ 0x017eb019,
+ 0x017fe004,
+ 0x01815005,
+ 0x01820000,
+ 0x0184b803,
+ 0x01880004,
+ 0x01898000,
+ 0x018c7800,
+ 0x018f200b,
+ 0x0190f800,
+ 0x05246802,
+ 0x05263808,
+ 0x05316013,
+ 0x05337803,
+ 0x0533a009,
+ 0x0534f001,
+ 0x05378001,
+ 0x0537c007,
+ 0x053e5804,
+ 0x053e9000,
+ 0x053ea000,
+ 0x053ed017,
+ 0x05401000,
+ 0x05403000,
+ 0x05405800,
+ 0x05412801,
+ 0x05416003,
+ 0x0541d005,
+ 0x0543c007,
+ 0x05462009,
+ 0x0546d017,
+ 0x0547f800,
+ 0x05493007,
+ 0x054a380a,
+ 0x054aa00a,
+ 0x054be805,
+ 0x054d9800,
+ 0x054db003,
+ 0x054de001,
+ 0x054e7000,
+ 0x054ed003,
+ 0x054f2800,
+ 0x054ff800,
+ 0x05514805,
+ 0x05518801,
+ 0x0551a80a,
+ 0x05521800,
+ 0x05526000,
+ 0x05527001,
+ 0x0552d001,
+ 0x0553e000,
+ 0x05558000,
+ 0x05559002,
+ 0x0555b801,
+ 0x0555f001,
+ 0x05560800,
+ 0x05561817,
+ 0x05576001,
+ 0x0557b00a,
+ 0x05583801,
+ 0x05587801,
+ 0x0558b808,
+ 0x05593800,
+ 0x05597800,
+ 0x055b6003,
+ 0x055f2800,
+ 0x055f4000,
+ 0x055f6802,
+ 0x055fd005,
+ 0x06bd200b,
+ 0x06be3803,
+ 0x06bfe7ff,
+ 0x06ffe7ff,
+ 0x073fe7ff,
+ 0x077fe7ff,
+ 0x07bfe103,
+ 0x07d37001,
+ 0x07d6d025,
+ 0x07d8380b,
+ 0x07d8c004,
+ 0x07d8f000,
+ 0x07d9b800,
+ 0x07d9e800,
+ 0x07d9f800,
+ 0x07da1000,
+ 0x07da2800,
+ 0x07de180f,
+ 0x07ec8001,
+ 0x07ee4006,
+ 0x07ee801f,
+ 0x07f0000f,
+ 0x07f0d015,
+ 0x07f29800,
+ 0x07f33800,
+ 0x07f36003,
+ 0x07f3a800,
+ 0x07f7e803,
+ 0x07fcf001,
+ 0x07fdf802,
+ 0x07fe4001,
+ 0x07fe8001,
+ 0x07fec001,
+ 0x07fee802,
+ 0x07ff3800,
+ 0x07ff780c,
+ 0x07fff001,
+ 0x08006000,
+ 0x08013800,
+ 0x0801d800,
+ 0x0801f000,
+ 0x08027001,
+ 0x0802f021,
+ 0x0807d804,
+ 0x08081803,
+ 0x0809a002,
+ 0x080c7800,
+ 0x080ce802,
+ 0x080d082e,
+ 0x080fe882,
+ 0x0814e802,
+ 0x0816880f,
+ 0x0817e003,
+ 0x08192008,
+ 0x081a5804,
+ 0x081bb009,
+ 0x081cf000,
+ 0x081e2003,
+ 0x081eb029,
+ 0x0824f001,
+ 0x08255005,
+ 0x0826a003,
+ 0x0827e003,
+ 0x08294007,
+ 0x082b200a,
+ 0x082bd800,
+ 0x082c5800,
+ 0x082c9800,
+ 0x082cb000,
+ 0x082d1000,
+ 0x082d9000,
+ 0x082dd000,
+ 0x082de842,
+ 0x0839b808,
+ 0x083ab009,
+ 0x083b4017,
+ 0x083c3000,
+ 0x083d8800,
+ 0x083dd844,
+ 0x08403001,
+ 0x08404800,
+ 0x0841b000,
+ 0x0841c802,
+ 0x0841e801,
+ 0x0842b000,
+ 0x0844f807,
+ 0x0845802f,
+ 0x08479800,
+ 0x0847b004,
+ 0x0848e002,
+ 0x0849d004,
+ 0x084a003f,
+ 0x084dc003,
+ 0x084e8001,
+ 0x0850080e,
+ 0x0850a000,
+ 0x0850c000,
+ 0x0851b009,
+ 0x08524806,
+ 0x0852c806,
+ 0x0855001f,
+ 0x08572805,
+ 0x0857b808,
+ 0x0859b002,
+ 0x085ab001,
+ 0x085b9804,
+ 0x085c9006,
+ 0x085ce80b,
+ 0x085d804f,
+ 0x08624836,
+ 0x0865980c,
+ 0x08679806,
+ 0x0869200b,
+ 0x0869d125,
+ 0x0873f800,
+ 0x08755002,
+ 0x08757001,
+ 0x0875904d,
+ 0x08794007,
+ 0x087a300a,
+ 0x087ad015,
+ 0x087c1003,
+ 0x087c5025,
+ 0x087e6013,
+ 0x087fb808,
+ 0x08800800,
+ 0x0881c00e,
+ 0x08827003,
+ 0x08838000,
+ 0x08839801,
+ 0x0883b00b,
+ 0x08859803,
+ 0x0885c801,
+ 0x0885e800,
+ 0x0886100d,
+ 0x08874806,
+ 0x0887d008,
+ 0x08893804,
+ 0x08896808,
+ 0x088a4007,
+ 0x088b9800,
+ 0x088bb80a,
+ 0x088db008,
+ 0x088e4803,
+ 0x088e7800,
+ 0x088f0000,
+ 0x088fa80a,
+ 0x08909000,
+ 0x08917802,
+ 0x0891a000,
+ 0x0891b001,
+ 0x0891f000,
+ 0x0892083e,
+ 0x08943800,
+ 0x08944800,
+ 0x08947000,
+ 0x0894f000,
+ 0x08955005,
+ 0x0896f800,
+ 0x0897180c,
+ 0x0897d007,
+ 0x08982000,
+ 0x08986801,
+ 0x08988801,
+ 0x08994800,
+ 0x08998800,
+ 0x0899a000,
+ 0x0899d002,
+ 0x0899f000,
+ 0x089a0000,
+ 0x089a2801,
+ 0x089a4801,
+ 0x089a7001,
+ 0x089a880b,
+ 0x089b209b,
+ 0x08a1c007,
+ 0x08a21002,
+ 0x08a23000,
+ 0x08a2e000,
+ 0x08a2f000,
+ 0x08a3101d,
+ 0x08a58000,
+ 0x08a59805,
+ 0x08a5d000,
+ 0x08a5e800,
+ 0x08a5f801,
+ 0x08a61001,
+ 0x08a64007,
+ 0x08a6d0a5,
+ 0x08ad7800,
+ 0x08ad9005,
+ 0x08ade001,
+ 0x08adf801,
+ 0x08aee023,
+ 0x08b19807,
+ 0x08b1e800,
+ 0x08b1f801,
+ 0x08b2280a,
+ 0x08b2d005,
+ 0x08b36812,
+ 0x08b55800,
+ 0x08b56800,
+ 0x08b58005,
+ 0x08b5b800,
+ 0x08b5d005,
+ 0x08b65035,
+ 0x08b8d804,
+ 0x08b91003,
+ 0x08b93808,
+ 0x08ba38b8,
+ 0x08c17808,
+ 0x08c1c801,
+ 0x08c1e063,
+ 0x08c7980b,
+ 0x08c83801,
+ 0x08c85001,
+ 0x08c8a000,
+ 0x08c8b800,
+ 0x08c98000,
+ 0x08c9b000,
+ 0x08c9c803,
+ 0x08c9f000,
+ 0x08ca1800,
+ 0x08ca3808,
+ 0x08cad045,
+ 0x08cd4001,
+ 0x08cea007,
+ 0x08cf0000,
+ 0x08cf281a,
+ 0x08d00809,
+ 0x08d19805,
+ 0x08d1d803,
+ 0x08d23808,
+ 0x08d28805,
+ 0x08d2c802,
+ 0x08d4500c,
+ 0x08d4c001,
+ 0x08d5180c,
+ 0x08d7c806,
+ 0x08d850f5,
+ 0x08e04800,
+ 0x08e1800d,
+ 0x08e1f800,
+ 0x08e23009,
+ 0x08e36802,
+ 0x08e48018,
+ 0x08e55006,
+ 0x08e59001,
+ 0x08e5a84a,
+ 0x08e83800,
+ 0x08e85000,
+ 0x08e98814,
+ 0x08ea3808,
+ 0x08ead005,
+ 0x08eb3000,
+ 0x08eb4800,
+ 0x08ec7803,
+ 0x08eca800,
+ 0x08ecb800,
+ 0x08ecc806,
+ 0x08ed5135,
+ 0x08f79801,
+ 0x08f7c808,
+ 0x08f88800,
+ 0x08f9b007,
+ 0x08fa0000,
+ 0x08fa1000,
+ 0x08fad055,
+ 0x08fd880e,
+ 0x08ff900c,
+ 0x091cd065,
+ 0x09237800,
+ 0x0923a80a,
+ 0x092a27ff,
+ 0x096a224b,
+ 0x097f980c,
+ 0x09a18010,
+ 0x09a23fff,
+ 0x09e23fb8,
+ 0x0a323fff,
+ 0x0a723fff,
+ 0x0ab23fff,
+ 0x0af23fff,
+ 0x0b3239b8,
+ 0x0b51c806,
+ 0x0b52f800,
+ 0x0b535003,
+ 0x0b55f800,
+ 0x0b565005,
+ 0x0b577006,
+ 0x0b57b009,
+ 0x0b598006,
+ 0x0b5a3009,
+ 0x0b5ad000,
+ 0x0b5b1000,
+ 0x0b5bc004,
+ 0x0b5c82af,
+ 0x0b74d864,
+ 0x0b7a5804,
+ 0x0b7c400a,
+ 0x0b7d003f,
+ 0x0b7f200b,
+ 0x0b7f900d,
+ 0x0c3fc007,
+ 0x0c66b029,
+ 0x0c684fff,
+ 0x0ca84fff,
+ 0x0ce84fff,
+ 0x0d284fff,
+ 0x0d684ae6,
+ 0x0d7fa000,
+ 0x0d7fe000,
+ 0x0d7ff800,
+ 0x0d89180e,
+ 0x0d89981c,
+ 0x0d8a9801,
+ 0x0d8ab00d,
+ 0x0d8b4007,
+ 0x0d97e7ff,
+ 0x0dd7e103,
+ 0x0de35804,
+ 0x0de3e802,
+ 0x0de44806,
+ 0x0de4d001,
+ 0x0de4e801,
+ 0x0de507ff,
+ 0x0e2507ff,
+ 0x0e6502af,
+ 0x0e7e203b,
+ 0x0e87b009,
+ 0x0e893801,
+ 0x0e8b2800,
+ 0x0e8b3802,
+ 0x0e8b7014,
+ 0x0e8c2806,
+ 0x0e8d5003,
+ 0x0e8f5814,
+ 0x0e921002,
+ 0x0e923079,
+ 0x0e96a00b,
+ 0x0e97a00b,
+ 0x0e9ab808,
+ 0x0e9bc886,
+ 0x0ea2a800,
+ 0x0ea4e800,
+ 0x0ea50001,
+ 0x0ea51801,
+ 0x0ea53801,
+ 0x0ea56800,
+ 0x0ea5d000,
+ 0x0ea5e000,
+ 0x0ea62000,
+ 0x0ea83000,
+ 0x0ea85801,
+ 0x0ea8a800,
+ 0x0ea8e800,
+ 0x0ea9d000,
+ 0x0ea9f800,
+ 0x0eaa2800,
+ 0x0eaa3802,
+ 0x0eaa8800,
+ 0x0eb53001,
+ 0x0ebe6001,
+ 0x0ed00036,
+ 0x0ed1d831,
+ 0x0ed3a800,
+ 0x0ed42000,
+ 0x0ed46473,
+ 0x0ef8f805,
+ 0x0ef95904,
+ 0x0f037091,
+ 0x0f096809,
+ 0x0f09f001,
+ 0x0f0a5003,
+ 0x0f0a813f,
+ 0x0f157011,
+ 0x0f176003,
+ 0x0f17d004,
+ 0x0f1801cf,
+ 0x0f276003,
+ 0x0f27d2e5,
+ 0x0f3f3800,
+ 0x0f3f6000,
+ 0x0f3f7800,
+ 0x0f3ff800,
+ 0x0f462801,
+ 0x0f46802f,
+ 0x0f4a2006,
+ 0x0f4a6003,
+ 0x0f4ad003,
+ 0x0f4b0310,
+ 0x0f65a84b,
+ 0x0f69f0c1,
+ 0x0f702000,
+ 0x0f710000,
+ 0x0f711800,
+ 0x0f712801,
+ 0x0f714000,
+ 0x0f719800,
+ 0x0f71c000,
+ 0x0f71d000,
+ 0x0f71e005,
+ 0x0f721803,
+ 0x0f724000,
+ 0x0f725000,
+ 0x0f726000,
+ 0x0f728000,
+ 0x0f729800,
+ 0x0f72a801,
+ 0x0f72c000,
+ 0x0f72d000,
+ 0x0f72e000,
+ 0x0f72f000,
+ 0x0f730000,
+ 0x0f731800,
+ 0x0f732801,
+ 0x0f735800,
+ 0x0f739800,
+ 0x0f73c000,
+ 0x0f73e800,
+ 0x0f73f800,
+ 0x0f745000,
+ 0x0f74e004,
+ 0x0f752000,
+ 0x0f755000,
+ 0x0f75e033,
+ 0x0f77910d,
+ 0x0f816003,
+ 0x0f84a00b,
+ 0x0f857801,
+ 0x0f860000,
+ 0x0f868000,
+ 0x0f87b009,
+ 0x0f8d7037,
+ 0x0f90180c,
+ 0x0f91e003,
+ 0x0f924806,
+ 0x0f92900d,
+ 0x0f933099,
+ 0x0fb6c003,
+ 0x0fb76802,
+ 0x0fb7e802,
+ 0x0fbbb803,
+ 0x0fbed005,
+ 0x0fbf6003,
+ 0x0fbf880e,
+ 0x0fc06003,
+ 0x0fc24007,
+ 0x0fc2d005,
+ 0x0fc44007,
+ 0x0fc57001,
+ 0x0fc5904d,
+ 0x0fd2a00b,
+ 0x0fd37001,
+ 0x0fd3e802,
+ 0x0fd44806,
+ 0x0fd5f000,
+ 0x0fd63007,
+ 0x0fd6e003,
+ 0x0fd74806,
+ 0x0fd7c806,
+ 0x0fdc9800,
+ 0x0fde5824,
+ 0x0fdfd405,
+ 0x1537001f,
+ 0x15b9d005,
+ 0x15c0f001,
+ 0x1675100d,
+ 0x175f0fff,
+ 0x179f0c1e,
+ 0x17d0f5e1,
+ 0x189a5804};
+
+/// At the end of the valid Unicode code points space a lot of code points are
+/// either reserved or a noncharacter. Adding all these entries to the
+/// lookup table would add 446 entries to the table (in Unicode 14).
+/// Instead the only the start of the region is stored, every code point in
+/// this region needs to be escaped.
+inline constexpr uint32_t __unallocated_region_lower_bound = 0x000323b0;
+
+/// Returns whether the code unit needs to be escaped.
+///
+/// \pre The code point is a valid Unicode code point.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool __needs_escape(const char32_t __code_point) noexcept {
+ // Since __unallocated_region_lower_bound contains the unshifted range do the
+ // comparison without shifting.
+ if (__code_point >= __unallocated_region_lower_bound)
+ return true;
+
+ ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
+ if (__i == 0)
+ return false;
+
+ --__i;
+ uint32_t __upper_bound = (__entries[__i] >> 11) + (__entries[__i] & 0x7ffu);
+ return __code_point <= __upper_bound;
+}
+
+} // namespace __escaped_output_table
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_ESCAPED_OUTPUT_TABLE_H
diff --git a/third_party/llvm-project/libcxx/include/__format/extended_grapheme_cluster_table.h b/third_party/llvm-project/libcxx/include/__format/extended_grapheme_cluster_table.h
new file mode 100644
index 0000000..0e00670
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/extended_grapheme_cluster_table.h
@@ -0,0 +1,1661 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// WARNING, this entire header is generated by
+// utils/generate_extended_grapheme_cluster_table.py
+// DO NOT MODIFY!
+
+// UNICODE, INC. LICENSE AGREEMENT - DATA FILES AND SOFTWARE
+//
+// See Terms of Use <https://www.unicode.org/copyright.html>
+// for definitions of Unicode Inc.'s Data Files and Software.
+//
+// NOTICE TO USER: Carefully read the following legal agreement.
+// BY DOWNLOADING, INSTALLING, COPYING OR OTHERWISE USING UNICODE INC.'S
+// DATA FILES ("DATA FILES"), AND/OR SOFTWARE ("SOFTWARE"),
+// YOU UNEQUIVOCALLY ACCEPT, AND AGREE TO BE BOUND BY, ALL OF THE
+// TERMS AND CONDITIONS OF THIS AGREEMENT.
+// IF YOU DO NOT AGREE, DO NOT DOWNLOAD, INSTALL, COPY, DISTRIBUTE OR USE
+// THE DATA FILES OR SOFTWARE.
+//
+// COPYRIGHT AND PERMISSION NOTICE
+//
+// Copyright (c) 1991-2022 Unicode, Inc. All rights reserved.
+// Distributed under the Terms of Use in https://www.unicode.org/copyright.html.
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of the Unicode data files and any associated documentation
+// (the "Data Files") or Unicode software and any associated documentation
+// (the "Software") to deal in the Data Files or Software
+// without restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, and/or sell copies of
+// the Data Files or Software, and to permit persons to whom the Data Files
+// or Software are furnished to do so, provided that either
+// (a) this copyright and permission notice appear with all copies
+// of the Data Files or Software, or
+// (b) this copyright and permission notice appear in associated
+// Documentation.
+//
+// THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
+// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+// WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT OF THIRD PARTY RIGHTS.
+// IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS
+// NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL
+// DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+// DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+// TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THE DATA FILES OR SOFTWARE.
+//
+// Except as contained in this notice, the name of a copyright holder
+// shall not be used in advertising or otherwise to promote the sale,
+// use or other dealings in these Data Files or Software without prior
+// written authorization of the copyright holder.
+
+#ifndef _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
+#define _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
+
+#include <__algorithm/ranges_upper_bound.h>
+#include <__config>
+#include <__iterator/access.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __extended_grapheme_custer_property_boundary {
+
+enum class __property : uint8_t {
+ // Values generated from the data files.
+ __CR,
+ __Control,
+ __Extend,
+ __Extended_Pictographic,
+ __L,
+ __LF,
+ __LV,
+ __LVT,
+ __Prepend,
+ __Regional_Indicator,
+ __SpacingMark,
+ __T,
+ __V,
+ __ZWJ,
+
+ // The properies below aren't stored in the "database".
+
+ // Text position properties.
+ __sot,
+ __eot,
+
+ // The code unit has none of above properties.
+ __none
+};
+
+/// The entries of the extended grapheme cluster bondary property table.
+///
+/// The data is generated from
+/// - https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
+/// - https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
+///
+/// The data has 3 values
+/// - bits [0, 3] The property. One of the values generated form the datafiles
+/// of \ref __property
+/// - bits [4, 10] The size of the range.
+/// - bits [11, 31] The lower bound code point of the range. The upper bound of
+/// the range is lower bound + size.
+///
+/// The 7 bits for the size allow a maximum range of 128 elements. Some ranges
+/// in the Unicode tables are larger. They are stored in multiple consecutive
+/// ranges in the data table. An alternative would be to store the sizes in a
+/// separate 16-bit value. The original MSVC STL code had such an approach, but
+/// this approach uses less space for the data and is about 4% faster in the
+/// following benchmark.
+/// libcxx/benchmarks/std_format_spec_string_unicode.bench.cpp
+inline constexpr uint32_t __entries[1496] = {
+ 0x00000091,
+ 0x00005005,
+ 0x00005811,
+ 0x00006800,
+ 0x00007111,
+ 0x0003fa01,
+ 0x00054803,
+ 0x00056801,
+ 0x00057003,
+ 0x001806f2,
+ 0x00241862,
+ 0x002c8ac2,
+ 0x002df802,
+ 0x002e0812,
+ 0x002e2012,
+ 0x002e3802,
+ 0x00300058,
+ 0x003080a2,
+ 0x0030e001,
+ 0x00325942,
+ 0x00338002,
+ 0x0036b062,
+ 0x0036e808,
+ 0x0036f852,
+ 0x00373812,
+ 0x00375032,
+ 0x00387808,
+ 0x00388802,
+ 0x003981a2,
+ 0x003d30a2,
+ 0x003f5882,
+ 0x003fe802,
+ 0x0040b032,
+ 0x0040d882,
+ 0x00412822,
+ 0x00414842,
+ 0x0042c822,
+ 0x00448018,
+ 0x0044c072,
+ 0x00465172,
+ 0x00471008,
+ 0x004719f2,
+ 0x0048180a,
+ 0x0049d002,
+ 0x0049d80a,
+ 0x0049e002,
+ 0x0049f02a,
+ 0x004a0872,
+ 0x004a483a,
+ 0x004a6802,
+ 0x004a701a,
+ 0x004a8862,
+ 0x004b1012,
+ 0x004c0802,
+ 0x004c101a,
+ 0x004de002,
+ 0x004df002,
+ 0x004df81a,
+ 0x004e0832,
+ 0x004e381a,
+ 0x004e581a,
+ 0x004e6802,
+ 0x004eb802,
+ 0x004f1012,
+ 0x004ff002,
+ 0x00500812,
+ 0x0050180a,
+ 0x0051e002,
+ 0x0051f02a,
+ 0x00520812,
+ 0x00523812,
+ 0x00525822,
+ 0x00528802,
+ 0x00538012,
+ 0x0053a802,
+ 0x00540812,
+ 0x0054180a,
+ 0x0055e002,
+ 0x0055f02a,
+ 0x00560842,
+ 0x00563812,
+ 0x0056480a,
+ 0x0056581a,
+ 0x00566802,
+ 0x00571012,
+ 0x0057d052,
+ 0x00580802,
+ 0x0058101a,
+ 0x0059e002,
+ 0x0059f012,
+ 0x005a000a,
+ 0x005a0832,
+ 0x005a381a,
+ 0x005a581a,
+ 0x005a6802,
+ 0x005aa822,
+ 0x005b1012,
+ 0x005c1002,
+ 0x005df002,
+ 0x005df80a,
+ 0x005e0002,
+ 0x005e081a,
+ 0x005e302a,
+ 0x005e502a,
+ 0x005e6802,
+ 0x005eb802,
+ 0x00600002,
+ 0x0060082a,
+ 0x00602002,
+ 0x0061e002,
+ 0x0061f022,
+ 0x0062083a,
+ 0x00623022,
+ 0x00625032,
+ 0x0062a812,
+ 0x00631012,
+ 0x00640802,
+ 0x0064101a,
+ 0x0065e002,
+ 0x0065f00a,
+ 0x0065f802,
+ 0x0066001a,
+ 0x00661002,
+ 0x0066181a,
+ 0x00663002,
+ 0x0066381a,
+ 0x0066501a,
+ 0x00666012,
+ 0x0066a812,
+ 0x00671012,
+ 0x0067980a,
+ 0x00680012,
+ 0x0068101a,
+ 0x0069d812,
+ 0x0069f002,
+ 0x0069f81a,
+ 0x006a0832,
+ 0x006a302a,
+ 0x006a502a,
+ 0x006a6802,
+ 0x006a7008,
+ 0x006ab802,
+ 0x006b1012,
+ 0x006c0802,
+ 0x006c101a,
+ 0x006e5002,
+ 0x006e7802,
+ 0x006e801a,
+ 0x006e9022,
+ 0x006eb002,
+ 0x006ec06a,
+ 0x006ef802,
+ 0x006f901a,
+ 0x00718802,
+ 0x0071980a,
+ 0x0071a062,
+ 0x00723872,
+ 0x00758802,
+ 0x0075980a,
+ 0x0075a082,
+ 0x00764062,
+ 0x0078c012,
+ 0x0079a802,
+ 0x0079b802,
+ 0x0079c802,
+ 0x0079f01a,
+ 0x007b88d2,
+ 0x007bf80a,
+ 0x007c0042,
+ 0x007c3012,
+ 0x007c68a2,
+ 0x007cca32,
+ 0x007e3002,
+ 0x00816832,
+ 0x0081880a,
+ 0x00819052,
+ 0x0081c812,
+ 0x0081d81a,
+ 0x0081e812,
+ 0x0082b01a,
+ 0x0082c012,
+ 0x0082f022,
+ 0x00838832,
+ 0x00841002,
+ 0x0084200a,
+ 0x00842812,
+ 0x00846802,
+ 0x0084e802,
+ 0x008805f4,
+ 0x008b047c,
+ 0x008d457b,
+ 0x009ae822,
+ 0x00b89022,
+ 0x00b8a80a,
+ 0x00b99012,
+ 0x00b9a00a,
+ 0x00ba9012,
+ 0x00bb9012,
+ 0x00bda012,
+ 0x00bdb00a,
+ 0x00bdb862,
+ 0x00bdf07a,
+ 0x00be3002,
+ 0x00be381a,
+ 0x00be48a2,
+ 0x00bee802,
+ 0x00c05822,
+ 0x00c07001,
+ 0x00c07802,
+ 0x00c42812,
+ 0x00c54802,
+ 0x00c90022,
+ 0x00c9183a,
+ 0x00c93812,
+ 0x00c9482a,
+ 0x00c9801a,
+ 0x00c99002,
+ 0x00c9985a,
+ 0x00c9c822,
+ 0x00d0b812,
+ 0x00d0c81a,
+ 0x00d0d802,
+ 0x00d2a80a,
+ 0x00d2b002,
+ 0x00d2b80a,
+ 0x00d2c062,
+ 0x00d30002,
+ 0x00d31002,
+ 0x00d32872,
+ 0x00d3685a,
+ 0x00d39892,
+ 0x00d3f802,
+ 0x00d581e2,
+ 0x00d80032,
+ 0x00d8200a,
+ 0x00d9a062,
+ 0x00d9d80a,
+ 0x00d9e002,
+ 0x00d9e84a,
+ 0x00da1002,
+ 0x00da181a,
+ 0x00db5882,
+ 0x00dc0012,
+ 0x00dc100a,
+ 0x00dd080a,
+ 0x00dd1032,
+ 0x00dd301a,
+ 0x00dd4012,
+ 0x00dd500a,
+ 0x00dd5822,
+ 0x00df3002,
+ 0x00df380a,
+ 0x00df4012,
+ 0x00df502a,
+ 0x00df6802,
+ 0x00df700a,
+ 0x00df7822,
+ 0x00df901a,
+ 0x00e1207a,
+ 0x00e16072,
+ 0x00e1a01a,
+ 0x00e1b012,
+ 0x00e68022,
+ 0x00e6a0c2,
+ 0x00e7080a,
+ 0x00e71062,
+ 0x00e76802,
+ 0x00e7a002,
+ 0x00e7b80a,
+ 0x00e7c012,
+ 0x00ee03f2,
+ 0x01005801,
+ 0x01006002,
+ 0x0100680d,
+ 0x01007011,
+ 0x01014061,
+ 0x0101e003,
+ 0x01024803,
+ 0x010300f1,
+ 0x01068202,
+ 0x01091003,
+ 0x0109c803,
+ 0x010ca053,
+ 0x010d4813,
+ 0x0118d013,
+ 0x01194003,
+ 0x011c4003,
+ 0x011e7803,
+ 0x011f48a3,
+ 0x011fc023,
+ 0x01261003,
+ 0x012d5013,
+ 0x012db003,
+ 0x012e0003,
+ 0x012fd833,
+ 0x01300053,
+ 0x013038b3,
+ 0x0130a713,
+ 0x01348753,
+ 0x013840a3,
+ 0x0138a003,
+ 0x0138b003,
+ 0x0138e803,
+ 0x01390803,
+ 0x01394003,
+ 0x01399813,
+ 0x013a2003,
+ 0x013a3803,
+ 0x013a6003,
+ 0x013a7003,
+ 0x013a9823,
+ 0x013ab803,
+ 0x013b1843,
+ 0x013ca823,
+ 0x013d0803,
+ 0x013d8003,
+ 0x013df803,
+ 0x0149a013,
+ 0x01582823,
+ 0x0158d813,
+ 0x015a8003,
+ 0x015aa803,
+ 0x01677822,
+ 0x016bf802,
+ 0x016f01f2,
+ 0x01815052,
+ 0x01818003,
+ 0x0181e803,
+ 0x0184c812,
+ 0x0194b803,
+ 0x0194c803,
+ 0x05337832,
+ 0x0533a092,
+ 0x0534f012,
+ 0x05378012,
+ 0x05401002,
+ 0x05403002,
+ 0x05405802,
+ 0x0541181a,
+ 0x05412812,
+ 0x0541380a,
+ 0x05416002,
+ 0x0544001a,
+ 0x0545a0fa,
+ 0x05462012,
+ 0x05470112,
+ 0x0547f802,
+ 0x05493072,
+ 0x054a38a2,
+ 0x054a901a,
+ 0x054b01c4,
+ 0x054c0022,
+ 0x054c180a,
+ 0x054d9802,
+ 0x054da01a,
+ 0x054db032,
+ 0x054dd01a,
+ 0x054de012,
+ 0x054df02a,
+ 0x054f2802,
+ 0x05514852,
+ 0x0551781a,
+ 0x05518812,
+ 0x0551981a,
+ 0x0551a812,
+ 0x05521802,
+ 0x05526002,
+ 0x0552680a,
+ 0x0553e002,
+ 0x05558002,
+ 0x05559022,
+ 0x0555b812,
+ 0x0555f012,
+ 0x05560802,
+ 0x0557580a,
+ 0x05576012,
+ 0x0557701a,
+ 0x0557a80a,
+ 0x0557b002,
+ 0x055f181a,
+ 0x055f2802,
+ 0x055f301a,
+ 0x055f4002,
+ 0x055f481a,
+ 0x055f600a,
+ 0x055f6802,
+ 0x05600006,
+ 0x056009a7,
+ 0x0560e006,
+ 0x0560e9a7,
+ 0x0561c006,
+ 0x0561c9a7,
+ 0x0562a006,
+ 0x0562a9a7,
+ 0x05638006,
+ 0x056389a7,
+ 0x05646006,
+ 0x056469a7,
+ 0x05654006,
+ 0x056549a7,
+ 0x05662006,
+ 0x056629a7,
+ 0x05670006,
+ 0x056709a7,
+ 0x0567e006,
+ 0x0567e9a7,
+ 0x0568c006,
+ 0x0568c9a7,
+ 0x0569a006,
+ 0x0569a9a7,
+ 0x056a8006,
+ 0x056a89a7,
+ 0x056b6006,
+ 0x056b69a7,
+ 0x056c4006,
+ 0x056c49a7,
+ 0x056d2006,
+ 0x056d29a7,
+ 0x056e0006,
+ 0x056e09a7,
+ 0x056ee006,
+ 0x056ee9a7,
+ 0x056fc006,
+ 0x056fc9a7,
+ 0x0570a006,
+ 0x0570a9a7,
+ 0x05718006,
+ 0x057189a7,
+ 0x05726006,
+ 0x057269a7,
+ 0x05734006,
+ 0x057349a7,
+ 0x05742006,
+ 0x057429a7,
+ 0x05750006,
+ 0x057509a7,
+ 0x0575e006,
+ 0x0575e9a7,
+ 0x0576c006,
+ 0x0576c9a7,
+ 0x0577a006,
+ 0x0577a9a7,
+ 0x05788006,
+ 0x057889a7,
+ 0x05796006,
+ 0x057969a7,
+ 0x057a4006,
+ 0x057a49a7,
+ 0x057b2006,
+ 0x057b29a7,
+ 0x057c0006,
+ 0x057c09a7,
+ 0x057ce006,
+ 0x057ce9a7,
+ 0x057dc006,
+ 0x057dc9a7,
+ 0x057ea006,
+ 0x057ea9a7,
+ 0x057f8006,
+ 0x057f89a7,
+ 0x05806006,
+ 0x058069a7,
+ 0x05814006,
+ 0x058149a7,
+ 0x05822006,
+ 0x058229a7,
+ 0x05830006,
+ 0x058309a7,
+ 0x0583e006,
+ 0x0583e9a7,
+ 0x0584c006,
+ 0x0584c9a7,
+ 0x0585a006,
+ 0x0585a9a7,
+ 0x05868006,
+ 0x058689a7,
+ 0x05876006,
+ 0x058769a7,
+ 0x05884006,
+ 0x058849a7,
+ 0x05892006,
+ 0x058929a7,
+ 0x058a0006,
+ 0x058a09a7,
+ 0x058ae006,
+ 0x058ae9a7,
+ 0x058bc006,
+ 0x058bc9a7,
+ 0x058ca006,
+ 0x058ca9a7,
+ 0x058d8006,
+ 0x058d89a7,
+ 0x058e6006,
+ 0x058e69a7,
+ 0x058f4006,
+ 0x058f49a7,
+ 0x05902006,
+ 0x059029a7,
+ 0x05910006,
+ 0x059109a7,
+ 0x0591e006,
+ 0x0591e9a7,
+ 0x0592c006,
+ 0x0592c9a7,
+ 0x0593a006,
+ 0x0593a9a7,
+ 0x05948006,
+ 0x059489a7,
+ 0x05956006,
+ 0x059569a7,
+ 0x05964006,
+ 0x059649a7,
+ 0x05972006,
+ 0x059729a7,
+ 0x05980006,
+ 0x059809a7,
+ 0x0598e006,
+ 0x0598e9a7,
+ 0x0599c006,
+ 0x0599c9a7,
+ 0x059aa006,
+ 0x059aa9a7,
+ 0x059b8006,
+ 0x059b89a7,
+ 0x059c6006,
+ 0x059c69a7,
+ 0x059d4006,
+ 0x059d49a7,
+ 0x059e2006,
+ 0x059e29a7,
+ 0x059f0006,
+ 0x059f09a7,
+ 0x059fe006,
+ 0x059fe9a7,
+ 0x05a0c006,
+ 0x05a0c9a7,
+ 0x05a1a006,
+ 0x05a1a9a7,
+ 0x05a28006,
+ 0x05a289a7,
+ 0x05a36006,
+ 0x05a369a7,
+ 0x05a44006,
+ 0x05a449a7,
+ 0x05a52006,
+ 0x05a529a7,
+ 0x05a60006,
+ 0x05a609a7,
+ 0x05a6e006,
+ 0x05a6e9a7,
+ 0x05a7c006,
+ 0x05a7c9a7,
+ 0x05a8a006,
+ 0x05a8a9a7,
+ 0x05a98006,
+ 0x05a989a7,
+ 0x05aa6006,
+ 0x05aa69a7,
+ 0x05ab4006,
+ 0x05ab49a7,
+ 0x05ac2006,
+ 0x05ac29a7,
+ 0x05ad0006,
+ 0x05ad09a7,
+ 0x05ade006,
+ 0x05ade9a7,
+ 0x05aec006,
+ 0x05aec9a7,
+ 0x05afa006,
+ 0x05afa9a7,
+ 0x05b08006,
+ 0x05b089a7,
+ 0x05b16006,
+ 0x05b169a7,
+ 0x05b24006,
+ 0x05b249a7,
+ 0x05b32006,
+ 0x05b329a7,
+ 0x05b40006,
+ 0x05b409a7,
+ 0x05b4e006,
+ 0x05b4e9a7,
+ 0x05b5c006,
+ 0x05b5c9a7,
+ 0x05b6a006,
+ 0x05b6a9a7,
+ 0x05b78006,
+ 0x05b789a7,
+ 0x05b86006,
+ 0x05b869a7,
+ 0x05b94006,
+ 0x05b949a7,
+ 0x05ba2006,
+ 0x05ba29a7,
+ 0x05bb0006,
+ 0x05bb09a7,
+ 0x05bbe006,
+ 0x05bbe9a7,
+ 0x05bcc006,
+ 0x05bcc9a7,
+ 0x05bda006,
+ 0x05bda9a7,
+ 0x05be8006,
+ 0x05be89a7,
+ 0x05bf6006,
+ 0x05bf69a7,
+ 0x05c04006,
+ 0x05c049a7,
+ 0x05c12006,
+ 0x05c129a7,
+ 0x05c20006,
+ 0x05c209a7,
+ 0x05c2e006,
+ 0x05c2e9a7,
+ 0x05c3c006,
+ 0x05c3c9a7,
+ 0x05c4a006,
+ 0x05c4a9a7,
+ 0x05c58006,
+ 0x05c589a7,
+ 0x05c66006,
+ 0x05c669a7,
+ 0x05c74006,
+ 0x05c749a7,
+ 0x05c82006,
+ 0x05c829a7,
+ 0x05c90006,
+ 0x05c909a7,
+ 0x05c9e006,
+ 0x05c9e9a7,
+ 0x05cac006,
+ 0x05cac9a7,
+ 0x05cba006,
+ 0x05cba9a7,
+ 0x05cc8006,
+ 0x05cc89a7,
+ 0x05cd6006,
+ 0x05cd69a7,
+ 0x05ce4006,
+ 0x05ce49a7,
+ 0x05cf2006,
+ 0x05cf29a7,
+ 0x05d00006,
+ 0x05d009a7,
+ 0x05d0e006,
+ 0x05d0e9a7,
+ 0x05d1c006,
+ 0x05d1c9a7,
+ 0x05d2a006,
+ 0x05d2a9a7,
+ 0x05d38006,
+ 0x05d389a7,
+ 0x05d46006,
+ 0x05d469a7,
+ 0x05d54006,
+ 0x05d549a7,
+ 0x05d62006,
+ 0x05d629a7,
+ 0x05d70006,
+ 0x05d709a7,
+ 0x05d7e006,
+ 0x05d7e9a7,
+ 0x05d8c006,
+ 0x05d8c9a7,
+ 0x05d9a006,
+ 0x05d9a9a7,
+ 0x05da8006,
+ 0x05da89a7,
+ 0x05db6006,
+ 0x05db69a7,
+ 0x05dc4006,
+ 0x05dc49a7,
+ 0x05dd2006,
+ 0x05dd29a7,
+ 0x05de0006,
+ 0x05de09a7,
+ 0x05dee006,
+ 0x05dee9a7,
+ 0x05dfc006,
+ 0x05dfc9a7,
+ 0x05e0a006,
+ 0x05e0a9a7,
+ 0x05e18006,
+ 0x05e189a7,
+ 0x05e26006,
+ 0x05e269a7,
+ 0x05e34006,
+ 0x05e349a7,
+ 0x05e42006,
+ 0x05e429a7,
+ 0x05e50006,
+ 0x05e509a7,
+ 0x05e5e006,
+ 0x05e5e9a7,
+ 0x05e6c006,
+ 0x05e6c9a7,
+ 0x05e7a006,
+ 0x05e7a9a7,
+ 0x05e88006,
+ 0x05e889a7,
+ 0x05e96006,
+ 0x05e969a7,
+ 0x05ea4006,
+ 0x05ea49a7,
+ 0x05eb2006,
+ 0x05eb29a7,
+ 0x05ec0006,
+ 0x05ec09a7,
+ 0x05ece006,
+ 0x05ece9a7,
+ 0x05edc006,
+ 0x05edc9a7,
+ 0x05eea006,
+ 0x05eea9a7,
+ 0x05ef8006,
+ 0x05ef89a7,
+ 0x05f06006,
+ 0x05f069a7,
+ 0x05f14006,
+ 0x05f149a7,
+ 0x05f22006,
+ 0x05f229a7,
+ 0x05f30006,
+ 0x05f309a7,
+ 0x05f3e006,
+ 0x05f3e9a7,
+ 0x05f4c006,
+ 0x05f4c9a7,
+ 0x05f5a006,
+ 0x05f5a9a7,
+ 0x05f68006,
+ 0x05f689a7,
+ 0x05f76006,
+ 0x05f769a7,
+ 0x05f84006,
+ 0x05f849a7,
+ 0x05f92006,
+ 0x05f929a7,
+ 0x05fa0006,
+ 0x05fa09a7,
+ 0x05fae006,
+ 0x05fae9a7,
+ 0x05fbc006,
+ 0x05fbc9a7,
+ 0x05fca006,
+ 0x05fca9a7,
+ 0x05fd8006,
+ 0x05fd89a7,
+ 0x05fe6006,
+ 0x05fe69a7,
+ 0x05ff4006,
+ 0x05ff49a7,
+ 0x06002006,
+ 0x060029a7,
+ 0x06010006,
+ 0x060109a7,
+ 0x0601e006,
+ 0x0601e9a7,
+ 0x0602c006,
+ 0x0602c9a7,
+ 0x0603a006,
+ 0x0603a9a7,
+ 0x06048006,
+ 0x060489a7,
+ 0x06056006,
+ 0x060569a7,
+ 0x06064006,
+ 0x060649a7,
+ 0x06072006,
+ 0x060729a7,
+ 0x06080006,
+ 0x060809a7,
+ 0x0608e006,
+ 0x0608e9a7,
+ 0x0609c006,
+ 0x0609c9a7,
+ 0x060aa006,
+ 0x060aa9a7,
+ 0x060b8006,
+ 0x060b89a7,
+ 0x060c6006,
+ 0x060c69a7,
+ 0x060d4006,
+ 0x060d49a7,
+ 0x060e2006,
+ 0x060e29a7,
+ 0x060f0006,
+ 0x060f09a7,
+ 0x060fe006,
+ 0x060fe9a7,
+ 0x0610c006,
+ 0x0610c9a7,
+ 0x0611a006,
+ 0x0611a9a7,
+ 0x06128006,
+ 0x061289a7,
+ 0x06136006,
+ 0x061369a7,
+ 0x06144006,
+ 0x061449a7,
+ 0x06152006,
+ 0x061529a7,
+ 0x06160006,
+ 0x061609a7,
+ 0x0616e006,
+ 0x0616e9a7,
+ 0x0617c006,
+ 0x0617c9a7,
+ 0x0618a006,
+ 0x0618a9a7,
+ 0x06198006,
+ 0x061989a7,
+ 0x061a6006,
+ 0x061a69a7,
+ 0x061b4006,
+ 0x061b49a7,
+ 0x061c2006,
+ 0x061c29a7,
+ 0x061d0006,
+ 0x061d09a7,
+ 0x061de006,
+ 0x061de9a7,
+ 0x061ec006,
+ 0x061ec9a7,
+ 0x061fa006,
+ 0x061fa9a7,
+ 0x06208006,
+ 0x062089a7,
+ 0x06216006,
+ 0x062169a7,
+ 0x06224006,
+ 0x062249a7,
+ 0x06232006,
+ 0x062329a7,
+ 0x06240006,
+ 0x062409a7,
+ 0x0624e006,
+ 0x0624e9a7,
+ 0x0625c006,
+ 0x0625c9a7,
+ 0x0626a006,
+ 0x0626a9a7,
+ 0x06278006,
+ 0x062789a7,
+ 0x06286006,
+ 0x062869a7,
+ 0x06294006,
+ 0x062949a7,
+ 0x062a2006,
+ 0x062a29a7,
+ 0x062b0006,
+ 0x062b09a7,
+ 0x062be006,
+ 0x062be9a7,
+ 0x062cc006,
+ 0x062cc9a7,
+ 0x062da006,
+ 0x062da9a7,
+ 0x062e8006,
+ 0x062e89a7,
+ 0x062f6006,
+ 0x062f69a7,
+ 0x06304006,
+ 0x063049a7,
+ 0x06312006,
+ 0x063129a7,
+ 0x06320006,
+ 0x063209a7,
+ 0x0632e006,
+ 0x0632e9a7,
+ 0x0633c006,
+ 0x0633c9a7,
+ 0x0634a006,
+ 0x0634a9a7,
+ 0x06358006,
+ 0x063589a7,
+ 0x06366006,
+ 0x063669a7,
+ 0x06374006,
+ 0x063749a7,
+ 0x06382006,
+ 0x063829a7,
+ 0x06390006,
+ 0x063909a7,
+ 0x0639e006,
+ 0x0639e9a7,
+ 0x063ac006,
+ 0x063ac9a7,
+ 0x063ba006,
+ 0x063ba9a7,
+ 0x063c8006,
+ 0x063c89a7,
+ 0x063d6006,
+ 0x063d69a7,
+ 0x063e4006,
+ 0x063e49a7,
+ 0x063f2006,
+ 0x063f29a7,
+ 0x06400006,
+ 0x064009a7,
+ 0x0640e006,
+ 0x0640e9a7,
+ 0x0641c006,
+ 0x0641c9a7,
+ 0x0642a006,
+ 0x0642a9a7,
+ 0x06438006,
+ 0x064389a7,
+ 0x06446006,
+ 0x064469a7,
+ 0x06454006,
+ 0x064549a7,
+ 0x06462006,
+ 0x064629a7,
+ 0x06470006,
+ 0x064709a7,
+ 0x0647e006,
+ 0x0647e9a7,
+ 0x0648c006,
+ 0x0648c9a7,
+ 0x0649a006,
+ 0x0649a9a7,
+ 0x064a8006,
+ 0x064a89a7,
+ 0x064b6006,
+ 0x064b69a7,
+ 0x064c4006,
+ 0x064c49a7,
+ 0x064d2006,
+ 0x064d29a7,
+ 0x064e0006,
+ 0x064e09a7,
+ 0x064ee006,
+ 0x064ee9a7,
+ 0x064fc006,
+ 0x064fc9a7,
+ 0x0650a006,
+ 0x0650a9a7,
+ 0x06518006,
+ 0x065189a7,
+ 0x06526006,
+ 0x065269a7,
+ 0x06534006,
+ 0x065349a7,
+ 0x06542006,
+ 0x065429a7,
+ 0x06550006,
+ 0x065509a7,
+ 0x0655e006,
+ 0x0655e9a7,
+ 0x0656c006,
+ 0x0656c9a7,
+ 0x0657a006,
+ 0x0657a9a7,
+ 0x06588006,
+ 0x065889a7,
+ 0x06596006,
+ 0x065969a7,
+ 0x065a4006,
+ 0x065a49a7,
+ 0x065b2006,
+ 0x065b29a7,
+ 0x065c0006,
+ 0x065c09a7,
+ 0x065ce006,
+ 0x065ce9a7,
+ 0x065dc006,
+ 0x065dc9a7,
+ 0x065ea006,
+ 0x065ea9a7,
+ 0x065f8006,
+ 0x065f89a7,
+ 0x06606006,
+ 0x066069a7,
+ 0x06614006,
+ 0x066149a7,
+ 0x06622006,
+ 0x066229a7,
+ 0x06630006,
+ 0x066309a7,
+ 0x0663e006,
+ 0x0663e9a7,
+ 0x0664c006,
+ 0x0664c9a7,
+ 0x0665a006,
+ 0x0665a9a7,
+ 0x06668006,
+ 0x066689a7,
+ 0x06676006,
+ 0x066769a7,
+ 0x06684006,
+ 0x066849a7,
+ 0x06692006,
+ 0x066929a7,
+ 0x066a0006,
+ 0x066a09a7,
+ 0x066ae006,
+ 0x066ae9a7,
+ 0x066bc006,
+ 0x066bc9a7,
+ 0x066ca006,
+ 0x066ca9a7,
+ 0x066d8006,
+ 0x066d89a7,
+ 0x066e6006,
+ 0x066e69a7,
+ 0x066f4006,
+ 0x066f49a7,
+ 0x06702006,
+ 0x067029a7,
+ 0x06710006,
+ 0x067109a7,
+ 0x0671e006,
+ 0x0671e9a7,
+ 0x0672c006,
+ 0x0672c9a7,
+ 0x0673a006,
+ 0x0673a9a7,
+ 0x06748006,
+ 0x067489a7,
+ 0x06756006,
+ 0x067569a7,
+ 0x06764006,
+ 0x067649a7,
+ 0x06772006,
+ 0x067729a7,
+ 0x06780006,
+ 0x067809a7,
+ 0x0678e006,
+ 0x0678e9a7,
+ 0x0679c006,
+ 0x0679c9a7,
+ 0x067aa006,
+ 0x067aa9a7,
+ 0x067b8006,
+ 0x067b89a7,
+ 0x067c6006,
+ 0x067c69a7,
+ 0x067d4006,
+ 0x067d49a7,
+ 0x067e2006,
+ 0x067e29a7,
+ 0x067f0006,
+ 0x067f09a7,
+ 0x067fe006,
+ 0x067fe9a7,
+ 0x0680c006,
+ 0x0680c9a7,
+ 0x0681a006,
+ 0x0681a9a7,
+ 0x06828006,
+ 0x068289a7,
+ 0x06836006,
+ 0x068369a7,
+ 0x06844006,
+ 0x068449a7,
+ 0x06852006,
+ 0x068529a7,
+ 0x06860006,
+ 0x068609a7,
+ 0x0686e006,
+ 0x0686e9a7,
+ 0x0687c006,
+ 0x0687c9a7,
+ 0x0688a006,
+ 0x0688a9a7,
+ 0x06898006,
+ 0x068989a7,
+ 0x068a6006,
+ 0x068a69a7,
+ 0x068b4006,
+ 0x068b49a7,
+ 0x068c2006,
+ 0x068c29a7,
+ 0x068d0006,
+ 0x068d09a7,
+ 0x068de006,
+ 0x068de9a7,
+ 0x068ec006,
+ 0x068ec9a7,
+ 0x068fa006,
+ 0x068fa9a7,
+ 0x06908006,
+ 0x069089a7,
+ 0x06916006,
+ 0x069169a7,
+ 0x06924006,
+ 0x069249a7,
+ 0x06932006,
+ 0x069329a7,
+ 0x06940006,
+ 0x069409a7,
+ 0x0694e006,
+ 0x0694e9a7,
+ 0x0695c006,
+ 0x0695c9a7,
+ 0x0696a006,
+ 0x0696a9a7,
+ 0x06978006,
+ 0x069789a7,
+ 0x06986006,
+ 0x069869a7,
+ 0x06994006,
+ 0x069949a7,
+ 0x069a2006,
+ 0x069a29a7,
+ 0x069b0006,
+ 0x069b09a7,
+ 0x069be006,
+ 0x069be9a7,
+ 0x069cc006,
+ 0x069cc9a7,
+ 0x069da006,
+ 0x069da9a7,
+ 0x069e8006,
+ 0x069e89a7,
+ 0x069f6006,
+ 0x069f69a7,
+ 0x06a04006,
+ 0x06a049a7,
+ 0x06a12006,
+ 0x06a129a7,
+ 0x06a20006,
+ 0x06a209a7,
+ 0x06a2e006,
+ 0x06a2e9a7,
+ 0x06a3c006,
+ 0x06a3c9a7,
+ 0x06a4a006,
+ 0x06a4a9a7,
+ 0x06a58006,
+ 0x06a589a7,
+ 0x06a66006,
+ 0x06a669a7,
+ 0x06a74006,
+ 0x06a749a7,
+ 0x06a82006,
+ 0x06a829a7,
+ 0x06a90006,
+ 0x06a909a7,
+ 0x06a9e006,
+ 0x06a9e9a7,
+ 0x06aac006,
+ 0x06aac9a7,
+ 0x06aba006,
+ 0x06aba9a7,
+ 0x06ac8006,
+ 0x06ac89a7,
+ 0x06ad6006,
+ 0x06ad69a7,
+ 0x06ae4006,
+ 0x06ae49a7,
+ 0x06af2006,
+ 0x06af29a7,
+ 0x06b00006,
+ 0x06b009a7,
+ 0x06b0e006,
+ 0x06b0e9a7,
+ 0x06b1c006,
+ 0x06b1c9a7,
+ 0x06b2a006,
+ 0x06b2a9a7,
+ 0x06b38006,
+ 0x06b389a7,
+ 0x06b46006,
+ 0x06b469a7,
+ 0x06b54006,
+ 0x06b549a7,
+ 0x06b62006,
+ 0x06b629a7,
+ 0x06b70006,
+ 0x06b709a7,
+ 0x06b7e006,
+ 0x06b7e9a7,
+ 0x06b8c006,
+ 0x06b8c9a7,
+ 0x06b9a006,
+ 0x06b9a9a7,
+ 0x06ba8006,
+ 0x06ba89a7,
+ 0x06bb6006,
+ 0x06bb69a7,
+ 0x06bc4006,
+ 0x06bc49a7,
+ 0x06bd816c,
+ 0x06be5b0b,
+ 0x07d8f002,
+ 0x07f000f2,
+ 0x07f100f2,
+ 0x07f7f801,
+ 0x07fcf012,
+ 0x07ff80b1,
+ 0x080fe802,
+ 0x08170002,
+ 0x081bb042,
+ 0x08500822,
+ 0x08502812,
+ 0x08506032,
+ 0x0851c022,
+ 0x0851f802,
+ 0x08572812,
+ 0x08692032,
+ 0x08755812,
+ 0x0877e822,
+ 0x087a30a2,
+ 0x087c1032,
+ 0x0880000a,
+ 0x08800802,
+ 0x0880100a,
+ 0x0881c0e2,
+ 0x08838002,
+ 0x08839812,
+ 0x0883f822,
+ 0x0884100a,
+ 0x0885802a,
+ 0x08859832,
+ 0x0885b81a,
+ 0x0885c812,
+ 0x0885e808,
+ 0x08861002,
+ 0x08866808,
+ 0x08880022,
+ 0x08893842,
+ 0x0889600a,
+ 0x08896872,
+ 0x088a281a,
+ 0x088b9802,
+ 0x088c0012,
+ 0x088c100a,
+ 0x088d982a,
+ 0x088db082,
+ 0x088df81a,
+ 0x088e1018,
+ 0x088e4832,
+ 0x088e700a,
+ 0x088e7802,
+ 0x0891602a,
+ 0x08917822,
+ 0x0891901a,
+ 0x0891a002,
+ 0x0891a80a,
+ 0x0891b012,
+ 0x0891f002,
+ 0x08920802,
+ 0x0896f802,
+ 0x0897002a,
+ 0x08971872,
+ 0x08980012,
+ 0x0898101a,
+ 0x0899d812,
+ 0x0899f002,
+ 0x0899f80a,
+ 0x089a0002,
+ 0x089a083a,
+ 0x089a381a,
+ 0x089a582a,
+ 0x089ab802,
+ 0x089b101a,
+ 0x089b3062,
+ 0x089b8042,
+ 0x08a1a82a,
+ 0x08a1c072,
+ 0x08a2001a,
+ 0x08a21022,
+ 0x08a2280a,
+ 0x08a23002,
+ 0x08a2f002,
+ 0x08a58002,
+ 0x08a5881a,
+ 0x08a59852,
+ 0x08a5c80a,
+ 0x08a5d002,
+ 0x08a5d81a,
+ 0x08a5e802,
+ 0x08a5f00a,
+ 0x08a5f812,
+ 0x08a6080a,
+ 0x08a61012,
+ 0x08ad7802,
+ 0x08ad801a,
+ 0x08ad9032,
+ 0x08adc03a,
+ 0x08ade012,
+ 0x08adf00a,
+ 0x08adf812,
+ 0x08aee012,
+ 0x08b1802a,
+ 0x08b19872,
+ 0x08b1d81a,
+ 0x08b1e802,
+ 0x08b1f00a,
+ 0x08b1f812,
+ 0x08b55802,
+ 0x08b5600a,
+ 0x08b56802,
+ 0x08b5701a,
+ 0x08b58052,
+ 0x08b5b00a,
+ 0x08b5b802,
+ 0x08b8e822,
+ 0x08b91032,
+ 0x08b9300a,
+ 0x08b93842,
+ 0x08c1602a,
+ 0x08c17882,
+ 0x08c1c00a,
+ 0x08c1c812,
+ 0x08c98002,
+ 0x08c9884a,
+ 0x08c9b81a,
+ 0x08c9d812,
+ 0x08c9e80a,
+ 0x08c9f002,
+ 0x08c9f808,
+ 0x08ca000a,
+ 0x08ca0808,
+ 0x08ca100a,
+ 0x08ca1802,
+ 0x08ce882a,
+ 0x08cea032,
+ 0x08ced012,
+ 0x08cee03a,
+ 0x08cf0002,
+ 0x08cf200a,
+ 0x08d00892,
+ 0x08d19852,
+ 0x08d1c80a,
+ 0x08d1d008,
+ 0x08d1d832,
+ 0x08d23802,
+ 0x08d28852,
+ 0x08d2b81a,
+ 0x08d2c822,
+ 0x08d42058,
+ 0x08d450c2,
+ 0x08d4b80a,
+ 0x08d4c012,
+ 0x08e1780a,
+ 0x08e18062,
+ 0x08e1c052,
+ 0x08e1f00a,
+ 0x08e1f802,
+ 0x08e49152,
+ 0x08e5480a,
+ 0x08e55062,
+ 0x08e5880a,
+ 0x08e59012,
+ 0x08e5a00a,
+ 0x08e5a812,
+ 0x08e98852,
+ 0x08e9d002,
+ 0x08e9e012,
+ 0x08e9f862,
+ 0x08ea3008,
+ 0x08ea3802,
+ 0x08ec504a,
+ 0x08ec8012,
+ 0x08ec981a,
+ 0x08eca802,
+ 0x08ecb00a,
+ 0x08ecb802,
+ 0x08f79812,
+ 0x08f7a81a,
+ 0x08f80012,
+ 0x08f81008,
+ 0x08f8180a,
+ 0x08f9a01a,
+ 0x08f9b042,
+ 0x08f9f01a,
+ 0x08fa0002,
+ 0x08fa080a,
+ 0x08fa1002,
+ 0x09a180f1,
+ 0x09a20002,
+ 0x09a238e2,
+ 0x0b578042,
+ 0x0b598062,
+ 0x0b7a7802,
+ 0x0b7a8b6a,
+ 0x0b7c7832,
+ 0x0b7f2002,
+ 0x0b7f801a,
+ 0x0de4e812,
+ 0x0de50031,
+ 0x0e7802d2,
+ 0x0e798162,
+ 0x0e8b2802,
+ 0x0e8b300a,
+ 0x0e8b3822,
+ 0x0e8b680a,
+ 0x0e8b7042,
+ 0x0e8b9871,
+ 0x0e8bd872,
+ 0x0e8c2862,
+ 0x0e8d5032,
+ 0x0e921022,
+ 0x0ed00362,
+ 0x0ed1db12,
+ 0x0ed3a802,
+ 0x0ed42002,
+ 0x0ed4d842,
+ 0x0ed508e2,
+ 0x0f000062,
+ 0x0f004102,
+ 0x0f00d862,
+ 0x0f011812,
+ 0x0f013042,
+ 0x0f047802,
+ 0x0f098062,
+ 0x0f157002,
+ 0x0f176032,
+ 0x0f276032,
+ 0x0f468062,
+ 0x0f4a2062,
+ 0x0f8007f3,
+ 0x0f8407f3,
+ 0x0f886823,
+ 0x0f897803,
+ 0x0f8b6053,
+ 0x0f8bf013,
+ 0x0f8c7003,
+ 0x0f8c8893,
+ 0x0f8d6b83,
+ 0x0f8f3199,
+ 0x0f9008e3,
+ 0x0f90d003,
+ 0x0f917803,
+ 0x0f919083,
+ 0x0f91e033,
+ 0x0f924ff3,
+ 0x0f964ff3,
+ 0x0f9a4ff3,
+ 0x0f9e4b13,
+ 0x0f9fd842,
+ 0x0fa007f3,
+ 0x0fa407f3,
+ 0x0fa803d3,
+ 0x0faa37f3,
+ 0x0fae37f3,
+ 0x0fb23093,
+ 0x0fb407f3,
+ 0x0fbba0b3,
+ 0x0fbeaaa3,
+ 0x0fc06033,
+ 0x0fc24073,
+ 0x0fc2d053,
+ 0x0fc44073,
+ 0x0fc57513,
+ 0x0fc862e3,
+ 0x0fc9e093,
+ 0x0fca3ff3,
+ 0x0fce3ff3,
+ 0x0fd23ff3,
+ 0x0fd63b83,
+ 0x0fe007f3,
+ 0x0fe407f3,
+ 0x0fe807f3,
+ 0x0fec07f3,
+ 0x0ff007f3,
+ 0x0ff407f3,
+ 0x0ff807f3,
+ 0x0ffc07d3,
+ 0x700001f1,
+ 0x700105f2,
+ 0x700407f1,
+ 0x700807f2,
+ 0x700c06f2,
+ 0x700f87f1,
+ 0x701387f1,
+ 0x701787f1,
+ 0x701b87f1,
+ 0x701f87f1,
+ 0x702387f1,
+ 0x702787f1,
+ 0x702b87f1,
+ 0x702f87f1,
+ 0x703387f1,
+ 0x703787f1,
+ 0x703b87f1,
+ 0x703f87f1,
+ 0x704387f1,
+ 0x704787f1,
+ 0x704b87f1,
+ 0x704f87f1,
+ 0x705387f1,
+ 0x705787f1,
+ 0x705b87f1,
+ 0x705f87f1,
+ 0x706387f1,
+ 0x706787f1,
+ 0x706b87f1,
+ 0x706f87f1,
+ 0x707387f1,
+ 0x707787f1,
+ 0x707b87f1,
+ 0x707f80f1};
+
+/// Returns the extended grapheme cluster bondary property of a code point.
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr __property __get_property(const char32_t __code_point) noexcept {
+ // The algorithm searches for the upper bound of the range and, when found,
+ // steps back one entry. This algorithm is used since the code point can be
+ // anywhere in the range. After a lower bound is found the next step is to
+ // compare whether the code unit is indeed in the range.
+ //
+ // Since the entry contains a code unit, size, and property the code point
+ // being sought needs to be adjusted. Just shifting the code point to the
+ // proper position doesn't work; suppose an entry has property 0, size 1,
+ // and lower bound 3. This results in the entry 0x1810.
+ // When searching for code point 3 it will search for 0x1800, find 0x1810
+ // and moves to the previous entry. Thus the lower bound value will never
+ // be found.
+ // The simple solution is to set the bits belonging to the property and
+ // size. Then the upper bound for code point 3 will return the entry after
+ // 0x1810. After moving to the previous entry the algorithm arrives at the
+ // correct entry.
+ ptrdiff_t __i = std::ranges::upper_bound(__entries, (__code_point << 11) | 0x7ffu) - __entries;
+ if (__i == 0)
+ return __property::__none;
+
+ --__i;
+ uint32_t __upper_bound = (__entries[__i] >> 11) + ((__entries[__i] >> 4) & 0x7f);
+ if (__code_point <= __upper_bound)
+ return static_cast<__property>(__entries[__i] & 0xf);
+
+ return __property::__none;
+}
+
+} // namespace __extended_grapheme_custer_property_boundary
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_EXTENDED_GRAPHEME_CLUSTER_TABLE_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_arg.h b/third_party/llvm-project/libcxx/include/__format/format_arg.h
new file mode 100644
index 0000000..771a03f
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_arg.h
@@ -0,0 +1,302 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_ARG_H
+#define _LIBCPP___FORMAT_FORMAT_ARG_H
+
+#include <__assert>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__format/format_error.h>
+#include <__format/format_fwd.h>
+#include <__format/format_parse_context.h>
+#include <__functional/invoke.h>
+#include <__memory/addressof.h>
+#include <__utility/forward.h>
+#include <__utility/unreachable.h>
+#include <__variant/monostate.h>
+#include <string>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+/// The type stored in @ref basic_format_arg.
+///
+/// @note The 128-bit types are unconditionally in the list to avoid the values
+/// of the enums to depend on the availability of 128-bit integers.
+///
+/// @note The value is stored as a 5-bit value in the __packed_arg_t_bits. This
+/// limits the maximum number of elements to 32.
+/// When modifying update the test
+/// test/libcxx/utilities/format/format.arguments/format.arg/arg_t.compile.pass.cpp
+/// It could be packed in 4-bits but that means a new type directly becomes an
+/// ABI break. The packed type is 64-bit so this reduces the maximum number of
+/// packed elements from 16 to 12.
+///
+/// @note Some members of this enum are an extension. These extensions need
+/// special behaviour in visit_format_arg. There they need to be wrapped in a
+/// handle to satisfy the user observable behaviour. The internal function
+/// __visit_format_arg doesn't do this wrapping. So in the format functions
+/// this function is used to avoid unneeded overhead.
+enum class _LIBCPP_ENUM_VIS __arg_t : uint8_t {
+ __none,
+ __boolean,
+ __char_type,
+ __int,
+ __long_long,
+ __i128, // extension
+ __unsigned,
+ __unsigned_long_long,
+ __u128, // extension
+ __float,
+ __double,
+ __long_double,
+ __const_char_type_ptr,
+ __string_view,
+ __ptr,
+ __handle
+};
+
+inline constexpr unsigned __packed_arg_t_bits = 5;
+inline constexpr uint8_t __packed_arg_t_mask = 0x1f;
+
+inline constexpr unsigned __packed_types_storage_bits = 64;
+inline constexpr unsigned __packed_types_max = __packed_types_storage_bits / __packed_arg_t_bits;
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr bool __use_packed_format_arg_store(size_t __size) { return __size <= __packed_types_max; }
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr __arg_t __get_packed_type(uint64_t __types, size_t __id) {
+ _LIBCPP_ASSERT(__id <= __packed_types_max, "");
+
+ if (__id > 0)
+ __types >>= __id * __packed_arg_t_bits;
+
+ return static_cast<__format::__arg_t>(__types & __packed_arg_t_mask);
+}
+
+} // namespace __format
+
+// This function is not user obervable, so it can directly use the non-standard
+// types of the "variant". See __arg_t for more details.
+template <class _Visitor, class _Context>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
+__visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
+ switch (__arg.__type_) {
+ case __format::__arg_t::__none:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__monostate_);
+ case __format::__arg_t::__boolean:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__boolean_);
+ case __format::__arg_t::__char_type:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__char_type_);
+ case __format::__arg_t::__int:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__int_);
+ case __format::__arg_t::__long_long:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_long_);
+ case __format::__arg_t::__i128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__i128_);
+# else
+ __libcpp_unreachable();
+# endif
+ case __format::__arg_t::__unsigned:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_);
+ case __format::__arg_t::__unsigned_long_long:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__unsigned_long_long_);
+ case __format::__arg_t::__u128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__u128_);
+# else
+ __libcpp_unreachable();
+# endif
+ case __format::__arg_t::__float:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__float_);
+ case __format::__arg_t::__double:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__double_);
+ case __format::__arg_t::__long_double:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__long_double_);
+ case __format::__arg_t::__const_char_type_ptr:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__const_char_type_ptr_);
+ case __format::__arg_t::__string_view:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__string_view_);
+ case __format::__arg_t::__ptr:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), __arg.__value_.__ptr_);
+ case __format::__arg_t::__handle:
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis),
+ typename basic_format_arg<_Context>::handle{__arg.__value_.__handle_});
+ }
+
+ __libcpp_unreachable();
+}
+
+/// Contains the values used in basic_format_arg.
+///
+/// This is a separate type so it's possible to store the values and types in
+/// separate arrays.
+template <class _Context>
+class __basic_format_arg_value {
+ using _CharT = typename _Context::char_type;
+
+public:
+ /// Contains the implementation for basic_format_arg::handle.
+ struct __handle {
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI explicit __handle(_Tp&& __v) noexcept
+ : __ptr_(_VSTD::addressof(__v)),
+ __format_([](basic_format_parse_context<_CharT>& __parse_ctx, _Context& __ctx, const void* __ptr) {
+ using _Dp = remove_cvref_t<_Tp>;
+ using _Formatter = typename _Context::template formatter_type<_Dp>;
+ constexpr bool __const_formattable =
+ requires { _Formatter().format(std::declval<const _Dp&>(), std::declval<_Context&>()); };
+ using _Qp = conditional_t<__const_formattable, const _Dp, _Dp>;
+
+ static_assert(__const_formattable || !is_const_v<remove_reference_t<_Tp>>, "Mandated by [format.arg]/18");
+
+ _Formatter __f;
+ __parse_ctx.advance_to(__f.parse(__parse_ctx));
+ __ctx.advance_to(__f.format(*const_cast<_Qp*>(static_cast<const _Dp*>(__ptr)), __ctx));
+ }) {}
+
+ const void* __ptr_;
+ void (*__format_)(basic_format_parse_context<_CharT>&, _Context&, const void*);
+ };
+
+ union {
+ monostate __monostate_;
+ bool __boolean_;
+ _CharT __char_type_;
+ int __int_;
+ unsigned __unsigned_;
+ long long __long_long_;
+ unsigned long long __unsigned_long_long_;
+# ifndef _LIBCPP_HAS_NO_INT128
+ __int128_t __i128_;
+ __uint128_t __u128_;
+# endif
+ float __float_;
+ double __double_;
+ long double __long_double_;
+ const _CharT* __const_char_type_ptr_;
+ basic_string_view<_CharT> __string_view_;
+ const void* __ptr_;
+ __handle __handle_;
+ };
+
+ // These constructors contain the exact storage type used. If adjustments are
+ // required, these will be done in __create_format_arg.
+
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value() noexcept : __monostate_() {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(bool __value) noexcept : __boolean_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(_CharT __value) noexcept : __char_type_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(int __value) noexcept : __int_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned __value) noexcept : __unsigned_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long long __value) noexcept : __long_long_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(unsigned long long __value) noexcept
+ : __unsigned_long_long_(__value) {}
+# ifndef _LIBCPP_HAS_NO_INT128
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__int128_t __value) noexcept : __i128_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__uint128_t __value) noexcept : __u128_(__value) {}
+# endif
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(float __value) noexcept : __float_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(double __value) noexcept : __double_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(long double __value) noexcept : __long_double_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const _CharT* __value) noexcept : __const_char_type_ptr_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(basic_string_view<_CharT> __value) noexcept
+ : __string_view_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(const void* __value) noexcept : __ptr_(__value) {}
+ _LIBCPP_HIDE_FROM_ABI __basic_format_arg_value(__handle __value) noexcept
+ // TODO FMT Investigate why it doesn't work without the forward.
+ : __handle_(std::forward<__handle>(__value)) {}
+};
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg {
+public:
+ class _LIBCPP_TEMPLATE_VIS handle;
+
+ _LIBCPP_HIDE_FROM_ABI basic_format_arg() noexcept
+ : __type_{__format::__arg_t::__none} {}
+
+ _LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept {
+ return __type_ != __format::__arg_t::__none;
+ }
+
+private:
+ using char_type = typename _Context::char_type;
+
+ // TODO FMT Implement constrain [format.arg]/4
+ // Constraints: The template specialization
+ // typename Context::template formatter_type<T>
+ // meets the Formatter requirements ([formatter.requirements]). The extent
+ // to which an implementation determines that the specialization meets the
+ // Formatter requirements is unspecified, except that as a minimum the
+ // expression
+ // typename Context::template formatter_type<T>()
+ // .format(declval<const T&>(), declval<Context&>())
+ // shall be well-formed when treated as an unevaluated operand.
+
+public:
+ __basic_format_arg_value<_Context> __value_;
+ __format::__arg_t __type_;
+
+ _LIBCPP_HIDE_FROM_ABI explicit basic_format_arg(__format::__arg_t __type,
+ __basic_format_arg_value<_Context> __value) noexcept
+ : __value_(__value), __type_(__type) {}
+};
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS basic_format_arg<_Context>::handle {
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ void format(basic_format_parse_context<char_type>& __parse_ctx, _Context& __ctx) const {
+ __handle_.__format_(__parse_ctx, __ctx, __handle_.__ptr_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI explicit handle(typename __basic_format_arg_value<_Context>::__handle& __handle) noexcept
+ : __handle_(__handle) {}
+
+private:
+ typename __basic_format_arg_value<_Context>::__handle& __handle_;
+};
+
+// This function is user facing, so it must wrap the non-standard types of
+// the "variant" in a handle to stay conforming. See __arg_t for more details.
+template <class _Visitor, class _Context>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT decltype(auto)
+visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
+ switch (__arg.__type_) {
+# ifndef _LIBCPP_HAS_NO_INT128
+ case __format::__arg_t::__i128: {
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__i128_};
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
+ }
+
+ case __format::__arg_t::__u128: {
+ typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
+ return _VSTD::invoke(_VSTD::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
+ }
+# endif
+ default:
+ return _VSTD::__visit_format_arg(_VSTD::forward<_Visitor>(__vis), __arg);
+ }
+}
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ARG_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_arg_store.h b/third_party/llvm-project/libcxx/include/__format/format_arg_store.h
new file mode 100644
index 0000000..6f4f4c3
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_arg_store.h
@@ -0,0 +1,254 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
+#define _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_arg.h>
+#include <__utility/forward.h>
+#include <cstring>
+#include <string>
+#include <string_view>
+#include <type_traits>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+/// \returns The @c __arg_t based on the type of the formatting argument.
+///
+/// \pre \c __formattable<_Tp, typename _Context::char_type>
+template <class _Context, class _Tp>
+consteval __arg_t __determine_arg_t();
+
+// Boolean
+template <class, same_as<bool> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__boolean;
+}
+
+// Char
+template <class _Context, same_as<typename _Context::char_type> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__char_type;
+}
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class _Context, class _CharT>
+ requires(same_as<typename _Context::char_type, wchar_t> && same_as<_CharT, char>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__char_type;
+}
+# endif
+
+// Signed integers
+template <class, __libcpp_signed_integer _Tp>
+consteval __arg_t __determine_arg_t() {
+ if constexpr (sizeof(_Tp) <= sizeof(int))
+ return __arg_t::__int;
+ else if constexpr (sizeof(_Tp) <= sizeof(long long))
+ return __arg_t::__long_long;
+# ifndef _LIBCPP_HAS_NO_INT128
+ else if constexpr (sizeof(_Tp) == sizeof(__int128_t))
+ return __arg_t::__i128;
+# endif
+ else
+ static_assert(sizeof(_Tp) == 0, "an unsupported signed integer was used");
+}
+
+// Unsigned integers
+template <class, __libcpp_unsigned_integer _Tp>
+consteval __arg_t __determine_arg_t() {
+ if constexpr (sizeof(_Tp) <= sizeof(unsigned))
+ return __arg_t::__unsigned;
+ else if constexpr (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __arg_t::__unsigned_long_long;
+# ifndef _LIBCPP_HAS_NO_INT128
+ else if constexpr (sizeof(_Tp) == sizeof(__uint128_t))
+ return __arg_t::__u128;
+# endif
+ else
+ static_assert(sizeof(_Tp) == 0, "an unsupported unsigned integer was used");
+}
+
+// Floating-point
+template <class, same_as<float> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__float;
+}
+template <class, same_as<double> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__double;
+}
+template <class, same_as<long double> _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__long_double;
+}
+
+// Char pointer
+template <class _Context, class _Tp>
+ requires(same_as<typename _Context::char_type*, _Tp> || same_as<const typename _Context::char_type*, _Tp>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__const_char_type_ptr;
+}
+
+// Char array
+template <class _Context, class _Tp>
+ requires(is_array_v<_Tp> && same_as<_Tp, typename _Context::char_type[extent_v<_Tp>]>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__string_view;
+}
+
+// String view
+template <class _Context, class _Tp>
+ requires(same_as<typename _Context::char_type, typename _Tp::value_type> &&
+ same_as<_Tp, basic_string_view<typename _Tp::value_type, typename _Tp::traits_type>>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__string_view;
+}
+
+// String
+template <class _Context, class _Tp>
+ requires(
+ same_as<typename _Context::char_type, typename _Tp::value_type> &&
+ same_as<_Tp, basic_string<typename _Tp::value_type, typename _Tp::traits_type, typename _Tp::allocator_type>>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__string_view;
+}
+
+// Pointers
+template <class, class _Ptr>
+ requires(same_as<_Ptr, void*> || same_as<_Ptr, const void*> || same_as<_Ptr, nullptr_t>)
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__ptr;
+}
+
+// Handle
+//
+// Note this version can't be constrained avoiding ambiguous overloads.
+// That means it can be instantiated by disabled formatters. To solve this, a
+// constrained version for not formattable formatters is added. That overload
+// is marked as deleted to fail creating a storage type for disabled formatters.
+template <class _Context, class _Tp>
+consteval __arg_t __determine_arg_t() {
+ return __arg_t::__handle;
+}
+
+template <class _Context, class _Tp>
+ requires(!__formattable<_Tp, typename _Context::char_type>)
+consteval __arg_t __determine_arg_t() = delete;
+
+template <class _Context, class _Tp>
+_LIBCPP_HIDE_FROM_ABI basic_format_arg<_Context> __create_format_arg(_Tp&& __value) noexcept {
+ constexpr __arg_t __arg = __determine_arg_t<_Context, remove_cvref_t<_Tp>>();
+ static_assert(__arg != __arg_t::__none);
+
+ // Not all types can be used to directly initialize the
+ // __basic_format_arg_value. First handle all types needing adjustment, the
+ // final else requires no adjustment.
+ if constexpr (__arg == __arg_t::__char_type)
+ // On some platforms initializing a wchar_t from a char is a narrowing
+ // conversion.
+ return basic_format_arg<_Context>{__arg, static_cast<typename _Context::char_type>(__value)};
+ else if constexpr (__arg == __arg_t::__int)
+ return basic_format_arg<_Context>{__arg, static_cast<int>(__value)};
+ else if constexpr (__arg == __arg_t::__long_long)
+ return basic_format_arg<_Context>{__arg, static_cast<long long>(__value)};
+ else if constexpr (__arg == __arg_t::__unsigned)
+ return basic_format_arg<_Context>{__arg, static_cast<unsigned>(__value)};
+ else if constexpr (__arg == __arg_t::__unsigned_long_long)
+ return basic_format_arg<_Context>{__arg, static_cast<unsigned long long>(__value)};
+ else if constexpr (__arg == __arg_t::__string_view)
+ // Using std::size on a character array will add the NUL-terminator to the size.
+ if constexpr (is_array_v<remove_cvref_t<_Tp>>)
+ return basic_format_arg<_Context>{
+ __arg, basic_string_view<typename _Context::char_type>{__value, extent_v<remove_cvref_t<_Tp>> - 1}};
+ else
+ // When the _Traits or _Allocator are different an implicit conversion will
+ // fail.
+ return basic_format_arg<_Context>{
+ __arg, basic_string_view<typename _Context::char_type>{__value.data(), __value.size()}};
+ else if constexpr (__arg == __arg_t::__ptr)
+ return basic_format_arg<_Context>{__arg, static_cast<const void*>(__value)};
+ else if constexpr (__arg == __arg_t::__handle)
+ return basic_format_arg<_Context>{
+ __arg, typename __basic_format_arg_value<_Context>::__handle{_VSTD::forward<_Tp>(__value)}};
+ else
+ return basic_format_arg<_Context>{__arg, __value};
+}
+
+template <class _Context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI void __create_packed_storage(uint64_t& __types, __basic_format_arg_value<_Context>* __values,
+ _Args&&... __args) noexcept {
+ int __shift = 0;
+ (
+ [&] {
+ basic_format_arg<_Context> __arg = __format::__create_format_arg<_Context>(__args);
+ if (__shift != 0)
+ __types |= static_cast<uint64_t>(__arg.__type_) << __shift;
+ else
+ // Assigns the initial value.
+ __types = static_cast<uint64_t>(__arg.__type_);
+ __shift += __packed_arg_t_bits;
+ *__values++ = __arg.__value_;
+ }(),
+ ...);
+}
+
+template <class _Context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI void __store_basic_format_arg(basic_format_arg<_Context>* __data, _Args&&... __args) noexcept {
+ ([&] { *__data++ = __format::__create_format_arg<_Context>(__args); }(), ...);
+}
+
+template <class _Context, size_t N>
+struct __packed_format_arg_store {
+ __basic_format_arg_value<_Context> __values_[N];
+ uint64_t __types_;
+};
+
+template <class _Context, size_t N>
+struct __unpacked_format_arg_store {
+ basic_format_arg<_Context> __args_[N];
+};
+
+} // namespace __format
+
+template <class _Context, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS __format_arg_store {
+ _LIBCPP_HIDE_FROM_ABI
+ __format_arg_store(_Args&... __args) noexcept {
+ if constexpr (sizeof...(_Args) != 0) {
+ if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args)))
+ __format::__create_packed_storage(__storage.__types_, __storage.__values_, __args...);
+ else
+ __format::__store_basic_format_arg<_Context>(__storage.__args_, __args...);
+ }
+ }
+
+ using _Storage = conditional_t<__format::__use_packed_format_arg_store(sizeof...(_Args)),
+ __format::__packed_format_arg_store<_Context, sizeof...(_Args)>,
+ __format::__unpacked_format_arg_store<_Context, sizeof...(_Args)>>;
+
+ _Storage __storage;
+};
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ARG_STORE_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_args.h b/third_party/llvm-project/libcxx/include/__format/format_args.h
new file mode 100644
index 0000000..8b8fbde
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_args.h
@@ -0,0 +1,80 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_ARGS_H
+#define _LIBCPP___FORMAT_FORMAT_ARGS_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_arg.h>
+#include <__format/format_arg_store.h>
+#include <__format/format_fwd.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_args {
+public:
+ _LIBCPP_HIDE_FROM_ABI basic_format_args() noexcept = default;
+
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI basic_format_args(const __format_arg_store<_Context, _Args...>& __store) noexcept
+ : __size_(sizeof...(_Args)) {
+ if constexpr (sizeof...(_Args) != 0) {
+ if constexpr (__format::__use_packed_format_arg_store(sizeof...(_Args))) {
+ __values_ = __store.__storage.__values_;
+ __types_ = __store.__storage.__types_;
+ } else
+ __args_ = __store.__storage.__args_;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ basic_format_arg<_Context> get(size_t __id) const noexcept {
+ if (__id >= __size_)
+ return basic_format_arg<_Context>{};
+
+ if (__format::__use_packed_format_arg_store(__size_))
+ return basic_format_arg<_Context>{__format::__get_packed_type(__types_, __id), __values_[__id]};
+
+ return __args_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI size_t __size() const noexcept { return __size_; }
+
+private:
+ size_t __size_{0};
+ // [format.args]/5
+ // [Note 1: Implementations are encouraged to optimize the representation of
+ // basic_format_args for small number of formatting arguments by storing
+ // indices of type alternatives separately from values and packing the
+ // former. - end note]
+ union {
+ struct {
+ const __basic_format_arg_value<_Context>* __values_;
+ uint64_t __types_;
+ };
+ const basic_format_arg<_Context>* __args_;
+ };
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_args);
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ARGS_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_context.h b/third_party/llvm-project/libcxx/include/__format/format_context.h
new file mode 100644
index 0000000..882a604
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_context.h
@@ -0,0 +1,147 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_CONTEXT_H
+#define _LIBCPP___FORMAT_FORMAT_CONTEXT_H
+
+#include <__availability>
+#include <__config>
+#include <__format/buffer.h>
+#include <__format/format_args.h>
+#include <__format/format_fwd.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/concepts.h>
+#include <__utility/move.h>
+#include <cstddef>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#include <locale>
+#include <optional>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _OutIt, class _CharT>
+requires output_iterator<_OutIt, const _CharT&>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+/**
+ * Helper to create a basic_format_context.
+ *
+ * This is needed since the constructor is private.
+ */
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT>
+__format_context_create(
+ _OutIt __out_it,
+ basic_format_args<basic_format_context<_OutIt, _CharT>> __args,
+ optional<_VSTD::locale>&& __loc = nullopt) {
+ return _VSTD::basic_format_context(_VSTD::move(__out_it), __args, _VSTD::move(__loc));
+}
+#else
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI basic_format_context<_OutIt, _CharT>
+__format_context_create(
+ _OutIt __out_it,
+ basic_format_args<basic_format_context<_OutIt, _CharT>> __args) {
+ return _VSTD::basic_format_context(_VSTD::move(__out_it), __args);
+}
+#endif
+
+using format_context =
+ basic_format_context<back_insert_iterator<__format::__output_buffer<char>>,
+ char>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_context = basic_format_context<
+ back_insert_iterator<__format::__output_buffer<wchar_t>>, wchar_t>;
+#endif
+
+template <class _OutIt, class _CharT>
+requires output_iterator<_OutIt, const _CharT&>
+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;
+ template <class _Tp>
+ using formatter_type = formatter<_Tp, _CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI basic_format_arg<basic_format_context>
+ arg(size_t __id) const noexcept {
+ return __args_.get(__id);
+ }
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ _LIBCPP_HIDE_FROM_ABI _VSTD::locale locale() {
+ if (!__loc_)
+ __loc_ = _VSTD::locale{};
+ return *__loc_;
+ }
+#endif
+ _LIBCPP_HIDE_FROM_ABI iterator out() { return std::move(__out_it_); }
+ _LIBCPP_HIDE_FROM_ABI void advance_to(iterator __it) { __out_it_ = std::move(__it); }
+
+private:
+ iterator __out_it_;
+ basic_format_args<basic_format_context> __args_;
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+ // The Standard doesn't specify how the locale is stored.
+ // [format.context]/6
+ // std::locale locale();
+ // Returns: The locale passed to the formatting function if the latter
+ // takes one, and std::locale() otherwise.
+ // This is done by storing the locale of the constructor in this optional. If
+ // locale() is called and the optional has no value the value will be created.
+ // This allows the implementation to lazily create the locale.
+ // TODO FMT Validate whether lazy creation is the best solution.
+ optional<_VSTD::locale> __loc_;
+
+ template <class __OutIt, class __CharT>
+ friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT>
+ __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>,
+ optional<_VSTD::locale>&&);
+
+ // Note: the Standard doesn't specify the required constructors.
+ _LIBCPP_HIDE_FROM_ABI
+ explicit basic_format_context(_OutIt __out_it,
+ basic_format_args<basic_format_context> __args,
+ optional<_VSTD::locale>&& __loc)
+ : __out_it_(_VSTD::move(__out_it)), __args_(__args),
+ __loc_(_VSTD::move(__loc)) {}
+#else
+ template <class __OutIt, class __CharT>
+ friend _LIBCPP_HIDE_FROM_ABI basic_format_context<__OutIt, __CharT>
+ __format_context_create(__OutIt, basic_format_args<basic_format_context<__OutIt, __CharT>>);
+
+ _LIBCPP_HIDE_FROM_ABI
+ explicit basic_format_context(_OutIt __out_it,
+ basic_format_args<basic_format_context> __args)
+ : __out_it_(_VSTD::move(__out_it)), __args_(__args) {}
+#endif
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_context);
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_CONTEXT_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_error.h b/third_party/llvm-project/libcxx/include/__format/format_error.h
new file mode 100644
index 0000000..002d1a4
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_error.h
@@ -0,0 +1,55 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_ERROR_H
+#define _LIBCPP___FORMAT_FORMAT_ERROR_H
+
+#include <__config>
+#include <cstdlib>
+#include <stdexcept>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error {
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s)
+ : runtime_error(__s) {}
+ _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
+ : runtime_error(__s) {}
+ // TODO FMT Remove when format is no longer experimental.
+ // Avoids linker errors when building the Clang-cl Windows DLL which doesn't
+ // support the experimental library.
+# ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
+ ~format_error() noexcept override;
+# else
+ ~format_error() noexcept override {}
+# endif
+};
+
+_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
+__throw_format_error(const char* __s) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw format_error(__s);
+#else
+ (void)__s;
+ _VSTD::abort();
+#endif
+}
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_ERROR_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_functions.h b/third_party/llvm-project/libcxx/include/__format/format_functions.h
new file mode 100644
index 0000000..185148c
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_functions.h
@@ -0,0 +1,661 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_FUNCTIONS
+#define _LIBCPP___FORMAT_FORMAT_FUNCTIONS
+
+// TODO FMT This is added to fix Apple back-deployment.
+#include <version>
+#if !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+#include <__algorithm/clamp.h>
+#include <__availability>
+#include <__concepts/convertible_to.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__debug>
+#include <__format/buffer.h>
+#include <__format/format_arg.h>
+#include <__format/format_arg_store.h>
+#include <__format/format_args.h>
+#include <__format/format_context.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/format_string.h>
+#include <__format/format_to_n_result.h>
+#include <__format/formatter.h>
+#include <__format/formatter_bool.h>
+#include <__format/formatter_char.h>
+#include <__format/formatter_floating_point.h>
+#include <__format/formatter_integer.h>
+#include <__format/formatter_pointer.h>
+#include <__format/formatter_string.h>
+#include <__format/parser_std_format_spec.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__iterator/incrementable_traits.h>
+#include <__variant/monostate.h>
+#include <array>
+#include <string>
+#include <string_view>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+#include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+// TODO FMT Evaluate which templates should be external templates. This
+// improves the efficiency of the header. However since the header is still
+// under heavy development and not all classes are stable it makes no sense
+// to do this optimization now.
+
+using format_args = basic_format_args<format_context>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_args = basic_format_args<wformat_context>;
+#endif
+
+template <class _Context = format_context, class... _Args>
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
+ return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
+ return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
+}
+#endif
+
+namespace __format {
+
+/// Helper class parse and handle argument.
+///
+/// When parsing a handle which is not enabled the code is ill-formed.
+/// This helper uses the parser of the appropriate formatter for the stored type.
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __compile_time_handle {
+public:
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr void __parse(basic_format_parse_context<_CharT>& __parse_ctx) const { __parse_(__parse_ctx); }
+
+ template <class _Tp>
+ _LIBCPP_HIDE_FROM_ABI constexpr void __enable() {
+ __parse_ = [](basic_format_parse_context<_CharT>& __parse_ctx) {
+ formatter<_Tp, _CharT> __f;
+ __parse_ctx.advance_to(__f.parse(__parse_ctx));
+ };
+ }
+
+ // Before calling __parse the proper handler needs to be set with __enable.
+ // The default handler isn't a core constant expression.
+ _LIBCPP_HIDE_FROM_ABI constexpr __compile_time_handle()
+ : __parse_([](basic_format_parse_context<_CharT>&) { std::__throw_format_error("Not a handle"); }) {}
+
+private:
+ void (*__parse_)(basic_format_parse_context<_CharT>&);
+};
+
+// Dummy format_context only providing the parts used during constant
+// validation of the basic_format_string.
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __compile_time_basic_format_context {
+public:
+ using char_type = _CharT;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __compile_time_basic_format_context(
+ const __arg_t* __args, const __compile_time_handle<_CharT>* __handles, size_t __size)
+ : __args_(__args), __handles_(__handles), __size_(__size) {}
+
+ // During the compile-time validation nothing needs to be written.
+ // Therefore all operations of this iterator are a NOP.
+ struct iterator {
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator=(_CharT) { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator& operator*() { return *this; }
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator operator++(int) { return *this; }
+ };
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __arg_t arg(size_t __id) const {
+ if (__id >= __size_)
+ std::__throw_format_error("Argument index out of bounds");
+ return __args_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const __compile_time_handle<_CharT>& __handle(size_t __id) const {
+ if (__id >= __size_)
+ std::__throw_format_error("Argument index out of bounds");
+ return __handles_[__id];
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr iterator out() { return {}; }
+ _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(iterator) {}
+
+private:
+ const __arg_t* __args_;
+ const __compile_time_handle<_CharT>* __handles_;
+ size_t __size_;
+};
+
+_LIBCPP_HIDE_FROM_ABI
+constexpr void __compile_time_validate_integral(__arg_t __type) {
+ switch (__type) {
+ case __arg_t::__int:
+ case __arg_t::__long_long:
+ case __arg_t::__i128:
+ case __arg_t::__unsigned:
+ case __arg_t::__unsigned_long_long:
+ case __arg_t::__u128:
+ return;
+
+ default:
+ std::__throw_format_error("Argument isn't an integral type");
+ }
+}
+
+// _HasPrecision does the formatter have a precision?
+template <class _CharT, class _Tp, bool _HasPrecision = false>
+_LIBCPP_HIDE_FROM_ABI constexpr void
+__compile_time_validate_argument(basic_format_parse_context<_CharT>& __parse_ctx,
+ __compile_time_basic_format_context<_CharT>& __ctx) {
+ formatter<_Tp, _CharT> __formatter;
+ __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
+ // [format.string.std]/7
+ // ... If the corresponding formatting argument is not of integral type, or
+ // its value is negative for precision or non-positive for width, an
+ // exception of type format_error is thrown.
+ //
+ // Validate whether the arguments are integrals.
+ if (__formatter.__parser_.__width_as_arg_)
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__width_));
+
+ if constexpr (_HasPrecision)
+ if (__formatter.__parser_.__precision_as_arg_)
+ __format::__compile_time_validate_integral(__ctx.arg(__formatter.__parser_.__precision_));
+}
+
+// This function is not user facing, so it can directly use the non-standard types of the "variant".
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __compile_time_visit_format_arg(basic_format_parse_context<_CharT>& __parse_ctx,
+ __compile_time_basic_format_context<_CharT>& __ctx,
+ __arg_t __type) {
+ switch (__type) {
+ case __arg_t::__none:
+ std::__throw_format_error("Invalid argument");
+ case __arg_t::__boolean:
+ return __format::__compile_time_validate_argument<_CharT, bool>(__parse_ctx, __ctx);
+ case __arg_t::__char_type:
+ return __format::__compile_time_validate_argument<_CharT, _CharT>(__parse_ctx, __ctx);
+ case __arg_t::__int:
+ return __format::__compile_time_validate_argument<_CharT, int>(__parse_ctx, __ctx);
+ case __arg_t::__long_long:
+ return __format::__compile_time_validate_argument<_CharT, long long>(__parse_ctx, __ctx);
+ case __arg_t::__i128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return __format::__compile_time_validate_argument<_CharT, __int128_t>(__parse_ctx, __ctx);
+# else
+ std::__throw_format_error("Invalid argument");
+# endif
+ return;
+ case __arg_t::__unsigned:
+ return __format::__compile_time_validate_argument<_CharT, unsigned>(__parse_ctx, __ctx);
+ case __arg_t::__unsigned_long_long:
+ return __format::__compile_time_validate_argument<_CharT, unsigned long long>(__parse_ctx, __ctx);
+ case __arg_t::__u128:
+# ifndef _LIBCPP_HAS_NO_INT128
+ return __format::__compile_time_validate_argument<_CharT, __uint128_t>(__parse_ctx, __ctx);
+# else
+ std::__throw_format_error("Invalid argument");
+# endif
+ return;
+ case __arg_t::__float:
+ return __format::__compile_time_validate_argument<_CharT, float, true>(__parse_ctx, __ctx);
+ case __arg_t::__double:
+ return __format::__compile_time_validate_argument<_CharT, double, true>(__parse_ctx, __ctx);
+ case __arg_t::__long_double:
+ return __format::__compile_time_validate_argument<_CharT, long double, true>(__parse_ctx, __ctx);
+ case __arg_t::__const_char_type_ptr:
+ return __format::__compile_time_validate_argument<_CharT, const _CharT*, true>(__parse_ctx, __ctx);
+ case __arg_t::__string_view:
+ return __format::__compile_time_validate_argument<_CharT, basic_string_view<_CharT>, true>(__parse_ctx, __ctx);
+ case __arg_t::__ptr:
+ return __format::__compile_time_validate_argument<_CharT, const void*>(__parse_ctx, __ctx);
+ case __arg_t::__handle:
+ std::__throw_format_error("Handle should use __compile_time_validate_handle_argument");
+ }
+ std::__throw_format_error("Invalid argument");
+}
+
+template <class _CharT, class _ParseCtx, class _Ctx>
+_LIBCPP_HIDE_FROM_ABI constexpr const _CharT*
+__handle_replacement_field(const _CharT* __begin, const _CharT* __end,
+ _ParseCtx& __parse_ctx, _Ctx& __ctx) {
+ __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx);
+
+ bool __parse = *__r.__ptr == _CharT(':');
+ switch (*__r.__ptr) {
+ case _CharT(':'):
+ // The arg-id has a format-specifier, advance the input to the format-spec.
+ __parse_ctx.advance_to(__r.__ptr + 1);
+ break;
+ case _CharT('}'):
+ // The arg-id has no format-specifier.
+ __parse_ctx.advance_to(__r.__ptr);
+ break;
+ default:
+ std::__throw_format_error("The replacement field arg-id should terminate at a ':' or '}'");
+ }
+
+ if constexpr (same_as<_Ctx, __compile_time_basic_format_context<_CharT>>) {
+ __arg_t __type = __ctx.arg(__r.__value);
+ if (__type == __arg_t::__handle)
+ __ctx.__handle(__r.__value).__parse(__parse_ctx);
+ else
+ __format::__compile_time_visit_format_arg(__parse_ctx, __ctx, __type);
+ } else
+ _VSTD::__visit_format_arg(
+ [&](auto __arg) {
+ if constexpr (same_as<decltype(__arg), monostate>)
+ std::__throw_format_error("Argument index out of bounds");
+ else if constexpr (same_as<decltype(__arg), typename basic_format_arg<_Ctx>::handle>)
+ __arg.format(__parse_ctx, __ctx);
+ else {
+ formatter<decltype(__arg), _CharT> __formatter;
+ if (__parse)
+ __parse_ctx.advance_to(__formatter.parse(__parse_ctx));
+ __ctx.advance_to(__formatter.format(__arg, __ctx));
+ }
+ },
+ __ctx.arg(__r.__value));
+
+ __begin = __parse_ctx.begin();
+ if (__begin == __end || *__begin != _CharT('}'))
+ std::__throw_format_error("The replacement field misses a terminating '}'");
+
+ return ++__begin;
+}
+
+template <class _ParseCtx, class _Ctx>
+_LIBCPP_HIDE_FROM_ABI constexpr typename _Ctx::iterator
+__vformat_to(_ParseCtx&& __parse_ctx, _Ctx&& __ctx) {
+ using _CharT = typename _ParseCtx::char_type;
+ static_assert(same_as<typename _Ctx::char_type, _CharT>);
+
+ const _CharT* __begin = __parse_ctx.begin();
+ const _CharT* __end = __parse_ctx.end();
+ typename _Ctx::iterator __out_it = __ctx.out();
+ while (__begin != __end) {
+ switch (*__begin) {
+ case _CharT('{'):
+ ++__begin;
+ if (__begin == __end)
+ std::__throw_format_error("The format string terminates at a '{'");
+
+ if (*__begin != _CharT('{')) [[likely]] {
+ __ctx.advance_to(_VSTD::move(__out_it));
+ __begin =
+ __format::__handle_replacement_field(__begin, __end, __parse_ctx, __ctx);
+ __out_it = __ctx.out();
+
+ // The output is written and __begin points to the next character. So
+ // start the next iteration.
+ continue;
+ }
+ // The string is an escape character.
+ break;
+
+ case _CharT('}'):
+ ++__begin;
+ if (__begin == __end || *__begin != _CharT('}'))
+ std::__throw_format_error("The format string contains an invalid escape sequence");
+
+ break;
+ }
+
+ // Copy the character to the output verbatim.
+ *__out_it++ = *__begin++;
+ }
+ return __out_it;
+}
+
+} // namespace __format
+
+template <class _CharT, class... _Args>
+struct _LIBCPP_TEMPLATE_VIS basic_format_string {
+ template <class _Tp>
+ requires convertible_to<const _Tp&, basic_string_view<_CharT>>
+ consteval basic_format_string(const _Tp& __str) : __str_{__str} {
+ __format::__vformat_to(basic_format_parse_context<_CharT>{__str_, sizeof...(_Args)},
+ _Context{__types_.data(), __handles_.data(), sizeof...(_Args)});
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT constexpr basic_string_view<_CharT> get() const noexcept {
+ return __str_;
+ }
+
+private:
+ basic_string_view<_CharT> __str_;
+
+ using _Context = __format::__compile_time_basic_format_context<_CharT>;
+
+ static constexpr array<__format::__arg_t, sizeof...(_Args)> __types_{
+ __format::__determine_arg_t<_Context, remove_cvref_t<_Args>>()...};
+
+ // TODO FMT remove this work-around when the AIX ICE has been resolved.
+# if defined(_AIX) && defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER < 1400
+ template <class _Tp>
+ static constexpr __format::__compile_time_handle<_CharT> __get_handle() {
+ __format::__compile_time_handle<_CharT> __handle;
+ if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
+ __handle.template __enable<_Tp>();
+
+ return __handle;
+ }
+
+ static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{
+ __get_handle<_Args>()...};
+# else
+ static constexpr array<__format::__compile_time_handle<_CharT>, sizeof...(_Args)> __handles_{[] {
+ using _Tp = remove_cvref_t<_Args>;
+ __format::__compile_time_handle<_CharT> __handle;
+ if (__format::__determine_arg_t<_Context, _Tp>() == __format::__arg_t::__handle)
+ __handle.template __enable<_Tp>();
+
+ return __handle;
+ }()...};
+# endif
+};
+
+template <class... _Args>
+using format_string = basic_format_string<char, type_identity_t<_Args>...>;
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+using wformat_string = basic_format_string<wchar_t, type_identity_t<_Args>...>;
+#endif
+
+template <class _OutIt, class _CharT, class _FormatOutIt>
+requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
+ __vformat_to(
+ _OutIt __out_it, basic_string_view<_CharT> __fmt,
+ basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
+ if constexpr (same_as<_OutIt, _FormatOutIt>)
+ return _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(_VSTD::move(__out_it), __args));
+ else {
+ __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
+ return _VSTD::move(__buffer).__out_it();
+ }
+}
+
+// The function is _LIBCPP_ALWAYS_INLINE since the compiler is bad at inlining
+// https://reviews.llvm.org/D110499#inline-1180704
+// TODO FMT Evaluate whether we want to file a Clang bug report regarding this.
+template <output_iterator<const char&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+vformat_to(_OutIt __out_it, string_view __fmt, format_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+vformat_to(_OutIt __out_it, wstring_view __fmt, wformat_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), __fmt, __args);
+}
+#endif
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), __fmt.get(),
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
+vformat(string_view __fmt, format_args __args) {
+ string __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
+ return __res;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+vformat(wstring_view __fmt, wformat_args __args) {
+ wstring __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
+ return __res;
+}
+#endif
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(format_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::vformat(__fmt.get(), _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+format(wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _Context, class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
+ basic_string_view<_CharT> __fmt,
+ basic_format_args<_Context> __args) {
+ __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, wformat_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, __fmt.get(), _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt, auto __args) {
+ __format::__formatted_size_buffer<_CharT> __buffer;
+ _VSTD::__format::__vformat_to(basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
+}
+#endif
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+
+template <class _OutIt, class _CharT, class _FormatOutIt>
+requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
+ __vformat_to(
+ _OutIt __out_it, locale __loc, basic_string_view<_CharT> __fmt,
+ basic_format_args<basic_format_context<_FormatOutIt, _CharT>> __args) {
+ if constexpr (same_as<_OutIt, _FormatOutIt>)
+ return _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(_VSTD::move(__out_it), __args, _VSTD::move(__loc)));
+ else {
+ __format::__format_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it)};
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).__out_it();
+ }
+}
+
+template <output_iterator<const char&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
+ _OutIt __out_it, locale __loc, string_view __fmt, format_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+ __args);
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt vformat_to(
+ _OutIt __out_it, locale __loc, wstring_view __fmt, wformat_args __args) {
+ return _VSTD::__vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt,
+ __args);
+}
+#endif
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT _OutIt
+format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat_to(_VSTD::move(__out_it), _VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string
+vformat(locale __loc, string_view __fmt, format_args __args) {
+ string __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
+ __args);
+ return __res;
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
+ wstring __res;
+ _VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
+ __args);
+ return __res;
+}
+#endif
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT string format(locale __loc,
+ format_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT wstring
+format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _Context, class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n,
+ locale __loc, basic_string_view<_CharT> __fmt,
+ basic_format_args<_Context> __args) {
+ __format::__format_to_n_buffer<_OutIt, _CharT> __buffer{_VSTD::move(__out_it), __n};
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <output_iterator<const char&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, format_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<format_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_format_args(__args...));
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <output_iterator<const wchar_t&> _OutIt, class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT format_to_n_result<_OutIt>
+format_to_n(_OutIt __out_it, iter_difference_t<_OutIt> __n, locale __loc, wformat_string<_Args...> __fmt,
+ _Args&&... __args) {
+ return _VSTD::__vformat_to_n<wformat_context>(_VSTD::move(__out_it), __n, _VSTD::move(__loc), __fmt.get(),
+ _VSTD::make_wformat_args(__args...));
+}
+#endif
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_CharT> __fmt, auto __args) {
+ __format::__formatted_size_buffer<_CharT> __buffer;
+ _VSTD::__format::__vformat_to(
+ basic_format_parse_context{__fmt, __args.__size()},
+ _VSTD::__format_context_create(__buffer.__make_output_iterator(), __args, _VSTD::move(__loc)));
+ return _VSTD::move(__buffer).__result();
+}
+
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
+}
+
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <class... _Args>
+_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI _LIBCPP_AVAILABILITY_FORMAT size_t
+formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
+ return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
+}
+#endif
+
+#endif // _LIBCPP_HAS_NO_LOCALIZATION
+
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // !defined(_LIBCPP_HAS_NO_INCOMPLETE_FORMAT)
+
+#endif // _LIBCPP___FORMAT_FORMAT_FUNCTIONS
diff --git a/third_party/llvm-project/libcxx/include/__format/format_fwd.h b/third_party/llvm-project/libcxx/include/__format/format_fwd.h
new file mode 100644
index 0000000..f7c72e2
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_fwd.h
@@ -0,0 +1,39 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_FWD_H
+#define _LIBCPP___FORMAT_FORMAT_FWD_H
+
+#include <__availability>
+#include <__config>
+#include <__iterator/concepts.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _Context>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_arg;
+
+template <class _OutIt, class _CharT>
+ requires output_iterator<_OutIt, const _CharT&>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_context;
+
+template <class _Tp, class _CharT = char>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter;
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_FWD_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_parse_context.h b/third_party/llvm-project/libcxx/include/__format/format_parse_context.h
new file mode 100644
index 0000000..30e3a7d
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_parse_context.h
@@ -0,0 +1,100 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
+#define _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
+
+#include <__config>
+#include <__format/format_error.h>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context {
+public:
+ using char_type = _CharT;
+ using const_iterator = typename basic_string_view<_CharT>::const_iterator;
+ using iterator = const_iterator;
+
+ _LIBCPP_HIDE_FROM_ABI
+ constexpr explicit basic_format_parse_context(basic_string_view<_CharT> __fmt,
+ size_t __num_args = 0) noexcept
+ : __begin_(__fmt.begin()),
+ __end_(__fmt.end()),
+ __indexing_(__unknown),
+ __next_arg_id_(0),
+ __num_args_(__num_args) {}
+
+ basic_format_parse_context(const basic_format_parse_context&) = delete;
+ basic_format_parse_context&
+ operator=(const basic_format_parse_context&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept {
+ return __begin_;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept {
+ return __end_;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(const_iterator __it) {
+ __begin_ = __it;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() {
+ if (__indexing_ == __manual)
+ std::__throw_format_error("Using automatic argument numbering in manual argument numbering mode");
+
+ if (__indexing_ == __unknown)
+ __indexing_ = __automatic;
+ return __next_arg_id_++;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void check_arg_id(size_t __id) {
+ if (__indexing_ == __automatic)
+ std::__throw_format_error("Using manual argument numbering in automatic argument numbering mode");
+
+ if (__indexing_ == __unknown)
+ __indexing_ = __manual;
+
+ // Throws an exception to make the expression a non core constant
+ // expression as required by:
+ // [format.parse.ctx]/11
+ // Remarks: Call expressions where id >= num_args_ are not core constant
+ // expressions ([expr.const]).
+ // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the
+ // behavior when id >= num_args_.
+ if (is_constant_evaluated() && __id >= __num_args_)
+ std::__throw_format_error("Argument index outside the valid range");
+ }
+
+private:
+ iterator __begin_;
+ iterator __end_;
+ enum _Indexing { __unknown, __manual, __automatic };
+ _Indexing __indexing_;
+ size_t __next_arg_id_;
+ size_t __num_args_;
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(basic_format_parse_context);
+
+using format_parse_context = basic_format_parse_context<char>;
+#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+using wformat_parse_context = basic_format_parse_context<wchar_t>;
+#endif
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_string.h b/third_party/llvm-project/libcxx/include/__format/format_string.h
new file mode 100644
index 0000000..d9caf86
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_string.h
@@ -0,0 +1,163 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_STRING_H
+#define _LIBCPP___FORMAT_FORMAT_STRING_H
+
+#include <__assert>
+#include <__config>
+#include <__format/format_error.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format {
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __parse_number_result {
+ const _CharT* __ptr;
+ uint32_t __value;
+};
+
+template <class _CharT>
+__parse_number_result(const _CharT*, uint32_t) -> __parse_number_result<_CharT>;
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_number(const _CharT* __begin, const _CharT* __end);
+
+/**
+ * The maximum value of a numeric argument.
+ *
+ * This is used for:
+ * * arg-id
+ * * width as value or arg-id.
+ * * precision as value or arg-id.
+ *
+ * The value is compatible with the maximum formatting width and precision
+ * using the `%*` syntax on a 32-bit system.
+ */
+inline constexpr uint32_t __number_max = INT32_MAX;
+
+namespace __detail {
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_zero(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
+ __parse_ctx.check_arg_id(0);
+ return {++__begin, 0}; // can never be larger than the maximum.
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_automatic(const _CharT* __begin, const _CharT*, auto& __parse_ctx) {
+ size_t __value = __parse_ctx.next_arg_id();
+ _LIBCPP_ASSERT(__value <= __number_max,
+ "Compilers don't support this number of arguments");
+
+ return {__begin, uint32_t(__value)};
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_manual(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ __parse_number_result<_CharT> __r = __format::__parse_number(__begin, __end);
+ __parse_ctx.check_arg_id(__r.__value);
+ return __r;
+}
+
+} // namespace __detail
+
+/**
+ * Parses a number.
+ *
+ * The number is used for the 31-bit values @em width and @em precision. This
+ * allows a maximum value of 2147483647.
+ */
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_number(const _CharT* __begin, const _CharT* __end_input) {
+ static_assert(__format::__number_max == INT32_MAX,
+ "The algorithm is implemented based on this value.");
+ /*
+ * Limit the input to 9 digits, otherwise we need two checks during every
+ * iteration:
+ * - Are we at the end of the input?
+ * - Does the value exceed width of an uint32_t? (Switching to uint64_t would
+ * have the same issue, but with a higher maximum.)
+ */
+ const _CharT* __end = __end_input - __begin > 9 ? __begin + 9 : __end_input;
+ uint32_t __value = *__begin - _CharT('0');
+ while (++__begin != __end) {
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ return {__begin, __value};
+
+ __value = __value * 10 + *__begin - _CharT('0');
+ }
+
+ if (__begin != __end_input && *__begin >= _CharT('0') &&
+ *__begin <= _CharT('9')) {
+
+ /*
+ * There are more than 9 digits, do additional validations:
+ * - Does the 10th digit exceed the maximum allowed value?
+ * - Are there more than 10 digits?
+ * (More than 10 digits always overflows the maximum.)
+ */
+ uint64_t __v = uint64_t(__value) * 10 + *__begin++ - _CharT('0');
+ if (__v > __number_max ||
+ (__begin != __end_input && *__begin >= _CharT('0') &&
+ *__begin <= _CharT('9')))
+ std::__throw_format_error("The numeric value of the format-spec is too large");
+
+ __value = __v;
+ }
+
+ return {__begin, __value};
+}
+
+/**
+ * Multiplexer for all parse functions.
+ *
+ * The parser will return a pointer beyond the last consumed character. This
+ * should be the closing '}' of the arg-id.
+ */
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __parse_number_result<_CharT>
+__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ switch (*__begin) {
+ case _CharT('0'):
+ return __detail::__parse_zero(__begin, __end, __parse_ctx);
+
+ case _CharT(':'):
+ // This case is conditionally valid. It's allowed in an arg-id in the
+ // replacement-field, but not in the std-format-spec. The caller can
+ // provide a better diagnostic, so accept it here unconditionally.
+ case _CharT('}'):
+ return __detail::__parse_automatic(__begin, __end, __parse_ctx);
+ }
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ std::__throw_format_error("The arg-id of the format-spec starts with an invalid character");
+
+ return __detail::__parse_manual(__begin, __end, __parse_ctx);
+}
+
+} // namespace __format
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_STRING_H
diff --git a/third_party/llvm-project/libcxx/include/__format/format_to_n_result.h b/third_party/llvm-project/libcxx/include/__format/format_to_n_result.h
new file mode 100644
index 0000000..f1ed9a0
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/format_to_n_result.h
@@ -0,0 +1,35 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H
+#define _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H
+
+#include <__config>
+#include <__iterator/incrementable_traits.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <class _OutIt>
+struct _LIBCPP_TEMPLATE_VIS format_to_n_result {
+ _OutIt out;
+ iter_difference_t<_OutIt> size;
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(format_to_n_result);
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMAT_TO_N_RESULT_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter.h b/third_party/llvm-project/libcxx/include/__format/formatter.h
new file mode 100644
index 0000000..900a09a
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter.h
@@ -0,0 +1,54 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_H
+#define _LIBCPP___FORMAT_FORMATTER_H
+
+#include <__availability>
+#include <__config>
+#include <__format/format_fwd.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+/// The default formatter template.
+///
+/// [format.formatter.spec]/5
+/// If F is a disabled specialization of formatter, these values are false:
+/// - is_default_constructible_v<F>,
+/// - is_copy_constructible_v<F>,
+/// - is_move_constructible_v<F>,
+/// - is_copy_assignable<F>, and
+/// - is_move_assignable<F>.
+template <class _Tp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter {
+ formatter() = delete;
+ formatter(const formatter&) = delete;
+ formatter& operator=(const formatter&) = delete;
+};
+
+# if _LIBCPP_STD_VER > 20
+
+template <class _Tp>
+_LIBCPP_HIDE_FROM_ABI constexpr void __set_debug_format(_Tp& __formatter) {
+ if constexpr (requires { __formatter.set_debug_format(); })
+ __formatter.set_debug_format();
+}
+
+# endif // _LIBCPP_STD_VER > 20
+#endif // _LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_bool.h b/third_party/llvm-project/libcxx/include/__format/formatter_bool.h
new file mode 100644
index 0000000..0d005a1
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_bool.h
@@ -0,0 +1,78 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_BOOL_H
+#define _LIBCPP___FORMAT_FORMATTER_BOOL_H
+
+#include <__algorithm/copy.h>
+#include <__availability>
+#include <__config>
+#include <__debug>
+#include <__format/concepts.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/parser_std_format_spec.h>
+#include <__utility/unreachable.h>
+#include <string_view>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<bool, _CharT> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
+ __format_spec::__process_parsed_bool(__parser_);
+ return __result;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto format(bool __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ switch (__parser_.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__string:
+ return __formatter::__format_bool(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
+
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ // Promotes bool to an integral type. This reduces the number of
+ // instantiations of __format_integer reducing code size.
+ return __formatter::__format_integer(
+ static_cast<unsigned>(__value), __ctx, __parser_.__get_parsed_std_specifications(__ctx));
+
+ default:
+ _LIBCPP_ASSERT(false, "The parse function should have validated the type");
+ __libcpp_unreachable();
+ }
+ }
+
+ __format_spec::__parser<_CharT> __parser_;
+};
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_BOOL_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_char.h b/third_party/llvm-project/libcxx/include/__format/formatter_char.h
new file mode 100644
index 0000000..8a92e74
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_char.h
@@ -0,0 +1,93 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_CHAR_H
+#define _LIBCPP___FORMAT_FORMATTER_CHAR_H
+
+#include <__availability>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__type_traits/conditional.h>
+#include <__type_traits/is_signed.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_char {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
+ __format_spec::__process_parsed_char(__parser_);
+ return __result;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ if (__parser_.__type_ == __format_spec::__type::__default || __parser_.__type_ == __format_spec::__type::__char)
+ return __formatter::__format_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+
+# if _LIBCPP_STD_VER > 20
+ if (__parser_.__type_ == __format_spec::__type::__debug)
+ return __formatter::__format_escaped_char(__value, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+# endif
+
+ if constexpr (sizeof(_CharT) <= sizeof(int))
+ // Promotes _CharT to an integral type. This reduces the number of
+ // instantiations of __format_integer reducing code size.
+ return __formatter::__format_integer(
+ static_cast<conditional_t<is_signed_v<_CharT>, int, unsigned>>(__value),
+ __ctx,
+ __parser_.__get_parsed_std_specifications(__ctx));
+ else
+ return __formatter::__format_integer(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto format(char __value, auto& __ctx) const -> decltype(__ctx.out())
+ requires(same_as<_CharT, wchar_t>)
+ {
+ return format(static_cast<wchar_t>(__value), __ctx);
+ }
+
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_debug_format() { __parser_.__type_ = __format_spec::__type::__debug; }
+# endif
+
+ __format_spec::__parser<_CharT> __parser_;
+};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, char> : public __formatter_char<char> {};
+
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<char, wchar_t> : public __formatter_char<wchar_t> {};
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<wchar_t, wchar_t> : public __formatter_char<wchar_t> {
+};
+
+# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_CHAR_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_floating_point.h b/third_party/llvm-project/libcxx/include/__format/formatter_floating_point.h
new file mode 100644
index 0000000..a544b53
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_floating_point.h
@@ -0,0 +1,757 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
+#define _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
+
+#include <__algorithm/copy_n.h>
+#include <__algorithm/find.h>
+#include <__algorithm/max.h>
+#include <__algorithm/min.h>
+#include <__algorithm/rotate.h>
+#include <__algorithm/transform.h>
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__memory/allocator.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
+#include <charconv>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __formatter {
+
+template <floating_point _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value) {
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+template <floating_point _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt) {
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+template <floating_point _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, chars_format __fmt, int __precision) {
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __fmt, __precision);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+// https://en.cppreference.com/w/cpp/language/types#cite_note-1
+// float min subnormal: +/-0x1p-149 max: +/- 3.402,823,4 10^38
+// double min subnormal: +/-0x1p-1074 max +/- 1.797,693,134,862,315,7 10^308
+// long double (x86) min subnormal: +/-0x1p-16446 max: +/- 1.189,731,495,357,231,765,021 10^4932
+//
+// The maximum number of digits required for the integral part is based on the
+// maximum's value power of 10. Every power of 10 requires one additional
+// decimal digit.
+// The maximum number of digits required for the fractional part is based on
+// the minimal subnormal hexadecimal output's power of 10. Every division of a
+// fraction's binary 1 by 2, requires one additional decimal digit.
+//
+// The maximum size of a formatted value depends on the selected output format.
+// Ignoring the fact the format string can request a precision larger than the
+// values maximum required, these values are:
+//
+// sign 1 code unit
+// __max_integral
+// radix point 1 code unit
+// __max_fractional
+// exponent character 1 code unit
+// sign 1 code unit
+// __max_fractional_value
+// -----------------------------------
+// total 4 code units extra required.
+//
+// TODO FMT Optimize the storage to avoid storing digits that are known to be zero.
+// https://www.exploringbinary.com/maximum-number-of-decimal-digits-in-binary-floating-point-numbers/
+
+// TODO FMT Add long double specialization when to_chars has proper long double support.
+template <class _Tp>
+struct __traits;
+
+template <floating_point _Fp>
+_LIBCPP_HIDE_FROM_ABI constexpr size_t __float_buffer_size(int __precision) {
+ using _Traits = __traits<_Fp>;
+ return 4 + _Traits::__max_integral + __precision + _Traits::__max_fractional_value;
+}
+
+template <>
+struct __traits<float> {
+ static constexpr int __max_integral = 38;
+ static constexpr int __max_fractional = 149;
+ static constexpr int __max_fractional_value = 3;
+ static constexpr size_t __stack_buffer_size = 256;
+
+ static constexpr int __hex_precision_digits = 3;
+};
+
+template <>
+struct __traits<double> {
+ static constexpr int __max_integral = 308;
+ static constexpr int __max_fractional = 1074;
+ static constexpr int __max_fractional_value = 4;
+ static constexpr size_t __stack_buffer_size = 1024;
+
+ static constexpr int __hex_precision_digits = 4;
+};
+
+/// Helper class to store the conversion buffer.
+///
+/// Depending on the maxium size required for a value, the buffer is allocated
+/// on the stack or the heap.
+template <floating_point _Fp>
+class _LIBCPP_TEMPLATE_VIS __float_buffer {
+ using _Traits = __traits<_Fp>;
+
+public:
+ // TODO FMT Improve this constructor to do a better estimate.
+ // When using a scientific formatting with a precision of 6 a stack buffer
+ // will always suffice. At the moment that isn't important since floats and
+ // doubles use a stack buffer, unless the precision used in the format string
+ // is large.
+ // When supporting long doubles the __max_integral part becomes 4932 which
+ // may be too much for some platforms. For these cases a better estimate is
+ // required.
+ explicit _LIBCPP_HIDE_FROM_ABI __float_buffer(int __precision)
+ : __precision_(__precision != -1 ? __precision : _Traits::__max_fractional) {
+
+ // When the precision is larger than _Traits::__max_fractional the digits in
+ // the range (_Traits::__max_fractional, precision] will contain the value
+ // zero. There's no need to request to_chars to write these zeros:
+ // - When the value is large a temporary heap buffer needs to be allocated.
+ // - When to_chars writes the values they need to be "copied" to the output:
+ // - char: std::fill on the output iterator is faster than std::copy.
+ // - wchar_t: same argument as char, but additional std::copy won't work.
+ // The input is always a char buffer, so every char in the buffer needs
+ // to be converted from a char to a wchar_t.
+ if (__precision_ > _Traits::__max_fractional) {
+ __num_trailing_zeros_ = __precision_ - _Traits::__max_fractional;
+ __precision_ = _Traits::__max_fractional;
+ }
+
+ __size_ = __formatter::__float_buffer_size<_Fp>(__precision_);
+ if (__size_ > _Traits::__stack_buffer_size)
+ // The allocated buffer's contents don't need initialization.
+ __begin_ = allocator<char>{}.allocate(__size_);
+ else
+ __begin_ = __buffer_;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI ~__float_buffer() {
+ if (__size_ > _Traits::__stack_buffer_size)
+ allocator<char>{}.deallocate(__begin_, __size_);
+ }
+ _LIBCPP_HIDE_FROM_ABI __float_buffer(const __float_buffer&) = delete;
+ _LIBCPP_HIDE_FROM_ABI __float_buffer& operator=(const __float_buffer&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI char* begin() const { return __begin_; }
+ _LIBCPP_HIDE_FROM_ABI char* end() const { return __begin_ + __size_; }
+
+ _LIBCPP_HIDE_FROM_ABI int __precision() const { return __precision_; }
+ _LIBCPP_HIDE_FROM_ABI int __num_trailing_zeros() const { return __num_trailing_zeros_; }
+ _LIBCPP_HIDE_FROM_ABI void __remove_trailing_zeros() { __num_trailing_zeros_ = 0; }
+ _LIBCPP_HIDE_FROM_ABI void __add_trailing_zeros(int __zeros) { __num_trailing_zeros_ += __zeros; }
+
+private:
+ int __precision_;
+ int __num_trailing_zeros_{0};
+ size_t __size_;
+ char* __begin_;
+ char __buffer_[_Traits::__stack_buffer_size];
+};
+
+struct __float_result {
+ /// Points at the beginning of the integral part in the buffer.
+ ///
+ /// When there's no sign character this points at the start of the buffer.
+ char* __integral;
+
+ /// Points at the radix point, when not present it's the same as \ref __last.
+ char* __radix_point;
+
+ /// Points at the exponent character, when not present it's the same as \ref __last.
+ char* __exponent;
+
+ /// Points beyond the last written element in the buffer.
+ char* __last;
+};
+
+/// Finds the position of the exponent character 'e' at the end of the buffer.
+///
+/// Assuming there is an exponent the input will terminate with
+/// eSdd and eSdddd (S = sign, d = digit)
+///
+/// \returns a pointer to the exponent or __last when not found.
+constexpr inline _LIBCPP_HIDE_FROM_ABI char* __find_exponent(char* __first, char* __last) {
+ ptrdiff_t __size = __last - __first;
+ if (__size >= 4) {
+ __first = __last - _VSTD::min(__size, ptrdiff_t(6));
+ for (; __first != __last - 3; ++__first) {
+ if (*__first == 'e')
+ return __first;
+ }
+ }
+ return __last;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_default(const __float_buffer<_Fp>& __buffer, _Tp __value,
+ char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value);
+
+ __result.__exponent = __formatter::__find_exponent(__result.__integral, __result.__last);
+
+ // Constrains:
+ // - There's at least one decimal digit before the radix point.
+ // - The radix point, when present, is placed before the exponent.
+ __result.__radix_point = _VSTD::find(__result.__integral + 1, __result.__exponent, '.');
+
+ // When the radix point isn't found its position is the exponent instead of
+ // __result.__last.
+ if (__result.__radix_point == __result.__exponent)
+ __result.__radix_point = __result.__last;
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent == __result.__last || *__result.__exponent == 'e'),
+ "Post-condition failure.");
+ // clang-format on
+
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_lower_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ if (__precision == -1)
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex);
+ else
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::hex, __precision);
+
+ // H = one or more hex-digits
+ // S = sign
+ // D = one or more decimal-digits
+ // When the fractional part is zero and no precision the output is 0p+0
+ // else the output is 0.HpSD
+ // So testing the second position can differentiate between these two cases.
+ char* __first = __integral + 1;
+ if (*__first == '.') {
+ __result.__radix_point = __first;
+ // One digit is the minimum
+ // 0.hpSd
+ // ^-- last
+ // ^---- integral = end of search
+ // ^-------- start of search
+ // 0123456
+ //
+ // Four digits is the maximum
+ // 0.hpSdddd
+ // ^-- last
+ // ^---- integral = end of search
+ // ^-------- start of search
+ // 0123456789
+ static_assert(__traits<_Fp>::__hex_precision_digits <= 4, "Guard against possible underflow.");
+
+ char* __last = __result.__last - 2;
+ __first = __last - __traits<_Fp>::__hex_precision_digits;
+ __result.__exponent = _VSTD::find(__first, __last, 'p');
+ } else {
+ __result.__radix_point = __result.__last;
+ __result.__exponent = __first;
+ }
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent != __result.__last && *__result.__exponent == 'p'),
+ "Post-condition failure.");
+ // clang-format on
+
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_hexadecimal_upper_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result =
+ __formatter::__format_buffer_hexadecimal_lower_case(__buffer, __value, __precision, __integral);
+ _VSTD::transform(__result.__integral, __result.__exponent, __result.__integral, __hex_to_upper);
+ *__result.__exponent = 'P';
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_lower_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last =
+ __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::scientific, __precision);
+
+ char* __first = __integral + 1;
+ _LIBCPP_ASSERT(__first != __result.__last, "No exponent present");
+ if (*__first == '.') {
+ __result.__radix_point = __first;
+ __result.__exponent = __formatter::__find_exponent(__first + 1, __result.__last);
+ } else {
+ __result.__radix_point = __result.__last;
+ __result.__exponent = __first;
+ }
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent != __result.__last && *__result.__exponent == 'e'),
+ "Post-condition failure.");
+ // clang-format on
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_scientific_upper_case(const __float_buffer<_Fp>& __buffer,
+ _Tp __value, int __precision,
+ char* __integral) {
+ __float_result __result =
+ __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __precision, __integral);
+ *__result.__exponent = 'E';
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_fixed(const __float_buffer<_Fp>& __buffer, _Tp __value,
+ int __precision, char* __integral) {
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::fixed, __precision);
+
+ // When there's no precision there's no radix point.
+ // Else the radix point is placed at __precision + 1 from the end.
+ // By converting __precision to a bool the subtraction can be done
+ // unconditionally.
+ __result.__radix_point = __result.__last - (__precision + bool(__precision));
+ __result.__exponent = __result.__last;
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent == __result.__last),
+ "Post-condition failure.");
+ // clang-format on
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_lower_case(__float_buffer<_Fp>& __buffer, _Tp __value,
+ int __precision, char* __integral) {
+
+ __buffer.__remove_trailing_zeros();
+
+ __float_result __result;
+ __result.__integral = __integral;
+ __result.__last = __formatter::__to_buffer(__integral, __buffer.end(), __value, chars_format::general, __precision);
+
+ char* __first = __integral + 1;
+ if (__first == __result.__last) {
+ __result.__radix_point = __result.__last;
+ __result.__exponent = __result.__last;
+ } else {
+ __result.__exponent = __formatter::__find_exponent(__first, __result.__last);
+ if (__result.__exponent != __result.__last)
+ // In scientific mode if there's a radix point it will always be after
+ // the first digit. (This is the position __first points at).
+ __result.__radix_point = *__first == '.' ? __first : __result.__last;
+ else {
+ // In fixed mode the algorithm truncates trailing spaces and possibly the
+ // radix point. There's no good guess for the position of the radix point
+ // therefore scan the output after the first digit.
+
+ __result.__radix_point = _VSTD::find(__first, __result.__last, '.');
+ }
+ }
+
+ // clang-format off
+ _LIBCPP_ASSERT((__result.__integral != __result.__last) &&
+ (__result.__radix_point == __result.__last || *__result.__radix_point == '.') &&
+ (__result.__exponent == __result.__last || *__result.__exponent == 'e'),
+ "Post-condition failure.");
+ // clang-format on
+
+ return __result;
+}
+
+template <class _Fp, class _Tp>
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer_general_upper_case(__float_buffer<_Fp>& __buffer, _Tp __value,
+ int __precision, char* __integral) {
+ __float_result __result = __formatter::__format_buffer_general_lower_case(__buffer, __value, __precision, __integral);
+ if (__result.__exponent != __result.__last)
+ *__result.__exponent = 'E';
+ return __result;
+}
+
+/// Fills the buffer with the data based on the requested formatting.
+///
+/// This function, when needed, turns the characters to upper case and
+/// determines the "interesting" locations which are returned to the caller.
+///
+/// This means the caller never has to convert the contents of the buffer to
+/// upper case or search for radix points and the location of the exponent.
+/// This gives a bit of overhead. The original code didn't do that, but due
+/// to the number of possible additional work needed to turn this number to
+/// the proper output the code was littered with tests for upper cases and
+/// searches for radix points and exponents.
+/// - When a precision larger than the type's precision is selected
+/// additional zero characters need to be written before the exponent.
+/// - alternate form needs to add a radix point when not present.
+/// - localization needs to do grouping in the integral part.
+template <class _Fp, class _Tp>
+// TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
+_LIBCPP_HIDE_FROM_ABI __float_result __format_buffer(
+ __float_buffer<_Fp>& __buffer,
+ _Tp __value,
+ bool __negative,
+ bool __has_precision,
+ __format_spec::__sign __sign,
+ __format_spec::__type __type) {
+ char* __first = __formatter::__insert_sign(__buffer.begin(), __negative, __sign);
+ switch (__type) {
+ case __format_spec::__type::__default:
+ if (__has_precision)
+ return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
+ else
+ return __formatter::__format_buffer_default(__buffer, __value, __first);
+
+ case __format_spec::__type::__hexfloat_lower_case:
+ return __formatter::__format_buffer_hexadecimal_lower_case(
+ __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
+
+ case __format_spec::__type::__hexfloat_upper_case:
+ return __formatter::__format_buffer_hexadecimal_upper_case(
+ __buffer, __value, __has_precision ? __buffer.__precision() : -1, __first);
+
+ case __format_spec::__type::__scientific_lower_case:
+ return __formatter::__format_buffer_scientific_lower_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__scientific_upper_case:
+ return __formatter::__format_buffer_scientific_upper_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__fixed_lower_case:
+ case __format_spec::__type::__fixed_upper_case:
+ return __formatter::__format_buffer_fixed(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__general_lower_case:
+ return __formatter::__format_buffer_general_lower_case(__buffer, __value, __buffer.__precision(), __first);
+
+ case __format_spec::__type::__general_upper_case:
+ return __formatter::__format_buffer_general_upper_case(__buffer, __value, __buffer.__precision(), __first);
+
+ default:
+ _LIBCPP_ASSERT(false, "The parser should have validated the type");
+ __libcpp_unreachable();
+ }
+}
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+template <class _OutIt, class _Fp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __format_locale_specific_form(
+ _OutIt __out_it,
+ const __float_buffer<_Fp>& __buffer,
+ const __float_result& __result,
+ _VSTD::locale __loc,
+ __format_spec::__parsed_specifications<_CharT> __specs) {
+ const auto& __np = std::use_facet<numpunct<_CharT>>(__loc);
+ string __grouping = __np.grouping();
+ char* __first = __result.__integral;
+ // When no radix point or exponent are present __last will be __result.__last.
+ char* __last = _VSTD::min(__result.__radix_point, __result.__exponent);
+
+ ptrdiff_t __digits = __last - __first;
+ if (!__grouping.empty()) {
+ if (__digits <= __grouping[0])
+ __grouping.clear();
+ else
+ __grouping = __formatter::__determine_grouping(__digits, __grouping);
+ }
+
+ ptrdiff_t __size =
+ __result.__last - __buffer.begin() + // Formatted string
+ __buffer.__num_trailing_zeros() + // Not yet rendered zeros
+ __grouping.size() - // Grouping contains one
+ !__grouping.empty(); // additional character
+
+ __formatter::__padding_size_result __padding = {0, 0};
+ bool __zero_padding = __specs.__alignment_ == __format_spec::__alignment::__zero_padding;
+ if (__size < __specs.__width_) {
+ if (__zero_padding) {
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+ __specs.__fill_ = _CharT('0');
+ }
+
+ __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
+ }
+
+ // sign and (zero padding or alignment)
+ if (__zero_padding && __first != __buffer.begin())
+ *__out_it++ = *__buffer.begin();
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ if (!__zero_padding && __first != __buffer.begin())
+ *__out_it++ = *__buffer.begin();
+
+ // integral part
+ if (__grouping.empty()) {
+ __out_it = __formatter::__copy(__first, __digits, _VSTD::move(__out_it));
+ } else {
+ auto __r = __grouping.rbegin();
+ auto __e = __grouping.rend() - 1;
+ _CharT __sep = __np.thousands_sep();
+ // The output is divided in small groups of numbers to write:
+ // - A group before the first separator.
+ // - A separator and a group, repeated for the number of separators.
+ // - A group after the last separator.
+ // This loop achieves that process by testing the termination condition
+ // midway in the loop.
+ while (true) {
+ __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
+ __first += *__r;
+
+ if (__r == __e)
+ break;
+
+ ++__r;
+ *__out_it++ = __sep;
+ }
+ }
+
+ // fractional part
+ if (__result.__radix_point != __result.__last) {
+ *__out_it++ = __np.decimal_point();
+ __out_it = __formatter::__copy(__result.__radix_point + 1, __result.__exponent, _VSTD::move(__out_it));
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __buffer.__num_trailing_zeros(), _CharT('0'));
+ }
+
+ // exponent
+ if (__result.__exponent != __result.__last)
+ __out_it = __formatter::__copy(__result.__exponent, __result.__last, _VSTD::move(__out_it));
+
+ // alignment
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+# endif // _LIBCPP_HAS_NO_LOCALIZATION
+
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __format_floating_point_non_finite(
+ _OutIt __out_it, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative, bool __isnan) {
+ char __buffer[4];
+ char* __last = __formatter::__insert_sign(__buffer, __negative, __specs.__std_.__sign_);
+
+ // to_chars can return inf, infinity, nan, and nan(n-char-sequence).
+ // The format library requires inf and nan.
+ // All in one expression to avoid dangling references.
+ bool __upper_case =
+ __specs.__std_.__type_ == __format_spec::__type::__hexfloat_upper_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__scientific_upper_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__fixed_upper_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__general_upper_case;
+ __last = _VSTD::copy_n(&("infnanINFNAN"[6 * __upper_case + 3 * __isnan]), 3, __last);
+
+ // [format.string.std]/13
+ // A zero (0) character preceding the width field pads the field with
+ // leading zeros (following any indication of sign or base) to the field
+ // width, except when applied to an infinity or NaN.
+ if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding)
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+
+ return __formatter::__write(__buffer, __last, _VSTD::move(__out_it), __specs);
+}
+
+template <floating_point _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_floating_point(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
+ -> decltype(__ctx.out()) {
+ bool __negative = _VSTD::signbit(__value);
+
+ if (!_VSTD::isfinite(__value)) [[unlikely]]
+ return __formatter::__format_floating_point_non_finite(__ctx.out(), __specs, __negative, _VSTD::isnan(__value));
+
+ // Depending on the std-format-spec string the sign and the value
+ // might not be outputted together:
+ // - zero-padding may insert additional '0' characters.
+ // Therefore the value is processed as a non negative value.
+ // The function @ref __insert_sign will insert a '-' when the value was
+ // negative.
+
+ if (__negative)
+ __value = -__value;
+
+ // TODO FMT _Fp should just be _Tp when to_chars has proper long double support.
+ using _Fp = conditional_t<same_as<_Tp, long double>, double, _Tp>;
+ // Force the type of the precision to avoid -1 to become an unsigned value.
+ __float_buffer<_Fp> __buffer(__specs.__precision_);
+ __float_result __result = __formatter::__format_buffer(
+ __buffer, __value, __negative, (__specs.__has_precision()), __specs.__std_.__sign_, __specs.__std_.__type_);
+
+ if (__specs.__std_.__alternate_form_) {
+ if (__result.__radix_point == __result.__last) {
+ *__result.__last++ = '.';
+
+ // When there is an exponent the point needs to be moved before the
+ // exponent. When there's no exponent the rotate does nothing. Since
+ // rotate tests whether the operation is a nop, call it unconditionally.
+ _VSTD::rotate(__result.__exponent, __result.__last - 1, __result.__last);
+ __result.__radix_point = __result.__exponent;
+
+ // The radix point is always placed before the exponent.
+ // - No exponent needs to point to the new last.
+ // - An exponent needs to move one position to the right.
+ // So it's safe to increment the value unconditionally.
+ ++__result.__exponent;
+ }
+
+ // [format.string.std]/6
+ // In addition, for g and G conversions, trailing zeros are not removed
+ // from the result.
+ //
+ // If the type option for a floating-point type is none it may use the
+ // general formatting, but it's not a g or G conversion. So in that case
+ // the formatting should not append trailing zeros.
+ bool __is_general = __specs.__std_.__type_ == __format_spec::__type::__general_lower_case ||
+ __specs.__std_.__type_ == __format_spec::__type::__general_upper_case;
+
+ if (__is_general) {
+ // https://en.cppreference.com/w/c/io/fprintf
+ // Let P equal the precision if nonzero, 6 if the precision is not
+ // specified, or 1 if the precision is 0. Then, if a conversion with
+ // style E would have an exponent of X:
+ int __p = _VSTD::max(1, (__specs.__has_precision() ? __specs.__precision_ : 6));
+ if (__result.__exponent == __result.__last)
+ // if P > X >= -4, the conversion is with style f or F and precision P - 1 - X.
+ // By including the radix point it calculates P - (1 + X)
+ __p -= __result.__radix_point - __buffer.begin();
+ else
+ // otherwise, the conversion is with style e or E and precision P - 1.
+ --__p;
+
+ ptrdiff_t __precision = (__result.__exponent - __result.__radix_point) - 1;
+ if (__precision < __p)
+ __buffer.__add_trailing_zeros(__p - __precision);
+ }
+ }
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (__specs.__std_.__locale_specific_form_)
+ return __formatter::__format_locale_specific_form(__ctx.out(), __buffer, __result, __ctx.locale(), __specs);
+# endif
+
+ ptrdiff_t __size = __result.__last - __buffer.begin();
+ int __num_trailing_zeros = __buffer.__num_trailing_zeros();
+ if (__size + __num_trailing_zeros >= __specs.__width_) {
+ if (__num_trailing_zeros && __result.__exponent != __result.__last)
+ // Insert trailing zeros before exponent character.
+ return __formatter::__copy(
+ __result.__exponent,
+ __result.__last,
+ __formatter::__fill(__formatter::__copy(__buffer.begin(), __result.__exponent, __ctx.out()),
+ __num_trailing_zeros,
+ _CharT('0')));
+
+ return __formatter::__fill(
+ __formatter::__copy(__buffer.begin(), __result.__last, __ctx.out()), __num_trailing_zeros, _CharT('0'));
+ }
+
+ auto __out_it = __ctx.out();
+ char* __first = __buffer.begin();
+ if (__specs.__alignment_ == __format_spec::__alignment ::__zero_padding) {
+ // When there is a sign output it before the padding. Note the __size
+ // doesn't need any adjustment, regardless whether the sign is written
+ // here or in __formatter::__write.
+ if (__first != __result.__integral)
+ *__out_it++ = *__first++;
+ // After the sign is written, zero padding is the same a right alignment
+ // with '0'.
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+ __specs.__fill_ = _CharT('0');
+ }
+
+ if (__num_trailing_zeros)
+ return __formatter::__write_using_trailing_zeros(
+ __first, __result.__last, _VSTD::move(__out_it), __specs, __size, __result.__exponent, __num_trailing_zeros);
+
+ return __formatter::__write(__first, __result.__last, _VSTD::move(__out_it), __specs, __size);
+}
+
+} // namespace __formatter
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS __formatter_floating_point {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_floating_point);
+ __format_spec::__process_parsed_floating_point(__parser_);
+ return __result;
+ }
+
+ template <floating_point _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ return __formatter::__format_floating_point(__value, __ctx, __parser_.__get_parsed_std_specifications(__ctx));
+ }
+
+ __format_spec::__parser<_CharT> __parser_;
+};
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<float, _CharT>
+ : public __formatter_floating_point<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<double, _CharT>
+ : public __formatter_floating_point<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long double, _CharT>
+ : public __formatter_floating_point<_CharT> {};
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMATTER_FLOATING_POINT_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_integer.h b/third_party/llvm-project/libcxx/include/__format/formatter_integer.h
new file mode 100644
index 0000000..b4be9f9
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_integer.h
@@ -0,0 +1,107 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGER_H
+#define _LIBCPP___FORMAT_FORMATTER_INTEGER_H
+
+#include <__availability>
+#include <__concepts/arithmetic.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__type_traits/make_32_64_or_128_bit.h>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+ _LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+ template <__fmt_char_type _CharT>
+ struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_integer {
+
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_integral);
+ __format_spec::__process_parsed_integer(__parser_);
+ return __result;
+ }
+
+ template <integral _Tp>
+ _LIBCPP_HIDE_FROM_ABI auto format(_Tp __value, auto& __ctx) const -> decltype(__ctx.out()) {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+
+ if (__specs.__std_.__type_ == __format_spec::__type::__char)
+ return __formatter::__format_char(__value, __ctx.out(), __specs);
+
+ using _Type = __make_32_64_or_128_bit_t<_Tp>;
+ static_assert(!is_same<_Type, void>::value, "unsupported integral type used in __formatter_integer::__format");
+
+ // Reduce the number of instantiation of the integer formatter
+ return __formatter::__format_integer(static_cast<_Type>(__value), __ctx, __specs);
+ }
+
+ __format_spec::__parser<_CharT> __parser_;
+};
+
+// Signed integral types.
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<signed char, _CharT>
+ : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<short, _CharT> : public __formatter_integer<_CharT> {
+};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<int, _CharT> : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long, _CharT> : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<long long, _CharT>
+ : public __formatter_integer<_CharT> {};
+# ifndef _LIBCPP_HAS_NO_INT128
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__int128_t, _CharT>
+ : public __formatter_integer<_CharT> {};
+# endif
+
+// Unsigned integral types.
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned char, _CharT>
+ : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned short, _CharT>
+ : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned, _CharT>
+ : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long, _CharT>
+ : public __formatter_integer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<unsigned long long, _CharT>
+ : public __formatter_integer<_CharT> {};
+# ifndef _LIBCPP_HAS_NO_INT128
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<__uint128_t, _CharT>
+ : public __formatter_integer<_CharT> {};
+# endif
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_INTEGER_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_integral.h b/third_party/llvm-project/libcxx/include/__format/formatter_integral.h
new file mode 100644
index 0000000..fe3a063
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_integral.h
@@ -0,0 +1,363 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
+#define _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
+
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_error.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__utility/unreachable.h>
+#include <array>
+#include <charconv>
+#include <limits>
+#include <string>
+
+#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# include <locale>
+#endif
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __formatter {
+
+//
+// Generic
+//
+
+_LIBCPP_HIDE_FROM_ABI inline char* __insert_sign(char* __buf, bool __negative, __format_spec::__sign __sign) {
+ if (__negative)
+ *__buf++ = '-';
+ else
+ switch (__sign) {
+ case __format_spec::__sign::__default:
+ case __format_spec::__sign::__minus:
+ // No sign added.
+ break;
+ case __format_spec::__sign::__plus:
+ *__buf++ = '+';
+ break;
+ case __format_spec::__sign::__space:
+ *__buf++ = ' ';
+ break;
+ }
+
+ return __buf;
+}
+
+/**
+ * Determines the required grouping based on the size of the input.
+ *
+ * The grouping's last element will be repeated. For simplicity this repeating
+ * is unwrapped based on the length of the input. (When the input is short some
+ * groups are not processed.)
+ *
+ * @returns The size of the groups to write. This means the number of
+ * separator characters written is size() - 1.
+ *
+ * @note Since zero-sized groups cause issues they are silently ignored.
+ *
+ * @note The grouping field of the locale is always a @c std::string,
+ * regardless whether the @c std::numpunct's type is @c char or @c wchar_t.
+ */
+_LIBCPP_HIDE_FROM_ABI inline string __determine_grouping(ptrdiff_t __size, const string& __grouping) {
+ _LIBCPP_ASSERT(!__grouping.empty() && __size > __grouping[0],
+ "The slow grouping formatting is used while there will be no "
+ "separators written");
+ string __r;
+ auto __end = __grouping.end() - 1;
+ auto __ptr = __grouping.begin();
+
+ while (true) {
+ __size -= *__ptr;
+ if (__size > 0)
+ __r.push_back(*__ptr);
+ else {
+ // __size <= 0 so the value pushed will be <= *__ptr.
+ __r.push_back(*__ptr + __size);
+ return __r;
+ }
+
+ // Proceed to the next group.
+ if (__ptr != __end) {
+ do {
+ ++__ptr;
+ // Skip grouping with a width of 0.
+ } while (*__ptr == 0 && __ptr != __end);
+ }
+ }
+
+ __libcpp_unreachable();
+}
+
+//
+// Char
+//
+
+template <__fmt_char_type _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __format_char(
+ integral auto __value,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ using _Tp = decltype(__value);
+ if constexpr (!same_as<_CharT, _Tp>) {
+ // cmp_less and cmp_greater can't be used for character types.
+ if constexpr (signed_integral<_CharT> == signed_integral<_Tp>) {
+ if (__value < numeric_limits<_CharT>::min() || __value > numeric_limits<_CharT>::max())
+ std::__throw_format_error("Integral value outside the range of the char type");
+ } else if constexpr (signed_integral<_CharT>) {
+ // _CharT is signed _Tp is unsigned
+ if (__value > static_cast<make_unsigned_t<_CharT>>(numeric_limits<_CharT>::max()))
+ std::__throw_format_error("Integral value outside the range of the char type");
+ } else {
+ // _CharT is unsigned _Tp is signed
+ if (__value < 0 || static_cast<make_unsigned_t<_Tp>>(__value) > numeric_limits<_CharT>::max())
+ std::__throw_format_error("Integral value outside the range of the char type");
+ }
+ }
+
+ const auto __c = static_cast<_CharT>(__value);
+ return __formatter::__write(_VSTD::addressof(__c), _VSTD::addressof(__c) + 1, _VSTD::move(__out_it), __specs);
+}
+
+//
+// Integer
+//
+
+/** Wrapper around @ref to_chars, returning the output pointer. */
+template <integral _Tp>
+_LIBCPP_HIDE_FROM_ABI char* __to_buffer(char* __first, char* __last, _Tp __value, int __base) {
+ // TODO FMT Evaluate code overhead due to not calling the internal function
+ // directly. (Should be zero overhead.)
+ to_chars_result __r = _VSTD::to_chars(__first, __last, __value, __base);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ return __r.ptr;
+}
+
+/**
+ * Helper to determine the buffer size to output a integer in Base @em x.
+ *
+ * There are several overloads for the supported bases. The function uses the
+ * base as template argument so it can be used in a constant expression.
+ */
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 2)
+{
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ + 2 // Reserve space for the '0[Bb]' prefix.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 8)
+{
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ / 3 // Adjust to octal.
+ + 1 // Turn floor to ceil.
+ + 1 // Reserve space for the '0' prefix.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 10)
+{
+ return numeric_limits<_Tp>::digits10 // The floored value.
+ + 1 // Turn floor to ceil.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, size_t _Base>
+consteval size_t __buffer_size() noexcept
+ requires(_Base == 16)
+{
+ return numeric_limits<_Tp>::digits // The number of binary digits.
+ / 4 // Adjust to hexadecimal.
+ + 2 // Reserve space for the '0[Xx]' prefix.
+ + 1; // Reserve space for the sign.
+}
+
+template <unsigned_integral _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __format_integer(
+ _Tp __value,
+ auto& __ctx,
+ __format_spec::__parsed_specifications<_CharT> __specs,
+ bool __negative,
+ char* __begin,
+ char* __end,
+ const char* __prefix,
+ int __base) -> decltype(__ctx.out()) {
+ char* __first = __formatter::__insert_sign(__begin, __negative, __specs.__std_.__sign_);
+ if (__specs.__std_.__alternate_form_ && __prefix)
+ while (*__prefix)
+ *__first++ = *__prefix++;
+
+ char* __last = __formatter::__to_buffer(__first, __end, __value, __base);
+
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (__specs.__std_.__locale_specific_form_) {
+ const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
+ string __grouping = __np.grouping();
+ ptrdiff_t __size = __last - __first;
+ // Writing the grouped form has more overhead than the normal output
+ // routines. If there will be no separators written the locale-specific
+ // form is identical to the normal routine. Test whether to grouped form
+ // is required.
+ if (!__grouping.empty() && __size > __grouping[0])
+ return __formatter::__write_using_decimal_separators(
+ __ctx.out(),
+ __begin,
+ __first,
+ __last,
+ __formatter::__determine_grouping(__size, __grouping),
+ __np.thousands_sep(),
+ __specs);
+ }
+# endif
+ auto __out_it = __ctx.out();
+ if (__specs.__alignment_ != __format_spec::__alignment::__zero_padding)
+ __first = __begin;
+ else {
+ // __buf contains [sign][prefix]data
+ // ^ location of __first
+ // The zero padding is done like:
+ // - Write [sign][prefix]
+ // - Write data right aligned with '0' as fill character.
+ __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
+ __specs.__alignment_ = __format_spec::__alignment::__right;
+ __specs.__fill_ = _CharT('0');
+ int32_t __size = __first - __begin;
+
+ __specs.__width_ -= _VSTD::min(__size, __specs.__width_);
+ }
+
+ if (__specs.__std_.__type_ != __format_spec::__type::__hexadecimal_upper_case) [[likely]]
+ return __formatter::__write(__first, __last, __ctx.out(), __specs);
+
+ return __formatter::__write_transformed(__first, __last, __ctx.out(), __specs, __formatter::__hex_to_upper);
+}
+
+template <unsigned_integral _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __format_integer(
+ _Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs, bool __negative = false)
+ -> decltype(__ctx.out()) {
+ switch (__specs.__std_.__type_) {
+ case __format_spec::__type::__binary_lower_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0b", 2);
+ }
+ case __format_spec::__type::__binary_upper_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 2>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0B", 2);
+ }
+ case __format_spec::__type::__octal: {
+ // Octal is special; if __value == 0 there's no prefix.
+ array<char, __formatter::__buffer_size<decltype(__value), 8>()> __array;
+ return __formatter::__format_integer(
+ __value, __ctx, __specs, __negative, __array.begin(), __array.end(), __value != 0 ? "0" : nullptr, 8);
+ }
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__decimal: {
+ array<char, __formatter::__buffer_size<decltype(__value), 10>()> __array;
+ return __formatter::__format_integer(
+ __value, __ctx, __specs, __negative, __array.begin(), __array.end(), nullptr, 10);
+ }
+ case __format_spec::__type::__hexadecimal_lower_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0x", 16);
+ }
+ case __format_spec::__type::__hexadecimal_upper_case: {
+ array<char, __formatter::__buffer_size<decltype(__value), 16>()> __array;
+ return __formatter::__format_integer(__value, __ctx, __specs, __negative, __array.begin(), __array.end(), "0X", 16);
+ }
+ default:
+ _LIBCPP_ASSERT(false, "The parse function should have validated the type");
+ __libcpp_unreachable();
+ }
+}
+
+template <signed_integral _Tp, class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_integer(_Tp __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
+ -> decltype(__ctx.out()) {
+ // Depending on the std-format-spec string the sign and the value
+ // might not be outputted together:
+ // - alternate form may insert a prefix string.
+ // - zero-padding may insert additional '0' characters.
+ // Therefore the value is processed as a positive unsigned value.
+ // The function @ref __insert_sign will a '-' when the value was negative.
+ auto __r = std::__to_unsigned_like(__value);
+ bool __negative = __value < 0;
+ if (__negative)
+ __r = std::__complement(__r);
+
+ return __formatter::__format_integer(__r, __ctx, __specs, __negative);
+}
+
+//
+// Formatter arithmetic (bool)
+//
+
+template <class _CharT>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings;
+
+template <>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings<char> {
+ static constexpr string_view __true{"true"};
+ static constexpr string_view __false{"false"};
+};
+
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+template <>
+struct _LIBCPP_TEMPLATE_VIS __bool_strings<wchar_t> {
+ static constexpr wstring_view __true{L"true"};
+ static constexpr wstring_view __false{L"false"};
+};
+# endif
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_bool(bool __value, auto& __ctx, __format_spec::__parsed_specifications<_CharT> __specs)
+ -> decltype(__ctx.out()) {
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
+ if (__specs.__std_.__locale_specific_form_) {
+ const auto& __np = std::use_facet<numpunct<_CharT>>(__ctx.locale());
+ basic_string<_CharT> __str = __value ? __np.truename() : __np.falsename();
+ return __formatter::__write_string_no_precision(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
+ }
+# endif
+ basic_string_view<_CharT> __str =
+ __value ? __formatter::__bool_strings<_CharT>::__true : __formatter::__bool_strings<_CharT>::__false;
+ return __formatter::__write(__str.begin(), __str.end(), __ctx.out(), __specs);
+}
+
+} // namespace __formatter
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_FORMATTER_INTEGRAL_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_output.h b/third_party/llvm-project/libcxx/include/__format/formatter_output.h
new file mode 100644
index 0000000..70eae15
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_output.h
@@ -0,0 +1,559 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
+#define _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
+
+#include <__algorithm/ranges_copy.h>
+#include <__algorithm/ranges_fill_n.h>
+#include <__algorithm/ranges_transform.h>
+#include <__chrono/statically_widen.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/buffer.h>
+#include <__format/concepts.h>
+#include <__format/escaped_output_table.h>
+#include <__format/formatter.h>
+#include <__format/parser_std_format_spec.h>
+#include <__format/unicode.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__type_traits/make_unsigned.h>
+#include <__utility/move.h>
+#include <__utility/unreachable.h>
+#include <charconv>
+#include <cstddef>
+#include <string>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __formatter {
+
+_LIBCPP_HIDE_FROM_ABI constexpr char __hex_to_upper(char __c) {
+ switch (__c) {
+ case 'a':
+ return 'A';
+ case 'b':
+ return 'B';
+ case 'c':
+ return 'C';
+ case 'd':
+ return 'D';
+ case 'e':
+ return 'E';
+ case 'f':
+ return 'F';
+ }
+ return __c;
+}
+
+struct _LIBCPP_TYPE_VIS __padding_size_result {
+ size_t __before_;
+ size_t __after_;
+};
+
+_LIBCPP_HIDE_FROM_ABI constexpr __padding_size_result
+__padding_size(size_t __size, size_t __width, __format_spec::__alignment __align) {
+ _LIBCPP_ASSERT(__width > __size, "don't call this function when no padding is required");
+ _LIBCPP_ASSERT(
+ __align != __format_spec::__alignment::__zero_padding, "the caller should have handled the zero-padding");
+
+ size_t __fill = __width - __size;
+ switch (__align) {
+ case __format_spec::__alignment::__zero_padding:
+ __libcpp_unreachable();
+
+ case __format_spec::__alignment::__left:
+ return {0, __fill};
+
+ case __format_spec::__alignment::__center: {
+ // The extra padding is divided per [format.string.std]/3
+ // __before = floor(__fill, 2);
+ // __after = ceil(__fill, 2);
+ size_t __before = __fill / 2;
+ size_t __after = __fill - __before;
+ return {__before, __after};
+ }
+ case __format_spec::__alignment::__default:
+ case __format_spec::__alignment::__right:
+ return {__fill, 0};
+ }
+ __libcpp_unreachable();
+}
+
+/// Copy wrapper.
+///
+/// This uses a "mass output function" of __format::__output_buffer when possible.
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __copy(basic_string_view<_CharT> __str, output_iterator<const _OutCharT&> auto __out_it)
+ -> decltype(__out_it) {
+ if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
+ __out_it.__get_container()->__copy(__str);
+ return __out_it;
+ } else {
+ return std::ranges::copy(__str, _VSTD::move(__out_it)).out;
+ }
+}
+
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__copy(const _CharT* __first, const _CharT* __last, output_iterator<const _OutCharT&> auto __out_it)
+ -> decltype(__out_it) {
+ return __formatter::__copy(basic_string_view{__first, __last}, _VSTD::move(__out_it));
+}
+
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __copy(const _CharT* __first, size_t __n, output_iterator<const _OutCharT&> auto __out_it)
+ -> decltype(__out_it) {
+ return __formatter::__copy(basic_string_view{__first, __n}, _VSTD::move(__out_it));
+}
+
+/// Transform wrapper.
+///
+/// This uses a "mass output function" of __format::__output_buffer when possible.
+template <__fmt_char_type _CharT, __fmt_char_type _OutCharT = _CharT, class _UnaryOperation>
+_LIBCPP_HIDE_FROM_ABI auto
+__transform(const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _OutCharT&> auto __out_it,
+ _UnaryOperation __operation) -> decltype(__out_it) {
+ if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_OutCharT>>>) {
+ __out_it.__get_container()->__transform(__first, __last, _VSTD::move(__operation));
+ return __out_it;
+ } else {
+ return std::ranges::transform(__first, __last, _VSTD::move(__out_it), __operation).out;
+ }
+}
+
+/// Fill wrapper.
+///
+/// This uses a "mass output function" of __format::__output_buffer when possible.
+template <__fmt_char_type _CharT, output_iterator<const _CharT&> _OutIt>
+_LIBCPP_HIDE_FROM_ABI _OutIt __fill(_OutIt __out_it, size_t __n, _CharT __value) {
+ if constexpr (_VSTD::same_as<decltype(__out_it), _VSTD::back_insert_iterator<__format::__output_buffer<_CharT>>>) {
+ __out_it.__get_container()->__fill(__n, __value);
+ return __out_it;
+ } else {
+ return std::ranges::fill_n(_VSTD::move(__out_it), __n, __value);
+ }
+}
+
+template <class _OutIt, class _CharT>
+_LIBCPP_HIDE_FROM_ABI _OutIt __write_using_decimal_separators(_OutIt __out_it, const char* __begin, const char* __first,
+ const char* __last, string&& __grouping, _CharT __sep,
+ __format_spec::__parsed_specifications<_CharT> __specs) {
+ int __size = (__first - __begin) + // [sign][prefix]
+ (__last - __first) + // data
+ (__grouping.size() - 1); // number of separator characters
+
+ __padding_size_result __padding = {0, 0};
+ if (__specs.__alignment_ == __format_spec::__alignment::__zero_padding) {
+ // Write [sign][prefix].
+ __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
+
+ if (__specs.__width_ > __size) {
+ // Write zero padding.
+ __padding.__before_ = __specs.__width_ - __size;
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __specs.__width_ - __size, _CharT('0'));
+ }
+ } else {
+ if (__specs.__width_ > __size) {
+ // Determine padding and write padding.
+ __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
+
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ }
+ // Write [sign][prefix].
+ __out_it = __formatter::__copy(__begin, __first, _VSTD::move(__out_it));
+ }
+
+ auto __r = __grouping.rbegin();
+ auto __e = __grouping.rend() - 1;
+ _LIBCPP_ASSERT(__r != __e, "The slow grouping formatting is used while "
+ "there will be no separators written.");
+ // The output is divided in small groups of numbers to write:
+ // - A group before the first separator.
+ // - A separator and a group, repeated for the number of separators.
+ // - A group after the last separator.
+ // This loop achieves that process by testing the termination condition
+ // midway in the loop.
+ //
+ // TODO FMT This loop evaluates the loop invariant `__parser.__type !=
+ // _Flags::_Type::__hexadecimal_upper_case` for every iteration. (This test
+ // happens in the __write call.) Benchmark whether making two loops and
+ // hoisting the invariant is worth the effort.
+ while (true) {
+ if (__specs.__std_.__type_ == __format_spec::__type::__hexadecimal_upper_case) {
+ __last = __first + *__r;
+ __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __hex_to_upper);
+ __first = __last;
+ } else {
+ __out_it = __formatter::__copy(__first, *__r, _VSTD::move(__out_it));
+ __first += *__r;
+ }
+
+ if (__r == __e)
+ break;
+
+ ++__r;
+ *__out_it++ = __sep;
+ }
+
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// Writes the input to the output with the required padding.
+///
+/// Since the output column width is specified the function can be used for
+/// ASCII and Unicode output.
+///
+/// \pre \a __size <= \a __width. Using this function when this pre-condition
+/// doesn't hold incurs an unwanted overhead.
+///
+/// \param __str The string to write.
+/// \param __out_it The output iterator to write to.
+/// \param __specs The parsed formatting specifications.
+/// \param __size The (estimated) output column width. When the elements
+/// to be written are ASCII the following condition holds
+/// \a __size == \a __last - \a __first.
+///
+/// \returns An iterator pointing beyond the last element written.
+///
+/// \note The type of the elements in range [\a __first, \a __last) can differ
+/// from the type of \a __specs. Integer output uses \c std::to_chars for its
+/// conversion, which means the [\a __first, \a __last) always contains elements
+/// of the type \c char.
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__write(basic_string_view<_CharT> __str,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ ptrdiff_t __size) -> decltype(__out_it) {
+ if (__size >= __specs.__width_)
+ return __formatter::__copy(__str, _VSTD::move(__out_it));
+
+ __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__std_.__alignment_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__copy(__str, _VSTD::move(__out_it));
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__write(const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ ptrdiff_t __size) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ return __formatter::__write(basic_string_view{__first, __last}, _VSTD::move(__out_it), __specs, __size);
+}
+
+/// \overload
+///
+/// Calls the function above where \a __size = \a __last - \a __first.
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__write(const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ return __formatter::__write(__first, __last, _VSTD::move(__out_it), __specs, __last - __first);
+}
+
+template <class _CharT, class _ParserCharT, class _UnaryOperation>
+_LIBCPP_HIDE_FROM_ABI auto __write_transformed(const _CharT* __first, const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ _UnaryOperation __op) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+
+ ptrdiff_t __size = __last - __first;
+ if (__size >= __specs.__width_)
+ return __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
+
+ __padding_size_result __padding = __formatter::__padding_size(__size, __specs.__width_, __specs.__alignment_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__transform(__first, __last, _VSTD::move(__out_it), __op);
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// Writes additional zero's for the precision before the exponent.
+/// This is used when the precision requested in the format string is larger
+/// than the maximum precision of the floating-point type. These precision
+/// digits are always 0.
+///
+/// \param __exponent The location of the exponent character.
+/// \param __num_trailing_zeros The number of 0's to write before the exponent
+/// character.
+template <class _CharT, class _ParserCharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_using_trailing_zeros(
+ const _CharT* __first,
+ const _CharT* __last,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_ParserCharT> __specs,
+ size_t __size,
+ const _CharT* __exponent,
+ size_t __num_trailing_zeros) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(__first <= __last, "Not a valid range");
+ _LIBCPP_ASSERT(__num_trailing_zeros > 0, "The overload not writing trailing zeros should have been used");
+
+ __padding_size_result __padding =
+ __formatter::__padding_size(__size + __num_trailing_zeros, __specs.__width_, __specs.__alignment_);
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __padding.__before_, __specs.__fill_);
+ __out_it = __formatter::__copy(__first, __exponent, _VSTD::move(__out_it));
+ __out_it = __formatter::__fill(_VSTD::move(__out_it), __num_trailing_zeros, _CharT('0'));
+ __out_it = __formatter::__copy(__exponent, __last, _VSTD::move(__out_it));
+ return __formatter::__fill(_VSTD::move(__out_it), __padding.__after_, __specs.__fill_);
+}
+
+/// Writes a string using format's width estimation algorithm.
+///
+/// \pre !__specs.__has_precision()
+///
+/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the
+/// input is ASCII.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_string_no_precision(
+ basic_string_view<_CharT> __str,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ _LIBCPP_ASSERT(!__specs.__has_precision(), "use __write_string");
+
+ // No padding -> copy the string
+ if (!__specs.__has_width())
+ return __formatter::__copy(__str, _VSTD::move(__out_it));
+
+ // Note when the estimated width is larger than size there's no padding. So
+ // there's no reason to get the real size when the estimate is larger than or
+ // equal to the minimum field width.
+ size_t __size =
+ __format_spec::__estimate_column_width(__str, __specs.__width_, __format_spec::__column_width_rounding::__up)
+ .__width_;
+ return __formatter::__write(__str, _VSTD::move(__out_it), __specs, __size);
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI int __truncate(basic_string_view<_CharT>& __str, int __precision) {
+ __format_spec::__column_width_result<_CharT> __result =
+ __format_spec::__estimate_column_width(__str, __precision, __format_spec::__column_width_rounding::__down);
+ __str = basic_string_view<_CharT>{__str.begin(), __result.__last_};
+ return __result.__width_;
+}
+
+/// Writes a string using format's width estimation algorithm.
+///
+/// \note When \c _LIBCPP_HAS_NO_UNICODE is defined the function assumes the
+/// input is ASCII.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto __write_string(
+ basic_string_view<_CharT> __str,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ if (!__specs.__has_precision())
+ return __formatter::__write_string_no_precision(__str, _VSTD::move(__out_it), __specs);
+
+ int __size = __formatter::__truncate(__str, __specs.__precision_);
+
+ return __formatter::__write(__str.begin(), __str.end(), _VSTD::move(__out_it), __specs, __size);
+}
+
+# if _LIBCPP_STD_VER > 20
+
+struct __nul_terminator {};
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI bool operator==(const _CharT* __cstr, __nul_terminator) {
+ return *__cstr == _CharT('\0');
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void
+__write_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value, const _CharT* __prefix) {
+ back_insert_iterator __out_it{__str};
+ std::ranges::copy(__prefix, __nul_terminator{}, __out_it);
+
+ char __buffer[8];
+ to_chars_result __r = std::to_chars(std::begin(__buffer), std::end(__buffer), __value, 16);
+ _LIBCPP_ASSERT(__r.ec == errc(0), "Internal buffer too small");
+ std::ranges::copy(std::begin(__buffer), __r.ptr, __out_it);
+
+ __str += _CharT('}');
+}
+
+// [format.string.escaped]/2.2.1.2
+// ...
+// then the sequence \u{hex-digit-sequence} is appended to E, where
+// hex-digit-sequence is the shortest hexadecimal representation of C using
+// lower-case hexadecimal digits.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void __write_well_formed_escaped_code_unit(basic_string<_CharT>& __str, char32_t __value) {
+ __formatter::__write_escaped_code_unit(__str, __value, _LIBCPP_STATICALLY_WIDEN(_CharT, "\\u{"));
+}
+
+// [format.string.escaped]/2.2.3
+// Otherwise (X is a sequence of ill-formed code units), each code unit U is
+// appended to E in order as the sequence \x{hex-digit-sequence}, where
+// hex-digit-sequence is the shortest hexadecimal representation of U using
+// lower-case hexadecimal digits.
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void __write_escape_ill_formed_code_unit(basic_string<_CharT>& __str, char32_t __value) {
+ __formatter::__write_escaped_code_unit(__str, __value, _LIBCPP_STATICALLY_WIDEN(_CharT, "\\x{"));
+}
+
+template <class _CharT>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool __is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value) {
+# ifdef _LIBCPP_HAS_NO_UNICODE
+ // For ASCII assume everything above 127 is printable.
+ if (__value > 127)
+ return false;
+# endif
+
+ if (!__escaped_output_table::__needs_escape(__value))
+ return false;
+
+ __formatter::__write_well_formed_escaped_code_unit(__str, __value);
+ return true;
+}
+
+template <class _CharT>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr char32_t __to_char32(_CharT __value) {
+ return static_cast<make_unsigned_t<_CharT>>(__value);
+}
+
+enum class _LIBCPP_ENUM_VIS __escape_quotation_mark { __apostrophe, __double_quote };
+
+// [format.string.escaped]/2
+template <class _CharT>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI bool
+__is_escaped_sequence_written(basic_string<_CharT>& __str, char32_t __value, __escape_quotation_mark __mark) {
+ // 2.2.1.1 - Mapped character in [tab:format.escape.sequences]
+ switch (__value) {
+ case _CharT('\t'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\t");
+ return true;
+ case _CharT('\n'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\n");
+ return true;
+ case _CharT('\r'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, "\\r");
+ return true;
+ case _CharT('\''):
+ if (__mark == __escape_quotation_mark::__apostrophe)
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\')");
+ else
+ __str += __value;
+ return true;
+ case _CharT('"'):
+ if (__mark == __escape_quotation_mark::__double_quote)
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\")");
+ else
+ __str += __value;
+ return true;
+ case _CharT('\\'):
+ __str += _LIBCPP_STATICALLY_WIDEN(_CharT, R"(\\)");
+ return true;
+
+ // 2.2.1.2 - Space
+ case _CharT(' '):
+ __str += __value;
+ return true;
+ }
+
+ // 2.2.2
+ // Otherwise, if X is a shift sequence, the effect on E and further
+ // decoding of S is unspecified.
+ // For now shift sequences are ignored and treated as Unicode. Other parts
+ // of the format library do the same. It's unknown how ostream treats them.
+ // TODO FMT determine what to do with shift sequences.
+
+ // 2.2.1.2.1 and 2.2.1.2.2 - Escape
+ return __formatter::__is_escaped_sequence_written(__str, __formatter::__to_char32(__value));
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI void
+__escape(basic_string<_CharT>& __str, basic_string_view<_CharT> __values, __escape_quotation_mark __mark) {
+ __unicode::__code_point_view<_CharT> __view{__values.begin(), __values.end()};
+
+ while (!__view.__at_end()) {
+ const _CharT* __first = __view.__position();
+ typename __unicode::__consume_p2286_result __result = __view.__consume_p2286();
+ if (__result.__ill_formed_size == 0) {
+ if (!__formatter::__is_escaped_sequence_written(__str, __result.__value, __mark))
+ // 2.2.1.3 - Add the character
+ ranges::copy(__first, __view.__position(), std::back_insert_iterator(__str));
+
+ } else {
+ // 2.2.3 sequence of ill-formed code units
+ // The number of code-units in __result.__value depends on the character type being used.
+ if constexpr (sizeof(_CharT) == 1) {
+ _LIBCPP_ASSERT(__result.__ill_formed_size == 1 || __result.__ill_formed_size == 4,
+ "illegal number of invalid code units.");
+ if (__result.__ill_formed_size == 1) // ill-formed, one code unit
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value & 0xff);
+ else { // out of valid range, four code units
+ // The code point was properly encoded, decode the value.
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value >> 18 | 0xf0);
+ __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value >> 12 & 0x3f) | 0x80);
+ __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value >> 6 & 0x3f) | 0x80);
+ __formatter::__write_escape_ill_formed_code_unit(__str, (__result.__value & 0x3f) | 0x80);
+ }
+ } else if constexpr (sizeof(_CharT) == 2) {
+ _LIBCPP_ASSERT(__result.__ill_formed_size == 1, "for UTF-16 at most one invalid code unit");
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value & 0xffff);
+ } else {
+ static_assert(sizeof(_CharT) == 4, "unsupported character width");
+ _LIBCPP_ASSERT(__result.__ill_formed_size == 1, "for UTF-32 one code unit is one code point");
+ __formatter::__write_escape_ill_formed_code_unit(__str, __result.__value);
+ }
+ }
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_escaped_char(_CharT __value,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ basic_string<_CharT> __str;
+ __str += _CharT('\'');
+ __formatter::__escape(__str, basic_string_view{std::addressof(__value), 1}, __escape_quotation_mark::__apostrophe);
+ __str += _CharT('\'');
+ return __formatter::__write(__str.data(), __str.data() + __str.size(), _VSTD::move(__out_it), __specs, __str.size());
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI auto
+__format_escaped_string(basic_string_view<_CharT> __values,
+ output_iterator<const _CharT&> auto __out_it,
+ __format_spec::__parsed_specifications<_CharT> __specs) -> decltype(__out_it) {
+ basic_string<_CharT> __str;
+ __str += _CharT('"');
+ __formatter::__escape(__str, __values, __escape_quotation_mark::__double_quote);
+ __str += _CharT('"');
+ return __formatter::__write_string(basic_string_view{__str}, _VSTD::move(__out_it), __specs);
+}
+
+# endif // _LIBCPP_STD_VER > 20
+
+} // namespace __formatter
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_OUTPUT_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_pointer.h b/third_party/llvm-project/libcxx/include/__format/formatter_pointer.h
new file mode 100644
index 0000000..31b49e1
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_pointer.h
@@ -0,0 +1,73 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_POINTER_H
+#define _LIBCPP___FORMAT_FORMATTER_POINTER_H
+
+#include <__availability>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_integral.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <cstddef>
+#include <cstdint>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS __formatter_pointer {
+public:
+ constexpr __formatter_pointer() { __parser_.__alignment_ = __format_spec::__alignment::__right; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr auto
+ parse(basic_format_parse_context<_CharT>& __parse_ctx) -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_pointer);
+ __format_spec::__process_display_type_pointer(__parser_.__type_);
+ return __result;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto format(const void* __ptr, auto& __ctx) const -> decltype(__ctx.out()) {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+ __specs.__std_.__alternate_form_ = true;
+ __specs.__std_.__type_ = __format_spec::__type::__hexadecimal_lower_case;
+ return __formatter::__format_integer(reinterpret_cast<uintptr_t>(__ptr), __ctx, __specs);
+ }
+
+ __format_spec::__parser<_CharT> __parser_;
+};
+
+// [format.formatter.spec]/2.4
+// For each charT, the pointer type specializations template<>
+// - struct formatter<nullptr_t, charT>;
+// - template<> struct formatter<void*, charT>;
+// - template<> struct formatter<const void*, charT>;
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<nullptr_t, _CharT>
+ : public __formatter_pointer<_CharT> {};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<void*, _CharT> : public __formatter_pointer<_CharT> {
+};
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const void*, _CharT>
+ : public __formatter_pointer<_CharT> {};
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_POINTER_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_string.h b/third_party/llvm-project/libcxx/include/__format/formatter_string.h
new file mode 100644
index 0000000..606fb79
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_string.h
@@ -0,0 +1,159 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_STRING_H
+#define _LIBCPP___FORMAT_FORMATTER_STRING_H
+
+#include <__availability>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__utility/move.h>
+#include <string>
+#include <string_view>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS __formatter_string {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto parse(basic_format_parse_context<_CharT>& __parse_ctx)
+ -> decltype(__parse_ctx.begin()) {
+ auto __result = __parser_.__parse(__parse_ctx, __format_spec::__fields_string);
+ __format_spec::__process_display_type_string(__parser_.__type_);
+ return __result;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT> __str, auto& __ctx) const -> decltype(__ctx.out()) {
+# if _LIBCPP_STD_VER > 20
+ if (__parser_.__type_ == __format_spec::__type::__debug)
+ return __formatter::__format_escaped_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+# endif
+
+ return __formatter::__write_string(__str, __ctx.out(), __parser_.__get_parsed_std_specifications(__ctx));
+ }
+
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_debug_format() { __parser_.__type_ = __format_spec::__type::__debug; }
+# endif
+
+ __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
+};
+
+// Formatter const char*.
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT*, _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(const _CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
+ _LIBCPP_ASSERT(__str, "The basic_format_arg constructor should have "
+ "prevented an invalid pointer.");
+
+ __format_spec::__parsed_specifications<_CharT> __specs = _Base::__parser_.__get_parsed_std_specifications(__ctx);
+# if _LIBCPP_STD_VER > 20
+ if (_Base::__parser_.__type_ == __format_spec::__type::__debug)
+ return __formatter::__format_escaped_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
+# endif
+
+ // When using a center or right alignment and the width option the length
+ // of __str must be known to add the padding upfront. This case is handled
+ // by the base class by converting the argument to a basic_string_view.
+ //
+ // When using left alignment and the width option the padding is added
+ // after outputting __str so the length can be determined while outputting
+ // __str. The same holds true for the precision, during outputting __str it
+ // can be validated whether the precision threshold has been reached. For
+ // now these optimizations aren't implemented. Instead the base class
+ // handles these options.
+ // TODO FMT Implement these improvements.
+ if (__specs.__has_width() || __specs.__has_precision())
+ return __formatter::__write_string(basic_string_view<_CharT>{__str}, __ctx.out(), __specs);
+
+ // No formatting required, copy the string to the output.
+ auto __out_it = __ctx.out();
+ while (*__str)
+ *__out_it++ = *__str++;
+ return __out_it;
+ }
+};
+
+// Formatter char*.
+template <__fmt_char_type _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT*, _CharT>
+ : public formatter<const _CharT*, _CharT> {
+ using _Base = formatter<const _CharT*, _CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT* __str, auto& __ctx) const -> decltype(__ctx.out()) {
+ return _Base::format(__str, __ctx);
+ }
+};
+
+// Formatter char[].
+template <__fmt_char_type _CharT, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_CharT[_Size], _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(_CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) {
+ return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
+ }
+};
+
+// Formatter const char[].
+template <__fmt_char_type _CharT, size_t _Size>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<const _CharT[_Size], _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(const _CharT __str[_Size], auto& __ctx) const -> decltype(__ctx.out()) {
+ return _Base::format(basic_string_view<_CharT>(__str, _Size), __ctx);
+ }
+};
+
+// Formatter std::string.
+template <__fmt_char_type _CharT, class _Traits, class _Allocator>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string<_CharT, _Traits, _Allocator>, _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(const basic_string<_CharT, _Traits, _Allocator>& __str, auto& __ctx) const
+ -> decltype(__ctx.out()) {
+ // Drop _Traits and _Allocator to have one std::basic_string formatter.
+ return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
+ }
+};
+
+// Formatter std::string_view.
+template <__fmt_char_type _CharT, class _Traits>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<basic_string_view<_CharT, _Traits>, _CharT>
+ : public __formatter_string<_CharT> {
+ using _Base = __formatter_string<_CharT>;
+
+ _LIBCPP_HIDE_FROM_ABI auto format(basic_string_view<_CharT, _Traits> __str, auto& __ctx) const
+ -> decltype(__ctx.out()) {
+ // Drop _Traits to have one std::basic_string_view formatter.
+ return _Base::format(basic_string_view<_CharT>(__str.data(), __str.size()), __ctx);
+ }
+};
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_STRING_H
diff --git a/third_party/llvm-project/libcxx/include/__format/formatter_tuple.h b/third_party/llvm-project/libcxx/include/__format/formatter_tuple.h
new file mode 100644
index 0000000..82f5ada
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/formatter_tuple.h
@@ -0,0 +1,178 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_FORMATTER_TUPLE_H
+#define _LIBCPP___FORMAT_FORMATTER_TUPLE_H
+
+#include <__algorithm/ranges_copy.h>
+#include <__availability>
+#include <__chrono/statically_widen.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/format_args.h>
+#include <__format/format_context.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/formatter.h>
+#include <__format/formatter_output.h>
+#include <__format/parser_std_format_spec.h>
+#include <__iterator/back_insert_iterator.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/integer_sequence.h>
+#include <__utility/pair.h>
+#include <string_view>
+#include <tuple>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+template <__fmt_char_type _CharT, class _Tuple, formattable<_CharT>... _Args>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __formatter_tuple {
+ _LIBCPP_HIDE_FROM_ABI constexpr void set_separator(basic_string_view<_CharT> __separator) {
+ __separator_ = __separator;
+ }
+ _LIBCPP_HIDE_FROM_ABI constexpr void
+ set_brackets(basic_string_view<_CharT> __opening_bracket, basic_string_view<_CharT> __closing_bracket) {
+ __opening_bracket_ = __opening_bracket;
+ __closing_bracket_ = __closing_bracket;
+ }
+
+ template <class _ParseContext>
+ _LIBCPP_HIDE_FROM_ABI constexpr typename _ParseContext::iterator parse(_ParseContext& __parse_ctx) {
+ const _CharT* __begin = __parser_.__parse(__parse_ctx, __format_spec::__fields_tuple);
+
+ // [format.tuple]/7
+ // ... For each element e in underlying_, if e.set_debug_format()
+ // is a valid expression, calls e.set_debug_format().
+ // TODO FMT this can be removed when P2733 is accepted.
+ std::__for_each_index_sequence(make_index_sequence<sizeof...(_Args)>(), [&]<size_t _Index> {
+ std::__set_debug_format(std::get<_Index>(__underlying_));
+ });
+
+ const _CharT* __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ if (*__begin == _CharT('m')) {
+ if constexpr (sizeof...(_Args) == 2) {
+ set_separator(_LIBCPP_STATICALLY_WIDEN(_CharT, ": "));
+ set_brackets({}, {});
+ ++__begin;
+ } else
+ std::__throw_format_error("The format specifier m requires a pair or a two-element tuple");
+ } else if (*__begin == _CharT('n')) {
+ set_brackets({}, {});
+ ++__begin;
+ }
+
+ if (__begin != __end && *__begin != _CharT('}'))
+ std::__throw_format_error("The format-spec should consume the input or end with a '}'");
+
+ return __begin;
+ }
+
+ template <class _FormatContext>
+ typename _FormatContext::iterator _LIBCPP_HIDE_FROM_ABI
+ format(conditional_t<(formattable<const _Args, _CharT> && ...), const _Tuple&, _Tuple&> __tuple,
+ _FormatContext& __ctx) const {
+ __format_spec::__parsed_specifications<_CharT> __specs = __parser_.__get_parsed_std_specifications(__ctx);
+
+ if (!__specs.__has_width())
+ return __format_tuple(__tuple, __ctx);
+
+ basic_string<_CharT> __str;
+
+ // Since the output is written to a different iterator a new context is
+ // created. Since the underlying formatter uses the default formatting it
+ // doesn't need a locale or the formatting arguments. So creating a new
+ // context works.
+ //
+ // This solution works for this formatter, but it will not work for the
+ // range_formatter. In that patch a generic solution is work in progress.
+ // Once that is finished it can be used here. (The range_formatter will use
+ // these features so it's easier to add it there and then port it.)
+ //
+ // TODO FMT Use formatting wrapping used in the range_formatter.
+ basic_format_context __c = std::__format_context_create(
+ back_insert_iterator{__str},
+ basic_format_args<basic_format_context<back_insert_iterator<basic_string<_CharT>>, _CharT>>{});
+
+ __format_tuple(__tuple, __c);
+
+ return __formatter::__write_string_no_precision(basic_string_view{__str}, __ctx.out(), __specs);
+ }
+
+ template <class _FormatContext>
+ _LIBCPP_HIDE_FROM_ABI typename _FormatContext::iterator __format_tuple(auto&& __tuple, _FormatContext& __ctx) const {
+ __ctx.advance_to(std::ranges::copy(__opening_bracket_, __ctx.out()).out);
+
+ std::__for_each_index_sequence(make_index_sequence<sizeof...(_Args)>(), [&]<size_t _Index> {
+ if constexpr (_Index)
+ __ctx.advance_to(std::ranges::copy(__separator_, __ctx.out()).out);
+
+ // During review Victor suggested to make the exposition only
+ // __underlying_ member a local variable. Currently the Standard
+ // requires nested debug-enabled formatter specializations not to
+ // output escaped output. P2733 fixes that bug, once accepted the
+ // code below can be used.
+ // (Note when a paper allows parsing a tuple-underlying-spec the
+ // exposition only member needs to be a class member. Earlier
+ // revisions of P2286 proposed that, but this was not pursued,
+ // due to time constrains and complexity of the matter.)
+ // TODO FMT This can be updated after P2733 is accepted.
+# if 0
+ // P2286 uses an exposition only member in the formatter
+ // tuple<formatter<remove_cvref_t<_Args>, _CharT>...> __underlying_;
+ // This was used in earlier versions of the paper since
+ // __underlying_.parse(...) was called. This is no longer the case
+ // so we can reduce the scope of the formatter.
+ //
+ // It does require the underlying's parse effect to be moved here too.
+ using _Arg = tuple_element<_Index, decltype(__tuple)>;
+ formatter<remove_cvref_t<_Args>, _CharT> __underlying;
+
+ // [format.tuple]/7
+ // ... For each element e in underlying_, if e.set_debug_format()
+ // is a valid expression, calls e.set_debug_format().
+ std::__set_debug_format(__underlying);
+# else
+ __ctx.advance_to(std::get<_Index>(__underlying_).format(std::get<_Index>(__tuple), __ctx));
+# endif
+ });
+
+ return std::ranges::copy(__closing_bracket_, __ctx.out()).out;
+ }
+
+ __format_spec::__parser<_CharT> __parser_{.__alignment_ = __format_spec::__alignment::__left};
+
+private:
+ tuple<formatter<remove_cvref_t<_Args>, _CharT>...> __underlying_;
+ basic_string_view<_CharT> __separator_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ", ");
+ basic_string_view<_CharT> __opening_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, "(");
+ basic_string_view<_CharT> __closing_bracket_ = _LIBCPP_STATICALLY_WIDEN(_CharT, ")");
+};
+
+template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<pair<_Args...>, _CharT>
+ : public __formatter_tuple<_CharT, pair<_Args...>, _Args...> {};
+
+template <__fmt_char_type _CharT, formattable<_CharT>... _Args>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<tuple<_Args...>, _CharT>
+ : public __formatter_tuple<_CharT, tuple<_Args...>, _Args...> {};
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_FORMATTER_TUPLE_H
diff --git a/third_party/llvm-project/libcxx/include/__format/parser_std_format_spec.h b/third_party/llvm-project/libcxx/include/__format/parser_std_format_spec.h
new file mode 100644
index 0000000..36f6505
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/parser_std_format_spec.h
@@ -0,0 +1,953 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
+#define _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
+
+/// \file Contains the std-format-spec parser.
+///
+/// Most of the code can be reused in the chrono-format-spec.
+/// This header has some support for the chrono-format-spec since it doesn't
+/// affect the std-format-spec.
+
+#include <__algorithm/find_if.h>
+#include <__algorithm/min.h>
+#include <__assert>
+#include <__concepts/arithmetic.h>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__debug>
+#include <__format/format_arg.h>
+#include <__format/format_error.h>
+#include <__format/format_parse_context.h>
+#include <__format/format_string.h>
+#include <__format/unicode.h>
+#include <__variant/monostate.h>
+#include <bit>
+#include <cstdint>
+#include <string_view>
+#include <type_traits>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __format_spec {
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __format::__parse_number_result< _CharT>
+__parse_arg_id(const _CharT* __begin, const _CharT* __end, auto& __parse_ctx) {
+ // This function is a wrapper to call the real parser. But it does the
+ // validation for the pre-conditions and post-conditions.
+ if (__begin == __end)
+ std::__throw_format_error("End of input while parsing format-spec arg-id");
+
+ __format::__parse_number_result __r = __format::__parse_arg_id(__begin, __end, __parse_ctx);
+
+ if (__r.__ptr == __end || *__r.__ptr != _CharT('}'))
+ std::__throw_format_error("Invalid arg-id");
+
+ ++__r.__ptr;
+ return __r;
+}
+
+template <class _Context>
+_LIBCPP_HIDE_FROM_ABI constexpr uint32_t
+__substitute_arg_id(basic_format_arg<_Context> __format_arg) {
+ // [format.string.std]/8
+ // If the corresponding formatting argument is not of integral type...
+ // This wording allows char and bool too. LWG-3720 changes the wording to
+ // If the corresponding formatting argument is not of standard signed or
+ // unsigned integer type,
+ // This means the 128-bit will not be valid anymore.
+ // TODO FMT Verify this resolution is accepted and add a test to verify
+ // 128-bit integrals fail and switch to visit_format_arg.
+ return _VSTD::__visit_format_arg(
+ [](auto __arg) -> uint32_t {
+ using _Type = decltype(__arg);
+ if constexpr (integral<_Type>) {
+ if constexpr (signed_integral<_Type>) {
+ if (__arg < 0)
+ std::__throw_format_error("A format-spec arg-id replacement shouldn't have a negative value");
+ }
+
+ using _CT = common_type_t<_Type, decltype(__format::__number_max)>;
+ if (static_cast<_CT>(__arg) >
+ static_cast<_CT>(__format::__number_max))
+ std::__throw_format_error("A format-spec arg-id replacement exceeds the maximum supported value");
+
+ return __arg;
+ } else if constexpr (same_as<_Type, monostate>)
+ std::__throw_format_error("Argument index out of bounds");
+ else
+ std::__throw_format_error("A format-spec arg-id replacement argument isn't an integral type");
+ },
+ __format_arg);
+}
+
+/// These fields are a filter for which elements to parse.
+///
+/// They default to false so when a new field is added it needs to be opted in
+/// explicitly.
+// TODO FMT Use an ABI tag for this struct.
+struct __fields {
+ uint8_t __sign_ : 1 {false};
+ uint8_t __alternate_form_ : 1 {false};
+ uint8_t __zero_padding_ : 1 {false};
+ uint8_t __precision_ : 1 {false};
+ uint8_t __locale_specific_form_ : 1 {false};
+ uint8_t __type_ : 1 {false};
+ // Determines the valid values for fill.
+ //
+ // Originally the fill could be any character except { and }. Range-based
+ // formatters use the colon to mark the beginning of the
+ // underlying-format-spec. To avoid parsing ambiguities these formatter
+ // specializations prohibit the use of the colon as a fill character.
+ uint8_t __allow_colon_in_fill_ : 1 {false};
+};
+
+// By not placing this constant in the formatter class it's not duplicated for
+// char and wchar_t.
+inline constexpr __fields __fields_integral{
+ .__sign_ = true,
+ .__alternate_form_ = true,
+ .__zero_padding_ = true,
+ .__locale_specific_form_ = true,
+ .__type_ = true};
+inline constexpr __fields __fields_floating_point{
+ .__sign_ = true,
+ .__alternate_form_ = true,
+ .__zero_padding_ = true,
+ .__precision_ = true,
+ .__locale_specific_form_ = true,
+ .__type_ = true};
+inline constexpr __fields __fields_string{.__precision_ = true, .__type_ = true};
+inline constexpr __fields __fields_pointer{.__type_ = true};
+
+# if _LIBCPP_STD_VER > 20
+inline constexpr __fields __fields_tuple{.__type_ = false, .__allow_colon_in_fill_ = true};
+# endif
+
+enum class _LIBCPP_ENUM_VIS __alignment : uint8_t {
+ /// No alignment is set in the format string.
+ __default,
+ __left,
+ __center,
+ __right,
+ __zero_padding
+};
+
+enum class _LIBCPP_ENUM_VIS __sign : uint8_t {
+ /// No sign is set in the format string.
+ ///
+ /// The sign isn't allowed for certain format-types. By using this value
+ /// it's possible to detect whether or not the user explicitly set the sign
+ /// flag. For formatting purposes it behaves the same as \ref __minus.
+ __default,
+ __minus,
+ __plus,
+ __space
+};
+
+enum class _LIBCPP_ENUM_VIS __type : uint8_t {
+ __default,
+ __string,
+ __binary_lower_case,
+ __binary_upper_case,
+ __octal,
+ __decimal,
+ __hexadecimal_lower_case,
+ __hexadecimal_upper_case,
+ __pointer,
+ __char,
+ __hexfloat_lower_case,
+ __hexfloat_upper_case,
+ __scientific_lower_case,
+ __scientific_upper_case,
+ __fixed_lower_case,
+ __fixed_upper_case,
+ __general_lower_case,
+ __general_upper_case,
+ __debug
+};
+
+struct __std {
+ __alignment __alignment_ : 3;
+ __sign __sign_ : 2;
+ bool __alternate_form_ : 1;
+ bool __locale_specific_form_ : 1;
+ __type __type_;
+};
+
+struct __chrono {
+ __alignment __alignment_ : 3;
+ bool __locale_specific_form_ : 1;
+ bool __weekday_name_ : 1;
+ bool __weekday_ : 1;
+ bool __day_of_year_ : 1;
+ bool __week_of_year_ : 1;
+ bool __month_name_ : 1;
+};
+
+/// Contains the parsed formatting specifications.
+///
+/// This contains information for both the std-format-spec and the
+/// chrono-format-spec. This results in some unused members for both
+/// specifications. However these unused members don't increase the size
+/// of the structure.
+///
+/// This struct doesn't cross ABI boundaries so its layout doesn't need to be
+/// kept stable.
+template <class _CharT>
+struct __parsed_specifications {
+ union {
+ // The field __alignment_ is the first element in __std_ and __chrono_.
+ // This allows the code to always inspect this value regards which member
+ // of the union is the active member [class.union.general]/2.
+ //
+ // This is needed since the generic output routines handle the alignment of
+ // the output.
+ __alignment __alignment_ : 3;
+ __std __std_;
+ __chrono __chrono_;
+ };
+
+ /// The requested width.
+ ///
+ /// When the format-spec used an arg-id for this field it has already been
+ /// replaced with the value of that arg-id.
+ int32_t __width_;
+
+ /// The requested precision.
+ ///
+ /// When the format-spec used an arg-id for this field it has already been
+ /// replaced with the value of that arg-id.
+ int32_t __precision_;
+
+ _CharT __fill_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_width() const { return __width_ > 0; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __has_precision() const { return __precision_ >= 0; }
+};
+
+// Validate the struct is small and cheap to copy since the struct is passed by
+// value in formatting functions.
+static_assert(sizeof(__parsed_specifications<char>) == 16);
+static_assert(is_trivially_copyable_v<__parsed_specifications<char>>);
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static_assert(sizeof(__parsed_specifications<wchar_t>) == 16);
+static_assert(is_trivially_copyable_v<__parsed_specifications<wchar_t>>);
+# endif
+
+/// The parser for the std-format-spec.
+///
+/// Note this class is a member of std::formatter specializations. It's
+/// expected developers will create their own formatter specializations that
+/// inherit from the std::formatter specializations. This means this class
+/// must be ABI stable. To aid the stability the unused bits in the class are
+/// set to zero. That way they can be repurposed if a future revision of the
+/// Standards adds new fields to std-format-spec.
+template <class _CharT>
+class _LIBCPP_TEMPLATE_VIS __parser {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr auto __parse(basic_format_parse_context<_CharT>& __parse_ctx, __fields __fields)
+ -> decltype(__parse_ctx.begin()) {
+
+ const _CharT* __begin = __parse_ctx.begin();
+ const _CharT* __end = __parse_ctx.end();
+ if (__begin == __end)
+ return __begin;
+
+ if (__parse_fill_align(__begin, __end, __fields.__allow_colon_in_fill_) && __begin == __end)
+ return __begin;
+
+ if (__fields.__sign_ && __parse_sign(__begin) && __begin == __end)
+ return __begin;
+
+ if (__fields.__alternate_form_ && __parse_alternate_form(__begin) && __begin == __end)
+ return __begin;
+
+ if (__fields.__zero_padding_ && __parse_zero_padding(__begin) && __begin == __end)
+ return __begin;
+
+ if (__parse_width(__begin, __end, __parse_ctx) && __begin == __end)
+ return __begin;
+
+ if (__fields.__precision_ && __parse_precision(__begin, __end, __parse_ctx) && __begin == __end)
+ return __begin;
+
+ if (__fields.__locale_specific_form_ && __parse_locale_specific_form(__begin) && __begin == __end)
+ return __begin;
+
+ if (__fields.__type_) {
+ __parse_type(__begin);
+
+ // When __type_ is false the calling parser is expected to do additional
+ // parsing. In that case that parser should do the end of format string
+ // validation.
+ if (__begin != __end && *__begin != _CharT('}'))
+ std::__throw_format_error("The format-spec should consume the input or end with a '}'");
+ }
+
+ return __begin;
+ }
+
+ /// \returns the `__parsed_specifications` with the resolved dynamic sizes..
+ _LIBCPP_HIDE_FROM_ABI
+ __parsed_specifications<_CharT> __get_parsed_std_specifications(auto& __ctx) const {
+ return __parsed_specifications<_CharT>{
+ .__std_ = __std{.__alignment_ = __alignment_,
+ .__sign_ = __sign_,
+ .__alternate_form_ = __alternate_form_,
+ .__locale_specific_form_ = __locale_specific_form_,
+ .__type_ = __type_},
+ .__width_{__get_width(__ctx)},
+ .__precision_{__get_precision(__ctx)},
+ .__fill_{__fill_}};
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __parsed_specifications<_CharT> __get_parsed_chrono_specifications(auto& __ctx) const {
+ return __parsed_specifications<_CharT>{
+ .__chrono_ =
+ __chrono{.__alignment_ = __alignment_,
+ .__locale_specific_form_ = __locale_specific_form_,
+ .__weekday_name_ = __weekday_name_,
+ .__weekday_ = __weekday_,
+ .__day_of_year_ = __day_of_year_,
+ .__week_of_year_ = __week_of_year_,
+ .__month_name_ = __month_name_},
+ .__width_{__get_width(__ctx)},
+ .__precision_{__get_precision(__ctx)},
+ .__fill_{__fill_}};
+ }
+
+ __alignment __alignment_ : 3 {__alignment::__default};
+ __sign __sign_ : 2 {__sign::__default};
+ bool __alternate_form_ : 1 {false};
+ bool __locale_specific_form_ : 1 {false};
+ bool __reserved_0_ : 1 {false};
+ __type __type_{__type::__default};
+
+ // These flags are only used for formatting chrono. Since the struct has
+ // padding space left it's added to this structure.
+ bool __weekday_name_ : 1 {false};
+ bool __weekday_ : 1 {false};
+
+ bool __day_of_year_ : 1 {false};
+ bool __week_of_year_ : 1 {false};
+
+ bool __month_name_ : 1 {false};
+
+ uint8_t __reserved_1_ : 3 {0};
+ uint8_t __reserved_2_ : 6 {0};
+ // These two flags are only used internally and not part of the
+ // __parsed_specifications. Therefore put them at the end.
+ bool __width_as_arg_ : 1 {false};
+ bool __precision_as_arg_ : 1 {false};
+
+ /// The requested width, either the value or the arg-id.
+ int32_t __width_{0};
+
+ /// The requested precision, either the value or the arg-id.
+ int32_t __precision_{-1};
+
+ // LWG 3576 will probably change this to always accept a Unicode code point
+ // To avoid changing the size with that change align the field so when it
+ // becomes 32-bit its alignment will remain the same. That also means the
+ // size will remain the same. (D2572 addresses the solution for LWG 3576.)
+ _CharT __fill_{_CharT(' ')};
+
+private:
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alignment(_CharT __c) {
+ switch (__c) {
+ case _CharT('<'):
+ __alignment_ = __alignment::__left;
+ return true;
+
+ case _CharT('^'):
+ __alignment_ = __alignment::__center;
+ return true;
+
+ case _CharT('>'):
+ __alignment_ = __alignment::__right;
+ return true;
+ }
+ return false;
+ }
+
+ // range-fill and tuple-fill are identical
+ _LIBCPP_HIDE_FROM_ABI constexpr bool
+ __parse_fill_align(const _CharT*& __begin, const _CharT* __end, bool __use_range_fill) {
+ _LIBCPP_ASSERT(__begin != __end, "when called with an empty input the function will cause "
+ "undefined behavior by evaluating data not in the input");
+ if (__begin + 1 != __end) {
+ if (__parse_alignment(*(__begin + 1))) {
+ if (__use_range_fill && (*__begin == _CharT('{') || *__begin == _CharT('}') || *__begin == _CharT(':')))
+ std::__throw_format_error("The format-spec range-fill field contains an invalid character");
+ else if (*__begin == _CharT('{') || *__begin == _CharT('}'))
+ std::__throw_format_error("The format-spec fill field contains an invalid character");
+
+ __fill_ = *__begin;
+ __begin += 2;
+ return true;
+ }
+ }
+
+ if (!__parse_alignment(*__begin))
+ return false;
+
+ ++__begin;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_sign(const _CharT*& __begin) {
+ switch (*__begin) {
+ case _CharT('-'):
+ __sign_ = __sign::__minus;
+ break;
+ case _CharT('+'):
+ __sign_ = __sign::__plus;
+ break;
+ case _CharT(' '):
+ __sign_ = __sign::__space;
+ break;
+ default:
+ return false;
+ }
+ ++__begin;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_alternate_form(const _CharT*& __begin) {
+ if (*__begin != _CharT('#'))
+ return false;
+
+ __alternate_form_ = true;
+ ++__begin;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_zero_padding(const _CharT*& __begin) {
+ if (*__begin != _CharT('0'))
+ return false;
+
+ if (__alignment_ == __alignment::__default)
+ __alignment_ = __alignment::__zero_padding;
+ ++__begin;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_width(const _CharT*& __begin, const _CharT* __end, auto& __parse_ctx) {
+ if (*__begin == _CharT('0'))
+ std::__throw_format_error("A format-spec width field shouldn't have a leading zero");
+
+ if (*__begin == _CharT('{')) {
+ __format::__parse_number_result __r = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
+ __width_as_arg_ = true;
+ __width_ = __r.__value;
+ __begin = __r.__ptr;
+ return true;
+ }
+
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ return false;
+
+ __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
+ __width_ = __r.__value;
+ _LIBCPP_ASSERT(__width_ != 0, "A zero value isn't allowed and should be impossible, "
+ "due to validations in this function");
+ __begin = __r.__ptr;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_precision(const _CharT*& __begin, const _CharT* __end,
+ auto& __parse_ctx) {
+ if (*__begin != _CharT('.'))
+ return false;
+
+ ++__begin;
+ if (__begin == __end)
+ std::__throw_format_error("End of input while parsing format-spec precision");
+
+ if (*__begin == _CharT('{')) {
+ __format::__parse_number_result __arg_id = __format_spec::__parse_arg_id(++__begin, __end, __parse_ctx);
+ __precision_as_arg_ = true;
+ __precision_ = __arg_id.__value;
+ __begin = __arg_id.__ptr;
+ return true;
+ }
+
+ if (*__begin < _CharT('0') || *__begin > _CharT('9'))
+ std::__throw_format_error("The format-spec precision field doesn't contain a value or arg-id");
+
+ __format::__parse_number_result __r = __format::__parse_number(__begin, __end);
+ __precision_ = __r.__value;
+ __precision_as_arg_ = false;
+ __begin = __r.__ptr;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __parse_locale_specific_form(const _CharT*& __begin) {
+ if (*__begin != _CharT('L'))
+ return false;
+
+ __locale_specific_form_ = true;
+ ++__begin;
+ return true;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr void __parse_type(const _CharT*& __begin) {
+ // Determines the type. It does not validate whether the selected type is
+ // valid. Most formatters have optional fields that are only allowed for
+ // certain types. These parsers need to do validation after the type has
+ // been parsed. So its easier to implement the validation for all types in
+ // the specific parse function.
+ switch (*__begin) {
+ case 'A':
+ __type_ = __type::__hexfloat_upper_case;
+ break;
+ case 'B':
+ __type_ = __type::__binary_upper_case;
+ break;
+ case 'E':
+ __type_ = __type::__scientific_upper_case;
+ break;
+ case 'F':
+ __type_ = __type::__fixed_upper_case;
+ break;
+ case 'G':
+ __type_ = __type::__general_upper_case;
+ break;
+ case 'X':
+ __type_ = __type::__hexadecimal_upper_case;
+ break;
+ case 'a':
+ __type_ = __type::__hexfloat_lower_case;
+ break;
+ case 'b':
+ __type_ = __type::__binary_lower_case;
+ break;
+ case 'c':
+ __type_ = __type::__char;
+ break;
+ case 'd':
+ __type_ = __type::__decimal;
+ break;
+ case 'e':
+ __type_ = __type::__scientific_lower_case;
+ break;
+ case 'f':
+ __type_ = __type::__fixed_lower_case;
+ break;
+ case 'g':
+ __type_ = __type::__general_lower_case;
+ break;
+ case 'o':
+ __type_ = __type::__octal;
+ break;
+ case 'p':
+ __type_ = __type::__pointer;
+ break;
+ case 's':
+ __type_ = __type::__string;
+ break;
+ case 'x':
+ __type_ = __type::__hexadecimal_lower_case;
+ break;
+# if _LIBCPP_STD_VER > 20
+ case '?':
+ __type_ = __type::__debug;
+ break;
+# endif
+ default:
+ return;
+ }
+ ++__begin;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ int32_t __get_width(auto& __ctx) const {
+ if (!__width_as_arg_)
+ return __width_;
+
+ return __format_spec::__substitute_arg_id(__ctx.arg(__width_));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI
+ int32_t __get_precision(auto& __ctx) const {
+ if (!__precision_as_arg_)
+ return __precision_;
+
+ return __format_spec::__substitute_arg_id(__ctx.arg(__precision_));
+ }
+};
+
+// Validates whether the reserved bitfields don't change the size.
+static_assert(sizeof(__parser<char>) == 16);
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+static_assert(sizeof(__parser<wchar_t>) == 16);
+# endif
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_string(__format_spec::__type __type) {
+ switch (__type) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__string:
+ case __format_spec::__type::__debug:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a string argument");
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_bool_string(__parser<_CharT>& __parser) {
+ if (__parser.__sign_ != __sign::__default)
+ std::__throw_format_error("A sign field isn't allowed in this format-spec");
+
+ if (__parser.__alternate_form_)
+ std::__throw_format_error("An alternate form field isn't allowed in this format-spec");
+
+ if (__parser.__alignment_ == __alignment::__zero_padding)
+ std::__throw_format_error("A zero-padding field isn't allowed in this format-spec");
+
+ if (__parser.__alignment_ == __alignment::__default)
+ __parser.__alignment_ = __alignment::__left;
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_char(__parser<_CharT>& __parser) {
+ __format_spec::__process_display_type_bool_string(__parser);
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_bool(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__string:
+ __format_spec::__process_display_type_bool_string(__parser);
+ break;
+
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a bool argument");
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_char(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__char:
+ case __format_spec::__type::__debug:
+ __format_spec::__process_display_type_char(__parser);
+ break;
+
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a char argument");
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_integer(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__binary_lower_case:
+ case __format_spec::__type::__binary_upper_case:
+ case __format_spec::__type::__octal:
+ case __format_spec::__type::__decimal:
+ case __format_spec::__type::__hexadecimal_lower_case:
+ case __format_spec::__type::__hexadecimal_upper_case:
+ break;
+
+ case __format_spec::__type::__char:
+ __format_spec::__process_display_type_char(__parser);
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for an integer argument");
+ }
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_parsed_floating_point(__parser<_CharT>& __parser) {
+ switch (__parser.__type_) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__hexfloat_lower_case:
+ case __format_spec::__type::__hexfloat_upper_case:
+ // Precision specific behavior will be handled later.
+ break;
+ case __format_spec::__type::__scientific_lower_case:
+ case __format_spec::__type::__scientific_upper_case:
+ case __format_spec::__type::__fixed_lower_case:
+ case __format_spec::__type::__fixed_upper_case:
+ case __format_spec::__type::__general_lower_case:
+ case __format_spec::__type::__general_upper_case:
+ if (!__parser.__precision_as_arg_ && __parser.__precision_ == -1)
+ // Set the default precision for the call to to_chars.
+ __parser.__precision_ = 6;
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a floating-point argument");
+ }
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr void __process_display_type_pointer(__format_spec::__type __type) {
+ switch (__type) {
+ case __format_spec::__type::__default:
+ case __format_spec::__type::__pointer:
+ break;
+
+ default:
+ std::__throw_format_error("The format-spec type has a type not supported for a pointer argument");
+ }
+}
+
+template <class _CharT>
+struct __column_width_result {
+ /// The number of output columns.
+ size_t __width_;
+ /// One beyond the last code unit used in the estimation.
+ ///
+ /// This limits the original output to fit in the wanted number of columns.
+ const _CharT* __last_;
+};
+
+template <class _CharT>
+__column_width_result(size_t, const _CharT*) -> __column_width_result<_CharT>;
+
+/// Since a column width can be two it's possible that the requested column
+/// width can't be achieved. Depending on the intended usage the policy can be
+/// selected.
+/// - When used as precision the maximum width may not be exceeded and the
+/// result should be "rounded down" to the previous boundary.
+/// - When used as a width we're done once the minimum is reached, but
+/// exceeding is not an issue. Rounding down is an issue since that will
+/// result in writing fill characters. Therefore the result needs to be
+/// "rounded up".
+enum class __column_width_rounding { __down, __up };
+
+# ifndef _LIBCPP_HAS_NO_UNICODE
+
+namespace __detail {
+
+/// Converts a code point to the column width.
+///
+/// The estimations are conforming to [format.string.general]/11
+///
+/// This version expects a value less than 0x1'0000, which is a 3-byte UTF-8
+/// character.
+_LIBCPP_HIDE_FROM_ABI constexpr int __column_width_3(uint32_t __c) noexcept {
+ _LIBCPP_ASSERT(__c < 0x10000, "Use __column_width_4 or __column_width for larger values");
+
+ // clang-format off
+ return 1 + (__c >= 0x1100 && (__c <= 0x115f ||
+ (__c >= 0x2329 && (__c <= 0x232a ||
+ (__c >= 0x2e80 && (__c <= 0x303e ||
+ (__c >= 0x3040 && (__c <= 0xa4cf ||
+ (__c >= 0xac00 && (__c <= 0xd7a3 ||
+ (__c >= 0xf900 && (__c <= 0xfaff ||
+ (__c >= 0xfe10 && (__c <= 0xfe19 ||
+ (__c >= 0xfe30 && (__c <= 0xfe6f ||
+ (__c >= 0xff00 && (__c <= 0xff60 ||
+ (__c >= 0xffe0 && (__c <= 0xffe6
+ ))))))))))))))))))));
+ // clang-format on
+}
+
+/// @overload
+///
+/// This version expects a value greater than or equal to 0x1'0000, which is a
+/// 4-byte UTF-8 character.
+_LIBCPP_HIDE_FROM_ABI constexpr int __column_width_4(uint32_t __c) noexcept {
+ _LIBCPP_ASSERT(__c >= 0x10000, "Use __column_width_3 or __column_width for smaller values");
+
+ // clang-format off
+ return 1 + (__c >= 0x1'f300 && (__c <= 0x1'f64f ||
+ (__c >= 0x1'f900 && (__c <= 0x1'f9ff ||
+ (__c >= 0x2'0000 && (__c <= 0x2'fffd ||
+ (__c >= 0x3'0000 && (__c <= 0x3'fffd
+ ))))))));
+ // clang-format on
+}
+
+/// @overload
+///
+/// The general case, accepting all values.
+_LIBCPP_HIDE_FROM_ABI constexpr int __column_width(uint32_t __c) noexcept {
+ if (__c < 0x10000)
+ return __detail::__column_width_3(__c);
+
+ return __detail::__column_width_4(__c);
+}
+
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width_grapheme_clustering(
+ const _CharT* __first, const _CharT* __last, size_t __maximum, __column_width_rounding __rounding) noexcept {
+ __unicode::__extended_grapheme_cluster_view<_CharT> __view{__first, __last};
+
+ __column_width_result<_CharT> __result{0, __first};
+ while (__result.__last_ != __last && __result.__width_ <= __maximum) {
+ typename __unicode::__extended_grapheme_cluster_view<_CharT>::__cluster __cluster = __view.__consume();
+ int __width = __detail::__column_width(__cluster.__code_point_);
+
+ // When the next entry would exceed the maximum width the previous width
+ // might be returned. For example when a width of 100 is requested the
+ // returned width might be 99, since the next code point has an estimated
+ // column width of 2. This depends on the rounding flag.
+ // When the maximum is exceeded the loop will abort the next iteration.
+ if (__rounding == __column_width_rounding::__down && __result.__width_ + __width > __maximum)
+ return __result;
+
+ __result.__width_ += __width;
+ __result.__last_ = __cluster.__last_;
+ }
+
+ return __result;
+}
+
+} // namespace __detail
+
+// Unicode can be stored in several formats: UTF-8, UTF-16, and UTF-32.
+// Depending on format the relation between the number of code units stored and
+// the number of output columns differs. The first relation is the number of
+// code units forming a code point. (The text assumes the code units are
+// unsigned.)
+// - UTF-8 The number of code units is between one and four. The first 127
+// Unicode code points match the ASCII character set. When the highest bit is
+// set it means the code point has more than one code unit.
+// - UTF-16: The number of code units is between 1 and 2. When the first
+// code unit is in the range [0xd800,0xdfff) it means the code point uses two
+// code units.
+// - UTF-32: The number of code units is always one.
+//
+// The code point to the number of columns is specified in
+// [format.string.std]/11. This list might change in the future.
+//
+// Another thing to be taken into account is Grapheme clustering. This means
+// that in some cases multiple code points are combined one element in the
+// output. For example:
+// - an ASCII character with a combined diacritical mark
+// - an emoji with a skin tone modifier
+// - a group of combined people emoji to create a family
+// - a combination of flag emoji
+//
+// See also:
+// - [format.string.general]/11
+// - https://en.wikipedia.org/wiki/UTF-8#Encoding
+// - https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_ascii(char32_t __c) { return __c < 0x80; }
+
+/// Determines the number of output columns needed to render the input.
+///
+/// \note When the scanner encounters malformed Unicode it acts as-if every
+/// code unit is a one column code point. Typically a terminal uses the same
+/// strategy and replaces every malformed code unit with a one column
+/// replacement character.
+///
+/// \param __first Points to the first element of the input range.
+/// \param __last Points beyond the last element of the input range.
+/// \param __maximum The maximum number of output columns. The returned number
+/// of estimated output columns will not exceed this value.
+/// \param __rounding Selects the rounding method.
+/// \c __down result.__width_ <= __maximum
+/// \c __up result.__width_ <= __maximum + 1
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT> __estimate_column_width(
+ basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding __rounding) noexcept {
+ // The width estimation is done in two steps:
+ // - Quickly process for the ASCII part. ASCII has the following properties
+ // - One code unit is one code point
+ // - Every code point has an estimated width of one
+ // - When needed it will a Unicode Grapheme clustering algorithm to find
+ // the proper place for truncation.
+
+ if (__str.empty() || __maximum == 0)
+ return {0, __str.begin()};
+
+ // ASCII has one caveat; when an ASCII character is followed by a non-ASCII
+ // character they might be part of an extended grapheme cluster. For example:
+ // an ASCII letter and a COMBINING ACUTE ACCENT
+ // The truncate should happen after the COMBINING ACUTE ACCENT. Therefore we
+ // need to scan one code unit beyond the requested precision. When this code
+ // unit is non-ASCII we omit the current code unit and let the Grapheme
+ // clustering algorithm do its work.
+ const _CharT* __it = __str.begin();
+ if (__format_spec::__is_ascii(*__it)) {
+ do {
+ --__maximum;
+ ++__it;
+ if (__it == __str.end())
+ return {__str.size(), __str.end()};
+
+ if (__maximum == 0) {
+ if (__format_spec::__is_ascii(*__it))
+ return {static_cast<size_t>(__it - __str.begin()), __it};
+
+ break;
+ }
+ } while (__format_spec::__is_ascii(*__it));
+ --__it;
+ ++__maximum;
+ }
+
+ ptrdiff_t __ascii_size = __it - __str.begin();
+ __column_width_result __result =
+ __detail::__estimate_column_width_grapheme_clustering(__it, __str.end(), __maximum, __rounding);
+
+ __result.__width_ += __ascii_size;
+ return __result;
+}
+# else // !defined(_LIBCPP_HAS_NO_UNICODE)
+template <class _CharT>
+_LIBCPP_HIDE_FROM_ABI constexpr __column_width_result<_CharT>
+__estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __column_width_rounding) noexcept {
+ // When Unicode isn't supported assume ASCII and every code unit is one code
+ // point. In ASCII the estimated column width is always one. Thus there's no
+ // need for rounding.
+ size_t __width_ = _VSTD::min(__str.size(), __maximum);
+ return {__width_, __str.begin() + __width_};
+}
+
+# endif // !defined(_LIBCPP_HAS_NO_UNICODE)
+
+} // namespace __format_spec
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FORMAT_PARSER_STD_FORMAT_SPEC_H
diff --git a/third_party/llvm-project/libcxx/include/__format/range_default_formatter.h b/third_party/llvm-project/libcxx/include/__format/range_default_formatter.h
new file mode 100644
index 0000000..56558f3
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/range_default_formatter.h
@@ -0,0 +1,137 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
+#define _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__availability>
+#include <__concepts/same_as.h>
+#include <__config>
+#include <__format/concepts.h>
+#include <__format/formatter.h>
+#include <__ranges/concepts.h>
+#include <__type_traits/remove_cvref.h>
+#include <__utility/pair.h>
+#include <tuple>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 20
+
+template <class _Rp, class _CharT>
+concept __const_formattable_range =
+ ranges::input_range<const _Rp> && formattable<ranges::range_reference_t<const _Rp>, _CharT>;
+
+template <class _Rp, class _CharT>
+using __fmt_maybe_const = conditional_t<__const_formattable_range<_Rp, _CharT>, const _Rp, _Rp>;
+
+_LIBCPP_DIAGNOSTIC_PUSH
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wshadow")
+_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wshadow")
+// This shadows map, set, and string.
+enum class range_format { disabled, map, set, sequence, string, debug_string };
+_LIBCPP_DIAGNOSTIC_POP
+
+// There is no definition of this struct, it's purely intended to be used to
+// generate diagnostics.
+template <class _Rp>
+struct _LIBCPP_TEMPLATE_VIS __instantiated_the_primary_template_of_format_kind;
+
+template <class _Rp>
+constexpr range_format format_kind = [] {
+ // [format.range.fmtkind]/1
+ // A program that instantiates the primary template of format_kind is ill-formed.
+ static_assert(sizeof(_Rp) != sizeof(_Rp), "create a template specialization of format_kind for your type");
+ return range_format::disabled;
+}();
+
+template <ranges::input_range _Rp>
+ requires same_as<_Rp, remove_cvref_t<_Rp>>
+inline constexpr range_format format_kind<_Rp> = [] {
+ // [format.range.fmtkind]/2
+
+ // 2.1 If same_as<remove_cvref_t<ranges::range_reference_t<R>>, R> is true,
+ // Otherwise format_kind<R> is range_format::disabled.
+ if constexpr (same_as<remove_cvref_t<ranges::range_reference_t<_Rp>>, _Rp>)
+ return range_format::disabled;
+ // 2.2 Otherwise, if the qualified-id R::key_type is valid and denotes a type:
+ else if constexpr (requires { typename _Rp::key_type; }) {
+ // 2.2.1 If the qualified-id R::mapped_type is valid and denotes a type ...
+ if constexpr (requires { typename _Rp::mapped_type; } &&
+ // 2.2.1 ... If either U is a specialization of pair or U is a specialization
+ // of tuple and tuple_size_v<U> == 2
+ __fmt_pair_like<remove_cvref_t<ranges::range_reference_t<_Rp>>>)
+ return range_format::map;
+ else
+ // 2.2.2 Otherwise format_kind<R> is range_format::set.
+ return range_format::set;
+ } else
+ // 2.3 Otherwise, format_kind<R> is range_format::sequence.
+ return range_format::sequence;
+}();
+
+// This is a non-standard work-around to fix instantiation of
+// formatter<const _CharT[N], _CharT>
+// const _CharT[N] satisfies the ranges::input_range concept.
+// remove_cvref_t<const _CharT[N]> is _CharT[N] so it does not satisfy the
+// requirement of the above specialization. Instead it will instantiate the
+// primary template, which is ill-formed.
+//
+// An alternative solution is to remove the offending formatter.
+//
+// https://godbolt.org/z/bqjhhaexx
+//
+// The removal is proposed in LWG3833, but use the work-around until the issue
+// has been adopted.
+// TODO FMT Implement LWG3833.
+template <class _CharT, size_t N>
+inline constexpr range_format format_kind<const _CharT[N]> = range_format::disabled;
+
+template <range_format _Kp, ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter;
+
+// Required specializations
+
+template <ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::sequence, _Rp, _CharT> {
+ __range_default_formatter() = delete; // TODO FMT Implement
+};
+
+template <ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::map, _Rp, _CharT> {
+ __range_default_formatter() = delete; // TODO FMT Implement
+};
+
+template <ranges::input_range _Rp, class _CharT>
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<range_format::set, _Rp, _CharT> {
+ __range_default_formatter() = delete; // TODO FMT Implement
+};
+
+template <range_format _Kp, ranges::input_range _Rp, class _CharT>
+ requires(_Kp == range_format::string || _Kp == range_format::debug_string)
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT __range_default_formatter<_Kp, _Rp, _CharT> {
+ __range_default_formatter() = delete; // TODO FMT Implement
+};
+
+// Dispatcher to select the specialization based on the type of the range.
+
+template <ranges::input_range _Rp, class _CharT>
+ requires(format_kind<_Rp> != range_format::disabled && formattable<ranges::range_reference_t<_Rp>, _CharT>)
+struct _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT formatter<_Rp, _CharT>
+ : __range_default_formatter<format_kind<_Rp>, _Rp, _CharT> {};
+
+#endif //_LIBCPP_STD_VER > 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_RANGE_DEFAULT_FORMATTER_H
diff --git a/third_party/llvm-project/libcxx/include/__format/unicode.h b/third_party/llvm-project/libcxx/include/__format/unicode.h
new file mode 100644
index 0000000..4327258
--- /dev/null
+++ b/third_party/llvm-project/libcxx/include/__format/unicode.h
@@ -0,0 +1,489 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP___FORMAT_UNICODE_H
+#define _LIBCPP___FORMAT_UNICODE_H
+
+#include <__assert>
+#include <__config>
+#include <__format/extended_grapheme_cluster_table.h>
+#include <__type_traits/make_unsigned.h>
+#include <__utility/unreachable.h>
+#include <bit>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER > 17
+
+namespace __unicode {
+
+# if _LIBCPP_STD_VER > 20
+
+/// The result of consuming a code point using P2286' semantics
+///
+/// TODO FMT Combine __consume and __consume_p2286 in one function.
+struct __consume_p2286_result {
+ // A size of 0 means well formed. This to differenciate between
+ // a valid code point and a code unit that's invalid like 0b11111xxx.
+ int __ill_formed_size;
+
+ // If well formed the consumed code point.
+ // Otherwise the ill-formed code units as unsigned 8-bit values. They are
+ // stored in reverse order, to make it easier to extract the values.
+ char32_t __value;
+};
+
+# endif // _LIBCPP_STD_VER > 20
+
+# ifndef _LIBCPP_HAS_NO_UNICODE
+
+/// Implements the grapheme cluster boundary rules
+///
+/// These rules are used to implement format's width estimation as stated in
+/// [format.string.std]/11
+///
+/// The Standard refers to UAX \#29 for Unicode 12.0.0
+/// https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
+///
+/// The data tables used are
+/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakProperty.txt
+/// https://www.unicode.org/Public/UCD/latest/ucd/emoji/emoji-data.txt
+/// https://www.unicode.org/Public/UCD/latest/ucd/auxiliary/GraphemeBreakTest.txt (for testing only)
+
+inline constexpr char32_t __replacement_character = U'\ufffd';
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_continuation(const char* __char, int __count) {
+ do {
+ if ((*__char & 0b1000'0000) != 0b1000'0000)
+ return false;
+ --__count;
+ ++__char;
+ } while (__count);
+ return true;
+}
+
+/// Helper class to extract a code unit from a Unicode character range.
+///
+/// The stored range is a view. There are multiple specialization for different
+/// character types.
+template <class _CharT>
+class __code_point_view;
+
+/// UTF-8 specialization.
+template <>
+class __code_point_view<char> {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const char* __first, const char* __last)
+ : __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const char* __position() const noexcept { return __first_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ // Based on the number of leading 1 bits the number of code units in the
+ // code point can be determined. See
+ // https://en.wikipedia.org/wiki/UTF-8#Encoding
+ switch (_VSTD::countl_one(static_cast<unsigned char>(*__first_))) {
+ case 0:
+ return *__first_++;
+
+ case 2:
+ if (__last_ - __first_ < 2 || !__unicode::__is_continuation(__first_ + 1, 1)) [[unlikely]]
+ break;
+ else {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return __value;
+ }
+
+ case 3:
+ if (__last_ - __first_ < 3 || !__unicode::__is_continuation(__first_ + 1, 2)) [[unlikely]]
+ break;
+ else {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return __value;
+ }
+
+ case 4:
+ if (__last_ - __first_ < 4 || !__unicode::__is_continuation(__first_ + 1, 3)) [[unlikely]]
+ break;
+ else {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return __value;
+ }
+ }
+ // An invalid number of leading ones can be garbage or a code unit in the
+ // middle of a code point. By consuming one code unit the parser may get
+ // "in sync" after a few code units.
+ ++__first_;
+ return __replacement_character;
+ }
+
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ // Based on the number of leading 1 bits the number of code units in the
+ // code point can be determined. See
+ // https://en.wikipedia.org/wiki/UTF-8#Encoding
+ switch (std::countl_one(static_cast<unsigned char>(*__first_))) {
+ case 0:
+ return {0, static_cast<unsigned char>(*__first_++)};
+
+ case 2:
+ if (__last_ - __first_ < 2) [[unlikely]]
+ break;
+
+ if (__unicode::__is_continuation(__first_ + 1, 1)) {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x1f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return {0, __value};
+ }
+ break;
+
+ case 3:
+ if (__last_ - __first_ < 3) [[unlikely]]
+ break;
+
+ if (__unicode::__is_continuation(__first_ + 1, 2)) {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x0f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ return {0, __value};
+ }
+ break;
+
+ case 4:
+ if (__last_ - __first_ < 4) [[unlikely]]
+ break;
+
+ if (__unicode::__is_continuation(__first_ + 1, 3)) {
+ char32_t __value = static_cast<unsigned char>(*__first_++) & 0x07;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+ __value <<= 6;
+ __value |= static_cast<unsigned char>(*__first_++) & 0x3f;
+
+ if (__value > 0x10FFFF) // Outside the valid Unicode range?
+ return {4, __value};
+
+ return {0, __value};
+ }
+ break;
+ }
+ // An invalid number of leading ones can be garbage or a code unit in the
+ // middle of a code point. By consuming one code unit the parser may get
+ // "in sync" after a few code units.
+ return {1, static_cast<unsigned char>(*__first_++)};
+ }
+# endif // _LIBCPP_STD_VER > 20
+
+private:
+ const char* __first_;
+ const char* __last_;
+};
+
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_high(wchar_t __value) {
+ return __value >= 0xd800 && __value <= 0xdbff;
+}
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __is_surrogate_pair_low(wchar_t __value) {
+ return __value >= 0xdc00 && __value <= 0xdfff;
+}
+
+/// This specialization depends on the size of wchar_t
+/// - 2 UTF-16 (for example Windows and AIX)
+/// - 4 UTF-32 (for example Linux)
+template <>
+class __code_point_view<wchar_t> {
+public:
+ static_assert(sizeof(wchar_t) == 2 || sizeof(wchar_t) == 4, "sizeof(wchar_t) has a not implemented value");
+
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const wchar_t* __first, const wchar_t* __last)
+ : __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const wchar_t* __position() const noexcept { return __first_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ if constexpr (sizeof(wchar_t) == 2) {
+ char32_t __result = *__first_++;
+ // Is the code unit part of a surrogate pair? See
+ // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+ if (__result >= 0xd800 && __result <= 0xDfff) {
+ // Malformed Unicode.
+ if (__first_ == __last_) [[unlikely]]
+ return __replacement_character;
+
+ __result -= 0xd800;
+ __result <<= 10;
+ __result += *__first_++ - 0xdc00;
+ __result += 0x10000;
+ }
+ return __result;
+
+ } else if constexpr (sizeof(wchar_t) == 4) {
+ char32_t __result = *__first_++;
+ if (__result > 0x10FFFF) [[unlikely]]
+ return __replacement_character;
+ return __result;
+ } else {
+ __libcpp_unreachable();
+ }
+ }
+
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ char32_t __result = *__first_++;
+ if constexpr (sizeof(wchar_t) == 2) {
+ // https://en.wikipedia.org/wiki/UTF-16#U+D800_to_U+DFFF
+ if (__is_surrogate_pair_high(__result)) {
+ // Malformed Unicode.
+ if (__first_ == __last_ || !__is_surrogate_pair_low(*(__first_ + 1))) [[unlikely]]
+ return {1, __result};
+
+ __result -= 0xd800;
+ __result <<= 10;
+ __result += *__first_++ - 0xdc00;
+ __result += 0x10000;
+ } else if (__is_surrogate_pair_low(__result))
+ // A code point shouldn't start with the low surrogate pair
+ return {1, __result};
+ } else {
+ if (__result > 0x10FFFF) [[unlikely]]
+ return {1, __result};
+ }
+
+ return {0, __result};
+ }
+# endif // _LIBCPP_STD_VER > 20
+
+private:
+ const wchar_t* __first_;
+ const wchar_t* __last_;
+};
+# endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+
+_LIBCPP_HIDE_FROM_ABI constexpr bool __at_extended_grapheme_cluster_break(
+ bool& __ri_break_allowed,
+ bool __has_extened_pictographic,
+ __extended_grapheme_custer_property_boundary::__property __prev,
+ __extended_grapheme_custer_property_boundary::__property __next) {
+ using __extended_grapheme_custer_property_boundary::__property;
+
+ __has_extened_pictographic |= __prev == __property::__Extended_Pictographic;
+
+ // https://www.unicode.org/reports/tr29/tr29-39.html#Grapheme_Cluster_Boundary_Rules
+
+ // *** Break at the start and end of text, unless the text is empty. ***
+
+ _LIBCPP_ASSERT(__prev != __property::__sot, "should be handled in the constructor"); // GB1
+ _LIBCPP_ASSERT(__prev != __property::__eot, "should be handled by our caller"); // GB2
+
+ // *** Do not break between a CR and LF. Otherwise, break before and after controls. ***
+ if (__prev == __property::__CR && __next == __property::__LF) // GB3
+ return false;
+
+ if (__prev == __property::__Control || __prev == __property::__CR || __prev == __property::__LF) // GB4
+ return true;
+
+ if (__next == __property::__Control || __next == __property::__CR || __next == __property::__LF) // GB5
+ return true;
+
+ // *** Do not break Hangul syllable sequences. ***
+ if (__prev == __property::__L &&
+ (__next == __property::__L || __next == __property::__V || __next == __property::__LV ||
+ __next == __property::__LVT)) // GB6
+ return false;
+
+ if ((__prev == __property::__LV || __prev == __property::__V) &&
+ (__next == __property::__V || __next == __property::__T)) // GB7
+ return false;
+
+ if ((__prev == __property::__LVT || __prev == __property::__T) && __next == __property::__T) // GB8
+ return false;
+
+ // *** Do not break before extending characters or ZWJ. ***
+ if (__next == __property::__Extend || __next == __property::__ZWJ)
+ return false; // GB9
+
+ // *** Do not break before SpacingMarks, or after Prepend characters. ***
+ if (__next == __property::__SpacingMark) // GB9a
+ return false;
+
+ if (__prev == __property::__Prepend) // GB9b
+ return false;
+
+ // *** Do not break within emoji modifier sequences or emoji zwj sequences. ***
+
+ // GB11 \p{Extended_Pictographic} Extend* ZWJ x \p{Extended_Pictographic}
+ //
+ // Note that several parts of this rule are matched by GB9: Any x (Extend | ZWJ)
+ // - \p{Extended_Pictographic} x Extend
+ // - Extend x Extend
+ // - \p{Extended_Pictographic} x ZWJ
+ // - Extend x ZWJ
+ //
+ // So the only case left to test is
+ // - \p{Extended_Pictographic}' x ZWJ x \p{Extended_Pictographic}
+ // where \p{Extended_Pictographic}' is stored in __has_extened_pictographic
+ if (__has_extened_pictographic && __prev == __property::__ZWJ && __next == __property::__Extended_Pictographic)
+ return false;
+
+ // *** Do not break within emoji flag sequences ***
+
+ // That is, do not break between regional indicator (RI) symbols if there
+ // is an odd number of RI characters before the break point.
+
+ if (__prev == __property::__Regional_Indicator && __next == __property::__Regional_Indicator) { // GB12 + GB13
+ __ri_break_allowed = !__ri_break_allowed;
+ return __ri_break_allowed;
+ }
+
+ // *** Otherwise, break everywhere. ***
+ return true; // GB999
+}
+
+/// Helper class to extract an extended grapheme cluster from a Unicode character range.
+///
+/// This function is used to determine the column width of an extended grapheme
+/// cluster. In order to do that only the first code point is evaluated.
+/// Therefore only this code point is extracted.
+template <class _CharT>
+class __extended_grapheme_cluster_view {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __extended_grapheme_cluster_view(const _CharT* __first, const _CharT* __last)
+ : __code_point_view_(__first, __last),
+ __next_code_point_(__code_point_view_.__consume()),
+ __next_prop_(__extended_grapheme_custer_property_boundary::__get_property(__next_code_point_)) {}
+
+ struct __cluster {
+ /// The first code point of the extended grapheme cluster.
+ ///
+ /// The first code point is used to estimate the width of the extended
+ /// grapheme cluster.
+ char32_t __code_point_;
+
+ /// Points one beyond the last code unit in the extended grapheme cluster.
+ ///
+ /// It's expected the caller has the start position and thus can determine
+ /// the code unit range of the extended grapheme cluster.
+ const _CharT* __last_;
+ };
+
+ _LIBCPP_HIDE_FROM_ABI constexpr __cluster __consume() {
+ _LIBCPP_ASSERT(
+ __next_prop_ != __extended_grapheme_custer_property_boundary::__property::__eot,
+ "can't move beyond the end of input");
+ char32_t __code_point = __next_code_point_;
+ if (!__code_point_view_.__at_end())
+ return {__code_point, __get_break()};
+
+ __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
+ return {__code_point, __code_point_view_.__position()};
+ }
+
+private:
+ __code_point_view<_CharT> __code_point_view_;
+
+ char32_t __next_code_point_;
+ __extended_grapheme_custer_property_boundary::__property __next_prop_;
+
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __get_break() {
+ bool __ri_break_allowed = true;
+ bool __has_extened_pictographic = false;
+ while (true) {
+ const _CharT* __result = __code_point_view_.__position();
+ __extended_grapheme_custer_property_boundary::__property __prev = __next_prop_;
+ if (__code_point_view_.__at_end()) {
+ __next_prop_ = __extended_grapheme_custer_property_boundary::__property::__eot;
+ return __result;
+ }
+ __next_code_point_ = __code_point_view_.__consume();
+ __next_prop_ = __extended_grapheme_custer_property_boundary::__get_property(__next_code_point_);
+
+ __has_extened_pictographic |=
+ __prev == __extended_grapheme_custer_property_boundary::__property::__Extended_Pictographic;
+
+ if (__at_extended_grapheme_cluster_break(__ri_break_allowed, __has_extened_pictographic, __prev, __next_prop_))
+ return __result;
+ }
+ }
+};
+
+template <class _CharT>
+__extended_grapheme_cluster_view(const _CharT*, const _CharT*) -> __extended_grapheme_cluster_view<_CharT>;
+
+# else // _LIBCPP_HAS_NO_UNICODE
+
+// For ASCII every character is a "code point".
+// This makes it easier to write code agnostic of the _LIBCPP_HAS_NO_UNICODE define.
+template <class _CharT>
+class __code_point_view {
+public:
+ _LIBCPP_HIDE_FROM_ABI constexpr explicit __code_point_view(const _CharT* __first, const _CharT* __last)
+ : __first_(__first), __last_(__last) {}
+
+ _LIBCPP_HIDE_FROM_ABI constexpr bool __at_end() const noexcept { return __first_ == __last_; }
+ _LIBCPP_HIDE_FROM_ABI constexpr const _CharT* __position() const noexcept { return __first_; }
+
+ _LIBCPP_HIDE_FROM_ABI constexpr char32_t __consume() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+ return *__first_++;
+ }
+
+# if _LIBCPP_STD_VER > 20
+ _LIBCPP_HIDE_FROM_ABI constexpr __consume_p2286_result __consume_p2286() noexcept {
+ _LIBCPP_ASSERT(__first_ != __last_, "can't move beyond the end of input");
+
+ return {0, std::make_unsigned_t<_CharT>(*__first_++)};
+ }
+# endif // _LIBCPP_STD_VER > 20
+
+private:
+ const _CharT* __first_;
+ const _CharT* __last_;
+};
+
+# endif // _LIBCPP_HAS_NO_UNICODE
+
+} // namespace __unicode
+
+#endif //_LIBCPP_STD_VER > 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FORMAT_UNICODE_H