最終更新日時(UTC):
が更新

履歴 編集

function
<format>

std::basic_format_arg::コンストラクタ(C++20)

namespace std {
  template<class Context>
  class basic_format_arg {
  private:
    using char_type = typename Context::char_type;                              // exposition only

    variant<monostate, bool, char_type,
            int, unsigned int, long long int, unsigned long long int,
            float, double, long double,
            const char_type*, basic_string_view<char_type>,
            const void*, handle> value;                                         // exposition only

    template<class T> explicit basic_format_arg(T& v) noexcept;                 // (2) exposition only

  public:
    basic_format_arg() noexcept; // (1)
  };
}

概要

  • (1): 空のbasic_format_argを構築する
  • (2): (説明専用)make_format_argsの内部で使用され、引数からbasic_format_argsを構築する。

テンプレートパラメーター制約

  • (2):
    • Tはフォーマットできる型であること

事前条件

  • (2): もし decay_t<T>char_type* または const char_type* である場合、 static_cast<const char_type*>(v) はヌル終端された char_type の配列を指すこと。

事後条件

  • (1): !(*this)

例外

投げない。

効果

  • (1): valuemonostateで初期化する。

  • (2): TDremove_const<T>として、以下の順にvalueを初期化する。

    • TDboolなら、vで初期化
    • TDcharかつchar_typewchar_tなら、valuestatic_cast<wchar_t>(v)で初期化
    • TDcharかつchar_typewchar_tなら、valuestatic_cast<wchar_t>(static_cast<unsigned char>(v))で初期化
    • TDが符号つき整数型かつsizeof(TD) <= sizeof(int)なら、valuestatic_cast<int>(v)で初期化
    • TDが符号なし整数型かつsizeof(TD) <= sizeof(unsigned int)なら、valuestatic_cast<unsigned int>(v)で初期化
    • TDが符号つき整数型かつsizeof(TD) <= sizeof(long long int)なら、valuestatic_cast<long long int>(v)で初期化
    • TDが符号なし整数型かつsizeof(TD) <= sizeof(unsigned long long int)なら、valuestatic_cast<unsigned long long int>(v)で初期化
    • TDが浮動小数点数なら、vで初期化
    • TDbasic_string_viewまたはbasic_stringの特殊化で、TD::value_typechar_typeと等しければ、valuebasic_string_view<char_type>(v.data(), v.size())で初期化
    • decay_t<T>char_type*または const char_type* なら、valuestatic_cast<const char_type*>(v)で初期化
    • is_void_v<remove_pointer_t<TD>>true、またはis_null_pointer_v<TD>trueなら、valuestatic_cast<const void*>(v)で初期化
    • それ以外なら、valuehandle(v)で初期化

バージョン

言語

  • C++20

処理系

参照