re2 1.23.0 → 1.23.2

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 (280) hide show
  1. package/README.md +2 -0
  2. package/binding.gyp +3 -2
  3. package/package.json +5 -5
  4. package/vendor/abseil-cpp/CMake/AbseilDll.cmake +25 -4
  5. package/vendor/abseil-cpp/CMake/AbseilHelpers.cmake +6 -1
  6. package/vendor/abseil-cpp/CMakeLists.txt +2 -2
  7. package/vendor/abseil-cpp/MODULE.bazel +2 -2
  8. package/vendor/abseil-cpp/absl/algorithm/BUILD.bazel +0 -1
  9. package/vendor/abseil-cpp/absl/algorithm/CMakeLists.txt +0 -2
  10. package/vendor/abseil-cpp/absl/algorithm/container.h +191 -140
  11. package/vendor/abseil-cpp/absl/algorithm/container_test.cc +818 -0
  12. package/vendor/abseil-cpp/absl/base/BUILD.bazel +44 -5
  13. package/vendor/abseil-cpp/absl/base/CMakeLists.txt +42 -3
  14. package/vendor/abseil-cpp/absl/base/attributes.h +5 -1
  15. package/vendor/abseil-cpp/absl/base/call_once_test.cc +10 -10
  16. package/vendor/abseil-cpp/absl/base/casts.cc +61 -0
  17. package/vendor/abseil-cpp/absl/base/casts.h +128 -2
  18. package/vendor/abseil-cpp/absl/base/casts_test.cc +151 -0
  19. package/vendor/abseil-cpp/absl/base/config.h +13 -37
  20. package/vendor/abseil-cpp/absl/base/internal/dynamic_annotations.h +1 -1
  21. package/vendor/abseil-cpp/absl/base/internal/iterator_traits.h +4 -0
  22. package/vendor/abseil-cpp/absl/base/internal/nullability_traits.h +71 -0
  23. package/vendor/abseil-cpp/absl/base/internal/nullability_traits_test.cc +98 -0
  24. package/vendor/abseil-cpp/absl/base/internal/raw_logging.cc +3 -4
  25. package/vendor/abseil-cpp/absl/base/internal/spinlock.cc +13 -7
  26. package/vendor/abseil-cpp/absl/base/internal/spinlock.h +16 -11
  27. package/vendor/abseil-cpp/absl/base/internal/strerror_test.cc +2 -1
  28. package/vendor/abseil-cpp/absl/base/internal/sysinfo.cc +0 -9
  29. package/vendor/abseil-cpp/absl/base/internal/sysinfo_test.cc +0 -6
  30. package/vendor/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +1 -1
  31. package/vendor/abseil-cpp/absl/base/internal/unscaledcycleclock_config.h +1 -1
  32. package/vendor/abseil-cpp/absl/base/macros.h +40 -17
  33. package/vendor/abseil-cpp/absl/base/nullability.h +1 -1
  34. package/vendor/abseil-cpp/absl/base/optimization.h +1 -3
  35. package/vendor/abseil-cpp/absl/base/options.h +1 -27
  36. package/vendor/abseil-cpp/absl/base/spinlock_test_common.cc +5 -8
  37. package/vendor/abseil-cpp/absl/cleanup/cleanup.h +4 -0
  38. package/vendor/abseil-cpp/absl/container/BUILD.bazel +195 -2
  39. package/vendor/abseil-cpp/absl/container/CMakeLists.txt +136 -2
  40. package/vendor/abseil-cpp/absl/container/btree_map.h +56 -6
  41. package/vendor/abseil-cpp/absl/container/btree_set.h +52 -6
  42. package/vendor/abseil-cpp/absl/container/btree_test.cc +107 -1
  43. package/vendor/abseil-cpp/absl/container/chunked_queue.h +755 -0
  44. package/vendor/abseil-cpp/absl/container/chunked_queue_benchmark.cc +386 -0
  45. package/vendor/abseil-cpp/absl/container/chunked_queue_test.cc +768 -0
  46. package/vendor/abseil-cpp/absl/container/fixed_array.h +4 -6
  47. package/vendor/abseil-cpp/absl/container/flat_hash_map.h +16 -6
  48. package/vendor/abseil-cpp/absl/container/flat_hash_map_test.cc +1 -2
  49. package/vendor/abseil-cpp/absl/container/flat_hash_set.h +16 -6
  50. package/vendor/abseil-cpp/absl/container/flat_hash_set_test.cc +0 -2
  51. package/vendor/abseil-cpp/absl/container/inlined_vector.h +12 -4
  52. package/vendor/abseil-cpp/absl/container/inlined_vector_test.cc +21 -0
  53. package/vendor/abseil-cpp/absl/container/internal/btree_container.h +14 -5
  54. package/vendor/abseil-cpp/absl/container/internal/chunked_queue.h +173 -0
  55. package/vendor/abseil-cpp/absl/container/internal/common.h +51 -0
  56. package/vendor/abseil-cpp/absl/container/internal/container_memory.h +7 -1
  57. package/vendor/abseil-cpp/absl/container/internal/container_memory_test.cc +11 -0
  58. package/vendor/abseil-cpp/absl/container/internal/hash_generator_testing.cc +0 -2
  59. package/vendor/abseil-cpp/absl/container/internal/hash_generator_testing.h +1 -2
  60. package/vendor/abseil-cpp/absl/container/internal/hash_policy_testing.h +0 -14
  61. package/vendor/abseil-cpp/absl/container/internal/hashtable_control_bytes.h +11 -8
  62. package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.cc +3 -4
  63. package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler.h +23 -6
  64. package/vendor/abseil-cpp/absl/container/internal/hashtablez_sampler_test.cc +31 -15
  65. package/vendor/abseil-cpp/absl/container/internal/heterogeneous_lookup_testing.h +80 -0
  66. package/vendor/abseil-cpp/absl/container/internal/inlined_vector.h +4 -12
  67. package/vendor/abseil-cpp/absl/container/internal/raw_hash_map.h +35 -10
  68. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set.cc +149 -23
  69. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set.h +120 -126
  70. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_allocator_test.cc +4 -0
  71. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_benchmark.cc +8 -0
  72. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_probe_benchmark.cc +14 -59
  73. package/vendor/abseil-cpp/absl/container/internal/raw_hash_set_test.cc +111 -22
  74. package/vendor/abseil-cpp/absl/container/internal/unordered_map_constructor_test.h +53 -112
  75. package/vendor/abseil-cpp/absl/container/internal/unordered_map_lookup_test.h +10 -15
  76. package/vendor/abseil-cpp/absl/container/internal/unordered_map_members_test.h +3 -3
  77. package/vendor/abseil-cpp/absl/container/internal/unordered_map_modifiers_test.h +45 -61
  78. package/vendor/abseil-cpp/absl/container/internal/unordered_set_constructor_test.h +53 -112
  79. package/vendor/abseil-cpp/absl/container/internal/unordered_set_lookup_test.h +6 -9
  80. package/vendor/abseil-cpp/absl/container/internal/unordered_set_members_test.h +3 -3
  81. package/vendor/abseil-cpp/absl/container/internal/unordered_set_modifiers_test.h +25 -31
  82. package/vendor/abseil-cpp/absl/container/linked_hash_map.h +666 -0
  83. package/vendor/abseil-cpp/absl/container/linked_hash_map_benchmark.cc +140 -0
  84. package/vendor/abseil-cpp/absl/container/linked_hash_map_test.cc +987 -0
  85. package/vendor/abseil-cpp/absl/container/linked_hash_set.h +527 -0
  86. package/vendor/abseil-cpp/absl/container/linked_hash_set_benchmark.cc +84 -0
  87. package/vendor/abseil-cpp/absl/container/linked_hash_set_test.cc +947 -0
  88. package/vendor/abseil-cpp/absl/container/node_hash_map.h +17 -6
  89. package/vendor/abseil-cpp/absl/container/node_hash_set.h +16 -5
  90. package/vendor/abseil-cpp/absl/container/node_hash_set_test.cc +1 -2
  91. package/vendor/abseil-cpp/absl/copts/GENERATED_AbseilCopts.cmake +79 -0
  92. package/vendor/abseil-cpp/absl/copts/GENERATED_copts.bzl +79 -0
  93. package/vendor/abseil-cpp/absl/copts/copts.py +17 -4
  94. package/vendor/abseil-cpp/absl/crc/internal/crc_x86_arm_combined.cc +67 -13
  95. package/vendor/abseil-cpp/absl/crc/internal/non_temporal_arm_intrinsics.h +4 -2
  96. package/vendor/abseil-cpp/absl/debugging/BUILD.bazel +31 -0
  97. package/vendor/abseil-cpp/absl/debugging/CMakeLists.txt +34 -0
  98. package/vendor/abseil-cpp/absl/debugging/failure_signal_handler.cc +2 -2
  99. package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.cc +118 -0
  100. package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer.h +71 -0
  101. package/vendor/abseil-cpp/absl/debugging/internal/borrowed_fixup_buffer_test.cc +97 -0
  102. package/vendor/abseil-cpp/absl/debugging/internal/demangle.cc +2 -2
  103. package/vendor/abseil-cpp/absl/debugging/internal/elf_mem_image.h +4 -4
  104. package/vendor/abseil-cpp/absl/debugging/internal/examine_stack.cc +4 -0
  105. package/vendor/abseil-cpp/absl/debugging/internal/examine_stack.h +7 -0
  106. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_aarch64-inl.inc +1 -1
  107. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_emscripten-inl.inc +0 -7
  108. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc +3 -2
  109. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_riscv-inl.inc +2 -1
  110. package/vendor/abseil-cpp/absl/debugging/internal/stacktrace_x86-inl.inc +8 -3
  111. package/vendor/abseil-cpp/absl/debugging/internal/symbolize.h +2 -2
  112. package/vendor/abseil-cpp/absl/debugging/stacktrace.cc +35 -67
  113. package/vendor/abseil-cpp/absl/debugging/stacktrace.h +3 -0
  114. package/vendor/abseil-cpp/absl/debugging/stacktrace_benchmark.cc +24 -1
  115. package/vendor/abseil-cpp/absl/debugging/stacktrace_test.cc +39 -15
  116. package/vendor/abseil-cpp/absl/debugging/symbolize_emscripten.inc +4 -17
  117. package/vendor/abseil-cpp/absl/debugging/symbolize_test.cc +25 -40
  118. package/vendor/abseil-cpp/absl/debugging/symbolize_win32.inc +2 -4
  119. package/vendor/abseil-cpp/absl/flags/BUILD.bazel +1 -0
  120. package/vendor/abseil-cpp/absl/flags/declare.h +9 -0
  121. package/vendor/abseil-cpp/absl/flags/flag.h +2 -1
  122. package/vendor/abseil-cpp/absl/flags/internal/commandlineflag.h +1 -1
  123. package/vendor/abseil-cpp/absl/flags/internal/flag.cc +3 -2
  124. package/vendor/abseil-cpp/absl/flags/marshalling.cc +1 -16
  125. package/vendor/abseil-cpp/absl/flags/parse.cc +4 -2
  126. package/vendor/abseil-cpp/absl/flags/parse_test.cc +1 -1
  127. package/vendor/abseil-cpp/absl/flags/reflection.cc +4 -3
  128. package/vendor/abseil-cpp/absl/functional/BUILD.bazel +4 -0
  129. package/vendor/abseil-cpp/absl/functional/CMakeLists.txt +4 -0
  130. package/vendor/abseil-cpp/absl/functional/any_invocable.h +3 -1
  131. package/vendor/abseil-cpp/absl/functional/function_ref.h +125 -20
  132. package/vendor/abseil-cpp/absl/functional/function_ref_test.cc +122 -9
  133. package/vendor/abseil-cpp/absl/functional/internal/any_invocable.h +13 -2
  134. package/vendor/abseil-cpp/absl/functional/internal/function_ref.h +42 -4
  135. package/vendor/abseil-cpp/absl/hash/hash_benchmark.cc +11 -0
  136. package/vendor/abseil-cpp/absl/hash/hash_test.cc +5 -2
  137. package/vendor/abseil-cpp/absl/hash/internal/hash.cc +184 -53
  138. package/vendor/abseil-cpp/absl/hash/internal/hash.h +116 -10
  139. package/vendor/abseil-cpp/absl/hash/internal/low_level_hash_test.cc +43 -4
  140. package/vendor/abseil-cpp/absl/log/BUILD.bazel +2 -0
  141. package/vendor/abseil-cpp/absl/log/CMakeLists.txt +35 -1
  142. package/vendor/abseil-cpp/absl/log/check_test_impl.inc +59 -4
  143. package/vendor/abseil-cpp/absl/log/die_if_null.cc +3 -1
  144. package/vendor/abseil-cpp/absl/log/die_if_null.h +24 -3
  145. package/vendor/abseil-cpp/absl/log/internal/BUILD.bazel +31 -1
  146. package/vendor/abseil-cpp/absl/log/internal/check_impl.h +2 -1
  147. package/vendor/abseil-cpp/absl/log/internal/check_op.cc +3 -1
  148. package/vendor/abseil-cpp/absl/log/internal/check_op.h +44 -18
  149. package/vendor/abseil-cpp/absl/log/internal/conditions.h +38 -35
  150. package/vendor/abseil-cpp/absl/log/internal/container.h +312 -0
  151. package/vendor/abseil-cpp/absl/log/internal/container_test.cc +254 -0
  152. package/vendor/abseil-cpp/absl/log/internal/log_impl.h +108 -110
  153. package/vendor/abseil-cpp/absl/log/internal/log_message.cc +5 -2
  154. package/vendor/abseil-cpp/absl/log/internal/log_message.h +5 -1
  155. package/vendor/abseil-cpp/absl/log/internal/strip.h +30 -31
  156. package/vendor/abseil-cpp/absl/log/internal/vlog_config.cc +19 -19
  157. package/vendor/abseil-cpp/absl/log/internal/vlog_config.h +0 -1
  158. package/vendor/abseil-cpp/absl/log/log.h +2 -2
  159. package/vendor/abseil-cpp/absl/meta/BUILD.bazel +51 -0
  160. package/vendor/abseil-cpp/absl/meta/CMakeLists.txt +46 -0
  161. package/vendor/abseil-cpp/absl/meta/internal/constexpr_testing.h +73 -0
  162. package/vendor/abseil-cpp/absl/meta/internal/constexpr_testing_test.cc +40 -0
  163. package/vendor/abseil-cpp/absl/meta/internal/requires.h +67 -0
  164. package/vendor/abseil-cpp/absl/meta/internal/requires_test.cc +66 -0
  165. package/vendor/abseil-cpp/absl/meta/type_traits.h +42 -1
  166. package/vendor/abseil-cpp/absl/meta/type_traits_test.cc +14 -0
  167. package/vendor/abseil-cpp/absl/numeric/int128.h +41 -21
  168. package/vendor/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +16 -22
  169. package/vendor/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +5 -7
  170. package/vendor/abseil-cpp/absl/numeric/int128_test.cc +52 -5
  171. package/vendor/abseil-cpp/absl/profiling/BUILD.bazel +1 -0
  172. package/vendor/abseil-cpp/absl/profiling/CMakeLists.txt +1 -0
  173. package/vendor/abseil-cpp/absl/profiling/hashtable.cc +18 -7
  174. package/vendor/abseil-cpp/absl/profiling/internal/profile_builder.cc +1 -0
  175. package/vendor/abseil-cpp/absl/random/internal/fastmath_test.cc +3 -5
  176. package/vendor/abseil-cpp/absl/random/internal/platform.h +0 -13
  177. package/vendor/abseil-cpp/absl/random/internal/randen_engine_test.cc +0 -1
  178. package/vendor/abseil-cpp/absl/random/internal/seed_material.cc +1 -27
  179. package/vendor/abseil-cpp/absl/status/BUILD.bazel +17 -0
  180. package/vendor/abseil-cpp/absl/status/CMakeLists.txt +16 -0
  181. package/vendor/abseil-cpp/absl/status/internal/status_internal.h +4 -2
  182. package/vendor/abseil-cpp/absl/status/internal/status_matchers.h +2 -2
  183. package/vendor/abseil-cpp/absl/status/internal/statusor_internal.h +2 -1
  184. package/vendor/abseil-cpp/absl/status/status.cc +4 -0
  185. package/vendor/abseil-cpp/absl/status/status.h +5 -0
  186. package/vendor/abseil-cpp/absl/status/status_matchers.h +48 -0
  187. package/vendor/abseil-cpp/absl/status/status_matchers_test.cc +27 -0
  188. package/vendor/abseil-cpp/absl/status/status_test.cc +1 -0
  189. package/vendor/abseil-cpp/absl/status/statusor.h +1 -1
  190. package/vendor/abseil-cpp/absl/strings/BUILD.bazel +101 -21
  191. package/vendor/abseil-cpp/absl/strings/CMakeLists.txt +99 -5
  192. package/vendor/abseil-cpp/absl/strings/ascii.h +9 -4
  193. package/vendor/abseil-cpp/absl/strings/cord.cc +15 -10
  194. package/vendor/abseil-cpp/absl/strings/cord.h +1 -1
  195. package/vendor/abseil-cpp/absl/strings/escaping.cc +126 -94
  196. package/vendor/abseil-cpp/absl/strings/internal/append_and_overwrite.h +93 -0
  197. package/vendor/abseil-cpp/absl/strings/internal/append_and_overwrite_test.cc +95 -0
  198. package/vendor/abseil-cpp/absl/strings/internal/cord_internal.h +2 -0
  199. package/vendor/abseil-cpp/absl/strings/internal/cord_rep_btree_test.cc +8 -8
  200. package/vendor/abseil-cpp/absl/strings/internal/cordz_info.cc +24 -18
  201. package/vendor/abseil-cpp/absl/strings/internal/cordz_info.h +10 -16
  202. package/vendor/abseil-cpp/absl/strings/internal/escaping.h +9 -7
  203. package/vendor/abseil-cpp/absl/strings/internal/generic_printer.cc +107 -0
  204. package/vendor/abseil-cpp/absl/strings/internal/generic_printer.h +115 -0
  205. package/vendor/abseil-cpp/absl/strings/internal/generic_printer_internal.h +423 -0
  206. package/vendor/abseil-cpp/absl/strings/internal/generic_printer_test.cc +685 -0
  207. package/vendor/abseil-cpp/absl/strings/internal/resize_uninitialized.h +0 -12
  208. package/vendor/abseil-cpp/absl/strings/internal/str_format/checker.h +2 -4
  209. package/vendor/abseil-cpp/absl/strings/internal/str_format/convert_test.cc +21 -7
  210. package/vendor/abseil-cpp/absl/strings/internal/str_format/float_conversion.cc +495 -8
  211. package/vendor/abseil-cpp/absl/strings/internal/str_join_internal.h +18 -15
  212. package/vendor/abseil-cpp/absl/strings/numbers.cc +71 -8
  213. package/vendor/abseil-cpp/absl/strings/numbers.h +25 -12
  214. package/vendor/abseil-cpp/absl/strings/numbers_test.cc +70 -0
  215. package/vendor/abseil-cpp/absl/strings/resize_and_overwrite.h +194 -0
  216. package/vendor/abseil-cpp/absl/strings/resize_and_overwrite_test.cc +154 -0
  217. package/vendor/abseil-cpp/absl/strings/str_cat.cc +96 -91
  218. package/vendor/abseil-cpp/absl/strings/str_cat.h +17 -12
  219. package/vendor/abseil-cpp/absl/strings/str_format_test.cc +4 -4
  220. package/vendor/abseil-cpp/absl/strings/str_split.h +1 -1
  221. package/vendor/abseil-cpp/absl/strings/str_split_test.cc +1 -1
  222. package/vendor/abseil-cpp/absl/strings/string_view.h +8 -718
  223. package/vendor/abseil-cpp/absl/strings/string_view_test.cc +1 -1265
  224. package/vendor/abseil-cpp/absl/strings/substitute.cc +24 -24
  225. package/vendor/abseil-cpp/absl/synchronization/BUILD.bazel +2 -3
  226. package/vendor/abseil-cpp/absl/synchronization/CMakeLists.txt +1 -0
  227. package/vendor/abseil-cpp/absl/synchronization/internal/kernel_timeout.h +2 -2
  228. package/vendor/abseil-cpp/absl/synchronization/internal/kernel_timeout_test.cc +15 -5
  229. package/vendor/abseil-cpp/absl/synchronization/mutex.cc +2 -1
  230. package/vendor/abseil-cpp/absl/synchronization/mutex.h +47 -23
  231. package/vendor/abseil-cpp/absl/synchronization/notification.h +1 -1
  232. package/vendor/abseil-cpp/absl/time/CMakeLists.txt +2 -0
  233. package/vendor/abseil-cpp/absl/time/civil_time_benchmark.cc +1 -2
  234. package/vendor/abseil-cpp/absl/time/civil_time_test.cc +58 -103
  235. package/vendor/abseil-cpp/absl/time/clock.cc +18 -16
  236. package/vendor/abseil-cpp/absl/time/clock_test.cc +2 -2
  237. package/vendor/abseil-cpp/absl/time/duration_benchmark.cc +144 -0
  238. package/vendor/abseil-cpp/absl/time/duration_test.cc +26 -29
  239. package/vendor/abseil-cpp/absl/time/internal/cctz/BUILD.bazel +7 -1
  240. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_format.cc +4 -2
  241. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_lookup.cc +6 -103
  242. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.cc +186 -0
  243. package/vendor/abseil-cpp/absl/time/internal/cctz/src/time_zone_name_win.h +37 -0
  244. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/version +1 -1
  245. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Ensenada +0 -0
  246. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Santa_Isabel +0 -0
  247. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/America/Tijuana +0 -0
  248. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/Mexico/BajaNorte +0 -0
  249. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/iso3166.tab +9 -9
  250. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/zone1970.tab +12 -12
  251. package/vendor/abseil-cpp/absl/time/internal/cctz/testdata/zoneinfo/zonenow.tab +47 -47
  252. package/vendor/abseil-cpp/absl/time/time.cc +4 -4
  253. package/vendor/abseil-cpp/absl/time/time.h +10 -10
  254. package/vendor/abseil-cpp/absl/time/time_test.cc +1 -0
  255. package/vendor/abseil-cpp/absl/types/compare.h +62 -61
  256. package/vendor/abseil-cpp/absl/types/compare_test.cc +3 -3
  257. package/vendor/abseil-cpp/absl/types/internal/span.h +1 -0
  258. package/vendor/abseil-cpp/absl/types/optional.h +2 -2
  259. package/vendor/abseil-cpp/absl/types/span.h +10 -2
  260. package/vendor/abseil-cpp/absl/utility/utility.h +13 -0
  261. package/vendor/abseil-cpp/ci/absl_alternate_options.h +0 -1
  262. package/vendor/abseil-cpp/ci/cmake_common.sh +1 -1
  263. package/vendor/abseil-cpp/ci/cmake_install_test.sh +6 -0
  264. package/vendor/abseil-cpp/ci/linux_arm_clang-latest_libcxx_bazel.sh +1 -0
  265. package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_asan_bazel.sh +2 -0
  266. package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_bazel.sh +1 -0
  267. package/vendor/abseil-cpp/ci/linux_clang-latest_libcxx_tsan_bazel.sh +1 -0
  268. package/vendor/abseil-cpp/ci/linux_clang-latest_libstdcxx_bazel.sh +1 -0
  269. package/vendor/abseil-cpp/ci/linux_gcc-floor_libstdcxx_bazel.sh +1 -0
  270. package/vendor/abseil-cpp/ci/linux_gcc-latest_libstdcxx_bazel.sh +1 -0
  271. package/vendor/abseil-cpp/ci/linux_gcc-latest_libstdcxx_cmake.sh +6 -0
  272. package/vendor/abseil-cpp/ci/linux_gcc_alpine_cmake.sh +6 -0
  273. package/vendor/abseil-cpp/ci/macos_xcode_bazel.sh +3 -2
  274. package/vendor/abseil-cpp/ci/macos_xcode_cmake.sh +5 -0
  275. package/vendor/abseil-cpp/ci/windows_clangcl_bazel.bat +1 -0
  276. package/vendor/abseil-cpp/ci/windows_msvc_bazel.bat +1 -0
  277. package/vendor/abseil-cpp/ci/windows_msvc_cmake.bat +6 -1
  278. package/vendor/abseil-cpp/absl/base/internal/identity.h +0 -39
  279. package/vendor/abseil-cpp/absl/strings/string_view.cc +0 -257
  280. package/vendor/abseil-cpp/absl/strings/string_view_benchmark.cc +0 -380
