// -*- 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 Out, class charT> class basic_format_context;
  using format_context = basic_format_context<unspecified, char>;
  using wformat_context = basic_format_context<unspecified, wchar_t>;

  // [format.args], class template basic_format_args
  template<class Context> class basic_format_args;
  using format_args = basic_format_args<format_context>;
  using wformat_args = basic_format_args<wformat_context>;

  // [format.fmt.string], class template basic_format_string
  template<class charT, class... Args>
    struct basic_format_string {                                // since C++23, exposition only before C++23
    private:
      basic_string_view<charT> str;                             // exposition only

    public:
      template<class T> consteval basic_format_string(const T& s);
      basic_format_string(runtime-format-string<charT> s) noexcept : str(s.str) {}   // since C++26

      constexpr basic_string_view<charT> get() const noexcept { return str; }
    };
  template<class... Args>
    using format_string =                                       // since C++23, exposition only before C++23
      basic_format_string<char, type_identity_t<Args>...>;
  template<class... Args>
    using wformat_string =                                      // since C++23, exposition only before C++23
      basic_format_string<wchar_t, type_identity_t<Args>...>;

  template<class charT> struct runtime-format-string {          // since C++26, exposition-only
  private:
    basic_string_view<charT> str;                               // exposition-only

  public:
    runtime-format-string(basic_string_view<charT> s) noexcept : str(s) {}

    runtime-format-string(const runtime-format-string&) = delete;
    runtime-format-string& operator=(const runtime-format-string&) = delete;
  };

  runtime-format-string<char> runtime_format(string_view fmt) noexcept {
    return fmt;
  }
  runtime-format-string<wchar_t> runtime_format(wstring_view fmt) noexcept {
    return fmt;
  }

  // [format.functions], formatting functions
  template<class... Args>
    string format(format-string<Args...> fmt, Args&&... args);
  template<class... Args>
    wstring format(wformat-string<Args...> fmt, Args&&... args);
  template<class... Args>
    string format(const locale& loc, format-string<Args...> fmt, Args&&... args);
  template<class... Args>
    wstring format(const locale& loc, wformat-string<Args...> 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<class Out, class... Args>
    Out format_to(Out out, format-string<Args...> fmt, Args&&... args);
  template<class Out, class... Args>
    Out format_to(Out out, wformat-string<Args...> fmt, Args&&... args);
  template<class Out, class... Args>
    Out format_to(Out out, const locale& loc, format-string<Args...> fmt, Args&&... args);
  template<class Out, class... Args>
    Out format_to(Out out, const locale& loc, wformat-string<Args...> fmt, Args&&... args);

  template<class Out>
    Out vformat_to(Out out, string_view fmt, format_args args);
  template<class Out>
    Out vformat_to(Out out, wstring_view fmt, wformat_args args);
  template<class Out>
    Out vformat_to(Out out, const locale& loc, string_view fmt,
                   format_args char> args);
  template<class Out>
    Out vformat_to(Out out, const locale& loc, wstring_view fmt,
                   wformat_args args);

  template<class Out> struct format_to_n_result {
    Out out;
    iter_difference_t<Out> size;
  };
  template<class Out, class... Args>
    format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
                                        format-string<Args...> fmt, Args&&... args);
  template<class Out, class... Args>
    format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
                                        wformat-string<Args...> fmt, Args&&... args);
  template<class Out, class... Args>
    format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
                                        const locale& loc, format-string<Args...> fmt,
                                        Args&&... args);
  template<class Out, class... Args>
    format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n,
                                        const locale& loc, wformat-string<Args...> fmt,
                                        Args&&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     