From 3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Sat, 11 Jul 2026 22:48:30 +0800 Subject: lib: establish Zircon libc++ and KTL foundation --- third_party/libcxx/include/c++/v1/format | 267 +++++++++++++++++++++++++++++++ 1 file changed, 267 insertions(+) create mode 100644 third_party/libcxx/include/c++/v1/format (limited to 'third_party/libcxx/include/c++/v1/format') diff --git a/third_party/libcxx/include/c++/v1/format b/third_party/libcxx/include/c++/v1/format new file mode 100644 index 0000000..7ff619f --- /dev/null +++ b/third_party/libcxx/include/c++/v1/format @@ -0,0 +1,267 @@ +// -*- 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 +#define _LIBCPP_FORMAT + +/* + +namespace std { + // [format.context], class template basic_format_context + template class basic_format_context; + using format_context = basic_format_context; + using wformat_context = basic_format_context; + + // [format.args], class template basic_format_args + template class basic_format_args; + using format_args = basic_format_args; + using wformat_args = basic_format_args; + + // [format.fmt.string], class template basic_format_string + template + struct basic_format_string { // since C++23, exposition only before C++23 + private: + basic_string_view str; // exposition only + + public: + template consteval basic_format_string(const T& s); + basic_format_string(dynamic-format-string s) noexcept : str(s.str) {} // since C++26 + + constexpr basic_string_view get() const noexcept { return str; } + }; + template + using format_string = // since C++23, exposition only before C++23 + basic_format_string...>; + template + using wformat_string = // since C++23, exposition only before C++23 + basic_format_string...>; + + template struct dynamic-format-string { // since C++26, exposition-only + private: + basic_string_view str; // exposition-only + + public: + dynamic-format-string(basic_string_view s) noexcept : str(s) {} + + dynamic-format-string(const dynamic-format-string&) = delete; + dynamic-format-string& operator=(const dynamic-format-string&) = delete; + }; + + dynamic-format-string dynamic_format(string_view fmt) noexcept { + return fmt; + } + dynamic-format-string dynamic_format(wstring_view fmt) noexcept { + return fmt; + } + + // [format.functions], formatting functions + template + string format(format-string fmt, Args&&... args); + template + wstring format(wformat-string fmt, Args&&... args); + template + string format(const locale& loc, format-string fmt, Args&&... args); + template + wstring format(const locale& loc, wformat-string fmt, Args&&... args); + + string vformat(string_view fmt, format_args args); + wstring vformat(wstring_view fmt, wformat_args args); + string vformat(const locale& loc, string_view fmt, format_args args); + wstring vformat(const locale& loc, wstring_view fmt, wformat_args args); + + template + Out format_to(Out out, format-string fmt, Args&&... args); + template + Out format_to(Out out, wformat-string fmt, Args&&... args); + template + Out format_to(Out out, const locale& loc, format-string fmt, Args&&... args); + template + Out format_to(Out out, const locale& loc, wformat-string fmt, Args&&... args); + + template + Out vformat_to(Out out, string_view fmt, format_args args); + template + Out vformat_to(Out out, wstring_view fmt, wformat_args args); + template + Out vformat_to(Out out, const locale& loc, string_view fmt, + format_args char> args); + template + Out vformat_to(Out out, const locale& loc, wstring_view fmt, + wformat_args args); + + template struct format_to_n_result { + Out out; + iter_difference_t size; + }; + template + format_to_n_result format_to_n(Out out, iter_difference_t n, + format-string fmt, Args&&... args); + template + format_to_n_result format_to_n(Out out, iter_difference_t n, + wformat-string fmt, Args&&... args); + template + format_to_n_result format_to_n(Out out, iter_difference_t n, + const locale& loc, format-string fmt, + Args&&... args); + template + format_to_n_result format_to_n(Out out, iter_difference_t n, + const locale& loc, wformat-string fmt, + Args&&... args); + + template + size_t formatted_size(format-string fmt, Args&&... args); + template + size_t formatted_size(wformat-string fmt, Args&&... args); + template + size_t formatted_size(const locale& loc, format-string fmt, Args&&... args); + template + size_t formatted_size(const locale& loc, wformat-string fmt, Args&&... args); + + // [format.formatter], formatter + template struct formatter; + + template + constexpr bool enable_nonlocking_formatter_optimization = false; // since C++23 + + // [format.parse.ctx], class template basic_format_parse_context + template class basic_format_parse_context; + using format_parse_context = basic_format_parse_context; + using wformat_parse_context = basic_format_parse_context; + + // [format.range], formatting of ranges + // [format.range.fmtkind], variable template format_kind + enum class range_format { // since C++23 + disabled, + map, + set, + sequence, + string, + debug_string + }; + + template + constexpr unspecified format_kind = unspecified; // since C++23 + + template + requires same_as> + constexpr range_format format_kind = see below; // since C++23 + + // [format.range.formatter], class template range_formatter + template + requires same_as, T> && formattable + class range_formatter; // since C++23 + + // [format.range.fmtdef], class template range-default-formatter + template + struct range-default-formatter; // exposition only, since C++23 + + // [format.range.fmtmap], [format.range.fmtset], [format.range.fmtstr], + // specializations for maps, sets, and strings + template + requires (format_kind != range_format::disabled) && + formattable, charT> + struct formatter : range-default-formatter, R, charT> { }; // since C++23 + + // [format.arguments], arguments + // [format.arg], class template basic_format_arg + template class basic_format_arg; + + template + see below visit_format_arg(Visitor&& vis, basic_format_arg arg); // Deprecated in C++26 + + // [format.arg.store], class template format-arg-store + template struct format-arg-store; // exposition only + + template + format-arg-store + make_format_args(Args&... args); + template + format-arg-store + make_wformat_args(Args&... args); + + // [format.error], class format_error + class format_error; +} + +*/ + +#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) +# include <__cxx03/__config> +#else +# include <__config> + +# if _LIBCPP_STD_VER >= 20 +# include <__format/buffer.h> +# include <__format/concepts.h> +# include <__format/container_adaptor.h> +# include <__format/enable_insertable.h> +# include <__format/escaped_output_table.h> +# include <__format/extended_grapheme_cluster_table.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_functions.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_impl.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/formatter_tuple.h> +# include <__format/parser_std_format_spec.h> +# include <__format/range_default_formatter.h> +# include <__format/range_formatter.h> +# include <__format/unicode.h> +# include <__fwd/format.h> +# endif + +# include + +# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 23 +# include +# endif + +# if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include +# include + +# if _LIBCPP_HAS_WIDE_CHARACTERS +# include +# endif +# endif +#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) + +#endif // _LIBCPP_FORMAT -- cgit v1.2.3