@@ -1,4 +1,3 @@
1
- //
2
1
  // Copyright 2017 The Abseil Authors.
3
2
  //
4
3
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,733 +16,24 @@
17
16
  // File: string_view.h
18
17
  // -----------------------------------------------------------------------------
19
18
  //
20
- // This file contains the definition of the `absl::string_view` class. A
21
- // `string_view` points to a contiguous span of characters, often part or all of
22
- // another `std::string`, double-quoted string literal, character array, or even
23
- // another `string_view`.
24
- //
25
- // This `absl::string_view` abstraction is designed to be a drop-in
26
- // replacement for the C++17 `std::string_view` abstraction.
19
+ // Historical note: Abseil once provided an implementation of
20
+ // `absl::string_view` as a polyfill for `std::string_view` prior to C++17. Now
21
+ // that C++17 is required, `absl::string_view` is an alias for
22
+ // `std::string_view`
23
+
27
24
  #ifndef ABSL_STRINGS_STRING_VIEW_H_
28
25
  #define ABSL_STRINGS_STRING_VIEW_H_
29
26
 
30
- #include <algorithm>
31
- #include <cassert>
32
- #include <cstddef>
33
- #include <cstring>
34
- #include <iosfwd>
35
- #include <iterator>
36
- #include <limits>
37
- #include <string>
27
+ #include <string_view>
38
28
 
