Storage.qbk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. [/
  2. Copyright Hans Dembinski 2018 - 2019.
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at
  5. https://www.boost.org/LICENSE_1_0.txt)
  6. ]
  7. [section:Storage Storage]
  8. A [*Storage] handles memory for the bin counters and provides a uniform vector-like interface for accessing cell values for reading and writing. Must be [@https://en.cppreference.com/w/cpp/named_req/DefaultConstructible DefaultConstructible], [@https://en.cppreference.com/w/cpp/named_req/CopyConstructible CopyConstructible], and [@https://en.cppreference.com/w/cpp/named_req/CopyAssignable CopyAssignable].
  9. [heading Required features]
  10. * `S` is a type meeting the requirements of [*Storage]
  11. * `s` is a value of types `S`
  12. * `i` and `n` are values of type `std::size_t`
  13. [table Valid expressions
  14. [[Expression] [Returns] [Semantics, Pre/Post-conditions]]
  15. [
  16. [`S::value_type`]
  17. []
  18. [
  19. Cell element type, may be either an integral type, floating-point type, or a type meeting the requirements of [link histogram.concepts.Accumulator [*Accumulator]].
  20. ]
  21. ]
  22. [
  23. [`S::reference`]
  24. []
  25. [
  26. `S::value_type&` or a proxy class which acts like a reference.
  27. ]
  28. ]
  29. [
  30. [`S::const_reference`]
  31. []
  32. [
  33. `const S::value_type&` or a proxy class which acts like a const reference. Implicitly convertible to `S::value_type`.
  34. ]
  35. ]
  36. [
  37. [`S::iterator`]
  38. []
  39. [
  40. Returns an STL-compliant iterator type which dereferences to `S::reference`.
  41. ]
  42. ]
  43. [
  44. [`S::const_iterator`]
  45. []
  46. [
  47. Returns an STL-compliant iterator type which dereferences to `S::const_reference`.
  48. ]
  49. ]
  50. [
  51. [`S::has_threading_support`]
  52. [bool]
  53. [
  54. Static constexpr member. True, if storage supports parallel read-write access to all cells.
  55. False, if such parallel access would either cause data corruption or require synchronization so that effectively only one cell can be accessed at a time, making cell-access single-threaded.
  56. ]
  57. ]
  58. [
  59. [`s.size()`]
  60. [`std::size_t`]
  61. [
  62. Const member function which returns the current number of cells in the storage.
  63. ]
  64. ]
  65. [
  66. [`s.reset(n)`]
  67. []
  68. [
  69. Non-const member function which discards current cell values, changes storage size to `n` and initializes all cells to the default-constructed state.
  70. ]
  71. ]
  72. [
  73. [`s.begin()`]
  74. [`S::iterator`]
  75. [
  76. Non-const member function which returns the iterator to the first storage cell.
  77. ]
  78. ]
  79. [
  80. [`s.begin()`]
  81. [`S::const_iterator`]
  82. [
  83. Likewise, but a const member function which returns the const_iterator.
  84. ]
  85. ]
  86. [
  87. [`s.end()`]
  88. [`S::iterator`]
  89. [
  90. Member function which returns the iterator to the cell after the last valid storage cell.
  91. ]
  92. ]
  93. [
  94. [`s.end()`]
  95. [`S::const_iterator`]
  96. [
  97. Likewise, but a const member function which returns the const_iterator.
  98. ]
  99. ]
  100. [
  101. [`s[i]`]
  102. [`S::reference`]
  103. [
  104. Member function which returns a reference to the cell which is addressed by `i`. The index `i` must be valid: `i < s.size()`.
  105. ]
  106. ]
  107. [
  108. [`s[i]`]
  109. [`S::const_reference`]
  110. [
  111. Likewise, but a const member function which returns a const reference.
  112. ]
  113. ]
  114. [
  115. [`s == t`]
  116. [`bool`]
  117. [
  118. `t` is another value of a type which meets the requirements of [*Storage]. Returns `true` if arguments have the same number of cells and all cells compare equal. Otherwise returns `false`.
  119. ]
  120. ]
  121. [
  122. [`s.get_allocator()`]
  123. [`Alloc`]
  124. [
  125. Const member function which returns the allocator `Alloc` used by `S`. May be omitted if `S` does not use allocators. If this member function exists, also a special constructor must exists so that `S(s.get_allocator())` is a valid expression.
  126. ]
  127. ]
  128. ]
  129. [heading Optional features]
  130. * `S` is a type meeting the requirements of [*Storage]
  131. * `s` is a value of types `S`
  132. * `x` is convertible to `double`
  133. * `ar` is a value of an archive with Boost.Serialization semantics
  134. [table Valid expressions
  135. [[Expression] [Returns] [Semantics, Pre/Post-conditions]]
  136. [
  137. [`s *= x`]
  138. [`S&`]
  139. [
  140. Scales all cell values by the factor `x` and returns a reference to self.
  141. ]
  142. ]
  143. [
  144. [`s.serialize(ar, n)`]
  145. []
  146. [
  147. `ar` is a value of an archive with Boost.Serialization semantics and `n` is an unsigned integral value. Saves to the archive or loads serialized state from the archive. The version number `n` is the stored version when the object is loaded or the current version when the object is saved.
  148. ]
  149. ]
  150. ]
  151. [heading Models]
  152. * [classref boost::histogram::unlimited_storage]
  153. * [classref boost::histogram::storage_adaptor]
  154. * [classref boost::histogram::dense_storage]
  155. * [classref boost::histogram::weight_storage]
  156. * [classref boost::histogram::profile_storage]
  157. * [classref boost::histogram::weighted_profile_storage]
  158. [endsect]