Skip to content

Latest commit

 

History

History
68 lines (51 loc) · 1.63 KB

runtime_format.md

File metadata and controls

68 lines (51 loc) · 1.63 KB

runtime_format

  • format[meta header]
  • function template[meta id-type]
  • std[meta namespace]
  • cpp26[meta cpp]
namespace std {
  runtime-format-string<char>
    runtime_format(string_view fmt) noexcept;  // (1) C++26

  runtime-format-string<wchar_t>
    runtime_format(wstring_view fmt) noexcept; // (2) C++26
}
  • runtime-format-string[link runtime-format-string.md]
  • wstring_view[link /reference/string_view/basic_string_view.md]

概要

実行時文字列を書式文字列として使用できるようラップする。

このクラスは、std::stringstd::string_viewの文字列を、書式文字列としてstd::format()関数に指定するための型に変換する関数である。

戻り値

return fmt;

#include <print>

int main()
{
  std::string fmt = "{}";

  std::string s = std::format(std::runtime_format(fmt), "Hello");
  std::println(std::runtime_format(fmt), s);
}
  • std::runtime_format[color ff0000]
  • std::format[link format.md]

出力

Hello

バージョン

言語

  • C++26

処理系

関連項目

参照