39
29
  #include "absl/base/attributes.h"
40
- #include "absl/base/nullability.h"
41
30
  #include "absl/base/config.h"
42
- #include "absl/base/internal/throw_delegate.h"
43
- #include "absl/base/macros.h"
44
- #include "absl/base/optimization.h"
45
- #include "absl/base/port.h"
46
-
47
- #ifdef ABSL_USES_STD_STRING_VIEW
48
-
49
- #include <string_view> // IWYU pragma: export
50
-
51
- namespace absl {
52
- ABSL_NAMESPACE_BEGIN
53
- using string_view = std::string_view;
54
- ABSL_NAMESPACE_END
55
- } // namespace absl
56
-
57
- #else // ABSL_USES_STD_STRING_VIEW
58
-
59
- #if ABSL_HAVE_BUILTIN(__builtin_memcmp) || \
60
- (defined(__GNUC__) && !defined(__clang__)) || \
61
- (defined(_MSC_VER) && _MSC_VER >= 1928)
62
- #define ABSL_INTERNAL_STRING_VIEW_MEMCMP __builtin_memcmp
63
- #else // ABSL_HAVE_BUILTIN(__builtin_memcmp)
64
- #define ABSL_INTERNAL_STRING_VIEW_MEMCMP memcmp
65
- #endif // ABSL_HAVE_BUILTIN(__builtin_memcmp)
31
+ #include "absl/base/nullability.h"
66
32
 
