Are numeric_limits min / max constexpr?

Does the C ++ 11 standard indicate that numeric_limits<T>::minthey maxshould be a constant expression that can be used in templates or static_assert?

More generally, how can I find a list of functions that are constant expressions according to the standard?

+5
source share
1 answer

Indeed, the standard (or my last working draft) lists all the members std::numeric_limitsin chapter 18.3.2.3 [numeric.limits] as constexpr(it will not be useful to actually quote these definitions here), for the generic generic version, as well as for all built-in specializations ( 18.3.2.7 [numeric.special] ). So yes, they are guaranteed to be constant expressions (to match implementations that also actually support constexpr, of course).

, , , , ++, , , . , cppreference.com.

+9

All Articles