@sentryware/s2-node 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (471) hide show
  1. package/.circleci/config.yml +45 -0
  2. package/.dockerignore +1 -0
  3. package/.gitmodules +3 -0
  4. package/CHANGELOG.md +33 -0
  5. package/LICENSE +201 -0
  6. package/README.md +147 -0
  7. package/binding.gyp +170 -0
  8. package/docker/Dockerfile.node20.test +8 -0
  9. package/docker/Dockerfile.node22.test +8 -0
  10. package/docker/Dockerfile.node24.test +8 -0
  11. package/index.d.ts +117 -0
  12. package/index.js +6 -0
  13. package/jest.config.js +184 -0
  14. package/package.json +43 -0
  15. package/publish-linux.sh +18 -0
  16. package/publish-osx.sh +19 -0
  17. package/src/builder.cc +84 -0
  18. package/src/builder.h +29 -0
  19. package/src/cell.cc +71 -0
  20. package/src/cell.h +26 -0
  21. package/src/cell_id.cc +210 -0
  22. package/src/cell_id.h +44 -0
  23. package/src/cell_union.cc +237 -0
  24. package/src/cell_union.h +34 -0
  25. package/src/earth.cc +185 -0
  26. package/src/earth.h +33 -0
  27. package/src/latlng.cc +132 -0
  28. package/src/latlng.h +28 -0
  29. package/src/loop.cc +51 -0
  30. package/src/loop.h +21 -0
  31. package/src/point.cc +69 -0
  32. package/src/point.h +23 -0
  33. package/src/polygon.cc +36 -0
  34. package/src/polygon.h +20 -0
  35. package/src/polyline.cc +186 -0
  36. package/src/polyline.h +34 -0
  37. package/src/region_coverer.cc +450 -0
  38. package/src/region_coverer.h +56 -0
  39. package/src/s2.cc +27 -0
  40. package/test/Cell.test.js +37 -0
  41. package/test/CellId.test.js +135 -0
  42. package/test/CellUnion.test.js +150 -0
  43. package/test/Earth.test.js +62 -0
  44. package/test/LatLng.test.js +45 -0
  45. package/test/Point.test.js +14 -0
  46. package/test/Polyline.test.js +78 -0
  47. package/test/RegionCoverer.test.js +301 -0
  48. package/test.sh +16 -0
  49. package/third_party/s2geometry/.travis.yml +163 -0
  50. package/third_party/s2geometry/AUTHORS +13 -0
  51. package/third_party/s2geometry/CONTRIBUTING.md +65 -0
  52. package/third_party/s2geometry/CONTRIBUTORS +30 -0
  53. package/third_party/s2geometry/LICENSE +202 -0
  54. package/third_party/s2geometry/NOTICE +5 -0
  55. package/third_party/s2geometry/README.md +127 -0
  56. package/third_party/s2geometry/doc/examples/point_index.cc +44 -0
  57. package/third_party/s2geometry/doc/examples/term_index.cc +99 -0
  58. package/third_party/s2geometry/doc/examples/term_index.py +101 -0
  59. package/third_party/s2geometry/src/python/coder.i +125 -0
  60. package/third_party/s2geometry/src/python/pywraps2_test.py +786 -0
  61. package/third_party/s2geometry/src/python/s2.i +37 -0
  62. package/third_party/s2geometry/src/python/s2_common.i +756 -0
  63. package/third_party/s2geometry/src/s2/_fp_contract_off.h +60 -0
  64. package/third_party/s2geometry/src/s2/base/casts.h +318 -0
  65. package/third_party/s2geometry/src/s2/base/commandlineflags.h +67 -0
  66. package/third_party/s2geometry/src/s2/base/integral_types.h +31 -0
  67. package/third_party/s2geometry/src/s2/base/log_severity.h +40 -0
  68. package/third_party/s2geometry/src/s2/base/logging.h +173 -0
  69. package/third_party/s2geometry/src/s2/base/mutex.h +61 -0
  70. package/third_party/s2geometry/src/s2/base/port.h +999 -0
  71. package/third_party/s2geometry/src/s2/base/spinlock.h +60 -0
  72. package/third_party/s2geometry/src/s2/base/stringprintf.cc +107 -0
  73. package/third_party/s2geometry/src/s2/base/stringprintf.h +53 -0
  74. package/third_party/s2geometry/src/s2/base/strtoint.cc +65 -0
  75. package/third_party/s2geometry/src/s2/base/strtoint.h +106 -0
  76. package/third_party/s2geometry/src/s2/base/timer.h +50 -0
  77. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.cc +164 -0
  78. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector.h +110 -0
  79. package/third_party/s2geometry/src/s2/encoded_s2cell_id_vector_test.cc +232 -0
  80. package/third_party/s2geometry/src/s2/encoded_s2point_vector.cc +838 -0
  81. package/third_party/s2geometry/src/s2/encoded_s2point_vector.h +140 -0
  82. package/third_party/s2geometry/src/s2/encoded_s2point_vector_test.cc +344 -0
  83. package/third_party/s2geometry/src/s2/encoded_s2shape_index.cc +181 -0
  84. package/third_party/s2geometry/src/s2/encoded_s2shape_index.h +276 -0
  85. package/third_party/s2geometry/src/s2/encoded_s2shape_index_test.cc +244 -0
  86. package/third_party/s2geometry/src/s2/encoded_string_vector.cc +66 -0
  87. package/third_party/s2geometry/src/s2/encoded_string_vector.h +164 -0
  88. package/third_party/s2geometry/src/s2/encoded_string_vector_test.cc +69 -0
  89. package/third_party/s2geometry/src/s2/encoded_uint_vector.h +299 -0
  90. package/third_party/s2geometry/src/s2/encoded_uint_vector_test.cc +124 -0
  91. package/third_party/s2geometry/src/s2/id_set_lexicon.cc +81 -0
  92. package/third_party/s2geometry/src/s2/id_set_lexicon.h +199 -0
  93. package/third_party/s2geometry/src/s2/id_set_lexicon_test.cc +70 -0
  94. package/third_party/s2geometry/src/s2/mutable_s2shape_index.cc +1585 -0
  95. package/third_party/s2geometry/src/s2/mutable_s2shape_index.h +600 -0
  96. package/third_party/s2geometry/src/s2/mutable_s2shape_index_test.cc +589 -0
  97. package/third_party/s2geometry/src/s2/r1interval.h +220 -0
  98. package/third_party/s2geometry/src/s2/r1interval_test.cc +185 -0
  99. package/third_party/s2geometry/src/s2/r2.h +26 -0
  100. package/third_party/s2geometry/src/s2/r2rect.cc +93 -0
  101. package/third_party/s2geometry/src/s2/r2rect.h +234 -0
  102. package/third_party/s2geometry/src/s2/r2rect_test.cc +228 -0
  103. package/third_party/s2geometry/src/s2/s1angle.cc +54 -0
  104. package/third_party/s2geometry/src/s2/s1angle.h +336 -0
  105. package/third_party/s2geometry/src/s2/s1angle_test.cc +185 -0
  106. package/third_party/s2geometry/src/s2/s1chord_angle.cc +159 -0
  107. package/third_party/s2geometry/src/s2/s1chord_angle.h +369 -0
  108. package/third_party/s2geometry/src/s2/s1chord_angle_test.cc +207 -0
  109. package/third_party/s2geometry/src/s2/s1interval.cc +296 -0
  110. package/third_party/s2geometry/src/s2/s1interval.h +266 -0
  111. package/third_party/s2geometry/src/s2/s1interval_test.cc +469 -0
  112. package/third_party/s2geometry/src/s2/s2boolean_operation.cc +2391 -0
  113. package/third_party/s2geometry/src/s2/s2boolean_operation.h +501 -0
  114. package/third_party/s2geometry/src/s2/s2boolean_operation_test.cc +1400 -0
  115. package/third_party/s2geometry/src/s2/s2builder.cc +1828 -0
  116. package/third_party/s2geometry/src/s2/s2builder.h +1057 -0
  117. package/third_party/s2geometry/src/s2/s2builder_graph.cc +1084 -0
  118. package/third_party/s2geometry/src/s2/s2builder_graph.h +799 -0
  119. package/third_party/s2geometry/src/s2/s2builder_graph_test.cc +462 -0
  120. package/third_party/s2geometry/src/s2/s2builder_layer.h +50 -0
  121. package/third_party/s2geometry/src/s2/s2builder_test.cc +1329 -0
  122. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.cc +313 -0
  123. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer.h +221 -0
  124. package/third_party/s2geometry/src/s2/s2builderutil_closed_set_normalizer_test.cc +261 -0
  125. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.cc +392 -0
  126. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies.h +86 -0
  127. package/third_party/s2geometry/src/s2/s2builderutil_find_polygon_degeneracies_test.cc +182 -0
  128. package/third_party/s2geometry/src/s2/s2builderutil_graph_shape.h +57 -0
  129. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.cc +212 -0
  130. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer.h +218 -0
  131. package/third_party/s2geometry/src/s2/s2builderutil_lax_polygon_layer_test.cc +367 -0
  132. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.cc +74 -0
  133. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer.h +122 -0
  134. package/third_party/s2geometry/src/s2/s2builderutil_s2point_vector_layer_test.cc +167 -0
  135. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.cc +191 -0
  136. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer.h +211 -0
  137. package/third_party/s2geometry/src/s2/s2builderutil_s2polygon_layer_test.cc +312 -0
  138. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.cc +105 -0
  139. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer.h +174 -0
  140. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_layer_test.cc +220 -0
  141. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.cc +98 -0
  142. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer.h +292 -0
  143. package/third_party/s2geometry/src/s2/s2builderutil_s2polyline_vector_layer_test.cc +233 -0
  144. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.cc +354 -0
  145. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions.h +239 -0
  146. package/third_party/s2geometry/src/s2/s2builderutil_snap_functions_test.cc +716 -0
  147. package/third_party/s2geometry/src/s2/s2builderutil_testing.cc +37 -0
  148. package/third_party/s2geometry/src/s2/s2builderutil_testing.h +100 -0
  149. package/third_party/s2geometry/src/s2/s2builderutil_testing_test.cc +85 -0
  150. package/third_party/s2geometry/src/s2/s2cap.cc +347 -0
  151. package/third_party/s2geometry/src/s2/s2cap.h +286 -0
  152. package/third_party/s2geometry/src/s2/s2cap_test.cc +379 -0
  153. package/third_party/s2geometry/src/s2/s2cell.cc +552 -0
  154. package/third_party/s2geometry/src/s2/s2cell.h +249 -0
  155. package/third_party/s2geometry/src/s2/s2cell_id.cc +619 -0
  156. package/third_party/s2geometry/src/s2/s2cell_id.h +705 -0
  157. package/third_party/s2geometry/src/s2/s2cell_id_test.cc +633 -0
  158. package/third_party/s2geometry/src/s2/s2cell_index.cc +149 -0
  159. package/third_party/s2geometry/src/s2/s2cell_index.h +660 -0
  160. package/third_party/s2geometry/src/s2/s2cell_index_test.cc +411 -0
  161. package/third_party/s2geometry/src/s2/s2cell_test.cc +687 -0
  162. package/third_party/s2geometry/src/s2/s2cell_union.cc +515 -0
  163. package/third_party/s2geometry/src/s2/s2cell_union.h +399 -0
  164. package/third_party/s2geometry/src/s2/s2cell_union_test.cc +598 -0
  165. package/third_party/s2geometry/src/s2/s2centroids.cc +84 -0
  166. package/third_party/s2geometry/src/s2/s2centroids.h +87 -0
  167. package/third_party/s2geometry/src/s2/s2centroids_test.cc +82 -0
  168. package/third_party/s2geometry/src/s2/s2closest_cell_query.cc +123 -0
  169. package/third_party/s2geometry/src/s2/s2closest_cell_query.h +385 -0
  170. package/third_party/s2geometry/src/s2/s2closest_cell_query_base.h +841 -0
  171. package/third_party/s2geometry/src/s2/s2closest_cell_query_base_test.cc +63 -0
  172. package/third_party/s2geometry/src/s2/s2closest_cell_query_test.cc +412 -0
  173. package/third_party/s2geometry/src/s2/s2closest_edge_query.cc +106 -0
  174. package/third_party/s2geometry/src/s2/s2closest_edge_query.h +421 -0
  175. package/third_party/s2geometry/src/s2/s2closest_edge_query_base.h +946 -0
  176. package/third_party/s2geometry/src/s2/s2closest_edge_query_base_test.cc +59 -0
  177. package/third_party/s2geometry/src/s2/s2closest_edge_query_test.cc +505 -0
  178. package/third_party/s2geometry/src/s2/s2closest_edge_query_testing.h +91 -0
  179. package/third_party/s2geometry/src/s2/s2closest_point_query.cc +66 -0
  180. package/third_party/s2geometry/src/s2/s2closest_point_query.h +465 -0
  181. package/third_party/s2geometry/src/s2/s2closest_point_query_base.h +767 -0
  182. package/third_party/s2geometry/src/s2/s2closest_point_query_base_test.cc +63 -0
  183. package/third_party/s2geometry/src/s2/s2closest_point_query_test.cc +312 -0
  184. package/third_party/s2geometry/src/s2/s2contains_point_query.h +328 -0
  185. package/third_party/s2geometry/src/s2/s2contains_point_query_test.cc +159 -0
  186. package/third_party/s2geometry/src/s2/s2contains_vertex_query.cc +39 -0
  187. package/third_party/s2geometry/src/s2/s2contains_vertex_query.h +66 -0
  188. package/third_party/s2geometry/src/s2/s2contains_vertex_query_test.cc +67 -0
  189. package/third_party/s2geometry/src/s2/s2convex_hull_query.cc +198 -0
  190. package/third_party/s2geometry/src/s2/s2convex_hull_query.h +110 -0
  191. package/third_party/s2geometry/src/s2/s2convex_hull_query_test.cc +208 -0
  192. package/third_party/s2geometry/src/s2/s2coords.cc +146 -0
  193. package/third_party/s2geometry/src/s2/s2coords.h +459 -0
  194. package/third_party/s2geometry/src/s2/s2coords_internal.h +71 -0
  195. package/third_party/s2geometry/src/s2/s2coords_test.cc +218 -0
  196. package/third_party/s2geometry/src/s2/s2crossing_edge_query.cc +380 -0
  197. package/third_party/s2geometry/src/s2/s2crossing_edge_query.h +220 -0
  198. package/third_party/s2geometry/src/s2/s2crossing_edge_query_test.cc +382 -0
  199. package/third_party/s2geometry/src/s2/s2debug.cc +23 -0
  200. package/third_party/s2geometry/src/s2/s2debug.h +69 -0
  201. package/third_party/s2geometry/src/s2/s2distance_target.h +165 -0
  202. package/third_party/s2geometry/src/s2/s2earth.cc +52 -0
  203. package/third_party/s2geometry/src/s2/s2earth.h +268 -0
  204. package/third_party/s2geometry/src/s2/s2earth_test.cc +146 -0
  205. package/third_party/s2geometry/src/s2/s2edge_clipping.cc +462 -0
  206. package/third_party/s2geometry/src/s2/s2edge_clipping.h +183 -0
  207. package/third_party/s2geometry/src/s2/s2edge_clipping_test.cc +335 -0
  208. package/third_party/s2geometry/src/s2/s2edge_crosser.cc +85 -0
  209. package/third_party/s2geometry/src/s2/s2edge_crosser.h +343 -0
  210. package/third_party/s2geometry/src/s2/s2edge_crosser_test.cc +264 -0
  211. package/third_party/s2geometry/src/s2/s2edge_crossings.cc +515 -0
  212. package/third_party/s2geometry/src/s2/s2edge_crossings.h +138 -0
  213. package/third_party/s2geometry/src/s2/s2edge_crossings_internal.h +59 -0
  214. package/third_party/s2geometry/src/s2/s2edge_crossings_test.cc +246 -0
  215. package/third_party/s2geometry/src/s2/s2edge_distances.cc +419 -0
  216. package/third_party/s2geometry/src/s2/s2edge_distances.h +192 -0
  217. package/third_party/s2geometry/src/s2/s2edge_distances_test.cc +539 -0
  218. package/third_party/s2geometry/src/s2/s2edge_tessellator.cc +276 -0
  219. package/third_party/s2geometry/src/s2/s2edge_tessellator.h +101 -0
  220. package/third_party/s2geometry/src/s2/s2edge_tessellator_test.cc +492 -0
  221. package/third_party/s2geometry/src/s2/s2edge_vector_shape.h +85 -0
  222. package/third_party/s2geometry/src/s2/s2edge_vector_shape_test.cc +66 -0
  223. package/third_party/s2geometry/src/s2/s2error.cc +29 -0
  224. package/third_party/s2geometry/src/s2/s2error.h +147 -0
  225. package/third_party/s2geometry/src/s2/s2error_test.cc +31 -0
  226. package/third_party/s2geometry/src/s2/s2furthest_edge_query.cc +117 -0
  227. package/third_party/s2geometry/src/s2/s2furthest_edge_query.h +439 -0
  228. package/third_party/s2geometry/src/s2/s2furthest_edge_query_test.cc +487 -0
  229. package/third_party/s2geometry/src/s2/s2latlng.cc +90 -0
  230. package/third_party/s2geometry/src/s2/s2latlng.h +234 -0
  231. package/third_party/s2geometry/src/s2/s2latlng_rect.cc +727 -0
  232. package/third_party/s2geometry/src/s2/s2latlng_rect.h +434 -0
  233. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.cc +344 -0
  234. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder.h +89 -0
  235. package/third_party/s2geometry/src/s2/s2latlng_rect_bounder_test.cc +306 -0
  236. package/third_party/s2geometry/src/s2/s2latlng_rect_test.cc +1030 -0
  237. package/third_party/s2geometry/src/s2/s2latlng_test.cc +165 -0
  238. package/third_party/s2geometry/src/s2/s2lax_loop_shape.cc +104 -0
  239. package/third_party/s2geometry/src/s2/s2lax_loop_shape.h +153 -0
  240. package/third_party/s2geometry/src/s2/s2lax_loop_shape_test.cc +101 -0
  241. package/third_party/s2geometry/src/s2/s2lax_polygon_shape.cc +348 -0
  242. package/third_party/s2geometry/src/s2/s2lax_polygon_shape.h +183 -0
  243. package/third_party/s2geometry/src/s2/s2lax_polygon_shape_test.cc +234 -0
  244. package/third_party/s2geometry/src/s2/s2lax_polyline_shape.cc +118 -0
  245. package/third_party/s2geometry/src/s2/s2lax_polyline_shape.h +124 -0
  246. package/third_party/s2geometry/src/s2/s2lax_polyline_shape_test.cc +62 -0
  247. package/third_party/s2geometry/src/s2/s2loop.cc +1509 -0
  248. package/third_party/s2geometry/src/s2/s2loop.h +711 -0
  249. package/third_party/s2geometry/src/s2/s2loop_measures.cc +313 -0
  250. package/third_party/s2geometry/src/s2/s2loop_measures.h +280 -0
  251. package/third_party/s2geometry/src/s2/s2loop_measures_test.cc +367 -0
  252. package/third_party/s2geometry/src/s2/s2loop_test.cc +1371 -0
  253. package/third_party/s2geometry/src/s2/s2max_distance_targets.cc +265 -0
  254. package/third_party/s2geometry/src/s2/s2max_distance_targets.h +241 -0
  255. package/third_party/s2geometry/src/s2/s2max_distance_targets_test.cc +367 -0
  256. package/third_party/s2geometry/src/s2/s2measures.cc +128 -0
  257. package/third_party/s2geometry/src/s2/s2measures.h +78 -0
  258. package/third_party/s2geometry/src/s2/s2measures_test.cc +135 -0
  259. package/third_party/s2geometry/src/s2/s2metrics.cc +122 -0
  260. package/third_party/s2geometry/src/s2/s2metrics.h +199 -0
  261. package/third_party/s2geometry/src/s2/s2metrics_test.cc +127 -0
  262. package/third_party/s2geometry/src/s2/s2min_distance_targets.cc +295 -0
  263. package/third_party/s2geometry/src/s2/s2min_distance_targets.h +273 -0
  264. package/third_party/s2geometry/src/s2/s2min_distance_targets_test.cc +239 -0
  265. package/third_party/s2geometry/src/s2/s2padded_cell.cc +162 -0
  266. package/third_party/s2geometry/src/s2/s2padded_cell.h +108 -0
  267. package/third_party/s2geometry/src/s2/s2padded_cell_test.cc +138 -0
  268. package/third_party/s2geometry/src/s2/s2point.h +38 -0
  269. package/third_party/s2geometry/src/s2/s2point_compression.cc +388 -0
  270. package/third_party/s2geometry/src/s2/s2point_compression.h +78 -0
  271. package/third_party/s2geometry/src/s2/s2point_compression_test.cc +305 -0
  272. package/third_party/s2geometry/src/s2/s2point_index.h +345 -0
  273. package/third_party/s2geometry/src/s2/s2point_index_test.cc +147 -0
  274. package/third_party/s2geometry/src/s2/s2point_region.cc +72 -0
  275. package/third_party/s2geometry/src/s2/s2point_region.h +76 -0
  276. package/third_party/s2geometry/src/s2/s2point_region_test.cc +100 -0
  277. package/third_party/s2geometry/src/s2/s2point_span.h +57 -0
  278. package/third_party/s2geometry/src/s2/s2point_test.cc +47 -0
  279. package/third_party/s2geometry/src/s2/s2point_vector_shape.h +127 -0
  280. package/third_party/s2geometry/src/s2/s2point_vector_shape_test.cc +59 -0
  281. package/third_party/s2geometry/src/s2/s2pointutil.cc +131 -0
  282. package/third_party/s2geometry/src/s2/s2pointutil.h +138 -0
  283. package/third_party/s2geometry/src/s2/s2pointutil_test.cc +157 -0
  284. package/third_party/s2geometry/src/s2/s2polygon.cc +1569 -0
  285. package/third_party/s2geometry/src/s2/s2polygon.h +934 -0
  286. package/third_party/s2geometry/src/s2/s2polygon_test.cc +3025 -0
  287. package/third_party/s2geometry/src/s2/s2polyline.cc +645 -0
  288. package/third_party/s2geometry/src/s2/s2polyline.h +379 -0
  289. package/third_party/s2geometry/src/s2/s2polyline_alignment.cc +414 -0
  290. package/third_party/s2geometry/src/s2/s2polyline_alignment.h +245 -0
  291. package/third_party/s2geometry/src/s2/s2polyline_alignment_internal.h +158 -0
  292. package/third_party/s2geometry/src/s2/s2polyline_alignment_test.cc +610 -0
  293. package/third_party/s2geometry/src/s2/s2polyline_measures.cc +42 -0
  294. package/third_party/s2geometry/src/s2/s2polyline_measures.h +53 -0
  295. package/third_party/s2geometry/src/s2/s2polyline_measures_test.cc +57 -0
  296. package/third_party/s2geometry/src/s2/s2polyline_simplifier.cc +187 -0
  297. package/third_party/s2geometry/src/s2/s2polyline_simplifier.h +109 -0
  298. package/third_party/s2geometry/src/s2/s2polyline_simplifier_test.cc +165 -0
  299. package/third_party/s2geometry/src/s2/s2polyline_test.cc +554 -0
  300. package/third_party/s2geometry/src/s2/s2predicates.cc +1486 -0
  301. package/third_party/s2geometry/src/s2/s2predicates.h +282 -0
  302. package/third_party/s2geometry/src/s2/s2predicates_internal.h +135 -0
  303. package/third_party/s2geometry/src/s2/s2predicates_test.cc +1427 -0
  304. package/third_party/s2geometry/src/s2/s2projections.cc +109 -0
  305. package/third_party/s2geometry/src/s2/s2projections.h +161 -0
  306. package/third_party/s2geometry/src/s2/s2projections_test.cc +78 -0
  307. package/third_party/s2geometry/src/s2/s2r2rect.cc +88 -0
  308. package/third_party/s2geometry/src/s2/s2r2rect.h +292 -0
  309. package/third_party/s2geometry/src/s2/s2r2rect_test.cc +312 -0
  310. package/third_party/s2geometry/src/s2/s2region.cc +26 -0
  311. package/third_party/s2geometry/src/s2/s2region.h +142 -0
  312. package/third_party/s2geometry/src/s2/s2region_coverer.cc +514 -0
  313. package/third_party/s2geometry/src/s2/s2region_coverer.h +356 -0
  314. package/third_party/s2geometry/src/s2/s2region_coverer_test.cc +509 -0
  315. package/third_party/s2geometry/src/s2/s2region_intersection.cc +84 -0
  316. package/third_party/s2geometry/src/s2/s2region_intersection.h +79 -0
  317. package/third_party/s2geometry/src/s2/s2region_term_indexer.cc +270 -0
  318. package/third_party/s2geometry/src/s2/s2region_term_indexer.h +299 -0
  319. package/third_party/s2geometry/src/s2/s2region_term_indexer_test.cc +209 -0
  320. package/third_party/s2geometry/src/s2/s2region_test.cc +370 -0
  321. package/third_party/s2geometry/src/s2/s2region_union.cc +90 -0
  322. package/third_party/s2geometry/src/s2/s2region_union.h +83 -0
  323. package/third_party/s2geometry/src/s2/s2region_union_test.cc +89 -0
  324. package/third_party/s2geometry/src/s2/s2shape.h +283 -0
  325. package/third_party/s2geometry/src/s2/s2shape_index.cc +321 -0
  326. package/third_party/s2geometry/src/s2/s2shape_index.h +781 -0
  327. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.cc +113 -0
  328. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region.h +135 -0
  329. package/third_party/s2geometry/src/s2/s2shape_index_buffered_region_test.cc +162 -0
  330. package/third_party/s2geometry/src/s2/s2shape_index_measures.cc +92 -0
  331. package/third_party/s2geometry/src/s2/s2shape_index_measures.h +100 -0
  332. package/third_party/s2geometry/src/s2/s2shape_index_measures_test.cc +136 -0
  333. package/third_party/s2geometry/src/s2/s2shape_index_region.h +350 -0
  334. package/third_party/s2geometry/src/s2/s2shape_index_region_test.cc +161 -0
  335. package/third_party/s2geometry/src/s2/s2shape_index_test.cc +24 -0
  336. package/third_party/s2geometry/src/s2/s2shape_measures.cc +138 -0
  337. package/third_party/s2geometry/src/s2/s2shape_measures.h +95 -0
  338. package/third_party/s2geometry/src/s2/s2shape_measures_test.cc +139 -0
  339. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.cc +120 -0
  340. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries.h +66 -0
  341. package/third_party/s2geometry/src/s2/s2shapeutil_build_polygon_boundaries_test.cc +170 -0
  342. package/third_party/s2geometry/src/s2/s2shapeutil_coding.cc +253 -0
  343. package/third_party/s2geometry/src/s2/s2shapeutil_coding.h +283 -0
  344. package/third_party/s2geometry/src/s2/s2shapeutil_coding_test.cc +54 -0
  345. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.cc +40 -0
  346. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force.h +41 -0
  347. package/third_party/s2geometry/src/s2/s2shapeutil_contains_brute_force_test.cc +55 -0
  348. package/third_party/s2geometry/src/s2/s2shapeutil_count_edges.h +57 -0
  349. package/third_party/s2geometry/src/s2/s2shapeutil_count_edges_test.cc +43 -0
  350. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.cc +45 -0
  351. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator.h +72 -0
  352. package/third_party/s2geometry/src/s2/s2shapeutil_edge_iterator_test.cc +116 -0
  353. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.cc +107 -0
  354. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point.h +48 -0
  355. package/third_party/s2geometry/src/s2/s2shapeutil_get_reference_point_test.cc +104 -0
  356. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.cc +58 -0
  357. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator.h +65 -0
  358. package/third_party/s2geometry/src/s2/s2shapeutil_range_iterator_test.cc +61 -0
  359. package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge.h +58 -0
  360. package/third_party/s2geometry/src/s2/s2shapeutil_shape_edge_id.h +97 -0
  361. package/third_party/s2geometry/src/s2/s2shapeutil_testing.cc +104 -0
  362. package/third_party/s2geometry/src/s2/s2shapeutil_testing.h +36 -0
  363. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.cc +440 -0
  364. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs.h +72 -0
  365. package/third_party/s2geometry/src/s2/s2shapeutil_visit_crossing_edge_pairs_test.cc +184 -0
  366. package/third_party/s2geometry/src/s2/s2testing.cc +464 -0
  367. package/third_party/s2geometry/src/s2/s2testing.h +385 -0
  368. package/third_party/s2geometry/src/s2/s2testing_test.cc +166 -0
  369. package/third_party/s2geometry/src/s2/s2text_format.cc +506 -0
  370. package/third_party/s2geometry/src/s2/s2text_format.h +289 -0
  371. package/third_party/s2geometry/src/s2/s2text_format_test.cc +417 -0
  372. package/third_party/s2geometry/src/s2/s2wedge_relations.cc +80 -0
  373. package/third_party/s2geometry/src/s2/s2wedge_relations.h +64 -0
  374. package/third_party/s2geometry/src/s2/s2wedge_relations_test.cc +89 -0
  375. package/third_party/s2geometry/src/s2/sequence_lexicon.h +296 -0
  376. package/third_party/s2geometry/src/s2/sequence_lexicon_test.cc +113 -0
  377. package/third_party/s2geometry/src/s2/strings/ostringstream.cc +35 -0
  378. package/third_party/s2geometry/src/s2/strings/ostringstream.h +105 -0
  379. package/third_party/s2geometry/src/s2/strings/serialize.cc +46 -0
  380. package/third_party/s2geometry/src/s2/strings/serialize.h +40 -0
  381. package/third_party/s2geometry/src/s2/third_party/absl/algorithm/algorithm.h +187 -0
  382. package/third_party/s2geometry/src/s2/third_party/absl/base/attributes.h +666 -0
  383. package/third_party/s2geometry/src/s2/third_party/absl/base/casts.h +189 -0
  384. package/third_party/s2geometry/src/s2/third_party/absl/base/config.h +462 -0
  385. package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.cc +129 -0
  386. package/third_party/s2geometry/src/s2/third_party/absl/base/dynamic_annotations.h +394 -0
  387. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/atomic_hook.h +168 -0
  388. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/identity.h +33 -0
  389. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/inline_variable.h +117 -0
  390. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/invoke.h +188 -0
  391. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.cc +254 -0
  392. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/raw_logging.h +205 -0
  393. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.cc +106 -0
  394. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/throw_delegate.h +71 -0
  395. package/third_party/s2geometry/src/s2/third_party/absl/base/internal/unaligned_access.h +322 -0
  396. package/third_party/s2geometry/src/s2/third_party/absl/base/log_severity.h +77 -0
  397. package/third_party/s2geometry/src/s2/third_party/absl/base/macros.h +236 -0
  398. package/third_party/s2geometry/src/s2/third_party/absl/base/optimization.h +177 -0
  399. package/third_party/s2geometry/src/s2/third_party/absl/base/policy_checks.h +124 -0
  400. package/third_party/s2geometry/src/s2/third_party/absl/base/port.h +97 -0
  401. package/third_party/s2geometry/src/s2/third_party/absl/base/thread_annotations.h +277 -0
  402. package/third_party/s2geometry/src/s2/third_party/absl/container/fixed_array.h +523 -0
  403. package/third_party/s2geometry/src/s2/third_party/absl/container/inlined_vector.h +1453 -0
  404. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/compressed_tuple.h +191 -0
  405. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/container_memory.h +424 -0
  406. package/third_party/s2geometry/src/s2/third_party/absl/container/internal/layout.h +739 -0
  407. package/third_party/s2geometry/src/s2/third_party/absl/memory/memory.h +755 -0
  408. package/third_party/s2geometry/src/s2/third_party/absl/meta/type_traits.h +436 -0
  409. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.cc +232 -0
  410. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128.h +656 -0
  411. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_have_intrinsic.inc +3 -0
  412. package/third_party/s2geometry/src/s2/third_party/absl/numeric/int128_no_intrinsic.inc +3 -0
  413. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.cc +198 -0
  414. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii.h +239 -0
  415. package/third_party/s2geometry/src/s2/third_party/absl/strings/ascii_ctype.h +66 -0
  416. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/bits.h +53 -0
  417. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.cc +110 -0
  418. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/memutil.h +146 -0
  419. package/third_party/s2geometry/src/s2/third_party/absl/strings/internal/resize_uninitialized.h +72 -0
  420. package/third_party/s2geometry/src/s2/third_party/absl/strings/match.cc +38 -0
  421. package/third_party/s2geometry/src/s2/third_party/absl/strings/match.h +89 -0
  422. package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.cc +909 -0
  423. package/third_party/s2geometry/src/s2/third_party/absl/strings/numbers.h +187 -0
  424. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.cc +240 -0
  425. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_cat.h +398 -0
  426. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_join.h +22 -0
  427. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.cc +47 -0
  428. package/third_party/s2geometry/src/s2/third_party/absl/strings/str_split.h +43 -0
  429. package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.cc +245 -0
  430. package/third_party/s2geometry/src/s2/third_party/absl/strings/string_view.h +602 -0
  431. package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.cc +42 -0
  432. package/third_party/s2geometry/src/s2/third_party/absl/strings/strip.h +130 -0
  433. package/third_party/s2geometry/src/s2/third_party/absl/types/span.h +793 -0
  434. package/third_party/s2geometry/src/s2/third_party/absl/utility/utility.h +299 -0
  435. package/third_party/s2geometry/src/s2/util/bits/bit-interleave.cc +274 -0
  436. package/third_party/s2geometry/src/s2/util/bits/bit-interleave.h +53 -0
  437. package/third_party/s2geometry/src/s2/util/bits/bits.cc +155 -0
  438. package/third_party/s2geometry/src/s2/util/bits/bits.h +745 -0
  439. package/third_party/s2geometry/src/s2/util/coding/coder.cc +83 -0
  440. package/third_party/s2geometry/src/s2/util/coding/coder.h +553 -0
  441. package/third_party/s2geometry/src/s2/util/coding/nth-derivative.h +134 -0
  442. package/third_party/s2geometry/src/s2/util/coding/transforms.h +62 -0
  443. package/third_party/s2geometry/src/s2/util/coding/varint.cc +289 -0
  444. package/third_party/s2geometry/src/s2/util/coding/varint.h +476 -0
  445. package/third_party/s2geometry/src/s2/util/endian/endian.h +859 -0
  446. package/third_party/s2geometry/src/s2/util/gtl/btree.h +2471 -0
  447. package/third_party/s2geometry/src/s2/util/gtl/btree_container.h +411 -0
  448. package/third_party/s2geometry/src/s2/util/gtl/btree_map.h +79 -0
  449. package/third_party/s2geometry/src/s2/util/gtl/btree_set.h +73 -0
  450. package/third_party/s2geometry/src/s2/util/gtl/compact_array.h +653 -0
  451. package/third_party/s2geometry/src/s2/util/gtl/container_logging.h +291 -0
  452. package/third_party/s2geometry/src/s2/util/gtl/dense_hash_set.h +358 -0
  453. package/third_party/s2geometry/src/s2/util/gtl/densehashtable.h +1493 -0
  454. package/third_party/s2geometry/src/s2/util/gtl/hashtable_common.h +253 -0
  455. package/third_party/s2geometry/src/s2/util/gtl/layout.h +28 -0
  456. package/third_party/s2geometry/src/s2/util/gtl/legacy_random_shuffle.h +77 -0
  457. package/third_party/s2geometry/src/s2/util/hash/mix.h +76 -0
  458. package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.cc +832 -0
  459. package/third_party/s2geometry/src/s2/util/math/exactfloat/exactfloat.h +646 -0
  460. package/third_party/s2geometry/src/s2/util/math/mathutil.cc +75 -0
  461. package/third_party/s2geometry/src/s2/util/math/mathutil.h +189 -0
  462. package/third_party/s2geometry/src/s2/util/math/matrix3x3.h +574 -0
  463. package/third_party/s2geometry/src/s2/util/math/vector.h +569 -0
  464. package/third_party/s2geometry/src/s2/util/math/vector3_hash.h +54 -0
  465. package/third_party/s2geometry/src/s2/util/units/length-units.cc +21 -0
  466. package/third_party/s2geometry/src/s2/util/units/length-units.h +135 -0
  467. package/third_party/s2geometry/src/s2/util/units/physical-units.h +313 -0
  468. package/third_party/s2geometry/src/s2/value_lexicon.h +234 -0
  469. package/third_party/s2geometry/src/s2/value_lexicon_test.cc +121 -0
  470. package/third_party/s2geometry/third_party/cmake/FindGFlags.cmake +48 -0
  471. package/third_party/s2geometry/third_party/cmake/FindGlog.cmake +48 -0