67
33
  namespace absl {
68
34
  ABSL_NAMESPACE_BEGIN
69
35
 
70
- // absl::string_view
71
- //
72
- // A `string_view` provides a lightweight view into the string data provided by
73
- // a `std::string`, double-quoted string literal, character array, or even
74
- // another `string_view`. A `string_view` does *not* own the string to which it
75
- // points, and that data cannot be modified through the view.
76
- //
77
- // You can use `string_view` as a function or method parameter anywhere a
78
- // parameter can receive a double-quoted string literal, `const char*`,
79
- // `std::string`, or another `absl::string_view` argument with no need to copy
80
- // the string data. Systematic use of `string_view` within function arguments
81
- // reduces data copies and `strlen()` calls.
82
- //
83
- // Because of its small size, prefer passing `string_view` by value:
84
- //
85
- // void MyFunction(absl::string_view arg);
86
- //
87
- // If circumstances require, you may also pass one by const reference:
88
- //
89
- // void MyFunction(const absl::string_view& arg); // not preferred
90
- //
91
- // Passing by value generates slightly smaller code for many architectures.
92
- //
93
- // In either case, the source data of the `string_view` must outlive the
94
- // `string_view` itself.
95
- //
96
- // A `string_view` is also suitable for local variables if you know that the
97
- // lifetime of the underlying object is longer than the lifetime of your
98
- // `string_view` variable. However, beware of binding a `string_view` to a
99
- // temporary value:
100
- //
101
- // // BAD use of string_view: lifetime problem
102
- // absl::string_view sv = obj.ReturnAString();
103
- //
104
- // // GOOD use of string_view: str outlives sv
105
- // std::string str = obj.ReturnAString();
106
- // absl::string_view sv = str;
107
- //
108
- // Due to lifetime issues, a `string_view` is sometimes a poor choice for a
109
- // return value and usually a poor choice for a data member. If you do use a
110
- // `string_view` this way, it is your responsibility to ensure that the object
111
- // pointed to by the `string_view` outlives the `string_view`.
112
- //
113
- // A `string_view` may represent a whole string or just part of a string. For
114
- // example, when splitting a string, `std::vector<absl::string_view>` is a
115
- // natural data type for the output.
116
- //
117
- // For another example, a Cord is a non-contiguous, potentially very
118
- // long string-like object. The Cord class has an interface that iteratively
119
- // provides string_view objects that point to the successive pieces of a Cord
120
- // object.
121
- //
122
- // When constructed from a source which is NUL-terminated, the `string_view`
123
- // itself will not include the NUL-terminator unless a specific size (including
124
- // the NUL) is passed to the constructor. As a result, common idioms that work
125
- // on NUL-terminated strings do not work on `string_view` objects. If you write
126
- // code that scans a `string_view`, you must check its length rather than test
127
- // for nul, for example. Note, however, that nuls may still be embedded within
128
- // a `string_view` explicitly.
129
- //
130
- // You may create a null `string_view` in two ways:
131
- //
132
- // absl::string_view sv;
133
- // absl::string_view sv(nullptr, 0);
134
- //
135
- // For the above, `sv.data() == nullptr`, `sv.length() == 0`, and
136
- // `sv.empty() == true`. Also, if you create a `string_view` with a non-null
137
- // pointer then `sv.data() != nullptr`. Thus, you can use `string_view()` to
138
- // signal an undefined value that is different from other `string_view` values
139
- // in a similar fashion to how `const char* p1 = nullptr;` is different from
140
- // `const char* p2 = "";`. However, in practice, it is not recommended to rely
141
- // on this behavior.
142
- //
143
- // Be careful not to confuse a null `string_view` with an empty one. A null
144
- // `string_view` is an empty `string_view`, but some empty `string_view`s are
145
- // not null. Prefer checking for emptiness over checking for null.
146
- //
147
- // There are many ways to create an empty string_view:
148
- //
149
- // const char* nullcp = nullptr;
150
- // // string_view.size() will return 0 in all cases.
151
- // absl::string_view();
152
- // absl::string_view(nullcp, 0);
153
- // absl::string_view("");
154
- // absl::string_view("", 0);
155
- // absl::string_view("abcdef", 0);
156
- // absl::string_view("abcdef" + 6, 0);
157
- //
158
- // All empty `string_view` objects whether null or not, are equal:
159
- //
160
- // absl::string_view() == absl::string_view("", 0)
161
- // absl::string_view(nullptr, 0) == absl::string_view("abcdef"+6, 0)
162
- class ABSL_ATTRIBUTE_VIEW string_view {
163
- public:
164
- using traits_type = std::char_traits<char>;
165
- using value_type = char;
166
- using pointer = char* absl_nullable;
167
- using const_pointer = const char* absl_nullable;
168
- using reference = char&;
169
- using const_reference = const char&;
170
- using const_iterator = const char* absl_nullable;
171
- using iterator = const_iterator;
172
- using const_reverse_iterator = std::reverse_iterator<const_iterator>;
173
- using reverse_iterator = const_reverse_iterator;
174
- using size_type = size_t;
175
- using difference_type = std::ptrdiff_t;
176
- using absl_internal_is_view = std::true_type;
177
-
178
- static constexpr size_type npos = static_cast<size_type>(-1);
179
-
180
- // Null `string_view` constructor
181
- constexpr string_view() noexcept : ptr_(nullptr), length_(0) {}
182
-
183
- // Implicit constructors
184
-
185
- template <typename Allocator>
186
- string_view( // NOLINT(runtime/explicit)
187
- const std::basic_string<char, std::char_traits<char>, Allocator>& str
188
- ABSL_ATTRIBUTE_LIFETIME_BOUND) noexcept
189
- // This is implemented in terms of `string_view(p, n)` so `str.size()`
190
- // doesn't need to be reevaluated after `ptr_` is set.
191
- // The length check is also skipped since it is unnecessary and causes
192
- // code bloat.
193
- : string_view(str.data(), str.size(), SkipCheckLengthTag{}) {}
194
-
195
- // Implicit constructor of a `string_view` from NUL-terminated `str`. When
196
- // accepting possibly null strings, use `absl::NullSafeStringView(str)`
197
- // instead (see below).
198
- // The length check is skipped since it is unnecessary and causes code bloat.
199
- constexpr string_view( // NOLINT(runtime/explicit)
200
- const char* absl_nonnull str)
201
- : ptr_(str), length_(str ? StrlenInternal(str) : 0) {
202
- assert(str != nullptr);
203
- }
204
-
205
- // Constructor of a `string_view` from a `const char*` and length.
206
- constexpr string_view(const char* absl_nullable data, size_type len)
207
- : ptr_(data), length_(CheckLengthInternal(len)) {
208
- ABSL_ASSERT(data != nullptr || len == 0);
209
- }
210
-
211
- constexpr string_view(const string_view&) noexcept = default;
212
- string_view& operator=(const string_view&) noexcept = default;
213
-
214
- // Iterators
215
-
216
- // string_view::begin()
217
- //
218
- // Returns an iterator pointing to the first character at the beginning of the
219
- // `string_view`, or `end()` if the `string_view` is empty.
220
- constexpr const_iterator begin() const noexcept { return ptr_; }
221
-
222
- // string_view::end()
223
- //
224
- // Returns an iterator pointing just beyond the last character at the end of
225
- // the `string_view`. This iterator acts as a placeholder; attempting to
226
- // access it results in undefined behavior.
227
- constexpr const_iterator end() const noexcept { return ptr_ + length_; }
228
-
229
- // string_view::cbegin()
230
- //
231
- // Returns a const iterator pointing to the first character at the beginning
232
- // of the `string_view`, or `end()` if the `string_view` is empty.
233
- constexpr const_iterator cbegin() const noexcept { return begin(); }
234
-
235
- // string_view::cend()
236
- //
237
- // Returns a const iterator pointing just beyond the last character at the end
238
- // of the `string_view`. This pointer acts as a placeholder; attempting to
239
- // access its element results in undefined behavior.
240
- constexpr const_iterator cend() const noexcept { return end(); }
241
-
242
- // string_view::rbegin()
243
- //
244
- // Returns a reverse iterator pointing to the last character at the end of the
245
- // `string_view`, or `rend()` if the `string_view` is empty.
246
- const_reverse_iterator rbegin() const noexcept {
247
- return const_reverse_iterator(end());
248
- }
249
-
250
- // string_view::rend()
251
- //
252
- // Returns a reverse iterator pointing just before the first character at the
253
- // beginning of the `string_view`. This pointer acts as a placeholder;
254
- // attempting to access its element results in undefined behavior.
255
- const_reverse_iterator rend() const noexcept {
256
- return const_reverse_iterator(begin());
257
- }
258
-
259
- // string_view::crbegin()
260
- //
261
- // Returns a const reverse iterator pointing to the last character at the end
262
- // of the `string_view`, or `crend()` if the `string_view` is empty.
263
- const_reverse_iterator crbegin() const noexcept { return rbegin(); }
264
-
265
- // string_view::crend()
266
- //
267
- // Returns a const reverse iterator pointing just before the first character
268
- // at the beginning of the `string_view`. This pointer acts as a placeholder;
269
- // attempting to access its element results in undefined behavior.
270
- const_reverse_iterator crend() const noexcept { return rend(); }
271
-
272
- // Capacity Utilities
273
-
274
- // string_view::size()
275
- //
276
- // Returns the number of characters in the `string_view`.
277
- constexpr size_type size() const noexcept { return length_; }
278
-
279
- // string_view::length()
280
- //
281
- // Returns the number of characters in the `string_view`. Alias for `size()`.
282
- constexpr size_type length() const noexcept { return size(); }
283
-
284
- // string_view::max_size()
285
- //
286
- // Returns the maximum number of characters the `string_view` can hold.
287
- constexpr size_type max_size() const noexcept { return kMaxSize; }
288
-
289
- // string_view::empty()
290
- //
291
- // Checks if the `string_view` is empty (refers to no characters).
292
- constexpr bool empty() const noexcept { return length_ == 0; }
293
-
294
- // string_view::operator[]
295
- //
296
- // Returns the ith element of the `string_view` using the array operator.
297
- // Note that this operator does not perform any bounds checking.
298
- constexpr const_reference operator[](size_type i) const {
299
- ABSL_HARDENING_ASSERT(i < size());
300
- return ptr_[i];
301
- }
302
-
303
- // string_view::at()
304
- //
305
- // Returns the ith element of the `string_view`. Bounds checking is performed,
306
- // and an exception of type `std::out_of_range` will be thrown on invalid
307
- // access.
308
- constexpr const_reference at(size_type i) const {
309
- if (ABSL_PREDICT_FALSE(i >= size())) {
310
- base_internal::ThrowStdOutOfRange("absl::string_view::at");
311
- }
312
- return ptr_[i];
313
- }
314
-
315
- // string_view::front()
316
- //
317
- // Returns the first element of a `string_view`.
318
- constexpr const_reference front() const {
319
- ABSL_HARDENING_ASSERT(!empty());
320
- return ptr_[0];
321
- }
322
-
323
- // string_view::back()
324
- //
325
- // Returns the last element of a `string_view`.
326
- constexpr const_reference back() const {
327
- ABSL_HARDENING_ASSERT(!empty());
328
- return ptr_[size() - 1];
329
- }
330
-
331
- // string_view::data()
332
- //
333
- // Returns a pointer to the underlying character array (which is of course
334
- // stored elsewhere). Note that `string_view::data()` may contain embedded nul
335
- // characters, but the returned buffer may or may not be NUL-terminated;
336
- // therefore, do not pass `data()` to a routine that expects a NUL-terminated
337
- // string.
338
- constexpr const_pointer data() const noexcept { return ptr_; }
339
-
340
- // Modifiers
341
-
342
- // string_view::remove_prefix()
343
- //
344
- // Removes the first `n` characters from the `string_view`. Note that the
345
- // underlying string is not changed, only the view.
346
- constexpr void remove_prefix(size_type n) {
347
- ABSL_HARDENING_ASSERT(n <= length_);
348
- ptr_ += n;
349
- length_ -= n;
350
- }
351
-
352
- // string_view::remove_suffix()
353
- //
354
- // Removes the last `n` characters from the `string_view`. Note that the
355
- // underlying string is not changed, only the view.
356
- constexpr void remove_suffix(size_type n) {
357
- ABSL_HARDENING_ASSERT(n <= length_);
358
- length_ -= n;
359
- }
360
-
361
- // string_view::swap()
362
- //
363
- // Swaps this `string_view` with another `string_view`.
364
- constexpr void swap(string_view& s) noexcept {
365
- auto t = *this;
366
- *this = s;
367
- s = t;
368
- }
369
-
370
- // Explicit conversion operators
371
-
372
- // Converts to `std::basic_string`.
373
- template <typename A>
374
- explicit operator std::basic_string<char, traits_type, A>() const {
375
- if (!data()) return {};
376
- return std::basic_string<char, traits_type, A>(data(), size());
377
- }
378
-
379
- // string_view::copy()
380
- //
381
- // Copies the contents of the `string_view` at offset `pos` and length `n`
382
- // into `buf`.
383
- size_type copy(char* absl_nonnull buf, size_type n, size_type pos = 0) const {
384
- if (ABSL_PREDICT_FALSE(pos > length_)) {
385
- base_internal::ThrowStdOutOfRange("absl::string_view::copy");
386
- }
387
- size_type rlen = (std::min)(length_ - pos, n);
388
- if (rlen > 0) {
389
- const char* start = ptr_ + pos;
390
- traits_type::copy(buf, start, rlen);
391
- }
392
- return rlen;
393
- }
394
-
395
- // string_view::substr()
396
- //
397
- // Returns a "substring" of the `string_view` (at offset `pos` and length
398
- // `n`) as another string_view. This function throws `std::out_of_bounds` if
399
- // `pos > size`.
400
- // Use absl::ClippedSubstr if you need a truncating substr operation.
401
- constexpr string_view substr(size_type pos = 0, size_type n = npos) const {
402
- if (ABSL_PREDICT_FALSE(pos > length_)) {
403
- base_internal::ThrowStdOutOfRange("absl::string_view::substr");
404
- }
405
- return string_view(ptr_ + pos, (std::min)(n, length_ - pos));
406
- }
407
-
408
- // string_view::compare()
409
- //
410
- // Performs a lexicographical comparison between this `string_view` and
411
- // another `string_view` `x`, returning a negative value if `*this` is less
412
- // than `x`, 0 if `*this` is equal to `x`, and a positive value if `*this`
413
- // is greater than `x`.
414
- constexpr int compare(string_view x) const noexcept {
415
- return CompareImpl(length_, x.length_,
416
- (std::min)(length_, x.length_) == 0
417
- ? 0
418
- : ABSL_INTERNAL_STRING_VIEW_MEMCMP(
419
- ptr_, x.ptr_, (std::min)(length_, x.length_)));
420
- }
421
-
422
- // Overload of `string_view::compare()` for comparing a substring of the
423
- // 'string_view` and another `absl::string_view`.
424
- constexpr int compare(size_type pos1, size_type count1, string_view v) const {
425
- return substr(pos1, count1).compare(v);
426
- }
427
-
428
- // Overload of `string_view::compare()` for comparing a substring of the
429
- // `string_view` and a substring of another `absl::string_view`.
430
- constexpr int compare(size_type pos1, size_type count1, string_view v,
431
- size_type pos2, size_type count2) const {
432
- return substr(pos1, count1).compare(v.substr(pos2, count2));
433
- }
434
-
435
- // Overload of `string_view::compare()` for comparing a `string_view` and a
436
- // a different C-style string `s`.
437
- constexpr int compare(const char* absl_nonnull s) const {
438
- return compare(string_view(s));
439
- }
440
-
441
- // Overload of `string_view::compare()` for comparing a substring of the
442
- // `string_view` and a different string C-style string `s`.
443
- constexpr int compare(size_type pos1, size_type count1,
444
- const char* absl_nonnull s) const {
445
- return substr(pos1, count1).compare(string_view(s));
446
- }
447
-
448
- // Overload of `string_view::compare()` for comparing a substring of the
449
- // `string_view` and a substring of a different C-style string `s`.
450
- constexpr int compare(size_type pos1, size_type count1,
451
- const char* absl_nonnull s, size_type count2) const {
452
- return substr(pos1, count1).compare(string_view(s, count2));
453
- }
454
-
455
- // Find Utilities
456
-
457
- // string_view::find()
458
- //
459
- // Finds the first occurrence of the substring `s` within the `string_view`,
460
- // returning the position of the first character's match, or `npos` if no
461
- // match was found.
462
- size_type find(string_view s, size_type pos = 0) const noexcept;
463
-
464
- // Overload of `string_view::find()` for finding the given character `c`
465
- // within the `string_view`.
466
- size_type find(char c, size_type pos = 0) const noexcept;
467
-
468
- // Overload of `string_view::find()` for finding a substring of a different
469
- // C-style string `s` within the `string_view`.
470
- size_type find(const char* absl_nonnull s, size_type pos,
471
- size_type count) const {
472
- return find(string_view(s, count), pos);
473
- }
474
-
475
- // Overload of `string_view::find()` for finding a different C-style string
476
- // `s` within the `string_view`.
477
- size_type find(const char* absl_nonnull s, size_type pos = 0) const {
478
- return find(string_view(s), pos);
479
- }
480
-
481
- // string_view::rfind()
482
- //
483
- // Finds the last occurrence of a substring `s` within the `string_view`,
484
- // returning the position of the first character's match, or `npos` if no
485
- // match was found.
486
- size_type rfind(string_view s, size_type pos = npos) const noexcept;
487
-
488
- // Overload of `string_view::rfind()` for finding the last given character `c`
489
- // within the `string_view`.
490
- size_type rfind(char c, size_type pos = npos) const noexcept;
491
-
492
- // Overload of `string_view::rfind()` for finding a substring of a different
493
- // C-style string `s` within the `string_view`.
494
- size_type rfind(const char* absl_nonnull s, size_type pos,
495
- size_type count) const {
496
- return rfind(string_view(s, count), pos);
497
- }
498
-
499
- // Overload of `string_view::rfind()` for finding a different C-style string
500
- // `s` within the `string_view`.
501
- size_type rfind(const char* absl_nonnull s, size_type pos = npos) const {
502
- return rfind(string_view(s), pos);
503
- }
504
-
505
- // string_view::find_first_of()
506
- //
507
- // Finds the first occurrence of any of the characters in `s` within the
508
- // `string_view`, returning the start position of the match, or `npos` if no
509
- // match was found.
510
- size_type find_first_of(string_view s, size_type pos = 0) const noexcept;
511
-
512
- // Overload of `string_view::find_first_of()` for finding a character `c`
513
- // within the `string_view`.
514
- size_type find_first_of(char c, size_type pos = 0) const noexcept {
515
- return find(c, pos);
516
- }
517
-
518
- // Overload of `string_view::find_first_of()` for finding a substring of a
519
- // different C-style string `s` within the `string_view`.
520
- size_type find_first_of(const char* absl_nonnull s, size_type pos,
521
- size_type count) const {
522
- return find_first_of(string_view(s, count), pos);
523
- }
524
-
525
- // Overload of `string_view::find_first_of()` for finding a different C-style
526
- // string `s` within the `string_view`.
527
- size_type find_first_of(const char* absl_nonnull s, size_type pos = 0) const {
528
- return find_first_of(string_view(s), pos);
529
- }
530
-
531
- // string_view::find_last_of()
532
- //
533
- // Finds the last occurrence of any of the characters in `s` within the
534
- // `string_view`, returning the start position of the match, or `npos` if no
535
- // match was found.
536
- size_type find_last_of(string_view s, size_type pos = npos) const noexcept;
537
-
538
- // Overload of `string_view::find_last_of()` for finding a character `c`
539
- // within the `string_view`.
540
- size_type find_last_of(char c, size_type pos = npos) const noexcept {
541
- return rfind(c, pos);
542
- }
543
-
544
- // Overload of `string_view::find_last_of()` for finding a substring of a
545
- // different C-style string `s` within the `string_view`.
546
- size_type find_last_of(const char* absl_nonnull s, size_type pos,
547
- size_type count) const {
548
- return find_last_of(string_view(s, count), pos);
549
- }
550
-
551
- // Overload of `string_view::find_last_of()` for finding a different C-style
552
- // string `s` within the `string_view`.
553
- size_type find_last_of(const char* absl_nonnull s,
554
- size_type pos = npos) const {
555
- return find_last_of(string_view(s), pos);
556
- }
557
-
558
- // string_view::find_first_not_of()
559
- //
560
- // Finds the first occurrence of any of the characters not in `s` within the
561
- // `string_view`, returning the start position of the first non-match, or
562
- // `npos` if no non-match was found.
563
- size_type find_first_not_of(string_view s, size_type pos = 0) const noexcept;
564
-
565
- // Overload of `string_view::find_first_not_of()` for finding a character
566
- // that is not `c` within the `string_view`.
567
- size_type find_first_not_of(char c, size_type pos = 0) const noexcept;
568
-
569
- // Overload of `string_view::find_first_not_of()` for finding a substring of a
570
- // different C-style string `s` within the `string_view`.
571
- size_type find_first_not_of(const char* absl_nonnull s, size_type pos,
572
- size_type count) const {
573
- return find_first_not_of(string_view(s, count), pos);
574
- }
575
-
576
- // Overload of `string_view::find_first_not_of()` for finding a different
577
- // C-style string `s` within the `string_view`.
578
- size_type find_first_not_of(const char* absl_nonnull s,
579
- size_type pos = 0) const {
580
- return find_first_not_of(string_view(s), pos);
581
- }
582
-
583
- // string_view::find_last_not_of()
584
- //
585
- // Finds the last occurrence of any of the characters not in `s` within the
586
- // `string_view`, returning the start position of the last non-match, or
587
- // `npos` if no non-match was found.
588
- size_type find_last_not_of(string_view s,
589
- size_type pos = npos) const noexcept;
590
-
591
- // Overload of `string_view::find_last_not_of()` for finding a character
592
- // that is not `c` within the `string_view`.
593
- size_type find_last_not_of(char c, size_type pos = npos) const noexcept;
594
-
595
- // Overload of `string_view::find_last_not_of()` for finding a substring of a
596
- // different C-style string `s` within the `string_view`.
597
- size_type find_last_not_of(const char* absl_nonnull s, size_type pos,
598
- size_type count) const {
599
- return find_last_not_of(string_view(s, count), pos);
600
- }
601
-
602
- // Overload of `string_view::find_last_not_of()` for finding a different
603
- // C-style string `s` within the `string_view`.
604
- size_type find_last_not_of(const char* absl_nonnull s,
605
- size_type pos = npos) const {
606
- return find_last_not_of(string_view(s), pos);
607
- }
608
-
609
- #if ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
610
- // string_view::starts_with()
611
- //
612
- // Returns true if the `string_view` starts with the prefix `s`.
613
- //
614
- // This method only exists when targeting at least C++20.
615
- // If support for C++ prior to C++20 is required, use `absl::StartsWith()`
616
- // from `//absl/strings/match.h` for compatibility.
617
- constexpr bool starts_with(string_view s) const noexcept {
618
- return s.empty() ||
619
- (size() >= s.size() &&
620
- ABSL_INTERNAL_STRING_VIEW_MEMCMP(data(), s.data(), s.size()) == 0);
621
- }
622
-
623
- // Overload of `string_view::starts_with()` that returns true if `c` is the
624
- // first character of the `string_view`.
625
- constexpr bool starts_with(char c) const noexcept {
626
- return !empty() && front() == c;
627
- }
628
-
629
- // Overload of `string_view::starts_with()` that returns true if the
630
- // `string_view` starts with the C-style prefix `s`.
631
- constexpr bool starts_with(const char* absl_nonnull s) const {
632
- return starts_with(string_view(s));
633
- }
634
-
635
- // string_view::ends_with()
636
- //
637
- // Returns true if the `string_view` ends with the suffix `s`.
638
- //
639
- // This method only exists when targeting at least C++20.
640
- // If support for C++ prior to C++20 is required, use `absl::EndsWith()`
641
- // from `//absl/strings/match.h` for compatibility.
642
- constexpr bool ends_with(string_view s) const noexcept {
643
- return s.empty() || (size() >= s.size() && ABSL_INTERNAL_STRING_VIEW_MEMCMP(
644
- data() + (size() - s.size()),
645
- s.data(), s.size()) == 0);
646
- }
647
-
648
- // Overload of `string_view::ends_with()` that returns true if `c` is the
649
- // last character of the `string_view`.
650
- constexpr bool ends_with(char c) const noexcept {
651
- return !empty() && back() == c;
652
- }
653
-
654
- // Overload of `string_view::ends_with()` that returns true if the
655
- // `string_view` ends with the C-style suffix `s`.
656
- constexpr bool ends_with(const char* absl_nonnull s) const {
657
- return ends_with(string_view(s));
658
- }
659
- #endif // ABSL_INTERNAL_CPLUSPLUS_LANG >= 202002L
660
-
661
- private:
662
- // The constructor from std::string delegates to this constructor.
663
- // See the comment on that constructor for the rationale.
664
- struct SkipCheckLengthTag {};
665
- string_view(const char* absl_nullable data, size_type len,
666
- SkipCheckLengthTag) noexcept
667
- : ptr_(data), length_(len) {}
668
-
669
- static constexpr size_type kMaxSize =
670
- (std::numeric_limits<difference_type>::max)();
671
-
672
- static constexpr size_type CheckLengthInternal(size_type len) {
673
- ABSL_HARDENING_ASSERT(len <= kMaxSize);
674
- return len;
675
- }
676
-
677
- static constexpr size_type StrlenInternal(const char* absl_nonnull str) {
678
- #if defined(_MSC_VER) && !defined(__clang__)
679
- // MSVC 2017+ can evaluate this at compile-time.
680
- const char* begin = str;
681
- while (*str != '\0') ++str;
682
- return str - begin;
683
- #elif ABSL_HAVE_BUILTIN(__builtin_strlen) || \
684
- (defined(__GNUC__) && !defined(__clang__))
685
- // GCC has __builtin_strlen according to
686
- // https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Other-Builtins.html, but
687
- // ABSL_HAVE_BUILTIN doesn't detect that, so we use the extra checks above.
688
- // __builtin_strlen is constexpr.
689
- return __builtin_strlen(str);
690
- #else
691
- return str ? strlen(str) : 0;
692
- #endif
693
- }
694
-
695
- static constexpr int CompareImpl(size_type length_a, size_type length_b,
696
- int compare_result) {
697
- return compare_result == 0 ? static_cast<int>(length_a > length_b) -
698
- static_cast<int>(length_a < length_b)
699
- : (compare_result < 0 ? -1 : 1);
700
- }
701
-
702
- const char* absl_nullable ptr_;
703
- size_type length_;
704
- };
705
-
706
- // This large function is defined inline so that in a fairly common case where
707
- // one of the arguments is a literal, the compiler can elide a lot of the
708
- // following comparisons.
709
- constexpr bool operator==(string_view x, string_view y) noexcept {
710
- return x.size() == y.size() &&
711
- (x.empty() ||
712
- ABSL_INTERNAL_STRING_VIEW_MEMCMP(x.data(), y.data(), x.size()) == 0);
713
- }
714
-
715
- constexpr bool operator!=(string_view x, string_view y) noexcept {
716
- return !(x == y);
717
- }
718
-
719
- constexpr bool operator<(string_view x, string_view y) noexcept {
720
- return x.compare(y) < 0;
721
- }
722
-
723
- constexpr bool operator>(string_view x, string_view y) noexcept {
724
- return y < x;
725
- }
726
-
727
- constexpr bool operator<=(string_view x, string_view y) noexcept {
728
- return !(y < x);
729
- }
730
-
731
- constexpr bool operator>=(string_view x, string_view y) noexcept {
732
- return !(x < y);
733
- }
734
-
735
- // IO Insertion Operator
736
- std::ostream& operator<<(std::ostream& o, string_view piece);
737
-
738
- ABSL_NAMESPACE_END
739
- } // namespace absl
740
-
741
- #undef ABSL_INTERNAL_STRING_VIEW_MEMCMP
742
-
743
- #endif // ABSL_USES_STD_STRING_VIEW
744
-
745
- namespace absl {
746
- ABSL_NAMESPACE_BEGIN
36
+ using std::string_view;
747
37
 
748
38
  // ClippedSubstr()
749
39
  //