標準ライブラリヘッダ <format>
提供: cppreference.com
このヘッダは書式化ライブラリの一部です。
クラス | ||
(C++20) | 指定された型のための書式化ルールを定義するクラステンプレート (クラステンプレート) | |
(C++20)(C++20)(C++20) | 書式化文字列のパーサの状態 (クラステンプレート) | |
(C++20)(C++20)(C++20) | すべての書式化引数と出力イテレータを含む書式化の状態 (クラステンプレート) | |
(C++20) | ユーザ定義フォーマッタのための書式化引数へのアクセスを提供するクラステンプレート (クラステンプレート) | |
(C++20)(C++20)(C++20)(C++20) | すべての書式化引数へのアクセスを提供するクラス (クラステンプレート) | |
(C++20) | 書式化のエラー時に投げられる例外の型 (クラス) | |
関数 | ||
(C++20) | 引数の書式化された表現を新しい文字列に格納します (関数テンプレート) | |
(C++20) | 引数の書式化された表現を出力イテレータを通して書き出します (関数テンプレート) | |
(C++20) | 引数の書式化された表現を出力イテレータを通して指定されたサイズを超えないように書き出します (関数テンプレート) | |
(C++20) | 引数の書式化された表現を格納するために必要な文字数を調べます (関数テンプレート) | |
(C++20) | 型消去された引数表現を用いる非テンプレート版の std::format (関数) | |
(C++20) | 型消去された引数表現を用いる非テンプレート版の std::format_to (関数テンプレート) | |
(C++20) | ユーザ定義フォーマッタのための引数 visit インタフェース (関数テンプレート) | |
(C++20)(C++20) | format_args に変換可能な、すべての書式化引数を参照する、型消去されたオブジェクトを作成します (関数テンプレート) |
[編集]概要
namespace std {// formatting functionstemplate<class... Args> string format(string_view fmt, const Args&... args);template<class... Args> wstring format(wstring_view fmt, const Args&... args);template<class... Args> string format(const locale& loc, string_view fmt, const Args&... args);template<class... Args> wstring format(const locale& loc, wstring_view fmt, const 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, string_view fmt, const Args&... args);template<class Out, class... Args> Out format_to(Out out, wstring_view fmt, const Args&... args);template<class Out, class... Args> Out format_to(Out out, const locale& loc, string_view fmt, const Args&... args);template<class Out, class... Args> Out format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args); template<class Out> Out vformat_to(Out out, string_view fmt, format_args_t<type_identity_t<Out>, char> args);template<class Out> Out vformat_to(Out out, wstring_view fmt, format_args_t<type_identity_t<Out>, wchar_t> args);template<class Out> Out vformat_to(Out out, const locale& loc, string_view fmt, format_args_t<type_identity_t<Out>, char> args);template<class Out> Out vformat_to(Out out, const locale& loc, wstring_view fmt, format_args_t<type_identity_t<Out>, wchar_t> 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, string_view fmt, const Args&... args);template<class Out, class... Args> format_to_n_result<Out> format_to_n(Out out, iter_difference_t<Out> n, wstring_view fmt, const 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, string_view fmt, const 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, wstring_view fmt, const Args&... args); template<class... Args> size_t formatted_size(string_view fmt, const Args&... args);template<class... Args> size_t formatted_size(wstring_view fmt, const Args&... args);template<class... Args> size_t formatted_size(const locale& loc, string_view fmt, const Args&... args);template<class... Args> size_t formatted_size(const locale& loc, wstring_view fmt, const Args&... args); // formattertemplate<class T, class charT =char>struct formatter; // class template basic_format_parse_contexttemplate<class charT>class basic_format_parse_context;using format_parse_context = basic_format_parse_context<char>;using wformat_parse_context = basic_format_parse_context<wchar_t>; 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>; // arguments// class template basic_format_argtemplate<class Context>class basic_format_arg; template<class Visitor, class Context>/* see description */ visit_format_arg(Visitor&& vis, basic_format_arg<Context> arg); // class template format-arg-storetemplate<class Context, class... Args>struct/*format-arg-store*/;// exposition only template<class Context = format_context, class... Args>/*format-arg-store*/<Context, Args...> make_format_args(const Args&... args);template<class... Args>/*format-arg-store*/<wformat_context, Args...> make_wformat_args(const Args&... args); // class template basic_format_argstemplate<class Context>class basic_format_args;using format_args = basic_format_args<format_context>;using wformat_args = basic_format_args<wformat_context>; template<class Out, class charT>using format_args_t = basic_format_args<basic_format_context<Out, charT>>; // class format_errorclass format_error;}
[編集]クラステンプレート std::basic_format_parse_context
namespace std {template<class charT>class basic_format_parse_context {public:using char_type = charT;using const_iterator =typename basic_string_view<charT>::const_iterator;using iterator = const_iterator; private: iterator begin_;// exposition only iterator end_;// exposition onlyenum indexing { unknown, manual, automatic };// exposition only indexing indexing_;// exposition only size_t next_arg_id_;// exposition only size_t num_args_;// exposition only public:constexprexplicit basic_format_parse_context(basic_string_view<charT> fmt, size_t num_args =0)noexcept; basic_format_parse_context(const basic_format_parse_context&)= delete; basic_format_parse_context& operator=(const basic_format_parse_context&)= delete; constexpr const_iterator begin()constnoexcept;constexpr const_iterator end()constnoexcept;constexprvoid advance_to(const_iterator it); constexpr size_t next_arg_id();constexprvoid check_arg_id(size_t id);};}
[編集]クラステンプレート std::basic_format_context
namespace std {template<class Out, class charT>class basic_format_context { basic_format_args<basic_format_context> args_;// exposition only Out out_;// exposition only public:using iterator = Out;using char_type = charT;template<class T>using formatter_type = formatter<T, charT>; basic_format_arg<basic_format_context> arg(size_t id)const;std::locale locale(); iterator out();void advance_to(iterator it);};}
[編集]クラステンプレート std::basic_format_arg
namespace std {template<class Context>class basic_format_arg {public:class handle; private:using char_type =typename Context::char_type;// exposition only variant<monostate, bool, char_type, int, unsignedint, longlongint, unsignedlonglongint, float, double, longdouble, const char_type*, basic_string_view<char_type>, constvoid*, handle> value;// exposition only template<class T>explicit basic_format_arg(const T& v)noexcept;// exposition onlyexplicit basic_format_arg(float n)noexcept;// exposition onlyexplicit basic_format_arg(double n)noexcept;// exposition onlyexplicit basic_format_arg(longdouble n)noexcept;// exposition onlyexplicit basic_format_arg(const char_type* s);// exposition only template<class traits>explicit basic_format_arg( basic_string_view<char_type, traits> s)noexcept;// exposition only template<class traits, class Allocator>explicit basic_format_arg(const basic_string<char_type, traits, Allocator>& s)noexcept;// exposition only explicit basic_format_arg(nullptr_t)noexcept;// exposition only template<class T>explicit basic_format_arg(const T* p)noexcept;// exposition only public: basic_format_arg()noexcept; explicit operator bool()constnoexcept;};}
[編集]クラス std::basic_format_arg::handle
namespace std {template<class Context>class basic_format_arg<Context>::handle{constvoid* ptr_;// exposition onlyvoid(*format_)(basic_format_parse_context<char_type>&, Context&, constvoid*);// exposition only template<class T>explicit handle(const T& val)noexcept;// exposition only friendclass basic_format_arg<Context>;// exposition only public:void format(basic_format_parse_context<char_type>&, Context& ctx)const;};}
[編集]クラステンプレート format-arg-store
namespace std {template<class Context, class... Args>struct/*format-arg-store*/{// exposition only array<basic_format_arg<Context>, sizeof...(Args)> args;};}
[編集]クラステンプレート std::basic_format_args
namespace std {template<class Context>class basic_format_args { size_t size_;// exposition onlyconst basic_format_arg<Context>* data_;// exposition only public: basic_format_args()noexcept; template<class... Args> basic_format_args(const/*format-arg-store*/<Context, Args...>& store)noexcept; basic_format_arg<Context> get(size_t i)constnoexcept;};}
[編集]クラス std::format_error
namespace std {class format_error :public runtime_error {public:explicit format_error(const string& what_arg);explicit format_error(constchar* what_arg);};}