C++ 参考手册
- C++11
- C++14
- C++17
- C++20
- C++ 编译器支持情况表
- 独立与宿主实现
- C++ 语言
- C++ 关键词
- 预处理器
- C++ 标准库头文件
- 具名要求
- 功能特性测试 (C++20)
- 工具库
- 类型支持(基本类型、RTTI、类型特性)
- 概念库 (C++20)
- 错误处理
- 动态内存管理
- 日期和时间工具
- 字符串库
- std::basic_string
- std::basic_string<CharT,Traits,Allocator>::npos
- std::basic_string<CharT,Traits,Allocator>::at
- std::hash (std::string, std::wstring, std::u16string, std::u32string, std::pmr::string, std::pmr::wstring, std::pmr::u16string, std::pmr::u32string)
- std::basic_string<CharT,Traits,Allocator>::assign
- std::basic_string<CharT,Traits,Allocator>::get_allocator
- std::basic_string<CharT,Traits,Allocator>::substr
- std::basic_string<CharT,Traits,Allocator>::basic_string
- std::basic_string<CharT,Traits,Allocator>::operator=
- std::basic_string<CharT,Traits,Allocator>::operator[]
- std::basic_string<CharT,Traits,Allocator>::front
- std::basic_string<CharT,Traits,Allocator>::back
- std::basic_string<CharT,Traits,Allocator>::data
- std::basic_string<CharT,Traits,Allocator>::c_str
- std::basic_string<CharT,Traits,Allocator>::operator basic_string_view
- std::basic_string<CharT,Traits,Allocator>::begin, std::basic_string<CharT,Traits,Allocator>::cbegin
- std::basic_string<CharT,Traits,Allocator>::end, std::basic_string<CharT,Traits,Allocator>::cend
- std::basic_string<CharT,Traits,Allocator>::rbegin, std::basic_string<CharT,Traits,Allocator>::crbegin
- std::basic_string<CharT,Traits,Allocator>::rend, std::basic_string<CharT,Traits,Allocator>::crend
- std::basic_string<CharT,Traits,Allocator>::empty
- std::basic_string<CharT,Traits,Allocator>::size, std::basic_string<CharT,Traits,Allocator>::length
- std::basic_string<CharT,Traits,Allocator>::max_size
- std::basic_string<CharT,Traits,Allocator>::reserve
- std::basic_string<CharT,Traits,Allocator>::capacity
- std::basic_string<CharT,Traits,Allocator>::shrink_to_fit
- std::basic_string<CharT,Traits,Allocator>::clear
- std::basic_string<CharT,Traits,Allocator>::insert
- std::basic_string<CharT,Traits,Allocator>::erase
- std::basic_string<CharT,Traits,Allocator>::push_back
- std::basic_string<CharT,Traits,Allocator>::pop_back
- std::basic_string<CharT,Traits,Allocator>::append
- std::basic_string<CharT,Traits,Allocator>::operator+=
- std::basic_string<CharT,Traits,Allocator>::compare
- std::basic_string<CharT,Traits,Allocator>::starts_with
- std::basic_string<CharT,Traits,Allocator>::ends_with
- std::basic_string<CharT,Traits,Allocator>::replace
- std::basic_string<CharT,Traits,Allocator>::copy
- std::basic_string<CharT,Traits,Allocator>::resize
- std::basic_string<CharT,Traits,Allocator>::swap
- std::basic_string<CharT,Traits,Allocator>::find
- std::basic_string<CharT,Traits,Allocator>::rfind
- std::basic_string<CharT,Traits,Allocator>::find_first_of
- std::basic_string<CharT,Traits,Allocator>::find_first_not_of
- std::basic_string<CharT,Traits,Allocator>::find_last_of
- std::basic_string<CharT,Traits,Allocator>::find_last_not_of
- std::operator+(std::basic_string)
- std::swap(std::basic_string)
- std::literals::string_literals::operator""s
- std::erase, std::erase_if (std::basic_string)
- operator<<,>>(std::basic_string)
- std::getline
- operator==,!=,<,<=,>,>=,<=>(std::basic_string)
- std::stoi, std::stol, std::stoll
- std::stoul, std::stoull
- std::stof, std::stod, std::stold
- std::to_string
- std::to_wstring
- std::basic_string 的推导指引
- std::basic_string_view
- 空终止字节字符串
- 空终止多字节字符串
- 空终止宽字符串
- std::char_traits
- 注释
- 容器库
- 迭代器库
- 范围库 (C++20)
- 算法库
- 数值库
- 输入/输出库
- 文件系统库
- 本地化库
- 正则表达式库
- 原子操作库
- 线程支持库
- 实验性 C++ 特性
- 有用的资源
- 索引
- std 符号索引
- 协程支持 (C++20)
- C++ 关键词
位置:首页 > C++ 参考手册 >字符串库 >std::basic_string > std::stoul, std::stoull
std::stoul, std::stoull
定义于头文件 <string>
|
||
unsigned long stoul( const std::string& str, std::size_t* pos = 0, int base = 10 ); unsigned long stoul( const std::wstring& str, std::size_t* pos = 0, int base = 10 ); |
(1) | (C++11 起) |
unsigned long long stoull( const std::string& str, std::size_t* pos = 0, int base = 10 ); unsigned long long stoull( const std::wstring& str, std::size_t* pos = 0, int base = 10 ); |
(2) | (C++11 起) |
转译字符串 str
中的无符号整数值。
舍弃所有空白符(以调用 isspace()
鉴别),直到找到首个非空白符,然后取尽可能多的字符组成底 n (其中 n=base )的无符号整数表示,并将它们转换成一个整数值。合法的无符号整数值由下列部分组成:
- (可选)正或负号
- (可选)指示八进制底的前缀(
0
)(仅当底为 8 或 0 时应用) - (可选)指示十六进制底的前缀(
0x
或0X
)(仅当底为 16 或 0 时应用) - 一个数字序列
底的合法集是 {0,2,3,...,36} 。合法数字集对于底 2 整数是 {0,1
},对于底3整数是 {0,1,2
} ,以此类推。对于大于 10
的底,合法数字包含字母字符,从对于底 11 整数的 Aa
到对于底36整数的 Zz
。忽略字符大小写。
当前安装的 C 本地环境可能接受另外的数字格式。
若 base 为 0 ,则自动检测数值进制:若前缀为 0
,则底为八进制,若前缀为 0x
或 0X
,则底为十六进制,否则底为十进制。
若符号是输入序列的一部分,则对从数字序列计算得来的数字值取反,如同用结果类型的一元减,它对无符号整数应用回卷规则。
若 pos
不是空指针,则转换函数内部的 ptr
指针会接收首个 str.c_str() 中未转换字符的地址,然后该字符的下标在计算后存储于 *pos
,给出转换所处理的字符数。
参数
str | - | 要转换的字符串 |
pos | - | 存储被处理字符数的整数的地址 |
base | - | 数字基底 |
返回值
转换到指定无符号整数类型的字符串。
异常
- 若不能进行转换则抛出 std::invalid_argument
- 若转换值会落在转换类型的范围之外,或底层函数( std::strtoul 或 std::strtoull )设 errno 为 ERANGE 则抛出 std::out_of_range 。
参阅
(C++11)(C++11)(C++11) |
转换字符串为有符号整数 (函数) |
(C++11)(C++11)(C++11) |
转换字符串为浮点值 (函数) |