stdint.h.xml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <chapter xml:id="stdint.h">
  2. <title><tt>__vic/stdint.h</tt></title>
  3. <p>ISO C99 <tt>&lt;stdint.h></tt> for C++98. Since C++11 - just a redirector to
  4. <tt>&lt;cstdint></tt>.</p>
  5. <p>Additionally, some metafunctions for template metaprogramming are provided.
  6. </p>
  7. <chapter xml:id="intN_t">
  8. <title>Exact-width integer types</title>
  9. <p>Following types are guaranteed to be available in the <b>global
  10. namespace</b>:</p>
  11. <list style="bulleted">
  12. <item><tt>int8_t</tt></item>
  13. <item><tt>int16_t</tt></item>
  14. <item><tt>int32_t</tt></item>
  15. <item><tt>int64_t</tt></item>
  16. <item><tt>uint8_t</tt></item>
  17. <item><tt>uint16_t</tt></item>
  18. <item><tt>uint32_t</tt></item>
  19. <item><tt>uint64_t</tt></item>
  20. </list>
  21. </chapter>
  22. <chapter xml:id="int_leastN_t">
  23. <title>Minimum-width integer types</title>
  24. <p>Following types are guaranteed to be available in the <b>global
  25. namespace</b>:</p>
  26. <list style="bulleted">
  27. <item><tt>int_least8_t</tt></item>
  28. <item><tt>int_least16_t</tt></item>
  29. <item><tt>int_least32_t</tt></item>
  30. <item><tt>int_least64_t</tt></item>
  31. <item><tt>uint_least8_t</tt></item>
  32. <item><tt>uint_least16_t</tt></item>
  33. <item><tt>uint_least32_t</tt></item>
  34. <item><tt>uint_least64_t</tt></item>
  35. </list>
  36. </chapter>
  37. <chapter xml:id="int_fastN_t">
  38. <title>Fastest minimum-width integer types</title>
  39. <p>Following types are guaranteed to be available in the <b>global
  40. namespace</b>:</p>
  41. <list style="bulleted">
  42. <item><tt>int_fast8_t</tt></item>
  43. <item><tt>int_fast16_t</tt></item>
  44. <item><tt>int_fast32_t</tt></item>
  45. <item><tt>int_fast64_t</tt></item>
  46. <item><tt>uint_fast8_t</tt></item>
  47. <item><tt>uint_fast16_t</tt></item>
  48. <item><tt>uint_fast32_t</tt></item>
  49. <item><tt>uint_fast64_t</tt></item>
  50. </list>
  51. </chapter>
  52. <chapter xml:id="intmax_t">
  53. <title>Greatest-width integer types</title>
  54. <p>Following types are guaranteed to be available in the <b>global
  55. namespace</b>:</p>
  56. <list style="bulleted">
  57. <item><tt>intmax_t</tt></item>
  58. <item><tt>uintmax_t</tt></item>
  59. </list>
  60. </chapter>
  61. <chapter xml:id="intptr_t">
  62. <title>Integer types capable of holding object pointers</title>
  63. <p>Following types are guaranteed to be available in the <b>global
  64. namespace</b>:</p>
  65. <list style="bulleted">
  66. <item><tt>intptr_t</tt></item>
  67. <item><tt>uintptr_t</tt></item>
  68. </list>
  69. </chapter>
  70. <chapter xml:id="int_exactly_bytes">
  71. <title><tt>int_exactly_bytes&lt;></tt>, <tt>uint_exactly_bytes&lt;></tt></title>
  72. <code-block lang="C++"><![CDATA[
  73. template<unsigned SizeInBytes>
  74. struct int_exactly_bytes
  75. {
  76. using type = ]]><nt>&lt;signed-integer-type-of-the-corresponding-size></nt><![CDATA[;
  77. };
  78. template<unsigned SizeInBytes>
  79. struct uint_exactly_bytes
  80. {
  81. using type = ]]><nt>&lt;unsigned-integer-type-of-the-corresponding-size></nt><![CDATA[;
  82. };
  83. // BEGIN C++11
  84. template<unsigned N>
  85. using int_exact_bytes = typename int_exactly_bytes<N>::type;
  86. template<unsigned N>
  87. using uint_exact_bytes = typename uint_exactly_bytes<N>::type;
  88. // END C++11
  89. ]]></code-block>
  90. <p>Metafunctions returning the signed/unsigned interger type of the requested
  91. exact size in bytes. Shorter aliases are available in C++11 mode and higher.
  92. Valid <tt>SizeInBytes</tt> values are <tt>1</tt>, <tt>2</tt>, <tt>4</tt>,
  93. <tt>8</tt>.</p>
  94. <section><title>Example</title>
  95. <code-block lang="C++"><![CDATA[
  96. typedef __vic::int_exactly_bytes< sizeof(void *) >::type my_intptr_t;
  97. // or in C++11
  98. using my_intptr_t = __vic::int_exact_bytes< sizeof(void *) >
  99. assert( sizeof(my_intptr) == sizeof(intptr_t) );
  100. ]]></code-block>
  101. </section>
  102. </chapter>
  103. </chapter>