Ubuntu 中的"int"
"int" in Ubuntu
有人能告诉我,在编译c++程序时,g++(Ubuntu/Linaro 4.4.4-14ubuntu5(4.4.5是否将int
s更改为long int
s吗?如果是这样的话,该如何改变呢?如果没有,我只是超载operator long
吗?它是否就像重载运算符uint32_t/uint64_t一样?这似乎是一种不同类型的打字(并非双关语(。
这导致了错误:
uint128_t.h: In function ‘std::ostream& operator<<(std::ostream&,
uint128_t)’:
uint128_t.h:593: error: conversion from ‘uint128_t’ to ‘long int’ is
ambiguous
uint128_t.h:83: note: candidates are: uint128_t::operator uint64_t()
uint128_t.h:79: note: uint128_t::operator uint32_t()
uint128_t.h:75: note: uint128_t::operator uint16_t()
uint128_t.h:71: note: uint128_t::operator uint8_t()
uint128_t.h:67: note: uint128_t::operator int()
uint128_t.h:63: note: uint128_t::operator char()
uint128_t.h:59: note: uint128_t::operator bool()
试试这个变体:
out = "0123456789abcdef"[size_t(rhs % div)] + out;
因为您已经提供了对所有无符号类型的转换,但没有提供对有符号int.的转换
是的,您可以定义一个到long int
的隐式转换,只需以与所有其他转换相同的方式定义operator long
即可。
最后,请注意,您选择的结构名称由POSIX保留,并且可能与标准库头stdint.h
的未来版本冲突。
不,不是。int就是int就是int。它是一个独立于long int
的类型。至于您重载了哪些运算符,这完全取决于您想做什么。你还没有真正描述过。
但是,如果您想定义一个运算符来处理int
,那么您应该为int
重载它。如果您希望它在long int
上工作,请为此定义一个重载。
你想干什么?为什么要将uint128_t
传递给操作员,却询问int
和long int
?
相关文章:
- 没有显式声明的int[]中的foreach
- 为什么我无法更改"set<set>"循环中的值<int>
- 比较if语句中的数组值和int值
- 如何将文本文件的特定行读取到 int 类型的数组中C++?
- 为什么 'main' 函数中的局部 int 变量会自动初始化?
- 将字符串中的 int 转换为字母;
- C++ 中文件输入输出中的长长 v/s int
- 逐字读取文本文件中的每一行并转换为 int(无限循环或崩溃?
- c++default-int中的语法错误
- 数组中使用 int 中的位的不同元素数
- 获取INT中的数字数,而无需分开10
- 如何在给定范围内找到 std::set<pair<int、int> > 中的最大值?
- 当我们在int上进行操作时,结果是暂时存储在int中的结果
- 读取int中的数字并对其进行计数
- 存储在 int 中的指针
- 将字符串中的数字与 int 中的数字进行比较
- 终止将输入读取到int中的内容
- 如何确定int中的位数
- 设置无符号int中的最后“n”位
- 如何计算标准::向量<int>中的值总和