@@ -0,0 +1,739 @@
1
+ // Copyright 2018 The Abseil Authors.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+ //
15
+ // MOTIVATION AND TUTORIAL
16
+ //
17
+ // If you want to put in a single heap allocation N doubles followed by M ints,
18
+ // it's easy if N and M are known at compile time.
19
+ //
20
+ // struct S {
21
+ // double a[N];
22
+ // int b[M];
23
+ // };
24
+ //
25
+ // S* p = new S;
26
+ //
27
+ // But what if N and M are known only in run time? Class template Layout to the
28
+ // rescue! It's a portable generalization of the technique known as struct hack.
29
+ //
30
+ // // This object will tell us everything we need to know about the memory
31
+ // // layout of double[N] followed by int[M]. It's structurally identical to
32
+ // // size_t[2] that stores N and M. It's very cheap to create.
33
+ // const Layout<double, int> layout(N, M);
34
+ //
35
+ // // Allocate enough memory for both arrays. `AllocSize()` tells us how much
36
+ // // memory is needed. We are free to use any allocation function we want as
37
+ // // long as it returns aligned memory.
38
+ // std::unique_ptr<unsigned char[]> p(new unsigned char[layout.AllocSize()]);
39
+ //
40
+ // // Obtain the pointer to the array of doubles.
41
+ // // Equivalent to `reinterpret_cast<double*>(p.get())`.
42
+ // //
43
+ // // We could have written layout.Pointer<0>(p) instead. If all the types are
44
+ // // unique you can use either form, but if some types are repeated you must
45
+ // // use the index form.
46
+ // double* a = layout.Pointer<double>(p.get());
47
+ //
48
+ // // Obtain the pointer to the array of ints.
49
+ // // Equivalent to `reinterpret_cast<int*>(p.get() + N * 8)`.
50
+ // int* b = layout.Pointer<int>(p);
51
+ //
52
+ // If we are unable to specify sizes of all fields, we can pass as many sizes as
53
+ // we can to `Partial()`. In return, it'll allow us to access the fields whose
54
+ // locations and sizes can be computed from the provided information.
55
+ // `Partial()` comes in handy when the array sizes are embedded into the
56
+ // allocation.
57
+ //
58
+ // // size_t[1] containing N, size_t[1] containing M, double[N], int[M].
59
+ // using L = Layout<size_t, size_t, double, int>;
60
+ //
61
+ // unsigned char* Allocate(size_t n, size_t m) {
62
+ // const L layout(1, 1, n, m);
63
+ // unsigned char* p = new unsigned char[layout.AllocSize()];
64
+ // *layout.Pointer<0>(p) = n;
65
+ // *layout.Pointer<1>(p) = m;
66
+ // return p;
67
+ // }
68
+ //
69
+ // void Use(unsigned char* p) {
70
+ // // First, extract N and M.
71
+ // // Specify that the first array has only one element. Using `prefix` we
72
+ // // can access the first two arrays but not more.
73
+ // constexpr auto prefix = L::Partial(1);
74
+ // size_t n = *prefix.Pointer<0>(p);
75
+ // size_t m = *prefix.Pointer<1>(p);
76
+ //
77
+ // // Now we can get pointers to the payload.
78
+ // const L layout(1, 1, n, m);
79
+ // double* a = layout.Pointer<double>(p);
80
+ // int* b = layout.Pointer<int>(p);
81
+ // }
82
+ //
83
+ // The layout we used above combines fixed-size with dynamically-sized fields.
84
+ // This is quite common. Layout is optimized for this use case and generates
85
+ // optimal code. All computations that can be performed at compile time are
86
+ // indeed performed at compile time.
87
+ //
88
+ // Efficiency tip: The order of fields matters. In `Layout<T1, ..., TN>` try to
89
+ // ensure that `alignof(T1) >= ... >= alignof(TN)`. This way you'll have no
90
+ // padding in between arrays.
91
+ //
92
+ // You can manually override the alignment of an array by wrapping the type in
93
+ // `Aligned<T, N>`. `Layout<..., Aligned<T, N>, ...>` has exactly the same API
94
+ // and behavior as `Layout<..., T, ...>` except that the first element of the
95
+ // array of `T` is aligned to `N` (the rest of the elements follow without
96
+ // padding). `N` cannot be less than `alignof(T)`.
97
+ //
98
+ // `AllocSize()` and `Pointer()` are the most basic methods for dealing with
99
+ // memory layouts. Check out the reference or code below to discover more.
100
+ //
101
+ // EXAMPLE
102
+ //
103
+ // // Immutable move-only string with sizeof equal to sizeof(void*). The
104
+ // // string size and the characters are kept in the same heap allocation.
105
+ // class CompactString {
106
+ // public:
107
+ // CompactString(const char* s = "") {
108
+ // const size_t size = strlen(s);
109
+ // // size_t[1] followed by char[size + 1].
110
+ // const L layout(1, size + 1);
111
+ // p_.reset(new unsigned char[layout.AllocSize()]);
112
+ // // If running under ASAN, mark the padding bytes, if any, to catch
113
+ // // memory errors.
114
+ // layout.PoisonPadding(p_.get());
115
+ // // Store the size in the allocation.
116
+ // *layout.Pointer<size_t>(p_.get()) = size;
117
+ // // Store the characters in the allocation.
118
+ // memcpy(layout.Pointer<char>(p_.get()), s, size + 1);
119
+ // }
120
+ //
121
+ // size_t size() const {
122
+ // // Equivalent to reinterpret_cast<size_t&>(*p).
123
+ // return *L::Partial().Pointer<size_t>(p_.get());
124
+ // }
125
+ //
126
+ // const char* c_str() const {
127
+ // // Equivalent to reinterpret_cast<char*>(p.get() + sizeof(size_t)).
128
+ // // The argument in Partial(1) specifies that we have size_t[1] in front
129
+ // // of the characters.
130
+ // return L::Partial(1).Pointer<char>(p_.get());
131
+ // }
132
+ //
133
+ // private:
134
+ // // Our heap allocation contains a size_t followed by an array of chars.
135
+ // using L = Layout<size_t, char>;
136
+ // std::unique_ptr<unsigned char[]> p_;
137
+ // };
138
+ //
139
+ // int main() {
140
+ // CompactString s = "hello";
141
+ // assert(s.size() == 5);
142
+ // assert(strcmp(s.c_str(), "hello") == 0);
143
+ // }
144
+ //
145
+ // DOCUMENTATION
146
+ //
147
+ // The interface exported by this file consists of:
148
+ // - class `Layout<>` and its public members.
149
+ // - The public members of class `internal_layout::LayoutImpl<>`. That class
150
+ // isn't intended to be used directly, and its name and template parameter
151
+ // list are internal implementation details, but the class itself provides
152
+ // most of the functionality in this file. See comments on its members for
153
+ // detailed documentation.
154
+ //
155
+ // `Layout<T1,... Tn>::Partial(count1,..., countm)` (where `m` <= `n`) returns a
156
+ // `LayoutImpl<>` object. `Layout<T1,..., Tn> layout(count1,..., countn)`
157
+ // creates a `Layout` object, which exposes the same functionality by inheriting
158
+ // from `LayoutImpl<>`.
159
+
160
+ #ifndef S2_THIRD_PARTY_ABSL_CONTAINER_INTERNAL_LAYOUT_H_
161
+ #define S2_THIRD_PARTY_ABSL_CONTAINER_INTERNAL_LAYOUT_H_
162
+
163
+ #include <cassert>
164
+ #include <cstddef>
165
+ #include <cstdint>
166
+ #include <ostream>
167
+ #include <string>
168
+ #include <tuple>
169
+ #include <type_traits>
170
+ #include <typeinfo>
171
+ #include <utility>
172
+
173
+ #ifdef ADDRESS_SANITIZER
174
+ #include <sanitizer/asan_interface.h>
175
+ #endif
176
+
177
+ #include "s2/third_party/absl/meta/type_traits.h"
178
+ #include "s2/third_party/absl/strings/str_cat.h"
179
+ #include "s2/third_party/absl/types/span.h"
180
+ #include "s2/third_party/absl/utility/utility.h"
181
+
182
+ #if defined(__GXX_RTTI)
183
+ #define ABSL_INTERNAL_HAS_CXA_DEMANGLE
184
+ #endif
185
+
186
+ #ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
187
+ #include <cxxabi.h>
188
+ #endif
189
+
190
+ namespace absl {
191
+ namespace container_internal {
192
+
193
+ // A type wrapper that instructs `Layout` to use the specific alignment for the
194
+ // array. `Layout<..., Aligned<T, N>, ...>` has exactly the same API
195
+ // and behavior as `Layout<..., T, ...>` except that the first element of the
196
+ // array of `T` is aligned to `N` (the rest of the elements follow without
197
+ // padding).
198
+ //
199
+ // Requires: `N >= alignof(T)` and `N` is a power of 2.
200
+ template <class T, size_t N>
201
+ struct Aligned;
202
+
203
+ namespace internal_layout {
204
+
205
+ template <class T>
206
+ struct NotAligned {};
207
+
208
+ template <class T, size_t N>
209
+ struct NotAligned<const Aligned<T, N>> {
210
+ static_assert(sizeof(T) == 0, "Aligned<T, N> cannot be const-qualified");
211
+ };
212
+
213
+ template <size_t>
214
+ using IntToSize = size_t;
215
+
216
+ template <class>
217
+ using TypeToSize = size_t;
218
+
219
+ template <class T>
220
+ struct Type : NotAligned<T> {
221
+ using type = T;
222
+ };
223
+
224
+ template <class T, size_t N>
225
+ struct Type<Aligned<T, N>> {
226
+ using type = T;
227
+ };
228
+
229
+ template <class T>
230
+ struct SizeOf : NotAligned<T>, std::integral_constant<size_t, sizeof(T)> {};
231
+
232
+ template <class T, size_t N>
233
+ struct SizeOf<Aligned<T, N>> : std::integral_constant<size_t, sizeof(T)> {};
234
+
235
+ // Note: workaround for https://gcc.gnu.org/PR88115
236
+ template <class T>
237
+ struct AlignOf : NotAligned<T> {
238
+ static constexpr size_t value = alignof(T);
239
+ };
240
+
241
+ template <class T, size_t N>
242
+ struct AlignOf<Aligned<T, N>> {
243
+ static_assert(N % alignof(T) == 0,
244
+ "Custom alignment can't be lower than the type's alignment");
245
+ static constexpr size_t value = N;
246
+ };
247
+
248
+ // Does `Ts...` contain `T`?
249
+ template <class T, class... Ts>
250
+ using Contains = absl::disjunction<std::is_same<T, Ts>...>;
251
+
252
+ template <class From, class To>
253
+ using CopyConst =
254
+ typename std::conditional<std::is_const<From>::value, const To, To>::type;
255
+
256
+ // Note: We're not qualifying this with absl:: because it doesn't compile under
257
+ // MSVC.
258
+ template <class T>
259
+ using SliceType = Span<T>;
260
+
261
+ // This namespace contains no types. It prevents functions defined in it from
262
+ // being found by ADL.
263
+ namespace adl_barrier {
264
+
265
+ template <class Needle, class... Ts>
266
+ constexpr size_t Find(Needle, Needle, Ts...) {
267
+ static_assert(!Contains<Needle, Ts...>(), "Duplicate element type");
268
+ return 0;
269
+ }
270
+
271
+ template <class Needle, class T, class... Ts>
272
+ constexpr size_t Find(Needle, T, Ts...) {
273
+ return adl_barrier::Find(Needle(), Ts()...) + 1;
274
+ }
275
+
276
+ constexpr bool IsPow2(size_t n) { return !(n & (n - 1)); }
277
+
278
+ // Returns `q * m` for the smallest `q` such that `q * m >= n`.
279
+ // Requires: `m` is a power of two. It's enforced by IsLegalElementType below.
280
+ constexpr size_t Align(size_t n, size_t m) { return (n + m - 1) & ~(m - 1); }
281
+
282
+ constexpr size_t Min(size_t a, size_t b) { return b < a ? b : a; }
283
+
284
+ constexpr size_t Max(size_t a) { return a; }
285
+
286
+ template <class... Ts>
287
+ constexpr size_t Max(size_t a, size_t b, Ts... rest) {
288
+ return adl_barrier::Max(b < a ? a : b, rest...);
289
+ }
290
+
291
+ template <class T>
292
+ string TypeName() {
293
+ string out;
294
+ int status = 0;
295
+ char* demangled = nullptr;
296
+ #ifdef ABSL_INTERNAL_HAS_CXA_DEMANGLE
297
+ demangled = abi::__cxa_demangle(typeid(T).name(), nullptr, nullptr, &status);
298
+ #endif
299
+ if (status == 0 && demangled != nullptr) { // Demangling succeeded.
300
+ absl::StrAppend(&out, "<", demangled, ">");
301
+ free(demangled);
302
+ } else {
303
+ #if defined(__GXX_RTTI) || defined(_CPPRTTI)
304
+ absl::StrAppend(&out, "<", typeid(T).name(), ">");
305
+ #endif
306
+ }
307
+ return out;
308
+ }
309
+
310
+ } // namespace adl_barrier
311
+
312
+ template <bool C>
313
+ using EnableIf = typename std::enable_if<C, int>::type;
314
+
315
+ // Can `T` be a template argument of `Layout`?
316
+ template <class T>
317
+ using IsLegalElementType = std::integral_constant<
318
+ bool, !std::is_reference<T>::value && !std::is_volatile<T>::value &&
319
+ !std::is_reference<typename Type<T>::type>::value &&
320
+ !std::is_volatile<typename Type<T>::type>::value &&
321
+ adl_barrier::IsPow2(AlignOf<T>::value)>;
322
+
323
+ template <class Elements, class SizeSeq, class OffsetSeq>
324
+ class LayoutImpl;
325
+
326
+ // Public base class of `Layout` and the result type of `Layout::Partial()`.
327
+ //
328
+ // `Elements...` contains all template arguments of `Layout` that created this
329
+ // instance.
330
+ //
331
+ // `SizeSeq...` is `[0, NumSizes)` where `NumSizes` is the number of arguments
332
+ // passed to `Layout::Partial()` or `Layout::Layout()`.
333
+ //
334
+ // `OffsetSeq...` is `[0, NumOffsets)` where `NumOffsets` is
335
+ // `Min(sizeof...(Elements), NumSizes + 1)` (the number of arrays for which we
336
+ // can compute offsets).
337
+ template <class... Elements, size_t... SizeSeq, size_t... OffsetSeq>
338
+ class LayoutImpl<std::tuple<Elements...>, absl::index_sequence<SizeSeq...>,
339
+ absl::index_sequence<OffsetSeq...>> {
340
+ private:
341
+ static_assert(sizeof...(Elements) > 0, "At least one field is required");
342
+ static_assert(absl::conjunction<IsLegalElementType<Elements>...>::value,
343
+ "Invalid element type (see IsLegalElementType)");
344
+
345
+ enum {
346
+ NumTypes = sizeof...(Elements),
347
+ NumSizes = sizeof...(SizeSeq),
348
+ NumOffsets = sizeof...(OffsetSeq),
349
+ };
350
+
351
+ // These are guaranteed by `Layout`.
352
+ static_assert(NumOffsets == adl_barrier::Min(NumTypes, NumSizes + 1),
353
+ "Internal error");
354
+ static_assert(NumTypes > 0, "Internal error");
355
+
356
+ // Returns the index of `T` in `Elements...`. Results in a compilation error
357
+ // if `Elements...` doesn't contain exactly one instance of `T`.
358
+ template <class T>
359
+ static constexpr size_t ElementIndex() {
360
+ static_assert(Contains<Type<T>, Type<typename Type<Elements>::type>...>(),
361
+ "Type not found");
362
+ return adl_barrier::Find(Type<T>(),
363
+ Type<typename Type<Elements>::type>()...);
364
+ }
365
+
366
+ template <size_t N>
367
+ using ElementAlignment =
368
+ AlignOf<typename std::tuple_element<N, std::tuple<Elements...>>::type>;
369
+
370
+ public:
371
+ // Element types of all arrays packed in a tuple.
372
+ using ElementTypes = std::tuple<typename Type<Elements>::type...>;
373
+
374
+ // Element type of the Nth array.
375
+ template <size_t N>
376
+ using ElementType = typename std::tuple_element<N, ElementTypes>::type;
377
+
378
+ constexpr explicit LayoutImpl(IntToSize<SizeSeq>... sizes)
379
+ : size_{sizes...} {}
380
+
381
+ // Alignment of the layout, equal to the strictest alignment of all elements.
382
+ // All pointers passed to the methods of layout must be aligned to this value.
383
+ static constexpr size_t Alignment() {
384
+ return adl_barrier::Max(AlignOf<Elements>::value...);
385
+ }
386
+
387
+ // Offset in bytes of the Nth array.
388
+ //
389
+ // // int[3], 4 bytes of padding, double[4].
390
+ // Layout<int, double> x(3, 4);
391
+ // assert(x.Offset<0>() == 0); // The ints starts from 0.
392
+ // assert(x.Offset<1>() == 16); // The doubles starts from 16.
393
+ //
394
+ // Requires: `N <= NumSizes && N < sizeof...(Ts)`.
395
+ template <size_t N, EnableIf<N == 0> = 0>
396
+ constexpr size_t Offset() const {
397
+ return 0;
398
+ }
399
+
400
+ template <size_t N, EnableIf<N != 0> = 0>
401
+ constexpr size_t Offset() const {
402
+ static_assert(N < NumOffsets, "Index out of bounds");
403
+ return adl_barrier::Align(
404
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>() * size_[N - 1],
405
+ ElementAlignment<N>::value);
406
+ }
407
+
408
+ // Offset in bytes of the array with the specified element type. There must
409
+ // be exactly one such array and its zero-based index must be at most
410
+ // `NumSizes`.
411
+ //
412
+ // // int[3], 4 bytes of padding, double[4].
413
+ // Layout<int, double> x(3, 4);
414
+ // assert(x.Offset<int>() == 0); // The ints starts from 0.
415
+ // assert(x.Offset<double>() == 16); // The doubles starts from 16.
416
+ template <class T>
417
+ constexpr size_t Offset() const {
418
+ return Offset<ElementIndex<T>()>();
419
+ }
420
+
421
+ // Offsets in bytes of all arrays for which the offsets are known.
422
+ constexpr std::array<size_t, NumOffsets> Offsets() const {
423
+ return {{Offset<OffsetSeq>()...}};
424
+ }
425
+
426
+ // The number of elements in the Nth array. This is the Nth argument of
427
+ // `Layout::Partial()` or `Layout::Layout()` (zero-based).
428
+ //
429
+ // // int[3], 4 bytes of padding, double[4].
430
+ // Layout<int, double> x(3, 4);
431
+ // assert(x.Size<0>() == 3);
432
+ // assert(x.Size<1>() == 4);
433
+ //
434
+ // Requires: `N < NumSizes`.
435
+ template <size_t N>
436
+ constexpr size_t Size() const {
437
+ static_assert(N < NumSizes, "Index out of bounds");
438
+ return size_[N];
439
+ }
440
+
441
+ // The number of elements in the array with the specified element type.
442
+ // There must be exactly one such array and its zero-based index must be
443
+ // at most `NumSizes`.
444
+ //
445
+ // // int[3], 4 bytes of padding, double[4].
446
+ // Layout<int, double> x(3, 4);
447
+ // assert(x.Size<int>() == 3);
448
+ // assert(x.Size<double>() == 4);
449
+ template <class T>
450
+ constexpr size_t Size() const {
451
+ return Size<ElementIndex<T>()>();
452
+ }
453
+
454
+ // The number of elements of all arrays for which they are known.
455
+ constexpr std::array<size_t, NumSizes> Sizes() const {
456
+ return {{Size<SizeSeq>()...}};
457
+ }
458
+
459
+ // Pointer to the beginning of the Nth array.
460
+ //
461
+ // `Char` must be `[const] [signed|unsigned] char`.
462
+ //
463
+ // // int[3], 4 bytes of padding, double[4].
464
+ // Layout<int, double> x(3, 4);
465
+ // unsigned char* p = new unsigned char[x.AllocSize()];
466
+ // int* ints = x.Pointer<0>(p);
467
+ // double* doubles = x.Pointer<1>(p);
468
+ //
469
+ // Requires: `N <= NumSizes && N < sizeof...(Ts)`.
470
+ // Requires: `p` is aligned to `Alignment()`.
471
+ template <size_t N, class Char>
472
+ CopyConst<Char, ElementType<N>>* Pointer(Char* p) const {
473
+ using C = typename std::remove_const<Char>::type;
474
+ static_assert(
475
+ std::is_same<C, char>() || std::is_same<C, unsigned char>() ||
476
+ std::is_same<C, signed char>(),
477
+ "The argument must be a pointer to [const] [signed|unsigned] char");
478
+ // Use a named variable to work around b/33479323.
479
+ constexpr size_t alignment = Alignment();
480
+ (void)alignment;
481
+ assert(reinterpret_cast<uintptr_t>(p) % alignment == 0);
482
+ return reinterpret_cast<CopyConst<Char, ElementType<N>>*>(p + Offset<N>());
483
+ }
484
+
485
+ // Pointer to the beginning of the array with the specified element type.
486
+ // There must be exactly one such array and its zero-based index must be at
487
+ // most `NumSizes`.
488
+ //
489
+ // `Char` must be `[const] [signed|unsigned] char`.
490
+ //
491
+ // // int[3], 4 bytes of padding, double[4].
492
+ // Layout<int, double> x(3, 4);
493
+ // unsigned char* p = new unsigned char[x.AllocSize()];
494
+ // int* ints = x.Pointer<int>(p);
495
+ // double* doubles = x.Pointer<double>(p);
496
+ //
497
+ // Requires: `p` is aligned to `Alignment()`.
498
+ template <class T, class Char>
499
+ CopyConst<Char, T>* Pointer(Char* p) const {
500
+ return Pointer<ElementIndex<T>()>(p);
501
+ }
502
+
503
+ // Pointers to all arrays for which pointers are known.
504
+ //
505
+ // `Char` must be `[const] [signed|unsigned] char`.
506
+ //
507
+ // // int[3], 4 bytes of padding, double[4].
508
+ // Layout<int, double> x(3, 4);
509
+ // unsigned char* p = new unsigned char[x.AllocSize()];
510
+ //
511
+ // int* ints;
512
+ // double* doubles;
513
+ // std::tie(ints, doubles) = x.Pointers(p);
514
+ //
515
+ // Requires: `p` is aligned to `Alignment()`.
516
+ //
517
+ // Note: We're not using ElementType alias here because it does not compile
518
+ // under MSVC.
519
+ template <class Char>
520
+ std::tuple<CopyConst<
521
+ Char, typename std::tuple_element<OffsetSeq, ElementTypes>::type>*...>
522
+ Pointers(Char* p) const {
523
+ return std::tuple<CopyConst<Char, ElementType<OffsetSeq>>*...>(
524
+ Pointer<OffsetSeq>(p)...);
525
+ }
526
+
527
+ // The Nth array.
528
+ //
529
+ // `Char` must be `[const] [signed|unsigned] char`.
530
+ //
531
+ // // int[3], 4 bytes of padding, double[4].
532
+ // Layout<int, double> x(3, 4);
533
+ // unsigned char* p = new unsigned char[x.AllocSize()];
534
+ // Span<int> ints = x.Slice<0>(p);
535
+ // Span<double> doubles = x.Slice<1>(p);
536
+ //
537
+ // Requires: `N < NumSizes`.
538
+ // Requires: `p` is aligned to `Alignment()`.
539
+ template <size_t N, class Char>
540
+ SliceType<CopyConst<Char, ElementType<N>>> Slice(Char* p) const {
541
+ return SliceType<CopyConst<Char, ElementType<N>>>(Pointer<N>(p), Size<N>());
542
+ }
543
+
544
+ // The array with the specified element type. There must be exactly one
545
+ // such array and its zero-based index must be less than `NumSizes`.
546
+ //
547
+ // `Char` must be `[const] [signed|unsigned] char`.
548
+ //
549
+ // // int[3], 4 bytes of padding, double[4].
550
+ // Layout<int, double> x(3, 4);
551
+ // unsigned char* p = new unsigned char[x.AllocSize()];
552
+ // Span<int> ints = x.Slice<int>(p);
553
+ // Span<double> doubles = x.Slice<double>(p);
554
+ //
555
+ // Requires: `p` is aligned to `Alignment()`.
556
+ template <class T, class Char>
557
+ SliceType<CopyConst<Char, T>> Slice(Char* p) const {
558
+ return Slice<ElementIndex<T>()>(p);
559
+ }
560
+
561
+ // All arrays with known sizes.
562
+ //
563
+ // `Char` must be `[const] [signed|unsigned] char`.
564
+ //
565
+ // // int[3], 4 bytes of padding, double[4].
566
+ // Layout<int, double> x(3, 4);
567
+ // unsigned char* p = new unsigned char[x.AllocSize()];
568
+ //
569
+ // Span<int> ints;
570
+ // Span<double> doubles;
571
+ // std::tie(ints, doubles) = x.Slices(p);
572
+ //
573
+ // Requires: `p` is aligned to `Alignment()`.
574
+ //
575
+ // Note: We're not using ElementType alias here because it does not compile
576
+ // under MSVC.
577
+ template <class Char>
578
+ std::tuple<SliceType<CopyConst<
579
+ Char, typename std::tuple_element<SizeSeq, ElementTypes>::type>>...>
580
+ Slices(Char* p) const {
581
+ // Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63875 (fixed
582
+ // in 6.1).
583
+ (void)p;
584
+ return std::tuple<SliceType<CopyConst<Char, ElementType<SizeSeq>>>...>(
585
+ Slice<SizeSeq>(p)...);
586
+ }
587
+
588
+ // The size of the allocation that fits all arrays.
589
+ //
590
+ // // int[3], 4 bytes of padding, double[4].
591
+ // Layout<int, double> x(3, 4);
592
+ // unsigned char* p = new unsigned char[x.AllocSize()]; // 48 bytes
593
+ //
594
+ // Requires: `NumSizes == sizeof...(Ts)`.
595
+ constexpr size_t AllocSize() const {
596
+ static_assert(NumTypes == NumSizes, "You must specify sizes of all fields");
597
+ return Offset<NumTypes - 1>() +
598
+ SizeOf<ElementType<NumTypes - 1>>() * size_[NumTypes - 1];
599
+ }
600
+
601
+ // If built with --config=asan, poisons padding bytes (if any) in the
602
+ // allocation. The pointer must point to a memory block at least
603
+ // `AllocSize()` bytes in length.
604
+ //
605
+ // `Char` must be `[const] [signed|unsigned] char`.
606
+ //
607
+ // Requires: `p` is aligned to `Alignment()`.
608
+ template <class Char, size_t N = NumOffsets - 1, EnableIf<N == 0> = 0>
609
+ void PoisonPadding(const Char* p) const {
610
+ Pointer<0>(p); // verify the requirements on `Char` and `p`
611
+ }
612
+
613
+ template <class Char, size_t N = NumOffsets - 1, EnableIf<N != 0> = 0>
614
+ void PoisonPadding(const Char* p) const {
615
+ static_assert(N < NumOffsets, "Index out of bounds");
616
+ (void)p;
617
+ #ifdef ADDRESS_SANITIZER
618
+ PoisonPadding<Char, N - 1>(p);
619
+ // The `if` is an optimization. It doesn't affect the observable behaviour.
620
+ if (ElementAlignment<N - 1>::value % ElementAlignment<N>::value) {
621
+ size_t start =
622
+ Offset<N - 1>() + SizeOf<ElementType<N - 1>>() * size_[N - 1];
623
+ ASAN_POISON_MEMORY_REGION(p + start, Offset<N>() - start);
624
+ }
625
+ #endif
626
+ }
627
+
628
+ // Human-readable description of the memory layout. Useful for debugging.
629
+ // Slow.
630
+ //
631
+ // // char[5], 3 bytes of padding, int[3], 4 bytes of padding, followed
632
+ // // by an unknown number of doubles.
633
+ // auto x = Layout<char, int, double>::Partial(5, 3);
634
+ // assert(x.DebugString() ==
635
+ // "@0<char>(1)[5]; @8<int>(4)[3]; @24<double>(8)");
636
+ //
637
+ // Each field is in the following format: @offset<type>(sizeof)[size] (<type>
638
+ // may be missing depending on the target platform). For example,
639
+ // @8<int>(4)[3] means that at offset 8 we have an array of ints, where each
640
+ // int is 4 bytes, and we have 3 of those ints. The size of the last field may
641
+ // be missing (as in the example above). Only fields with known offsets are
642
+ // described. Type names may differ across platforms: one compiler might
643
+ // produce "unsigned*" where another produces "unsigned int *".
644
+ string DebugString() const {
645
+ const auto offsets = Offsets();
646
+ const size_t sizes[] = {SizeOf<ElementType<OffsetSeq>>()...};
647
+ const string types[] = {adl_barrier::TypeName<ElementType<OffsetSeq>>()...};
648
+ string res = absl::StrCat("@0", types[0], "(", sizes[0], ")");
649
+ for (size_t i = 0; i != NumOffsets - 1; ++i) {
650
+ absl::StrAppend(&res, "[", size_[i], "]; @", offsets[i + 1], types[i + 1],
651
+ "(", sizes[i + 1], ")");
652
+ }
653
+ // NumSizes is a constant that may be zero. Some compilers cannot see that
654
+ // inside the if statement "size_[NumSizes - 1]" must be valid.
655
+ int last = static_cast<int>(NumSizes) - 1;
656
+ if (NumTypes == NumSizes && last >= 0) {
657
+ absl::StrAppend(&res, "[", size_[last], "]");
658
+ }
659
+ return res;
660
+ }
661
+
662
+ private:
663
+ // Arguments of `Layout::Partial()` or `Layout::Layout()`.
664
+ size_t size_[NumSizes > 0 ? NumSizes : 1];
665
+ };
666
+
667
+ template <size_t NumSizes, class... Ts>
668
+ using LayoutType = LayoutImpl<
669
+ std::tuple<Ts...>, absl::make_index_sequence<NumSizes>,
670
+ absl::make_index_sequence<adl_barrier::Min(sizeof...(Ts), NumSizes + 1)>>;
671
+
672
+ } // namespace internal_layout
673
+
674
+ // Descriptor of arrays of various types and sizes laid out in memory one after
675
+ // another. See the top of the file for documentation.
676
+ //
677
+ // Check out the public API of internal_layout::LayoutImpl above. The type is
678
+ // internal to the library but its methods are public, and they are inherited
679
+ // by `Layout`.
680
+ template <class... Ts>
681
+ class Layout : public internal_layout::LayoutType<sizeof...(Ts), Ts...> {
682
+ public:
683
+ static_assert(sizeof...(Ts) > 0, "At least one field is required");
684
+ static_assert(
685
+ absl::conjunction<internal_layout::IsLegalElementType<Ts>...>::value,
686
+ "Invalid element type (see IsLegalElementType)");
687
+
688
+ // The result type of `Partial()` with `NumSizes` arguments.
689
+ template <size_t NumSizes>
690
+ using PartialType = internal_layout::LayoutType<NumSizes, Ts...>;
691
+
692
+ // `Layout` knows the element types of the arrays we want to lay out in
693
+ // memory but not the number of elements in each array.
694
+ // `Partial(size1, ..., sizeN)` allows us to specify the latter. The
695
+ // resulting immutable object can be used to obtain pointers to the
696
+ // individual arrays.
697
+ //
698
+ // It's allowed to pass fewer array sizes than the number of arrays. E.g.,
699
+ // if all you need is to the offset of the second array, you only need to
700
+ // pass one argument -- the number of elements in the first array.
701
+ //
702
+ // // int[3] followed by 4 bytes of padding and an unknown number of
703
+ // // doubles.
704
+ // auto x = Layout<int, double>::Partial(3);
705
+ // // doubles start at byte 16.
706
+ // assert(x.Offset<1>() == 16);
707
+ //
708
+ // If you know the number of elements in all arrays, you can still call
709
+ // `Partial()` but it's more convenient to use the constructor of `Layout`.
710
+ //
711
+ // Layout<int, double> x(3, 5);
712
+ //
713
+ // Note: The sizes of the arrays must be specified in number of elements,
714
+ // not in bytes.
715
+ //
716
+ // Requires: `sizeof...(Sizes) <= sizeof...(Ts)`.
717
+ // Requires: all arguments are convertible to `size_t`.
718
+ template <class... Sizes>
719
+ static constexpr PartialType<sizeof...(Sizes)> Partial(Sizes&&... sizes) {
720
+ static_assert(sizeof...(Sizes) <= sizeof...(Ts), "");
721
+ return PartialType<sizeof...(Sizes)>(absl::forward<Sizes>(sizes)...);
722
+ }
723
+
724
+ // Creates a layout with the sizes of all arrays specified. If you know
725
+ // only the sizes of the first N arrays (where N can be zero), you can use
726
+ // `Partial()` defined above. The constructor is essentially equivalent to
727
+ // calling `Partial()` and passing in all array sizes; the constructor is
728
+ // provided as a convenient abbreviation.
729
+ //
730
+ // Note: The sizes of the arrays must be specified in number of elements,
731
+ // not in bytes.
732
+ constexpr explicit Layout(internal_layout::TypeToSize<Ts>... sizes)
733
+ : internal_layout::LayoutType<sizeof...(Ts), Ts...>(sizes...) {}
734
+ };
735
+
736
+ } // namespace container_internal
737
+ } // namespace absl
738
+
739
+ #endif // S2_THIRD_PARTY_ABSL_CONTAINER_INTERNAL_LAYOUT_H_