cxxomfort  rel.20211024
Simple backports for C++ - https://ryan.gulix.cl/fossil.cgi/cxxomfort/
Classes | Namespaces
limits.hpp File Reference

Classes

struct  integral_limits< T >
 An extension to numeric_limits that deals specifically with integer-like types. More...
 

Namespaces

 cxxomfort
 Namespace of the cxxomfort library.
 
 cxxomfort::fix
 Fixes for implementation issues in std.
 

Detailed Description

Author
Luis Machuca Bezzaza <luis [dot] machuca [at] gulix [dot] cl>

Interfaces defined in this header:


Class Documentation

◆ cxxomfort::fix::integral_limits

struct cxxomfort::fix::integral_limits

template<typename T>
struct cxxomfort::fix::integral_limits< T >

An extension to numeric_limits that deals specifically with integer-like types.

Compile-time constants for integral limits

For a given integral or integer-like type Ty , integral_limits<Ty> provides an interface to std::numeric_limits<Ty> and in fact inherits from the latter. The interface is expanded to add some useful information about the integral type that is only available at compile time as macros pre-C++11.

integral_limits provides the following new members:

  • const_min - minimum value as a value (min is constexpr function in C++>=11).
  • const_max - maximum value as a value (max is constexpr function in C++>=11).
  • digits_base<N> - the total number of digits required to represent any value in the given base.

Pending members :

  • narrower_type - an alias to the next smaller integral type of the same signedness.
  • wider_type - an alias to the next larger integral type of the same signedness.
  • lo_mask - an integral value that can be AND-ed with this type to keep only the lower bits.
  • hi_mask - an integral value that can be AND-ed with this type to keep only the higher bits.

cxxomfort provides specializations of the new integral_limits for all the types that are defined as integral. The list explicitly includes:

short, int, long, long long in their signed and unsigned variants.