在 pthread_t 为数字的平台上,0 保证为无效值
On platforms where pthread_t is numeric, is 0 guaranteed to be an invalid value?
pthread_t
(由 pthread_self()
返回(是一种不透明的类型,但在某些平台上实际上是数字,例如 typedef
ed to unsigned long
。在这些平台上,0
是否是无效的pthread_t
值?-1
呢?
如果我想要一个pthread_t
或无效的值,我会使用 C++1y 中的boost::optional<pthread_t>
或std::optional<pthread_t>
。
这具有很少的开销(字节(,表示我想要的内容(此值可能是也可能不是pthread_t
(,并且不依赖于特定于平台的行为。
相关文章:
- 正在查找文档以获得PS4平台的C++中的设备信息
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 无法访问嵌套类.类的使用无效
- 如果用户输入无效,如何使用字符串变量-C++重复输入命令
- 如何解决错误:SCIP C++中的 SCIP 阶段无效 <10>
- 在没有参数列表的情况下使用模板名称"Event"无效,模板问题
- FFMPEG配置文件级别id大小无效
- 错误:从"int"到枚举c++的转换无效
- 如何修复此错误:className::className的无效使用
- 为什么将值返回函数传递给重载=运算符对运算符函数有效,而对其他运算符无效
- C++-模板嵌套类的引用初始化无效
- 错误:无效的预处理指令 #i 的意思是 #if?
- 多维数组 C++ 中数组下标的类型"int[int]"无效
- 在 C++ 中使用正则表达式错误时出现问题 括号表达式中的范围无效
- 从 'int' 到 'int*' CPP 的转换无效
- C/C++ - 查询平台相关的换行符(用于内存映射文件)
- 如何接受 [ENTER] 键作为无效输入并发送错误消息
- 由于无效的 ValidateRgn() 子窗口不会收到WM_PAINT消息
- 发行配置的无效配置参数在X64平台上独立执行
- 错误 MSB8007:项目 XXX 的平台无效。平台='x64'