标准库头文件 <charconv>

来自cppreference.com
< cpp‎ | header
 
 
 

指定 std::to_charsstd::from_chars 所用的格式
(枚举)

函数

转换字符序列到整数或浮点值
(函数)
(C++17)
转换整数或浮点值到字符序列
(函数)

概要

namespace std {
    // 基本数值转换所用的浮点格式
    enum class chars_format {
        scientific = /*未指明*/ ,
        fixed = /*未指明*/ ,
        hex = /*未指明*/ ,
        general = fixed | scientific
    };
    // 基本数值输出转换
    struct to_chars_result {
        char* ptr;
        errc ec;
    };
    to_chars_result to_chars(char* first, char* last,
                             /*见描述*/ value, int base = 10);
    to_chars_result to_chars(char* first, char* last, float value);
    to_chars_result to_chars(char* first, char* last, double value);
    to_chars_result to_chars(char* first, char* last, long double value);
    to_chars_result to_chars(char* first, char* last, float value,
                             chars_format fmt);
    to_chars_result to_chars(char* first, char* last, double value, 
                             chars_format fmt);
    to_chars_result to_chars(char* first, char* last, long double value,
                             chars_format fmt);
    to_chars_result to_chars(char* first, char* last, float value,
                             chars_format fmt, int precision);
    to_chars_result to_chars(char* first, char* last, double value,
                             chars_format fmt, int precision);
    to_chars_result to_chars(char* first, char* last, long double value,
                             chars_format fmt, int precision);
    // 基本数值输入转换
    struct from_chars_result {
        const char* ptr;
        errc ec;
    };
    from_chars_result from_chars(const char* first, const char* last,
                                 /*见描述*/ & value, int base = 10);
    from_chars_result from_chars(const char* first, const char* last, float& value,
                                 chars_format fmt = chars_format::general);
    from_chars_result from_chars(const char* first, const char* last, double& value,
                                 chars_format fmt = chars_format::general);
    from_chars_result from_chars(const char* first, const char* last, long double& value,
                                 chars_format fmt = chars_format::general);
}