Can anyone tell me if, when compiling a c++ program, does g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 change ints to long ints? if so, how can this be changed? If not, do I just overload operator long? Is it just like overloading operator uint32_t/uint64_t? It seems like a different type of typecasting (no pun intended).
this is causing the errors:
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()
Try this variation:
since you’ve provided conversions to all manner of unsigned types, but not to signed int.
And yes, you can define an implicit conversion to
long intjust be definingoperator longin the same manner as all the other conversions.Finally, please note that your choice of structure name is reserved by POSIX, and likely to conflict with future versions of the standard library header
stdint.h.