cstdint.qbk 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. [/
  2. Boost.Config
  3. Copyright (c) 2001 Beman Dawes
  4. Copyright (c) 2001 Vesa Karvonen
  5. Copyright (c) 2001 John Maddock
  6. Distributed under the Boost Software License, Version 1.0.
  7. (See accompanying file LICENSE_1_0.txt or copy at
  8. http://www.boost.org/LICENSE_1_0.txt)
  9. ]
  10. [section:cstdint Standard Integer Types]
  11. [section Overview]
  12. The header [^[@../../../../boost/cstdint.hpp <boost/cstdint.hpp>]] provides the typedef's useful
  13. for writing portable code that requires certain integer widths. All typedef's are in namespace boost.
  14. The specifications for these types are based on the ISO/IEC 9899:1999 C Language standard header <stdint.h>.
  15. The 64-bit types required by the C standard are ['not required] in the boost header,
  16. and may not be supplied for all platforms/compilers, because [^long long] is not [yet] included in the C++ standard.
  17. See [@../../test/cstdint_test.cpp cstdint_test.cpp] for a test program.
  18. [endsect]
  19. [section:rationale Rationale]
  20. The organization of the Boost.Integer headers and classes is designed to take advantage of <stdint.h> types from the
  21. 1999 C standard without causing undefined behavior in terms of the 1998 C++ standard.
  22. The header <boost/cstdint.hpp> makes the standard integer types safely available in namespace [^boost]
  23. without placing any names in namespace [^std]. The intension is to complement rather than compete
  24. with the C++ Standard Library. Should some future C++ standard include <stdint.h> and <cstdint>,
  25. then <boost/cstdint.hpp> will continue to function, but will become redundant and may be safely deprecated.
  26. Because these are boost headers, their names conform to boost header naming conventions rather than
  27. C++ Standard Library header naming conventions.
  28. [endsect]
  29. [section:ce ['Caveat emptor]]
  30. As an implementation artifact, certain C <limits.h> macro names may possibly be
  31. visible to users of <boost/cstdint.hpp>. Don't use these macros; they are not part of
  32. any Boost-specified interface. Use [^boost::integer_traits<>] or [^std::numeric_limits<>] instead.
  33. As another implementation artifact, certain C <stdint.h> typedef names may possibly be visible
  34. in the global namespace to users of <boost/cstdint.hpp>. Don't use these names, they are not part of
  35. any Boost-specified interface. Use the respective names in namespace [^boost] instead.
  36. [endsect]
  37. [section Exact-width integer types]
  38. The typedef [^int#_t], with # replaced by the width, designates a signed integer type of exactly # bits;
  39. for example [^int8_t] denotes an 8-bit signed integer type. Similarly, the typedef [^uint#_t] designates an unsigned
  40. integer type of exactly # bits.
  41. These types are optional. However, if a platform supports integer types with widths of
  42. 8, 16, 32, 64, or any combination thereof, then <boost/cstdint.hpp> does provide the
  43. corresponding typedefs.
  44. The absence of int64_t and uint64_t is indicated by the macro `BOOST_NO_INT64_T`.
  45. [endsect]
  46. [section Minimum-width integer types]
  47. The typedef [^int_least#_t], with # replaced by the width, designates a signed integer type with a width
  48. of at least # bits, such that no signed integer type with lesser size has at least the specified width.
  49. Thus, [^int_least32_t] denotes the smallest signed integer type with a width of at least 32 bits.
  50. Similarly, the typedef name [^uint_least#_t] designates an unsigned integer type with a width of at least # bits,
  51. such that no unsigned integer type with lesser size has at least the specified width.
  52. The following minimum-width integer types are provided for all platforms:
  53. * [^int_least8_t]
  54. * [^int_least16_t]
  55. * [^int_least32_t]
  56. * [^uint_least8_t]
  57. * [^uint_least16_t]
  58. * [^uint_least32_t]
  59. The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
  60. * [^int_least64_t]
  61. * [^uint_least64_t]
  62. All other minimum-width integer types are optional.
  63. [endsect]
  64. [section Fastest minimum-width integer types]
  65. The typedef [^int_fast#_t], with # replaced by the width, designates the fastest signed integer type
  66. with a width of at least # bits. Similarly, the typedef name [^uint_fast#_t] designates the fastest
  67. unsigned integer type with a width of at least # bits.
  68. There is no guarantee that these types are fastest for all purposes. In any case, however, they satisfy
  69. the signedness and width requirements.
  70. The following fastest minimum-width integer types are provided for all platforms:
  71. * [^int_fast8_t]
  72. * [^int_fast16_t]
  73. * [^int_fast32_t]
  74. * [^uint_fast8_t]
  75. * [^uint_fast16_t]
  76. * [^uint_fast32_t]
  77. The following types are available only if, after including <boost/cstdint.hpp>, the macro BOOST_NO_INT64_T is not defined:
  78. * [^int_fast64_t]
  79. * [^uint_fast64_t]
  80. All other fastest minimum-width integer types are optional.
  81. [endsect]
  82. [section Greatest-width integer types]
  83. The typedef [^intmax_t ]designates a signed integer type capable of representing any value of any signed integer type.
  84. The typedef [^uintmax_t] designates an unsigned integer type capable of representing any value of any unsigned integer type.
  85. These types are provided for all platforms.
  86. [endsect]
  87. [section Integer Constant Macros]
  88. The following macros are always defined after inclusion of this header, these allow
  89. integer constants of at least the specified width to be declared:
  90. INT8_C, UINT8_C, INT16_C, UINT16_C, INT32_C, UINT32_C, INTMAX_C, UINTMAX_C.
  91. The macros INT64_C and UINT64_C are also defined if the the macro BOOST_NO_INT64_T is not defined.
  92. The C99 macro __STDC_CONSTANT_MACROS is also defined as an artifact of the implementation.
  93. For example:
  94. #include <boost/cstdint.hpp>
  95. // Here the constant 0x1FFFFFFFF has the correct suffix applied:
  96. static const boost::uint64_t c = INT64_C(0x1FFFFFFFF);
  97. [endsect]
  98. [section:intptr Integers for Storing Pointers]
  99. The typedefs [^intptr_t] and [^uintptr_t] defined signed and unsigned integers respectively each capable of storing a pointer. The macro [^BOOST_HAS_INTPTR_T] is set when these types are available.
  100. [endsect]
  101. [endsect]