标准库头文件 <charconv>

来自cppreference.com
< cpp‎ | header
 
 
 

[编辑]

指定 std::to_charsstd::from_chars 所用的格式
(枚举) [编辑]

[编辑] 函数

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

[编辑] 概要

namespace std {
  // 原始数值转换所用的浮点格式
  enum class chars_format {
    scientific = /*unspecified*/ ,
    fixed = /*unspecified*/ ,
    hex = /*unspecified*/ ,
    general = fixed | scientific
  };
  // 原始数值输入转换
  struct to_chars_result {
    char* ptr;
    errc ec;
  };
  to_chars_result to_chars(char* first, char* last, /*see description*/ 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,
                               /*see description*/ & 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);
}