• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

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

    履歴 編集

    function
    <string>

    std::char_traits::to_int_type

    static int_type to_int_type(const char_type& c);             // C++03
    static constexpr int_type to_int_type(char_type c) noexcept; // C++11
    

    概要

    文字を数値に変換する。

    戻り値

    to_char_typeeq_int_typeの定義によって制約される文字eを返す。

    計算量

    定数時間

    #include <iostream>
    #include <string>
    
    int main()
    {
      int x = std::char_traits<char>::to_int_type('A');
      std::cout << std::hex << x << std::endl;
    }
    

    出力例

    41
    

    参照