lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] Specializing std::numeric_limits?


From: Greg Chicares
Subject: [lmi] Specializing std::numeric_limits?
Date: Sat, 6 Mar 2021 23:24:09 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

https://git.savannah.nongnu.org/cgit/lmi.git/commit/?h=odd/eraseme_limits
|
| Although it's assuredly possible to specialize std::numeric_limits for
| a UDT, it seems that almost nobody does.
|
| Perhaps this exercise shows that it's not generally advisable.

Vadim--Is std::numeric_limits as rarely specialized in practice as I
infer from the meagerness of stackexchange discussions on this topic?

At any rate, lmi's class template minmax was originally intended to provide
a "safe" cover for std::minmax_element(), hiding the pointers (which until
today could have been null, so it wasn't safe) behind functions. Then it
was enhanced, using std::numeric_limits to set a priori extrema...which
were not "meaningful" according to the Standard in all actual use cases
(fixed now). So we could have instantiated minmax<some_random_class>
whose minimum() and maximum() would both have either returned zero,
or segfaulted.

I think I've fixed the problems now, without specializing numeric_limits,
except that the "maximum" double is DBL_MAX, and I know a double value
that exceeds DBL_MAX (and one less than the "minimum", -DBL_MAX).


reply via email to

[Prev in Thread] Current Thread [Next in Thread]