diff --git a/cstdint.htm b/cstdint.htm new file mode 100644 index 0000000..ab4c4c1 --- /dev/null +++ b/cstdint.htm @@ -0,0 +1,79 @@ + + +
+ + + +The header <boost/cstdint.hpp>
+places the contents of the header <boost/stdint.h>
+in namespace boost. That header consists entirely of typedef's useful for
+writing portable code that requires certain integer widths.
The specifications are based on the ISO/IEC 9899:1999 C Language standard
+header stdint.h. The 64-bit types required by the C standard are not
+required in the boost header, and may not be supplied in all implementations,
+because long long
is not [yet] included in the C++ standard.
See cstdint_test.cpp for a test program.
+The typedef int#_t
, with # replaced by the width, designates a
+signed integer type of exactly # bits; int8_t
denotes an 8-bit
+signed integer type. Similarly, the typedef uint#_t
+designates and unsigned integer type of exactly # bits.
These types are optional. However, if an implementation provides integer +types with widths of 8, 16, 32, or 64 bits, it shall define the corresponding +typedef names.
+The typedef int_least#_t
, with # replaced by the width,
+designates a signed integer type with a width of at least # bits, such that no
+signed integer type with lesser size has at least the specified width. Thus, int_least32_t
+denotes a signed integer type with a width of at least 32 bits. Similarly, the
+typedef name uint_least#_t
designates an unsigned integer type with
+a width of at least # bits, such that no unsigned integer type with lesser size
+has at least the specified width.
Required minimum-width integer types:
+int_least8_t
int_least16_t
int_least32_t
uint_least8_t
uint_least16_t
uint_least32_t
All other minimum-width integer types are optional.
+The typedef int_fast#_t
, with # replaced by the width,
+designates the fastest signed integer type with a width of at least # bits.
+Similarly, the typedef name uint_fast#_t
designates the fastest
+unsigned integer type with a width of at least # bits.
There is no guarantee that these types are fastest for all purposes. In +any case, however, they satisfy the signedness and width requirements.
+Required fastest minimum-width integer types:
+int_fast8_t
int_fast16_t
int_fast32_t
uint_fast8_t
uint_fast16_t
uint_fast32_t
All other fastest minimum-width integer types are optional.
+The typedef intmax_t
designates a signed integer type capable of
+representing any value of any signed integer type.
The typedef uintmax_t
designates an unsigned integer type
+capable of representing any value of any unsigned integer type.
These types are required.
+Revised 29 Jun 2000 +
++ + + + diff --git a/index.htm b/index.htm new file mode 100644 index 0000000..8da0dbb --- /dev/null +++ b/index.htm @@ -0,0 +1,98 @@ + + + + + + + +
![]() |
+ Home | +Libraries | +People | +FAQ | +More | +
Header / Docs | +Contents | +Use | +
<boost/cstdint.hpp> + documentation + |
+ Contents of <boost/stdint.h> wrapped in namespace boost. |
+ Supplies typedefs for standard integer types such as int32_t or uint_least16_t .
+ Use in preference to <stdint.h> or <boost/stdint.h>
+ because the names are safely placed in the boost namespace. |
+
<boost/stdint.h> |
+ Typedefs as defined in the C99 standard header <stdint.h> .
+ This implementation #includes the compiler
+ supplied <stdint.h> , if present. |
+ Supplied + for use in the implementation of <boost/cstdint.hpp> and to ease transition to the C99 standard. + Other uses are not recommended because this header places its names in the global 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. | +
The organization of boost integer headers and classes is designed to take
+advantage of <stdint.h>
types from in 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 the
+global namespace or 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/stdint.h>
and <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. An
+exception is <boost/stdint.h>
which uses a .h extension to indicate its C rather than C++ heritage.
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.
+ +Revised: 05 Mar 2000 +
+ + + + diff --git a/integer.htm b/integer.htm new file mode 100644 index 0000000..9dc16a1 --- /dev/null +++ b/integer.htm @@ -0,0 +1,110 @@ + + + + + + +The <boost/integer.hpp>
+type selection templates allow integer types to be selected based on desired
+characteristics such as number of bits or maximum value. This facility is
+particularly useful for solving generic programming problems.
The templates int_t<> and uint_t<> supply typedefs least +and fast. The least type be the smallest type which holds at +least the number of bits (including sign) specified. The fast type will +be at least as large as the least type, but may possible be larger. +There is no guarantee that the fast type will actually be faster than +other possible types.
+ +If the number of bits required is known beforehand, it may be more
+appropriate to use the types supplied in <boost/cstdint.hpp>
.
++namespace boost +{ + // fast integers from least integers + template< typename LeastInt > // Required: LeastInt is integral type, not bool + struct int_fast_t { typedef LeastInt fast; }; // implementations may specialize + + // signed + template< int Bits > // bits (including sign) required, 0-32 valid + struct int_t + { + typedef implementation-supplied least; + typedef int_fast_t<least>::fast fast; + }; + + // unsigned + template< int Bits > // bits required, 0-32 valid + struct uint_t + { + typedef implementation-supplied least; + typedef int_fast_t<least>::fast fast; + }; +} // namespace boost ++ +
[Templates to select type based on maximum value are under development.] +
+ +++#include <boost/integer.hpp> +using boost::int_t; + +... +int_t<24>::least my_var;+ +
The program integer_test.cpp is a not very +smart demonstration of the results from instantiating various int_t<> +and uint_t<> examples.
+ +The rationale for the design of the templates in this header includes:
+ +The author of the Boost integer type choosing templates is Beman +Dawes. He thanks to Valentin Bonnard and + Kevlin Henney for sharing their designs for similar templates.
+ +Revised August 31, 1999
+ +© Copyright Beman Dawes 1999. Permission to copy, use, modify, sell +and distribute this document is granted provided this copyright notice appears in all +copies. This document is provided "as is" without express or implied warranty, +and with no claim as to its suitability for any purpose.
+ + + ++ + + + diff --git a/integer_traits.html b/integer_traits.html new file mode 100644 index 0000000..1f52f84 --- /dev/null +++ b/integer_traits.html @@ -0,0 +1,89 @@ + + + + + +
+The C++ Standard Library <limits> header supplies a class template +numeric_limits<> with specializations for each fundamental +type.
++For integer types, the interesting members of std::numeric_limits<> are: +
static const bool is_specialized; // will be true for integers + static T min() throw(); + static T max() throw(); + static const int digits; // for integers, # value bits + static const int digits10; + static const bool is_signed; + static const bool is_integer; // will be true for integers+For many uses, these are sufficient. But min() and max() are problematical because they are not constant expressions +(std::5.19), yet some usages require constant expressions. +
+The template class integer_traits
addresses this
+problem.
+
+
+
integer_traits.hpp
Synopsisnamespace boost { + template<class T> + class integer_traits : public std::numeric_limits<T> + { + static const bool is_integral = false; + }; + + // specializations for all integral types +}+ + +
integer_traits
is derived from
+std::numeric_limits
. In general, it adds the single
+bool
member is_integral
with the
+compile-time constant value false
. However, for all
+integral types T
(std::3.9.1/7 [basic.fundamental]),
+there are specializations provided with the following compile-time
+constants defined:
++
member | type | value |
---|---|---|
is_integral | bool | true |
const_min | T | equivalent
+to std::numeric_limits<T>::min() |
const_max | T | equivalent
+to std::numeric_limits<T>::max() |
+
+Note: A flag is_integral
is provided, because a
+user-defined integer class should specialize
+std::numeric_limits<>::is_integer = true
,
+nonetheless compile-time constants const_min
and
+const_max
cannot be provided for that user-defined class.
+
+
+
+The program integer_traits_test.cpp
+exercises the integer_traits
class.
+
+