On Tuesday, October 9, 2018 at 4:53:53 PM UTC-4, Öö Tiib wrote:
> On Tuesday, 9 October 2018 23:05:08 UTC+3, Daniel wrote:
> > Compiling on travis using g++ 4.8 and above (up to 8), and clang 3.8 and above (up to 6), on x64 and Ubuntu, I see std::numeric_limits<__int128>::is_specialized evaluate to false (unexpected.)
> >
>
> I remember there were some discussions about it few years ago.
> Perhaps in some of gcc mailing lists.
>
> My understanding of it was such that when the __int128 was introduced
> it was not extended integer type at first. Reason was that the compiler
> that had (and used) it could not immediately follow all requirements
> that standards imposed upon extended integer types. Once the support
> was implemented to comply with requirements it was made into extended
> integer type too.
>
Thanks for the pointer.
Following up on that, it seems that the g++ std::numeric_limits
specializations for __int128 are not defined when __STRICT_ANSI__ is defined,
which is the case when code is compiled with -std=c++NN rather than -
std=gnu++NN.
Given the existence of a 128 bit integer type, all I need is min() and max().
So a second question: would it be save to forgo std::numeric_limits and rely
on something like
template<typename T>
struct integer_traits
{
static const T __min = (((T)(-1) < 0) ?
(T)1 << (sizeof(T) * 8 - ((T)(-1) < 0)) : (T)0);
static const T __max = (((T)(-1) < 0) ?
(((((T)1 << ((sizeof(T) * 8 - ((T)(-1) < 0)) - 1)) - 1) << 1) + 1) : ~(T)0);
};
Thanks,
Daniel