Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

Click here to view the latest version of this page.

Boost Integer Library

Header / Docs Contents Use
<boost/integer_fwd.hpp> Forward declarations of classes and class templates When just the name of a class is needed
<boost/cstdint.hpp>

documentation
Typedef's based on the 1999 C Standard header <stdint.h>, wrapped in namespace boost. This implementation may #include the compiler supplied <stdint.h>, if present. Supplies typedefs for standard integer types such as int32_t or uint_least16_t. Use in preference to <stdint.h> for enhanced portability. Furthermore, all names are safely placed in the boost namespace.
<boost/integer_traits.hpp>

documentation
Template class boost::integer_traits, derived from std::numeric_limits.  Adds const_min and const_max members. Use to obtain the characteristics of a known integer type.
<boost/integer.hpp>

documentation
Templates for integer type selection based on properties such as maximum value or number of bits. Use to select the type an integer when some property such as maximum value or number of bits is known. Useful for generic programming.
<boost/integer/integer_mask.hpp>

documentation
Templates for the selection of integer masks, single or lowest group, based on the number of bits. Use to select a particular mask when the bit position(s) are based on a compile-time variable. Useful for generic programming.
<boost/integer/static_log2.hpp>

documentation
Template for finding the highest power of two in a number. Use to find the bit-size/range based on a maximum value. Useful for generic programming.
<boost/integer/static_min_max.hpp>

documentation
Templates for finding the extrema of two numbers. Use to find a bound based on a minimum or maximum value. Useful for generic programming.

Rationale

The organization of boost integer headers and classes is designed to take advantage of <stdint.h> types from the 1999 C standard without resorting to undefined behavior in terms of the 1998 C++ standard. The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace boost without placing any names in namespace std. As always, the intension is to complement rather than compete with the C++ Standard Library. Should some future C++ standard include <stdint.h> and <cstdint>, then <boost/cstdint.hpp> will continue to function, but will become redundant and may be safely deprecated.

Because these are boost headers, their names conform to boost header naming conventions rather than C++ Standard Library header naming conventions.

Caveat emptor

As an implementation artifact, certain C <limits.h> macro names may possibly be visible to users of <boost/cstdint.hpp>. Don't use these macros; they are not part of any Boost-specified interface. Use boost::integer_traits<> or std::numeric_limits<> instead.

As another implementation artifact, certain C <stdint.h> typedef names may possibly be visible in the global namespace to users of <boost/cstdint.hpp>. Don't use these names, they are not part of any Boost-specified interface. Use the respective names in namespace boost instead.


Revised: 06 Nov 2007

Copyright Beman Dawes 2003

Distributed under the Boost Software License, Version 1.0. See www.boost.org/LICENSE_1_0.txt