> +unsigned clamp_dim(unsigned dim)
> +{
> + return std::min<unsigned long>(std::numeric_limits<long>::max(), dim);
> +}
>
> Why max "long" - the signedness of it confuses me. What is this clamping "dim"
> to?
>
> If sizeof(unsigned) < sizeof(long), this always returns "dim", so the only
> interesting case is if sizeof(unsigned) == sizeof(long), where this clamps dim
> in the bottom 1/2 of the unsigned ints. Intended?
That was the intent, yes. To clamp dim to the shared range of long and unsigned int.
> +unsigned clamp_dim(unsigned dim) :numeric_ limits< long>:: max(), dim);
> +{
> + return std::min<unsigned long>(std:
> +}
>
> Why max "long" - the signedness of it confuses me. What is this clamping "dim"
> to?
>
> If sizeof(unsigned) < sizeof(long), this always returns "dim", so the only
> interesting case is if sizeof(unsigned) == sizeof(long), where this clamps dim
> in the bottom 1/2 of the unsigned ints. Intended?
That was the intent, yes. To clamp dim to the shared range of long and unsigned int.