react-native-windows 0.81.32 → 0.81.35

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 (891) hide show
  1. package/Directory.Build.props +2 -17
  2. package/Folly/ThreadNameStub.cpp +4 -6
  3. package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +1 -1
  4. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +27 -4
  5. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +8 -4
  6. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +7 -3
  7. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -8
  8. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -3
  9. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
  10. package/PropertySheets/Bundle.props +3 -3
  11. package/PropertySheets/CIBuildOptimizations.props +2 -2
  12. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  13. package/PropertySheets/JSEngine.props +1 -1
  14. package/PropertySheets/NuGet.LockFile.props +2 -1
  15. package/PropertySheets/React.Cpp.props +4 -4
  16. package/ReactCommon/ReactCommon.vcxproj +0 -10
  17. package/ReactCommon/packages.lock.win32.json +0 -10
  18. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +61 -6
  19. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -37
  20. package/Scripts/Warm-RnwFeedCache.ps1 +413 -0
  21. package/Scripts/creaternwapp.cmd +5 -1
  22. package/Scripts/creaternwlib.cmd +8 -2
  23. package/Shared/Shared.vcxitems +2 -0
  24. package/{Folly → external}/.clang-format +0 -1
  25. package/external/External.vcxitems +10 -0
  26. package/external/fast-float/.syncignore +11 -0
  27. package/external/fast-float/LICENSE-APACHE +190 -0
  28. package/external/fast-float/LICENSE-BOOST +23 -0
  29. package/external/fast-float/LICENSE-MIT +27 -0
  30. package/external/fast-float/cgmanifest.json +15 -0
  31. package/external/fast-float/fast-float.vcxitems +14 -0
  32. package/external/fast-float/include/fast_float/ascii_number.h +588 -0
  33. package/external/fast-float/include/fast_float/bigint.h +638 -0
  34. package/external/fast-float/include/fast_float/constexpr_feature_detect.h +46 -0
  35. package/external/fast-float/include/fast_float/decimal_to_binary.h +212 -0
  36. package/external/fast-float/include/fast_float/digit_comparison.h +457 -0
  37. package/external/fast-float/include/fast_float/fast_float.h +59 -0
  38. package/external/fast-float/include/fast_float/fast_table.h +708 -0
  39. package/external/fast-float/include/fast_float/float_common.h +1240 -0
  40. package/external/fast-float/include/fast_float/parse_number.h +399 -0
  41. package/external/fast-float/sync-config.json +8 -0
  42. package/external/fmt/.syncignore +12 -0
  43. package/external/fmt/CONTRIBUTING.md +20 -0
  44. package/external/fmt/LICENSE +27 -0
  45. package/{fmt → external/fmt}/cgmanifest.json +1 -1
  46. package/external/fmt/fmt.vcxitems +28 -0
  47. package/external/fmt/include/fmt/args.h +228 -0
  48. package/{fmt/TEMP_UntilFmtUpdate/core.h → external/fmt/include/fmt/base.h} +1188 -1036
  49. package/external/fmt/include/fmt/chrono.h +2432 -0
  50. package/external/fmt/include/fmt/color.h +612 -0
  51. package/external/fmt/include/fmt/compile.h +529 -0
  52. package/external/fmt/include/fmt/core.h +5 -0
  53. package/external/fmt/include/fmt/format-inl.h +1928 -0
  54. package/external/fmt/include/fmt/format.h +4427 -0
  55. package/external/fmt/include/fmt/os.h +439 -0
  56. package/external/fmt/include/fmt/ostream.h +211 -0
  57. package/external/fmt/include/fmt/printf.h +656 -0
  58. package/external/fmt/include/fmt/ranges.h +882 -0
  59. package/external/fmt/include/fmt/std.h +699 -0
  60. package/external/fmt/include/fmt/xchar.h +322 -0
  61. package/external/fmt/src/fmt.cc +135 -0
  62. package/external/fmt/src/format.cc +43 -0
  63. package/external/fmt/src/os.cc +403 -0
  64. package/external/fmt/sync-config.json +8 -0
  65. package/external/folly/.syncignore +61 -0
  66. package/external/folly/LICENSE +200 -0
  67. package/{fmt → external/folly/folly}/.clang-format +0 -1
  68. package/external/folly/folly/AtomicHashArray-inl.h +546 -0
  69. package/external/folly/folly/AtomicHashArray.h +431 -0
  70. package/external/folly/folly/AtomicHashMap-inl.h +653 -0
  71. package/external/folly/folly/AtomicHashMap.h +484 -0
  72. package/external/folly/folly/AtomicIntrusiveLinkedList.h +206 -0
  73. package/external/folly/folly/AtomicLinkedList.h +110 -0
  74. package/external/folly/folly/AtomicUnorderedMap.h +522 -0
  75. package/external/folly/folly/BUCK +1631 -0
  76. package/external/folly/folly/BUILD_MODE.bzl +72 -0
  77. package/external/folly/folly/Benchmark.cpp +986 -0
  78. package/external/folly/folly/Benchmark.h +680 -0
  79. package/external/folly/folly/BenchmarkUtil.h +47 -0
  80. package/external/folly/folly/Bits.h +17 -0
  81. package/external/folly/folly/CMakeLists.txt +110 -0
  82. package/external/folly/folly/CPortability.h +338 -0
  83. package/external/folly/folly/CancellationToken-inl.h +449 -0
  84. package/external/folly/folly/CancellationToken.cpp +250 -0
  85. package/external/folly/folly/CancellationToken.h +365 -0
  86. package/external/folly/folly/Chrono.h +132 -0
  87. package/external/folly/folly/ClockGettimeWrappers.cpp +93 -0
  88. package/external/folly/folly/ClockGettimeWrappers.h +29 -0
  89. package/external/folly/folly/ConcurrentBitSet.h +157 -0
  90. package/external/folly/folly/ConcurrentLazy.h +74 -0
  91. package/external/folly/folly/ConcurrentSkipList-inl.h +341 -0
  92. package/external/folly/folly/ConcurrentSkipList.h +824 -0
  93. package/external/folly/folly/ConstructorCallbackList.h +158 -0
  94. package/external/folly/folly/Conv.h +2026 -0
  95. package/external/folly/folly/CppAttributes.h +170 -0
  96. package/external/folly/folly/CpuId.h +297 -0
  97. package/external/folly/folly/DefaultKeepAliveExecutor.h +172 -0
  98. package/external/folly/folly/Demangle.cpp +255 -0
  99. package/external/folly/folly/Demangle.h +73 -0
  100. package/external/folly/folly/DiscriminatedPtr.h +236 -0
  101. package/external/folly/folly/DynamicConverter.h +17 -0
  102. package/external/folly/folly/Exception.h +150 -0
  103. package/external/folly/folly/ExceptionString.cpp +51 -0
  104. package/external/folly/folly/ExceptionString.h +33 -0
  105. package/external/folly/folly/ExceptionWrapper-inl.h +264 -0
  106. package/external/folly/folly/ExceptionWrapper.cpp +37 -0
  107. package/external/folly/folly/ExceptionWrapper.h +377 -0
  108. package/external/folly/folly/Executor.cpp +111 -0
  109. package/external/folly/folly/Executor.h +351 -0
  110. package/external/folly/folly/Expected.h +1725 -0
  111. package/external/folly/folly/FBString.h +2888 -0
  112. package/external/folly/folly/FBVector.h +17 -0
  113. package/external/folly/folly/File.cpp +180 -0
  114. package/external/folly/folly/File.h +177 -0
  115. package/external/folly/folly/FileUtil.cpp +378 -0
  116. package/external/folly/folly/FileUtil.h +332 -0
  117. package/external/folly/folly/Fingerprint.cpp +135 -0
  118. package/external/folly/folly/Fingerprint.h +289 -0
  119. package/external/folly/folly/FixedString.h +2965 -0
  120. package/external/folly/folly/FollyMemcpy.cpp +30 -0
  121. package/external/folly/folly/FollyMemcpy.h +23 -0
  122. package/external/folly/folly/FollyMemset.cpp +29 -0
  123. package/external/folly/folly/FollyMemset.h +25 -0
  124. package/external/folly/folly/Format-inl.h +1152 -0
  125. package/external/folly/folly/Format.cpp +429 -0
  126. package/external/folly/folly/Format.h +463 -0
  127. package/external/folly/folly/FormatArg.h +285 -0
  128. package/external/folly/folly/FormatTraits.h +65 -0
  129. package/external/folly/folly/Function.h +1159 -0
  130. package/external/folly/folly/GLog.h +85 -0
  131. package/external/folly/folly/GroupVarint.cpp +153 -0
  132. package/external/folly/folly/GroupVarint.h +630 -0
  133. package/external/folly/folly/Hash.h +20 -0
  134. package/external/folly/folly/IPAddress.cpp +490 -0
  135. package/external/folly/folly/IPAddress.h +667 -0
  136. package/external/folly/folly/IPAddressException.h +82 -0
  137. package/external/folly/folly/IPAddressV4.cpp +305 -0
  138. package/external/folly/folly/IPAddressV4.h +495 -0
  139. package/external/folly/folly/IPAddressV6.cpp +541 -0
  140. package/external/folly/folly/IPAddressV6.h +627 -0
  141. package/external/folly/folly/Indestructible.h +164 -0
  142. package/external/folly/folly/IndexedMemPool.h +550 -0
  143. package/external/folly/folly/IntrusiveList.h +17 -0
  144. package/external/folly/folly/Lazy.h +142 -0
  145. package/external/folly/folly/Likely.h +76 -0
  146. package/external/folly/folly/MPMCPipeline.h +280 -0
  147. package/external/folly/folly/MPMCQueue.h +1556 -0
  148. package/external/folly/folly/MacAddress.cpp +188 -0
  149. package/external/folly/folly/MacAddress.h +260 -0
  150. package/external/folly/folly/MapUtil.h +17 -0
  151. package/external/folly/folly/Math.h +258 -0
  152. package/external/folly/folly/MaybeManagedPtr.h +120 -0
  153. package/external/folly/folly/Memory.h +900 -0
  154. package/external/folly/folly/MicroLock.cpp +76 -0
  155. package/external/folly/folly/MicroLock.h +354 -0
  156. package/external/folly/folly/MicroSpinLock.h +17 -0
  157. package/external/folly/folly/MoveWrapper.h +76 -0
  158. package/external/folly/folly/ObserverContainer.h +1026 -0
  159. package/external/folly/folly/Optional.h +743 -0
  160. package/external/folly/folly/Overload.h +325 -0
  161. package/external/folly/folly/PackedSyncPtr.h +147 -0
  162. package/external/folly/folly/Padded.h +464 -0
  163. package/external/folly/folly/Poly-inl.h +230 -0
  164. package/external/folly/folly/Poly.h +1095 -0
  165. package/external/folly/folly/PolyException.h +43 -0
  166. package/external/folly/folly/Portability.h +644 -0
  167. package/external/folly/folly/Preprocessor.h +236 -0
  168. package/external/folly/folly/ProducerConsumerQueue.h +182 -0
  169. package/external/folly/folly/RWSpinLock.h +17 -0
  170. package/external/folly/folly/Random-inl.h +86 -0
  171. package/external/folly/folly/Random.cpp +184 -0
  172. package/external/folly/folly/Random.h +434 -0
  173. package/external/folly/folly/Range.h +1772 -0
  174. package/external/folly/folly/Replaceable.h +636 -0
  175. package/external/folly/folly/ScopeGuard.cpp +29 -0
  176. package/external/folly/folly/ScopeGuard.h +420 -0
  177. package/external/folly/folly/SharedMutex.cpp +81 -0
  178. package/external/folly/folly/SharedMutex.h +1751 -0
  179. package/external/folly/folly/Singleton-inl.h +332 -0
  180. package/external/folly/folly/Singleton.cpp +512 -0
  181. package/external/folly/folly/Singleton.h +891 -0
  182. package/external/folly/folly/SingletonThreadLocal.cpp +53 -0
  183. package/external/folly/folly/SingletonThreadLocal.h +263 -0
  184. package/external/folly/folly/SocketAddress.cpp +786 -0
  185. package/external/folly/folly/SocketAddress.h +768 -0
  186. package/external/folly/folly/SpinLock.h +55 -0
  187. package/external/folly/folly/String-inl.h +668 -0
  188. package/external/folly/folly/String.cpp +777 -0
  189. package/external/folly/folly/String.h +767 -0
  190. package/external/folly/folly/Subprocess.cpp +1142 -0
  191. package/external/folly/folly/Subprocess.h +1055 -0
  192. package/external/folly/folly/Synchronized.h +1833 -0
  193. package/external/folly/folly/SynchronizedPtr.h +106 -0
  194. package/external/folly/folly/ThreadCachedInt.h +175 -0
  195. package/external/folly/folly/ThreadLocal.h +478 -0
  196. package/external/folly/folly/TimeoutQueue.cpp +78 -0
  197. package/external/folly/folly/TimeoutQueue.h +123 -0
  198. package/external/folly/folly/TokenBucket.h +673 -0
  199. package/external/folly/folly/Traits.h +1442 -0
  200. package/external/folly/folly/Try-inl.h +372 -0
  201. package/external/folly/folly/Try.cpp +23 -0
  202. package/external/folly/folly/Try.h +728 -0
  203. package/external/folly/folly/UTF8String.h +56 -0
  204. package/external/folly/folly/Unicode.cpp +201 -0
  205. package/external/folly/folly/Unicode.h +94 -0
  206. package/external/folly/folly/Unit.h +65 -0
  207. package/external/folly/folly/Uri-inl.h +101 -0
  208. package/external/folly/folly/Uri.cpp +190 -0
  209. package/external/folly/folly/Uri.h +142 -0
  210. package/external/folly/folly/Utility.h +932 -0
  211. package/external/folly/folly/VERSION +1 -0
  212. package/external/folly/folly/Varint.h +230 -0
  213. package/external/folly/folly/VirtualExecutor.h +17 -0
  214. package/external/folly/folly/algorithm/simd/BUCK +47 -0
  215. package/external/folly/folly/algorithm/simd/Contains.cpp +42 -0
  216. package/external/folly/folly/algorithm/simd/Contains.h +116 -0
  217. package/external/folly/folly/algorithm/simd/FindFixed.h +301 -0
  218. package/external/folly/folly/algorithm/simd/Ignore.h +52 -0
  219. package/external/folly/folly/algorithm/simd/Movemask.h +207 -0
  220. package/external/folly/folly/algorithm/simd/detail/BUCK +70 -0
  221. package/external/folly/folly/algorithm/simd/detail/ContainsImpl.h +91 -0
  222. package/external/folly/folly/algorithm/simd/detail/SimdAnyOf.h +83 -0
  223. package/external/folly/folly/algorithm/simd/detail/SimdForEach.h +209 -0
  224. package/external/folly/folly/algorithm/simd/detail/SimdPlatform.h +445 -0
  225. package/external/folly/folly/algorithm/simd/detail/Traits.h +125 -0
  226. package/external/folly/folly/algorithm/simd/detail/UnrollUtils.h +126 -0
  227. package/external/folly/folly/base64.h +264 -0
  228. package/external/folly/folly/chrono/BUCK +29 -0
  229. package/external/folly/folly/chrono/Clock.h +65 -0
  230. package/external/folly/folly/chrono/Conv.h +712 -0
  231. package/external/folly/folly/chrono/test/BUCK +26 -0
  232. package/external/folly/folly/chrono/test/ClockTest.cpp +68 -0
  233. package/external/folly/folly/chrono/test/ConvTest.cpp +652 -0
  234. package/external/folly/folly/concurrency/AtomicSharedPtr.h +387 -0
  235. package/external/folly/folly/concurrency/BUCK +170 -0
  236. package/external/folly/folly/concurrency/CacheLocality.h +460 -0
  237. package/external/folly/folly/concurrency/ConcurrentHashMap.h +822 -0
  238. package/external/folly/folly/concurrency/CoreCachedSharedPtr.h +232 -0
  239. package/external/folly/folly/concurrency/DeadlockDetector.cpp +27 -0
  240. package/external/folly/folly/concurrency/DeadlockDetector.h +44 -0
  241. package/external/folly/folly/concurrency/DynamicBoundedQueue.h +751 -0
  242. package/external/folly/folly/concurrency/PriorityUnboundedQueueSet.h +207 -0
  243. package/external/folly/folly/concurrency/ProcessLocalUniqueId.cpp +46 -0
  244. package/external/folly/folly/concurrency/ProcessLocalUniqueId.h +38 -0
  245. package/external/folly/folly/concurrency/SingletonRelaxedCounter.h +325 -0
  246. package/external/folly/folly/concurrency/ThreadCachedSynchronized.h +227 -0
  247. package/external/folly/folly/concurrency/UnboundedQueue.h +891 -0
  248. package/external/folly/folly/concurrency/container/BUCK +77 -0
  249. package/external/folly/folly/concurrency/container/FlatCombiningPriorityQueue.h +426 -0
  250. package/external/folly/folly/concurrency/container/LockFreeRingBuffer.h +306 -0
  251. package/external/folly/folly/concurrency/container/RelaxedConcurrentPriorityQueue.h +1212 -0
  252. package/external/folly/folly/concurrency/container/SingleWriterFixedHashMap.h +322 -0
  253. package/external/folly/folly/concurrency/container/atomic_grow_array.h +564 -0
  254. package/external/folly/folly/concurrency/container/test/BUCK +75 -0
  255. package/external/folly/folly/concurrency/container/test/FlatCombiningPriorityQueueTest.cpp +570 -0
  256. package/external/folly/folly/concurrency/container/test/LockFreeRingBufferTest.cpp +276 -0
  257. package/external/folly/folly/concurrency/container/test/RelaxedConcurrentPriorityQueueTest.cpp +1570 -0
  258. package/external/folly/folly/concurrency/container/test/SingleWriterFixedHashMapTest.cpp +401 -0
  259. package/external/folly/folly/concurrency/container/test/atomic_grow_array_test.cpp +187 -0
  260. package/external/folly/folly/concurrency/detail/AtomicSharedPtr-detail.h +212 -0
  261. package/external/folly/folly/concurrency/detail/ConcurrentHashMap-detail.h +1911 -0
  262. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.cpp +43 -0
  263. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.h +190 -0
  264. package/external/folly/folly/concurrency/memory/BUCK +53 -0
  265. package/external/folly/folly/concurrency/memory/PrimaryPtr.h +338 -0
  266. package/external/folly/folly/concurrency/memory/ReadMostlySharedPtr.h +511 -0
  267. package/external/folly/folly/concurrency/memory/TLRefCount.h +228 -0
  268. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrBenchmark.cpp +56 -0
  269. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrTest.cpp +454 -0
  270. package/external/folly/folly/concurrency/memory/test/BUCK +95 -0
  271. package/external/folly/folly/concurrency/memory/test/PrimaryPtrTest.cpp +303 -0
  272. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrBenchmark.cpp +138 -0
  273. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrStressTest.cpp +75 -0
  274. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrTest.cpp +378 -0
  275. package/external/folly/folly/concurrency/memory/test/RefCountBenchmark.cpp +90 -0
  276. package/external/folly/folly/concurrency/memory/test/RefCountTest.cpp +168 -0
  277. package/external/folly/folly/concurrency/test/AtomicSharedPtrCounted.h +156 -0
  278. package/external/folly/folly/concurrency/test/AtomicSharedPtrPerformance.cpp +255 -0
  279. package/external/folly/folly/concurrency/test/AtomicSharedPtrTest.cpp +257 -0
  280. package/external/folly/folly/concurrency/test/BUCK +229 -0
  281. package/external/folly/folly/concurrency/test/CacheLocalityBenchmark.cpp +392 -0
  282. package/external/folly/folly/concurrency/test/CacheLocalityTest.cpp +1229 -0
  283. package/external/folly/folly/concurrency/test/ConcurrentHashMapBench.cpp +260 -0
  284. package/external/folly/folly/concurrency/test/ConcurrentHashMapTest.cpp +1242 -0
  285. package/external/folly/folly/concurrency/test/CoreCachedSharedPtrTest.cpp +408 -0
  286. package/external/folly/folly/concurrency/test/DynamicBoundedQueueTest.cpp +984 -0
  287. package/external/folly/folly/concurrency/test/PriorityUnboundedQueueSetTest.cpp +73 -0
  288. package/external/folly/folly/concurrency/test/ProcessLocalUniqueIdTest.cpp +66 -0
  289. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterBench.cpp +101 -0
  290. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterTest.cpp +185 -0
  291. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedBench.cpp +76 -0
  292. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedTest.cpp +93 -0
  293. package/external/folly/folly/concurrency/test/UnboundedQueueTest.cpp +1302 -0
  294. package/external/folly/folly/container/Access.h +57 -0
  295. package/external/folly/folly/container/Array.h +87 -0
  296. package/external/folly/folly/container/BUCK +353 -0
  297. package/external/folly/folly/container/BitIterator.h +203 -0
  298. package/external/folly/folly/container/Enumerate.h +162 -0
  299. package/external/folly/folly/container/EvictingCacheMap.h +730 -0
  300. package/external/folly/folly/container/F14.md +300 -0
  301. package/external/folly/folly/container/F14Map-fwd.h +113 -0
  302. package/external/folly/folly/container/F14Map.h +2108 -0
  303. package/external/folly/folly/container/F14Set-fwd.h +95 -0
  304. package/external/folly/folly/container/F14Set.h +1603 -0
  305. package/external/folly/folly/container/FBVector.h +1711 -0
  306. package/external/folly/folly/container/Foreach-inl.h +316 -0
  307. package/external/folly/folly/container/Foreach.h +209 -0
  308. package/external/folly/folly/container/HeterogeneousAccess-fwd.h +33 -0
  309. package/external/folly/folly/container/HeterogeneousAccess.h +171 -0
  310. package/external/folly/folly/container/IntrusiveHeap.h +268 -0
  311. package/external/folly/folly/container/IntrusiveList.h +131 -0
  312. package/external/folly/folly/container/Iterator.h +843 -0
  313. package/external/folly/folly/container/MapUtil.h +376 -0
  314. package/external/folly/folly/container/Merge.h +90 -0
  315. package/external/folly/folly/container/RegexMatchCache.cpp +521 -0
  316. package/external/folly/folly/container/RegexMatchCache.h +699 -0
  317. package/external/folly/folly/container/Reserve.h +109 -0
  318. package/external/folly/folly/container/SparseByteSet.h +123 -0
  319. package/external/folly/folly/container/View.h +81 -0
  320. package/external/folly/folly/container/WeightedEvictingCacheMap.h +651 -0
  321. package/external/folly/folly/container/detail/BUCK +115 -0
  322. package/external/folly/folly/container/detail/BitIteratorDetail.h +87 -0
  323. package/external/folly/folly/container/detail/F14Defaults.h +34 -0
  324. package/external/folly/folly/container/detail/F14IntrinsicsAvailability.h +67 -0
  325. package/external/folly/folly/container/detail/F14MapFallback.h +717 -0
  326. package/external/folly/folly/container/detail/F14Mask.h +235 -0
  327. package/external/folly/folly/container/detail/F14Policy.h +1523 -0
  328. package/external/folly/folly/container/detail/F14SetFallback.h +528 -0
  329. package/external/folly/folly/container/detail/F14Table.cpp +71 -0
  330. package/external/folly/folly/container/detail/F14Table.h +2680 -0
  331. package/external/folly/folly/container/detail/Util.h +303 -0
  332. package/external/folly/folly/container/detail/tape_detail.h +135 -0
  333. package/external/folly/folly/container/detail/test/BUCK +14 -0
  334. package/external/folly/folly/container/detail/test/F14DetailTest.cpp +47 -0
  335. package/external/folly/folly/container/heap_vector_types.h +1683 -0
  336. package/external/folly/folly/container/range_traits.h +81 -0
  337. package/external/folly/folly/container/small_vector.h +1476 -0
  338. package/external/folly/folly/container/sorted_vector_types.h +1652 -0
  339. package/external/folly/folly/container/span.h +408 -0
  340. package/external/folly/folly/container/tape.h +608 -0
  341. package/external/folly/folly/container/test/.clang-tidy +12 -0
  342. package/external/folly/folly/container/test/AccessTest.cpp +138 -0
  343. package/external/folly/folly/container/test/ArrayTest.cpp +84 -0
  344. package/external/folly/folly/container/test/BUCK +568 -0
  345. package/external/folly/folly/container/test/BitIteratorBench.cpp +112 -0
  346. package/external/folly/folly/container/test/BitIteratorTest.cpp +109 -0
  347. package/external/folly/folly/container/test/EnumerateTest.cpp +294 -0
  348. package/external/folly/folly/container/test/EvictingCacheMapBench.cpp +80 -0
  349. package/external/folly/folly/container/test/EvictingCacheMapTest.cpp +842 -0
  350. package/external/folly/folly/container/test/F14AsanSupportTest.cpp +143 -0
  351. package/external/folly/folly/container/test/F14FwdTest.cpp +37 -0
  352. package/external/folly/folly/container/test/F14InterprocessTest.cpp +404 -0
  353. package/external/folly/folly/container/test/F14MapTest.cpp +2543 -0
  354. package/external/folly/folly/container/test/F14PolicyTest.cpp +49 -0
  355. package/external/folly/folly/container/test/F14SetTest.cpp +1738 -0
  356. package/external/folly/folly/container/test/F14SmallOverheads.cpp +215 -0
  357. package/external/folly/folly/container/test/F14TestUtil.h +117 -0
  358. package/external/folly/folly/container/test/FBVectorBenchmark.cpp +380 -0
  359. package/external/folly/folly/container/test/FBVectorBenchmarks.cpp.h +100 -0
  360. package/external/folly/folly/container/test/FBVectorTest.cpp +326 -0
  361. package/external/folly/folly/container/test/FBVectorTests.cpp.h +304 -0
  362. package/external/folly/folly/container/test/ForeachBenchmark.cpp +388 -0
  363. package/external/folly/folly/container/test/ForeachTest.cpp +338 -0
  364. package/external/folly/folly/container/test/HashMapsBench.cpp +458 -0
  365. package/external/folly/folly/container/test/HeterogeneousAccessTest.cpp +242 -0
  366. package/external/folly/folly/container/test/IntrusiveHeapTest.cpp +262 -0
  367. package/external/folly/folly/container/test/IteratorTest.cpp +989 -0
  368. package/external/folly/folly/container/test/MapUtilTest.cpp +365 -0
  369. package/external/folly/folly/container/test/MergeTest.cpp +66 -0
  370. package/external/folly/folly/container/test/RegexMatchCacheTest.cpp +634 -0
  371. package/external/folly/folly/container/test/ReserveTest.cpp +173 -0
  372. package/external/folly/folly/container/test/SparseByteSetBenchmark.cpp +153 -0
  373. package/external/folly/folly/container/test/SparseByteSetTest.cpp +117 -0
  374. package/external/folly/folly/container/test/TrackingTypes.h +584 -0
  375. package/external/folly/folly/container/test/UtilTest.cpp +609 -0
  376. package/external/folly/folly/container/test/WeightedEvictingCacheMapTest.cpp +800 -0
  377. package/external/folly/folly/container/test/heap_vector_types_test.cpp +1774 -0
  378. package/external/folly/folly/container/test/range_traits_test.cpp +59 -0
  379. package/external/folly/folly/container/test/small_vector_test.cpp +1571 -0
  380. package/external/folly/folly/container/test/sorted_vector_test.cpp +1589 -0
  381. package/external/folly/folly/container/test/span_test.cpp +520 -0
  382. package/external/folly/folly/container/test/tape_bench.cpp +200 -0
  383. package/external/folly/folly/container/test/tape_test.cpp +590 -0
  384. package/external/folly/folly/defs.bzl +238 -0
  385. package/external/folly/folly/detail/AsyncTrace.cpp +36 -0
  386. package/external/folly/folly/detail/AsyncTrace.h +44 -0
  387. package/external/folly/folly/detail/AtomicHashUtils.h +42 -0
  388. package/external/folly/folly/detail/AtomicUnorderedMapUtils.h +80 -0
  389. package/external/folly/folly/detail/BUCK +406 -0
  390. package/external/folly/folly/detail/DiscriminatedPtrDetail.h +172 -0
  391. package/external/folly/folly/detail/FileUtilDetail.cpp +63 -0
  392. package/external/folly/folly/detail/FileUtilDetail.h +85 -0
  393. package/external/folly/folly/detail/FileUtilVectorDetail.h +81 -0
  394. package/external/folly/folly/detail/FingerprintPolynomial.h +132 -0
  395. package/external/folly/folly/detail/Futex-inl.h +123 -0
  396. package/external/folly/folly/detail/Futex.cpp +273 -0
  397. package/external/folly/folly/detail/Futex.h +109 -0
  398. package/external/folly/folly/detail/GroupVarintDetail.h +101 -0
  399. package/external/folly/folly/detail/IPAddress.cpp +37 -0
  400. package/external/folly/folly/detail/IPAddress.h +57 -0
  401. package/external/folly/folly/detail/IPAddressSource.h +278 -0
  402. package/external/folly/folly/detail/Iterators.h +156 -0
  403. package/external/folly/folly/detail/MPMCPipelineDetail.h +122 -0
  404. package/external/folly/folly/detail/MemoryIdler.cpp +233 -0
  405. package/external/folly/folly/detail/MemoryIdler.h +216 -0
  406. package/external/folly/folly/detail/PerfScoped.cpp +112 -0
  407. package/external/folly/folly/detail/PerfScoped.h +70 -0
  408. package/external/folly/folly/detail/PolyDetail.h +921 -0
  409. package/external/folly/folly/detail/RangeCommon.cpp +55 -0
  410. package/external/folly/folly/detail/RangeCommon.h +93 -0
  411. package/external/folly/folly/detail/RangeSse42.cpp +198 -0
  412. package/external/folly/folly/detail/RangeSse42.h +30 -0
  413. package/external/folly/folly/detail/SimpleSimdStringUtils.cpp +31 -0
  414. package/external/folly/folly/detail/SimpleSimdStringUtils.h +27 -0
  415. package/external/folly/folly/detail/SimpleSimdStringUtilsImpl.h +63 -0
  416. package/external/folly/folly/detail/Singleton.h +34 -0
  417. package/external/folly/folly/detail/SlowFingerprint.h +90 -0
  418. package/external/folly/folly/detail/SocketFastOpen.cpp +175 -0
  419. package/external/folly/folly/detail/SocketFastOpen.h +89 -0
  420. package/external/folly/folly/detail/SplitStringSimd.cpp +84 -0
  421. package/external/folly/folly/detail/SplitStringSimd.h +151 -0
  422. package/external/folly/folly/detail/SplitStringSimdImpl.h +149 -0
  423. package/external/folly/folly/detail/Sse.cpp +35 -0
  424. package/external/folly/folly/detail/Sse.h +45 -0
  425. package/external/folly/folly/detail/StaticSingletonManager.cpp +119 -0
  426. package/external/folly/folly/detail/StaticSingletonManager.h +298 -0
  427. package/external/folly/folly/detail/ThreadLocalDetail.cpp +492 -0
  428. package/external/folly/folly/detail/ThreadLocalDetail.h +800 -0
  429. package/external/folly/folly/detail/TrapOnAvx512.cpp +41 -0
  430. package/external/folly/folly/detail/TrapOnAvx512.h +21 -0
  431. package/external/folly/folly/detail/TurnSequencer.h +295 -0
  432. package/external/folly/folly/detail/TypeList.h +551 -0
  433. package/external/folly/folly/detail/UniqueInstance.cpp +136 -0
  434. package/external/folly/folly/detail/UniqueInstance.h +68 -0
  435. package/external/folly/folly/detail/base64_detail/BUCK +102 -0
  436. package/external/folly/folly/detail/base64_detail/Base64Api.cpp +40 -0
  437. package/external/folly/folly/detail/base64_detail/Base64Api.h +101 -0
  438. package/external/folly/folly/detail/base64_detail/Base64Common.h +80 -0
  439. package/external/folly/folly/detail/base64_detail/Base64Constants.h +79 -0
  440. package/external/folly/folly/detail/base64_detail/Base64HiddenConstants.h +129 -0
  441. package/external/folly/folly/detail/base64_detail/Base64SWAR.cpp +161 -0
  442. package/external/folly/folly/detail/base64_detail/Base64SWAR.h +32 -0
  443. package/external/folly/folly/detail/base64_detail/Base64Scalar.h +262 -0
  444. package/external/folly/folly/detail/base64_detail/Base64Simd.h +102 -0
  445. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.cpp +42 -0
  446. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.h +33 -0
  447. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2_Platform.h +167 -0
  448. package/external/folly/folly/detail/base64_detail/README.md +392 -0
  449. package/external/folly/folly/detail/base64_detail/tests/BUCK +36 -0
  450. package/external/folly/folly/detail/base64_detail/tests/Base64AgainstScalarTest.cpp +141 -0
  451. package/external/folly/folly/detail/base64_detail/tests/Base64PlatformTest.cpp +273 -0
  452. package/external/folly/folly/detail/base64_detail/tests/Base64SpecialCasesTest.cpp +555 -0
  453. package/external/folly/folly/detail/test/AsyncTraceTest.cpp +43 -0
  454. package/external/folly/folly/detail/test/BUCK +118 -0
  455. package/external/folly/folly/detail/test/FileUtilDetailTest.cpp +56 -0
  456. package/external/folly/folly/detail/test/PerfScopedTest.cpp +107 -0
  457. package/external/folly/folly/detail/test/SimpleSimdStringUtilsTest.cpp +92 -0
  458. package/external/folly/folly/detail/test/SplitStringSimdTest.cpp +242 -0
  459. package/external/folly/folly/detail/test/StaticSingletonManagerTest.cpp +121 -0
  460. package/external/folly/folly/detail/test/ThreadLocalBenchmark.cpp +116 -0
  461. package/external/folly/folly/detail/test/ThreadLocalDetailTest.cpp +194 -0
  462. package/external/folly/folly/detail/test/TrapOnAvx512TestNegative.cpp +29 -0
  463. package/external/folly/folly/detail/test/UniqueInstanceTest.cpp +60 -0
  464. package/external/folly/folly/detail/thread_local_globals.cpp +69 -0
  465. package/external/folly/folly/detail/thread_local_globals.h +36 -0
  466. package/external/folly/folly/dynamic-inl.h +17 -0
  467. package/external/folly/folly/dynamic.h +17 -0
  468. package/external/folly/folly/folly_extended_library.bzl +28 -0
  469. package/external/folly/folly/functional/ApplyTuple.h +204 -0
  470. package/external/folly/folly/functional/BUCK +57 -0
  471. package/external/folly/folly/functional/Invoke.h +880 -0
  472. package/external/folly/folly/functional/Partial.h +130 -0
  473. package/external/folly/folly/functional/protocol.h +203 -0
  474. package/external/folly/folly/functional/test/ApplyTupleTest.cpp +549 -0
  475. package/external/folly/folly/functional/test/BUCK +57 -0
  476. package/external/folly/folly/functional/test/InvokeTest.cpp +483 -0
  477. package/external/folly/folly/functional/test/PartialTest.cpp +141 -0
  478. package/external/folly/folly/functional/test/protocol_test.cpp +177 -0
  479. package/external/folly/folly/functional/test/traits_test.cpp +551 -0
  480. package/external/folly/folly/functional/traits.h +675 -0
  481. package/external/folly/folly/hash/BUCK +86 -0
  482. package/external/folly/folly/hash/Checksum.cpp +275 -0
  483. package/external/folly/folly/hash/Checksum.h +94 -0
  484. package/external/folly/folly/hash/FarmHash.h +46 -0
  485. package/external/folly/folly/hash/Hash.h +1045 -0
  486. package/external/folly/folly/hash/MurmurHash.h +86 -0
  487. package/external/folly/folly/hash/SpookyHashV1.cpp +391 -0
  488. package/external/folly/folly/hash/SpookyHashV1.h +307 -0
  489. package/external/folly/folly/hash/SpookyHashV2.cpp +392 -0
  490. package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/hash/SpookyHashV2.h +6 -1
  491. package/external/folly/folly/hash/detail/BUCK +26 -0
  492. package/external/folly/folly/hash/detail/ChecksumDetail.cpp +296 -0
  493. package/external/folly/folly/hash/detail/ChecksumDetail.h +137 -0
  494. package/external/folly/folly/hash/detail/Crc32CombineDetail.cpp +191 -0
  495. package/external/folly/folly/hash/detail/Crc32cDetail.cpp +303 -0
  496. package/external/folly/folly/hash/test/BUCK +132 -0
  497. package/external/folly/folly/hash/test/ChecksumBenchmark.cpp +91 -0
  498. package/external/folly/folly/hash/test/ChecksumTest.cpp +587 -0
  499. package/external/folly/folly/hash/test/FarmHashTest.cpp +41 -0
  500. package/external/folly/folly/hash/test/HashBenchmark.cpp +238 -0
  501. package/external/folly/folly/hash/test/HashTest.cpp +997 -0
  502. package/external/folly/folly/hash/test/MurmurHashTest.cpp +76 -0
  503. package/external/folly/folly/hash/test/SpookyHashV1Test.cpp +559 -0
  504. package/external/folly/folly/hash/test/SpookyHashV2Test.cpp +549 -0
  505. package/external/folly/folly/hash/test/traits_test.cpp +69 -0
  506. package/external/folly/folly/hash/traits.h +115 -0
  507. package/external/folly/folly/json/BUCK +155 -0
  508. package/external/folly/folly/json/DynamicConverter.h +464 -0
  509. package/external/folly/folly/json/DynamicParser-inl.h +316 -0
  510. package/external/folly/folly/json/DynamicParser.cpp +198 -0
  511. package/external/folly/folly/json/DynamicParser.h +394 -0
  512. package/external/folly/folly/json/JSONSchema.cpp +1030 -0
  513. package/external/folly/folly/json/JSONSchema.h +73 -0
  514. package/external/folly/folly/json/JsonMockUtil.h +73 -0
  515. package/external/folly/folly/json/JsonTestUtil.cpp +167 -0
  516. package/external/folly/folly/json/JsonTestUtil.h +88 -0
  517. package/external/folly/folly/json/bser/BUCK +24 -0
  518. package/external/folly/folly/json/bser/Bser.h +107 -0
  519. package/external/folly/folly/json/bser/Dump.cpp +253 -0
  520. package/external/folly/folly/json/bser/Load.cpp +246 -0
  521. package/external/folly/folly/json/bser/test/BUCK +14 -0
  522. package/external/folly/folly/json/bser/test/BserTest.cpp +149 -0
  523. package/external/folly/folly/json/dynamic.cpp +552 -0
  524. package/external/folly/folly/json/dynamic.h +1346 -0
  525. package/external/folly/folly/json/json.h +238 -0
  526. package/external/folly/folly/json/json_patch.cpp +325 -0
  527. package/external/folly/folly/json/json_patch.h +126 -0
  528. package/external/folly/folly/json/json_pointer.cpp +114 -0
  529. package/external/folly/folly/json/json_pointer.h +87 -0
  530. package/external/folly/folly/json/test/BUCK +147 -0
  531. package/external/folly/folly/json/test/DynamicBenchmark.cpp +146 -0
  532. package/external/folly/folly/json/test/DynamicConverterTest.cpp +518 -0
  533. package/external/folly/folly/json/test/DynamicOtherTest.cpp +344 -0
  534. package/external/folly/folly/json/test/DynamicParserTest.cpp +443 -0
  535. package/external/folly/folly/json/test/DynamicTest.cpp +1647 -0
  536. package/external/folly/folly/json/test/JSONSchemaTest.cpp +450 -0
  537. package/external/folly/folly/json/test/JsonBenchmark.cpp +264 -0
  538. package/external/folly/folly/json/test/JsonOtherTest.cpp +51 -0
  539. package/external/folly/folly/json/test/JsonTest.cpp +1153 -0
  540. package/external/folly/folly/json/test/JsonTestUtilTest.cpp +97 -0
  541. package/external/folly/folly/json/test/json_patch_test.cpp +361 -0
  542. package/external/folly/folly/json/test/json_pointer_test.cpp +58 -0
  543. package/external/folly/folly/json/tool/BUCK +13 -0
  544. package/external/folly/folly/json/tool/JSONSchemaTester.cpp +58 -0
  545. package/external/folly/folly/json.h +17 -0
  546. package/external/folly/folly/json_patch.h +17 -0
  547. package/external/folly/folly/json_pointer.h +17 -0
  548. package/external/folly/folly/lang/Access.h +29 -0
  549. package/external/folly/folly/lang/Align.h +240 -0
  550. package/external/folly/folly/lang/Aligned.h +92 -0
  551. package/external/folly/folly/lang/Assume.h +82 -0
  552. package/external/folly/folly/lang/BUCK +287 -0
  553. package/external/folly/folly/lang/Badge.h +108 -0
  554. package/external/folly/folly/lang/Bits.h +570 -0
  555. package/external/folly/folly/lang/BitsClass.h +312 -0
  556. package/external/folly/folly/lang/Builtin.h +74 -0
  557. package/external/folly/folly/lang/CArray.h +34 -0
  558. package/external/folly/folly/lang/CString.cpp +86 -0
  559. package/external/folly/folly/lang/CString.h +55 -0
  560. package/external/folly/folly/lang/Cast.h +51 -0
  561. package/external/folly/folly/lang/CheckedMath.h +253 -0
  562. package/external/folly/folly/lang/CustomizationPoint.h +58 -0
  563. package/external/folly/folly/lang/Exception.cpp +822 -0
  564. package/external/folly/folly/lang/Exception.h +716 -0
  565. package/external/folly/folly/lang/Extern.h +55 -0
  566. package/external/folly/folly/lang/Hint-inl.h +144 -0
  567. package/external/folly/folly/lang/Hint.h +238 -0
  568. package/external/folly/folly/lang/Keep.h +98 -0
  569. package/external/folly/folly/lang/New.h +124 -0
  570. package/external/folly/folly/lang/Ordering.h +140 -0
  571. package/external/folly/folly/lang/Pretty.h +159 -0
  572. package/external/folly/folly/lang/PropagateConst.h +413 -0
  573. package/external/folly/folly/lang/RValueReferenceWrapper.h +152 -0
  574. package/external/folly/folly/lang/SafeAssert.cpp +589 -0
  575. package/external/folly/folly/lang/StaticConst.h +33 -0
  576. package/external/folly/folly/lang/Thunk.h +100 -0
  577. package/external/folly/folly/lang/TypeInfo.h +58 -0
  578. package/external/folly/folly/lang/UncaughtExceptions.cpp +17 -0
  579. package/external/folly/folly/lang/UncaughtExceptions.h +19 -0
  580. package/external/folly/folly/lang/test/AlignTest.cpp +87 -0
  581. package/external/folly/folly/lang/test/AlignedTest.cpp +130 -0
  582. package/external/folly/folly/lang/test/BUCK +258 -0
  583. package/external/folly/folly/lang/test/BadgeTest.cpp +89 -0
  584. package/external/folly/folly/lang/test/BitsBenchmark.cpp +164 -0
  585. package/external/folly/folly/lang/test/BitsClassBenchmark.cpp +122 -0
  586. package/external/folly/folly/lang/test/BitsClassTest.cpp +379 -0
  587. package/external/folly/folly/lang/test/BitsTest.cpp +577 -0
  588. package/external/folly/folly/lang/test/CStringTest.cpp +60 -0
  589. package/external/folly/folly/lang/test/CastTest.cpp +47 -0
  590. package/external/folly/folly/lang/test/CheckedMathTest.cpp +394 -0
  591. package/external/folly/folly/lang/test/ExceptionBench.cpp +427 -0
  592. package/external/folly/folly/lang/test/ExceptionTest.cpp +413 -0
  593. package/external/folly/folly/lang/test/ExternTest.cpp +39 -0
  594. package/external/folly/folly/lang/test/HintTest.cpp +100 -0
  595. package/external/folly/folly/lang/test/NewTest.cpp +38 -0
  596. package/external/folly/folly/lang/test/OrderingTest.cpp +105 -0
  597. package/external/folly/folly/lang/test/PrettyTest.cpp +44 -0
  598. package/external/folly/folly/lang/test/PropagateConstTest.cpp +356 -0
  599. package/external/folly/folly/lang/test/RValueReferenceWrapperTest.cpp +85 -0
  600. package/external/folly/folly/lang/test/SafeAssertTest.cpp +75 -0
  601. package/external/folly/folly/lang/test/ThunkTest.cpp +105 -0
  602. package/external/folly/folly/lang/test/ToAsciiBench.cpp +466 -0
  603. package/external/folly/folly/lang/test/ToAsciiTest.cpp +266 -0
  604. package/external/folly/folly/lang/test/TypeInfoTest.cpp +56 -0
  605. package/external/folly/folly/memcpy.S +292 -0
  606. package/external/folly/folly/memcpy_select_aarch64.cpp +145 -0
  607. package/external/folly/folly/memory/Arena-inl.h +83 -0
  608. package/external/folly/folly/memory/Arena.h +325 -0
  609. package/external/folly/folly/memory/BUCK +191 -0
  610. package/external/folly/folly/memory/JemallocHugePageAllocator.cpp +449 -0
  611. package/external/folly/folly/memory/JemallocHugePageAllocator.h +105 -0
  612. package/external/folly/folly/memory/JemallocHugePageAllocatorTest.cpp +341 -0
  613. package/external/folly/folly/memory/JemallocNodumpAllocator.cpp +176 -0
  614. package/external/folly/folly/memory/JemallocNodumpAllocator.h +119 -0
  615. package/external/folly/folly/memory/JemallocNodumpAllocatorTest.cpp +61 -0
  616. package/external/folly/folly/memory/MallctlHelper.cpp +37 -0
  617. package/external/folly/folly/memory/MallctlHelper.h +167 -0
  618. package/external/folly/folly/memory/Malloc.h +551 -0
  619. package/external/folly/folly/memory/MemoryResource.h +57 -0
  620. package/external/folly/folly/memory/ReentrantAllocator.cpp +162 -0
  621. package/external/folly/folly/memory/ReentrantAllocator.h +261 -0
  622. package/external/folly/folly/memory/SanitizeAddress.cpp +75 -0
  623. package/external/folly/folly/memory/SanitizeAddress.h +117 -0
  624. package/external/folly/folly/memory/SanitizeLeak.cpp +119 -0
  625. package/external/folly/folly/memory/SanitizeLeak.h +108 -0
  626. package/external/folly/folly/memory/ThreadCachedArena.cpp +53 -0
  627. package/external/folly/folly/memory/ThreadCachedArena.h +90 -0
  628. package/external/folly/folly/memory/UninitializedMemoryHacks.h +426 -0
  629. package/external/folly/folly/memory/detail/BUCK +10 -0
  630. package/external/folly/folly/memory/detail/MallocImpl.cpp +52 -0
  631. package/external/folly/folly/memory/detail/MallocImpl.h +97 -0
  632. package/external/folly/folly/memory/not_null-inl.h +522 -0
  633. package/external/folly/folly/memory/not_null.h +449 -0
  634. package/external/folly/folly/memory/test/ArenaTest.cpp +354 -0
  635. package/external/folly/folly/memory/test/BUCK +146 -0
  636. package/external/folly/folly/memory/test/MallctlHelperTest.cpp +169 -0
  637. package/external/folly/folly/memory/test/MallocBenchmark.cpp +91 -0
  638. package/external/folly/folly/memory/test/MallocTest.cpp +78 -0
  639. package/external/folly/folly/memory/test/MemoryResourceTest.cpp +31 -0
  640. package/external/folly/folly/memory/test/ReentrantAllocatorTest.cpp +144 -0
  641. package/external/folly/folly/memory/test/SanitizeAddressTest.cpp +67 -0
  642. package/external/folly/folly/memory/test/SanitizeLeakTest.cpp +139 -0
  643. package/external/folly/folly/memory/test/ThreadCachedArenaTest.cpp +276 -0
  644. package/external/folly/folly/memory/test/UninitializedMemoryHacksODR.cpp +21 -0
  645. package/external/folly/folly/memory/test/UninitializedMemoryHacksTest.cpp +327 -0
  646. package/external/folly/folly/memory/test/not_null_test.cpp +608 -0
  647. package/external/folly/folly/memset.S +245 -0
  648. package/external/folly/folly/memset_select_aarch64.cpp +72 -0
  649. package/external/folly/folly/portability/Asm.h +50 -0
  650. package/external/folly/folly/portability/Atomic.h +31 -0
  651. package/external/folly/folly/portability/BUCK +456 -0
  652. package/external/folly/folly/portability/Builtins.cpp +31 -0
  653. package/external/folly/folly/portability/Builtins.h +161 -0
  654. package/external/folly/folly/portability/Config.h +43 -0
  655. package/external/folly/folly/portability/Constexpr.h +145 -0
  656. package/external/folly/folly/portability/Dirent.cpp +140 -0
  657. package/external/folly/folly/portability/Dirent.h +41 -0
  658. package/external/folly/folly/portability/Event.h +44 -0
  659. package/external/folly/folly/portability/Fcntl.cpp +120 -0
  660. package/external/folly/folly/portability/Fcntl.h +67 -0
  661. package/external/folly/folly/portability/Filesystem.cpp +67 -0
  662. package/external/folly/folly/portability/Filesystem.h +114 -0
  663. package/external/folly/folly/portability/FmtCompile.h +40 -0
  664. package/external/folly/folly/portability/GFlags.h +139 -0
  665. package/external/folly/folly/portability/GMock.h +35 -0
  666. package/external/folly/folly/portability/GTest.h +35 -0
  667. package/external/folly/folly/portability/IOVec.h +34 -0
  668. package/external/folly/folly/portability/Libgen.cpp +59 -0
  669. package/external/folly/folly/portability/Libgen.h +29 -0
  670. package/external/folly/folly/portability/Libunwind.h +21 -0
  671. package/external/folly/folly/portability/Malloc.cpp +31 -0
  672. package/external/folly/folly/portability/Malloc.h +53 -0
  673. package/external/folly/folly/portability/Math.h +90 -0
  674. package/external/folly/folly/portability/Memory.h +26 -0
  675. package/external/folly/folly/portability/OpenSSL.cpp +17 -0
  676. package/external/folly/folly/portability/OpenSSL.h +102 -0
  677. package/external/folly/folly/portability/PThread.cpp +697 -0
  678. package/external/folly/folly/portability/PThread.h +148 -0
  679. package/external/folly/folly/portability/README.md +21 -0
  680. package/external/folly/folly/portability/Sched.cpp +41 -0
  681. package/external/folly/folly/portability/Sched.h +45 -0
  682. package/external/folly/folly/portability/Sockets.cpp +245 -0
  683. package/external/folly/folly/portability/Sockets.h +155 -0
  684. package/external/folly/folly/portability/SourceLocation.h +49 -0
  685. package/external/folly/folly/portability/Stdio.cpp +77 -0
  686. package/external/folly/folly/portability/Stdio.h +32 -0
  687. package/external/folly/folly/portability/Stdlib.cpp +172 -0
  688. package/external/folly/folly/portability/Stdlib.h +64 -0
  689. package/external/folly/folly/portability/String.cpp +53 -0
  690. package/external/folly/folly/portability/String.h +39 -0
  691. package/external/folly/folly/portability/SysFile.cpp +46 -0
  692. package/external/folly/folly/portability/SysFile.h +27 -0
  693. package/external/folly/folly/portability/SysMembarrier.cpp +104 -0
  694. package/external/folly/folly/portability/SysMembarrier.h +26 -0
  695. package/external/folly/folly/portability/SysMman.cpp +242 -0
  696. package/external/folly/folly/portability/SysMman.h +68 -0
  697. package/external/folly/folly/portability/SysResource.cpp +108 -0
  698. package/external/folly/folly/portability/SysResource.h +71 -0
  699. package/external/folly/folly/portability/SysStat.cpp +66 -0
  700. package/external/folly/folly/portability/SysStat.h +52 -0
  701. package/external/folly/folly/portability/SysSyscall.h +73 -0
  702. package/external/folly/folly/portability/SysTime.cpp +62 -0
  703. package/external/folly/folly/portability/SysTime.h +50 -0
  704. package/external/folly/folly/portability/SysTypes.h +44 -0
  705. package/external/folly/folly/portability/SysUio.cpp +179 -0
  706. package/external/folly/folly/portability/SysUio.h +51 -0
  707. package/external/folly/folly/portability/Syslog.h +39 -0
  708. package/external/folly/folly/portability/Time.cpp +357 -0
  709. package/external/folly/folly/portability/Time.h +74 -0
  710. package/external/folly/folly/portability/Unistd.h +111 -0
  711. package/external/folly/folly/portability/Windows.h +108 -0
  712. package/external/folly/folly/portability/openat2.c +30 -0
  713. package/external/folly/folly/portability/openat2.h +39 -0
  714. package/external/folly/folly/portability/test/BUCK +59 -0
  715. package/external/folly/folly/portability/test/ConstexprTest.cpp +102 -0
  716. package/external/folly/folly/portability/test/FilesystemTest.cpp +35 -0
  717. package/external/folly/folly/portability/test/LibgenTest.cpp +35 -0
  718. package/external/folly/folly/portability/test/OpenSSLPortabilityTest.cpp +108 -0
  719. package/external/folly/folly/portability/test/PThreadTest.cpp +80 -0
  720. package/external/folly/folly/portability/test/TimeTest.cpp +90 -0
  721. package/external/folly/folly/small_vector.h +17 -0
  722. package/external/folly/folly/somerge_defs.bzl +399 -0
  723. package/external/folly/folly/sorted_vector_types.h +17 -0
  724. package/external/folly/folly/stop_watch.h +317 -0
  725. package/external/folly/folly/synchronization/AsymmetricThreadFence.cpp +91 -0
  726. package/external/folly/folly/synchronization/AsymmetricThreadFence.h +60 -0
  727. package/external/folly/folly/synchronization/AtomicNotification-inl.h +146 -0
  728. package/external/folly/folly/synchronization/AtomicNotification.cpp +34 -0
  729. package/external/folly/folly/synchronization/AtomicNotification.h +117 -0
  730. package/external/folly/folly/synchronization/AtomicRef.h +181 -0
  731. package/external/folly/folly/synchronization/AtomicStruct.h +150 -0
  732. package/external/folly/folly/synchronization/AtomicUtil-inl.h +482 -0
  733. package/external/folly/folly/synchronization/AtomicUtil.h +179 -0
  734. package/external/folly/folly/synchronization/BUCK +418 -0
  735. package/external/folly/folly/synchronization/Baton.h +419 -0
  736. package/external/folly/folly/synchronization/CallOnce.h +263 -0
  737. package/external/folly/folly/synchronization/DelayedInit.h +179 -0
  738. package/external/folly/folly/synchronization/DistributedMutex-inl.h +1744 -0
  739. package/external/folly/folly/synchronization/DistributedMutex.cpp +27 -0
  740. package/external/folly/folly/synchronization/DistributedMutex.h +342 -0
  741. package/external/folly/folly/synchronization/EventCount.h +200 -0
  742. package/external/folly/folly/synchronization/FlatCombining.h +629 -0
  743. package/external/folly/folly/synchronization/Hazptr-fwd.h +217 -0
  744. package/external/folly/folly/synchronization/Hazptr.cpp +36 -0
  745. package/external/folly/folly/synchronization/Hazptr.h +209 -0
  746. package/external/folly/folly/synchronization/HazptrDomain.cpp +68 -0
  747. package/external/folly/folly/synchronization/HazptrDomain.h +832 -0
  748. package/external/folly/folly/synchronization/HazptrHolder.h +431 -0
  749. package/external/folly/folly/synchronization/HazptrObj.h +533 -0
  750. package/external/folly/folly/synchronization/HazptrObjLinked.h +315 -0
  751. package/external/folly/folly/synchronization/HazptrRec.h +68 -0
  752. package/external/folly/folly/synchronization/HazptrThrLocal.h +180 -0
  753. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.cpp +46 -0
  754. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.h +25 -0
  755. package/external/folly/folly/synchronization/Latch.h +160 -0
  756. package/external/folly/folly/synchronization/LifoSem.h +767 -0
  757. package/external/folly/folly/synchronization/Lock.h +887 -0
  758. package/external/folly/folly/synchronization/MicroSpinLock.h +154 -0
  759. package/external/folly/folly/synchronization/NativeSemaphore.h +187 -0
  760. package/external/folly/folly/synchronization/ParkingLot.cpp +37 -0
  761. package/external/folly/folly/synchronization/ParkingLot.h +330 -0
  762. package/external/folly/folly/synchronization/PicoSpinLock.h +167 -0
  763. package/external/folly/folly/synchronization/RWSpinLock.h +549 -0
  764. package/external/folly/folly/synchronization/Rcu.cpp +26 -0
  765. package/external/folly/folly/synchronization/Rcu.h +553 -0
  766. package/external/folly/folly/synchronization/RelaxedAtomic.h +336 -0
  767. package/external/folly/folly/synchronization/SanitizeThread.cpp +141 -0
  768. package/external/folly/folly/synchronization/SanitizeThread.h +166 -0
  769. package/external/folly/folly/synchronization/SaturatingSemaphore.h +324 -0
  770. package/external/folly/folly/synchronization/SmallLocks.h +36 -0
  771. package/external/folly/folly/synchronization/ThrottledLifoSem.h +362 -0
  772. package/external/folly/folly/synchronization/WaitOptions.cpp +25 -0
  773. package/external/folly/folly/synchronization/WaitOptions.h +75 -0
  774. package/external/folly/folly/synchronization/detail/AtomicUtils.h +59 -0
  775. package/external/folly/folly/synchronization/detail/BUCK +104 -0
  776. package/external/folly/folly/synchronization/detail/Hardware.cpp +192 -0
  777. package/external/folly/folly/synchronization/detail/Hardware.h +75 -0
  778. package/external/folly/folly/synchronization/detail/HazptrUtils.h +339 -0
  779. package/external/folly/folly/synchronization/detail/InlineFunctionRef.h +229 -0
  780. package/external/folly/folly/synchronization/detail/Sleeper.cpp +27 -0
  781. package/external/folly/folly/synchronization/detail/Sleeper.h +62 -0
  782. package/external/folly/folly/synchronization/detail/Spin.h +96 -0
  783. package/external/folly/folly/synchronization/detail/ThreadCachedLists.h +174 -0
  784. package/external/folly/folly/synchronization/detail/ThreadCachedReaders.h +189 -0
  785. package/external/folly/folly/synchronization/detail/ThreadCachedTag.h +26 -0
  786. package/external/folly/folly/synchronization/detail/test/BUCK +28 -0
  787. package/external/folly/folly/synchronization/detail/test/HardwareTest.cpp +74 -0
  788. package/external/folly/folly/synchronization/detail/test/InlineFunctionRefTest.cpp +286 -0
  789. package/external/folly/folly/synchronization/example/BUCK +27 -0
  790. package/external/folly/folly/synchronization/example/HazptrLockFreeLIFO.h +88 -0
  791. package/external/folly/folly/synchronization/example/HazptrSWMRSet.h +133 -0
  792. package/external/folly/folly/synchronization/example/HazptrWideCAS.h +62 -0
  793. package/external/folly/folly/synchronization/test/AtomicNotificationTest.cpp +236 -0
  794. package/external/folly/folly/synchronization/test/AtomicRefTest.cpp +170 -0
  795. package/external/folly/folly/synchronization/test/AtomicStructTest.cpp +65 -0
  796. package/external/folly/folly/synchronization/test/AtomicUtilBench.cpp +457 -0
  797. package/external/folly/folly/synchronization/test/AtomicUtilTest.cpp +650 -0
  798. package/external/folly/folly/synchronization/test/BUCK +495 -0
  799. package/external/folly/folly/synchronization/test/Barrier.h +52 -0
  800. package/external/folly/folly/synchronization/test/BarrierTest.cpp +56 -0
  801. package/external/folly/folly/synchronization/test/BatonBenchmark.cpp +77 -0
  802. package/external/folly/folly/synchronization/test/BatonTest.cpp +164 -0
  803. package/external/folly/folly/synchronization/test/BatonTestHelpers.h +118 -0
  804. package/external/folly/folly/synchronization/test/CallOnceBenchmark.cpp +72 -0
  805. package/external/folly/folly/synchronization/test/CallOnceTest.cpp +153 -0
  806. package/external/folly/folly/synchronization/test/DelayedInitTest.cpp +281 -0
  807. package/external/folly/folly/synchronization/test/DistributedMutexTest.cpp +2074 -0
  808. package/external/folly/folly/synchronization/test/EventCountTest.cpp +124 -0
  809. package/external/folly/folly/synchronization/test/FlatCombiningBenchmark.cpp +1789 -0
  810. package/external/folly/folly/synchronization/test/FlatCombiningExamples.h +222 -0
  811. package/external/folly/folly/synchronization/test/FlatCombiningTest.cpp +121 -0
  812. package/external/folly/folly/synchronization/test/FlatCombiningTestHelpers.h +227 -0
  813. package/external/folly/folly/synchronization/test/HazptrTest.cpp +1689 -0
  814. package/external/folly/folly/synchronization/test/LatchTest.cpp +224 -0
  815. package/external/folly/folly/synchronization/test/LifoSemBench.cpp +185 -0
  816. package/external/folly/folly/synchronization/test/LifoSemTests.cpp +353 -0
  817. package/external/folly/folly/synchronization/test/LockTest.cpp +1239 -0
  818. package/external/folly/folly/synchronization/test/NativeSemaphoreTest.cpp +37 -0
  819. package/external/folly/folly/synchronization/test/ParkingLotBenchmark.cpp +239 -0
  820. package/external/folly/folly/synchronization/test/ParkingLotTest.cpp +170 -0
  821. package/external/folly/folly/synchronization/test/RWSpinLockTest.cpp +235 -0
  822. package/external/folly/folly/synchronization/test/RcuBench.cpp +66 -0
  823. package/external/folly/folly/synchronization/test/RcuTest.cpp +330 -0
  824. package/external/folly/folly/synchronization/test/RelaxedAtomicTest.cpp +389 -0
  825. package/external/folly/folly/synchronization/test/SaturatingSemaphoreTest.cpp +166 -0
  826. package/external/folly/folly/synchronization/test/Semaphore.h +242 -0
  827. package/external/folly/folly/synchronization/test/SemaphoreTest.cpp +271 -0
  828. package/external/folly/folly/synchronization/test/SmallLocksBenchmark.cpp +1296 -0
  829. package/external/folly/folly/synchronization/test/SmallLocksTest.cpp +510 -0
  830. package/external/folly/folly/synchronization/test/ThreadCachedEpochBench.h +67 -0
  831. package/external/folly/folly/synchronization/test/ThreadCachedReadersBench.cpp +42 -0
  832. package/external/folly/folly/synchronization/test/ThreadCachedReadersTest.cpp +52 -0
  833. package/external/folly/folly/synchronization/test/ThrottledLifoSemTest.cpp +243 -0
  834. package/external/folly/folly/system/AtFork.cpp +205 -0
  835. package/external/folly/folly/system/AtFork.h +116 -0
  836. package/external/folly/folly/system/AuxVector.h +198 -0
  837. package/external/folly/folly/system/BUCK +144 -0
  838. package/external/folly/folly/system/EnvUtil.cpp +93 -0
  839. package/external/folly/folly/system/EnvUtil.h +113 -0
  840. package/external/folly/folly/system/HardwareConcurrency.cpp +39 -0
  841. package/external/folly/folly/system/HardwareConcurrency.h +23 -0
  842. package/external/folly/folly/system/MemoryMapping.cpp +477 -0
  843. package/external/folly/folly/system/MemoryMapping.h +287 -0
  844. package/external/folly/folly/system/Pid.cpp +87 -0
  845. package/external/folly/folly/system/Pid.h +34 -0
  846. package/external/folly/folly/system/Shell.cpp +33 -0
  847. package/external/folly/folly/system/Shell.h +93 -0
  848. package/external/folly/folly/system/ThreadId.cpp +89 -0
  849. package/external/folly/folly/system/ThreadId.h +62 -0
  850. package/external/folly/folly/system/ThreadName.cpp +330 -0
  851. package/external/folly/folly/system/ThreadName.h +72 -0
  852. package/external/folly/folly/system/test/AtForkTest.cpp +309 -0
  853. package/external/folly/folly/system/test/AuxVectorTest.cpp +55 -0
  854. package/external/folly/folly/system/test/BUCK +120 -0
  855. package/external/folly/folly/system/test/EnvUtilSubprocess.cpp +26 -0
  856. package/external/folly/folly/system/test/EnvUtilTest.cpp +197 -0
  857. package/external/folly/folly/system/test/MemoryMappingTest.cpp +179 -0
  858. package/external/folly/folly/system/test/PidTest.cpp +46 -0
  859. package/external/folly/folly/system/test/ShellTest.cpp +66 -0
  860. package/external/folly/folly/system/test/ThreadIdTest.cpp +114 -0
  861. package/external/folly/folly/system/test/ThreadNameTest.cpp +85 -0
  862. package/external/folly/folly.vcxitems +164 -0
  863. package/external/folly/sync-config.json +8 -0
  864. package/package.json +6 -6
  865. package/template/cpp-app/proj/MyApp.sln +0 -33
  866. package/template/cpp-lib/proj/MyLib.sln +0 -33
  867. package/template/cs-app/proj/MyApp.sln +0 -33
  868. package/template/cs-lib/proj/MyLib.sln +0 -33
  869. package/templates/cpp-app/windows/MyApp.sln +0 -33
  870. package/templates/cpp-lib/windows/MyLib.sln +0 -33
  871. package/Folly/Folly.vcxproj +0 -383
  872. package/Folly/Folly.vcxproj.filters +0 -558
  873. package/Folly/Folly.win32.vcxproj +0 -11
  874. package/Folly/packages.lock.win32.json +0 -20
  875. package/fmt/fmt.vcxproj +0 -163
  876. package/fmt/fmt.vcxproj.filters +0 -59
  877. package/fmt/fmt.win32.vcxproj +0 -10
  878. package/fmt/pch.cpp +0 -4
  879. package/fmt/pch.h +0 -2
  880. /package/{Folly → external/folly}/Folly.natvis +0 -0
  881. /package/{Folly → external/folly}/cgmanifest.json +0 -0
  882. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/ConstexprMath.h +0 -0
  883. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/Conv.cpp +0 -0
  884. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/chrono/Hardware.h +0 -0
  885. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/concurrency/CacheLocality.cpp +0 -0
  886. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/dynamic-inl.h +0 -0
  887. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/json.cpp +0 -0
  888. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/SafeAssert.h +0 -0
  889. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.cpp +0 -0
  890. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.h +0 -0
  891. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/portability/Unistd.cpp +0 -0
@@ -0,0 +1,1772 @@
1
+ /*
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ //
18
+ // Docs: https://fburl.com/fbcref_range
19
+ //
20
+
21
+ /**
22
+ * Range abstraction using a pair of iterators. It is not
23
+ * similar to boost's range abstraction because an API identical
24
+ * with the former StringPiece class is required, which is used alot
25
+ * internally. This abstraction does fulfill the needs of boost's
26
+ * range-oriented algorithms though.
27
+ *
28
+ * Note: (Keep memory lifetime in mind when using this class, since it
29
+ * does not manage the data it refers to - just like an iterator
30
+ * would not.)
31
+ *
32
+ * Additional documentation is in folly/docs/Range.md
33
+ *
34
+ * @refcode folly/docs/examples/folly/Range.h
35
+ * @struct folly::range
36
+ */
37
+
38
+ #pragma once
39
+
40
+ #include <folly/Portability.h>
41
+ #include <folly/hash/SpookyHashV2.h>
42
+ #include <folly/lang/CString.h>
43
+ #include <folly/lang/Exception.h>
44
+ #include <folly/portability/Constexpr.h>
45
+
46
+ #include <algorithm>
47
+ #include <array>
48
+ #include <cassert>
49
+ #include <climits>
50
+ #include <cstddef>
51
+ #include <cstring>
52
+ #include <iosfwd>
53
+ #include <iterator>
54
+ #include <stdexcept>
55
+ #include <string>
56
+ #include <string_view>
57
+ #include <type_traits>
58
+
59
+ #if __has_include(<fmt/format.h>)
60
+ #include <fmt/format.h>
61
+ #endif
62
+
63
+ #include <folly/CpuId.h>
64
+ #include <folly/Likely.h>
65
+ #include <folly/Traits.h>
66
+ #include <folly/detail/RangeCommon.h>
67
+ #include <folly/detail/RangeSse42.h>
68
+
69
+ // Ignore shadowing warnings within this file, so includers can use -Wshadow.
70
+ FOLLY_PUSH_WARNING
71
+ FOLLY_GNU_DISABLE_WARNING("-Wshadow")
72
+
73
+ namespace folly {
74
+
75
+ /**
76
+ * Ubiquitous helper template for knowing what's a string.
77
+ */
78
+ template <class T>
79
+ struct IsSomeString : std::false_type {};
80
+
81
+ template <typename Alloc>
82
+ struct IsSomeString<std::basic_string<char, std::char_traits<char>, Alloc>>
83
+ : std::true_type {};
84
+
85
+ template <class Iter>
86
+ class Range;
87
+
88
+ /**
89
+ * Finds the first occurrence of needle in haystack. The algorithm is on
90
+ * average faster than O(haystack.size() * needle.size()) but not as fast
91
+ * as Boyer-Moore. On the upside, it does not do any upfront
92
+ * preprocessing and does not allocate memory.
93
+ */
94
+ template <
95
+ class Iter,
96
+ class Comp = std::equal_to<typename Range<Iter>::value_type>>
97
+ inline size_t qfind(
98
+ const Range<Iter>& haystack, const Range<Iter>& needle, Comp eq = Comp());
99
+
100
+ /**
101
+ * Finds the first occurrence of needle in haystack. The result is the
102
+ * offset reported to the beginning of haystack, or string::npos if
103
+ * needle wasn't found.
104
+ */
105
+ template <class Iter>
106
+ size_t qfind(
107
+ const Range<Iter>& haystack,
108
+ const typename Range<Iter>::value_type& needle);
109
+
110
+ /**
111
+ * Finds the last occurrence of needle in haystack. The result is the
112
+ * offset reported to the beginning of haystack, or string::npos if
113
+ * needle wasn't found.
114
+ */
115
+ template <class Iter>
116
+ size_t rfind(
117
+ const Range<Iter>& haystack,
118
+ const typename Range<Iter>::value_type& needle);
119
+
120
+ /**
121
+ * Finds the first occurrence of any element of needle in
122
+ * haystack. The algorithm is O(haystack.size() * needle.size()).
123
+ */
124
+ template <class Iter>
125
+ inline size_t qfind_first_of(
126
+ const Range<Iter>& haystack, const Range<Iter>& needle);
127
+
128
+ /**
129
+ * Small internal helper - returns the value just before an iterator.
130
+ */
131
+ namespace detail {
132
+
133
+ /*
134
+ * Use IsCharPointer<T>::type to enable const char* or char*.
135
+ * Use IsCharPointer<T>::const_type to enable only const char*.
136
+ */
137
+ template <class T>
138
+ struct IsCharPointer {};
139
+
140
+ template <>
141
+ struct IsCharPointer<char*> {
142
+ using type = int;
143
+ };
144
+
145
+ template <>
146
+ struct IsCharPointer<const char*> {
147
+ using const_type = int;
148
+ using type = int;
149
+ };
150
+
151
+ template <class T>
152
+ struct IsUnsignedCharPointer {};
153
+
154
+ template <>
155
+ struct IsUnsignedCharPointer<unsigned char*> {
156
+ using type = int;
157
+ };
158
+
159
+ template <>
160
+ struct IsUnsignedCharPointer<const unsigned char*> {
161
+ using const_type = int;
162
+ using type = int;
163
+ };
164
+
165
+ void range_is_char_type_f_(char const*);
166
+ void range_is_char_type_f_(wchar_t const*);
167
+ #if (defined(__cpp_char8_t) && __cpp_char8_t >= 201811L) || \
168
+ FOLLY_CPLUSPLUS >= 202002
169
+ void range_is_char_type_f_(char8_t const*);
170
+ #endif
171
+ void range_is_char_type_f_(char16_t const*);
172
+ void range_is_char_type_f_(char32_t const*);
173
+ template <typename Iter>
174
+ using range_is_char_type_d_ =
175
+ decltype(folly::detail::range_is_char_type_f_(FOLLY_DECLVAL(Iter)));
176
+ template <typename Iter>
177
+ constexpr bool range_is_char_type_v_ =
178
+ is_detected_v<range_is_char_type_d_, Iter>;
179
+
180
+ void range_is_byte_type_f_(unsigned char const*);
181
+ void range_is_byte_type_f_(signed char const*);
182
+ void range_is_byte_type_f_(std::byte const*);
183
+ template <typename Iter>
184
+ using range_is_byte_type_d_ =
185
+ decltype(folly::detail::range_is_byte_type_f_(FOLLY_DECLVAL(Iter)));
186
+ template <typename Iter>
187
+ constexpr bool range_is_byte_type_v_ =
188
+ is_detected_v<range_is_byte_type_d_, Iter>;
189
+
190
+ struct range_traits_char_ {
191
+ template <typename Value>
192
+ using apply = std::char_traits<Value>;
193
+ };
194
+ struct range_traits_byte_ {
195
+ template <typename Value>
196
+ struct apply {
197
+ FOLLY_ERASE static constexpr bool eq(Value a, Value b) { return a == b; }
198
+
199
+ FOLLY_ERASE static constexpr int compare(
200
+ Value const* a, Value const* b, std::size_t c) {
201
+ return !c ? 0 : std::memcmp(a, b, c);
202
+ }
203
+ };
204
+ };
205
+ struct range_traits_fbck_ {
206
+ template <typename Value>
207
+ struct apply {
208
+ FOLLY_ERASE static constexpr bool eq(Value a, Value b) { return a == b; }
209
+
210
+ FOLLY_ERASE static constexpr int compare(
211
+ Value const* a, Value const* b, std::size_t c) {
212
+ while (c--) {
213
+ auto&& ai = *a++;
214
+ auto&& bi = *b++;
215
+ if (ai < bi) {
216
+ return -1;
217
+ }
218
+ if (bi < ai) {
219
+ return +1;
220
+ }
221
+ }
222
+ return 0;
223
+ }
224
+ };
225
+ };
226
+
227
+ template <typename Iter>
228
+ using range_traits_c_ = conditional_t<
229
+ range_is_char_type_v_<Iter>,
230
+ range_traits_char_,
231
+ conditional_t< //
232
+ range_is_byte_type_v_<Iter>,
233
+ range_traits_byte_,
234
+ range_traits_fbck_>>;
235
+ template <typename Iter, typename Value>
236
+ using range_traits_t_ = typename range_traits_c_<Iter>::template apply<Value>;
237
+
238
+ } // namespace detail
239
+
240
+ template <class Iter>
241
+ class Range {
242
+ private:
243
+ using iter_traits = std::iterator_traits<Iter>;
244
+
245
+ template <typename Alloc>
246
+ using string = std::basic_string<char, std::char_traits<char>, Alloc>;
247
+
248
+ public:
249
+ using value_type = typename iter_traits::value_type;
250
+ using size_type = std::size_t;
251
+ using difference_type = typename iter_traits::difference_type;
252
+ using iterator = Iter;
253
+ using const_iterator = Iter;
254
+ using reference = typename iter_traits::reference;
255
+ using const_reference = conditional_t<
256
+ std::is_lvalue_reference_v<reference>,
257
+ std::add_lvalue_reference_t<
258
+ std::add_const_t<std::remove_reference_t<reference>>>,
259
+ conditional_t<
260
+ std::is_rvalue_reference_v<reference>,
261
+ std::add_rvalue_reference_t<
262
+ std::add_const_t<std::remove_reference_t<reference>>>,
263
+ reference>>;
264
+
265
+ /*
266
+ * For MutableStringPiece and MutableByteRange we define StringPiece
267
+ * and ByteRange as const_range_type (for everything else its just
268
+ * identity). We do that to enable operations such as find with
269
+ * args which are const.
270
+ */
271
+ using const_range_type = typename std::conditional<
272
+ std::is_same<Iter, char*>::value ||
273
+ std::is_same<Iter, unsigned char*>::value,
274
+ Range<const value_type*>,
275
+ Range<Iter>>::type;
276
+
277
+ using traits_type = detail::range_traits_t_<Iter, value_type>;
278
+
279
+ static const size_type npos;
280
+
281
+ /**
282
+ * Works for all iterator
283
+ *
284
+ *
285
+ * @methodset Range
286
+ */
287
+ constexpr Range() : b_(), e_() {}
288
+
289
+ constexpr Range(const Range&) = default;
290
+ constexpr Range(Range&&) = default;
291
+
292
+ public:
293
+ /**
294
+ * Works for all iterators
295
+ *
296
+ *
297
+ * @methodset Range
298
+ */
299
+ constexpr Range(Iter start, Iter end) : b_(start), e_(end) {}
300
+ /**
301
+ * Works only for random-access iterators
302
+ *
303
+ *
304
+ * @methodset Range
305
+ */
306
+ constexpr Range(Iter start, size_t size) : b_(start), e_(start + size) {}
307
+
308
+ /* implicit */ Range(std::nullptr_t) = delete;
309
+
310
+ constexpr /* implicit */ Range(Iter str)
311
+ : b_(str), e_(str + constexpr_strlen(str)) {
312
+ static_assert(
313
+ std::is_same<int, typename detail::IsCharPointer<Iter>::type>::value,
314
+ "This constructor is only available for character ranges");
315
+ }
316
+
317
+ template <
318
+ class Alloc,
319
+ class T = Iter,
320
+ typename detail::IsCharPointer<T>::const_type = 0>
321
+ /* implicit */ Range(const string<Alloc>& str)
322
+ : b_(str.data()), e_(b_ + str.size()) {}
323
+
324
+ template <
325
+ class Alloc,
326
+ class T = Iter,
327
+ typename detail::IsCharPointer<T>::const_type = 0>
328
+ Range(const string<Alloc>& str, typename string<Alloc>::size_type startFrom) {
329
+ if (FOLLY_UNLIKELY(startFrom > str.size())) {
330
+ throw_exception<std::out_of_range>("index out of range");
331
+ }
332
+ b_ = str.data() + startFrom;
333
+ e_ = str.data() + str.size();
334
+ }
335
+
336
+ template <
337
+ class Alloc,
338
+ class T = Iter,
339
+ typename detail::IsCharPointer<T>::const_type = 0>
340
+ Range(
341
+ const string<Alloc>& str,
342
+ typename string<Alloc>::size_type startFrom,
343
+ typename string<Alloc>::size_type size) {
344
+ if (FOLLY_UNLIKELY(startFrom > str.size())) {
345
+ throw_exception<std::out_of_range>("index out of range");
346
+ }
347
+ b_ = str.data() + startFrom;
348
+ if (str.size() - startFrom < size) {
349
+ e_ = str.data() + str.size();
350
+ } else {
351
+ e_ = b_ + size;
352
+ }
353
+ }
354
+
355
+ Range(const Range& other, size_type first, size_type length = npos)
356
+ : Range(other.subpiece(first, length)) {}
357
+
358
+ template <
359
+ class Container,
360
+ class = typename std::enable_if<
361
+ std::is_same<Iter, typename Container::const_pointer>::value>::type,
362
+ class = decltype(
363
+ Iter(std::declval<Container const&>().data()),
364
+ Iter(
365
+ std::declval<Container const&>().data() +
366
+ std::declval<Container const&>().size()))>
367
+ /* implicit */ constexpr Range(Container const& container)
368
+ : Range(container.data(), container.size()) {}
369
+
370
+ template <
371
+ class Container,
372
+ class = typename std::enable_if<
373
+ std::is_same<Iter, typename Container::const_pointer>::value>::type,
374
+ class = decltype(
375
+ Iter(std::declval<Container const&>().data()),
376
+ Iter(
377
+ std::declval<Container const&>().data() +
378
+ std::declval<Container const&>().size()))>
379
+ Range(Container const& container, typename Container::size_type startFrom) {
380
+ auto const cdata = container.data();
381
+ auto const csize = container.size();
382
+ if (FOLLY_UNLIKELY(startFrom > csize)) {
383
+ throw_exception<std::out_of_range>("index out of range");
384
+ }
385
+ b_ = cdata + startFrom;
386
+ e_ = cdata + csize;
387
+ }
388
+
389
+ template <
390
+ class Container,
391
+ class = typename std::enable_if<
392
+ std::is_same<Iter, typename Container::const_pointer>::value>::type,
393
+ class = decltype(
394
+ Iter(std::declval<Container const&>().data()),
395
+ Iter(
396
+ std::declval<Container const&>().data() +
397
+ std::declval<Container const&>().size()))>
398
+ Range(
399
+ Container const& container,
400
+ typename Container::size_type startFrom,
401
+ typename Container::size_type size) {
402
+ auto const cdata = container.data();
403
+ auto const csize = container.size();
404
+ if (FOLLY_UNLIKELY(startFrom > csize)) {
405
+ throw_exception<std::out_of_range>("index out of range");
406
+ }
407
+ b_ = cdata + startFrom;
408
+ if (csize - startFrom < size) {
409
+ e_ = cdata + csize;
410
+ } else {
411
+ e_ = b_ + size;
412
+ }
413
+ }
414
+
415
+ /**
416
+ * @brief Allow explicit construction of ByteRange from std::string_view or
417
+ * std::string.
418
+
419
+ * Given that we allow implicit construction of ByteRange from
420
+ * StringPiece, it makes sense to allow this explicit construction, and avoids
421
+ * callers having to say ByteRange{StringPiece{str}} when they want a
422
+ * ByteRange pointing to data in a std::string.
423
+ *
424
+ *
425
+ * @methodset Range
426
+ */
427
+ template <
428
+ class Container,
429
+ class T = Iter,
430
+ typename detail::IsUnsignedCharPointer<T>::const_type = 0,
431
+ class = typename std::enable_if<
432
+ std::is_same<typename Container::const_pointer, const char*>::value
433
+ >::type,
434
+ class = decltype(
435
+ Iter(std::declval<Container const&>().data()),
436
+ Iter(
437
+ std::declval<Container const&>().data() +
438
+ std::declval<Container const&>().size()))>
439
+ explicit Range(const Container& str)
440
+ : b_(reinterpret_cast<Iter>(str.data())), e_(b_ + str.size()) {}
441
+ /**
442
+ * @brief Allow implicit conversion from Range<const char*> (aka StringPiece)
443
+ to
444
+ * Range<const unsigned char*> (aka ByteRange).
445
+
446
+ * Give both are frequently
447
+ * used to represent ranges of bytes. Allow explicit conversion in the other
448
+ * direction.
449
+ *
450
+ * @methodset Range
451
+ */
452
+ template <
453
+ class OtherIter,
454
+ typename std::enable_if<
455
+ (std::is_same<Iter, const unsigned char*>::value &&
456
+ (std::is_same<OtherIter, const char*>::value ||
457
+ std::is_same<OtherIter, char*>::value)),
458
+ int>::type = 0>
459
+ /* implicit */ Range(const Range<OtherIter>& other)
460
+ : b_(reinterpret_cast<const unsigned char*>(other.begin())),
461
+ e_(reinterpret_cast<const unsigned char*>(other.end())) {}
462
+
463
+ template <
464
+ class OtherIter,
465
+ typename std::enable_if<
466
+ (std::is_same<Iter, unsigned char*>::value &&
467
+ std::is_same<OtherIter, char*>::value),
468
+ int>::type = 0>
469
+ /* implicit */ Range(const Range<OtherIter>& other)
470
+ : b_(reinterpret_cast<unsigned char*>(other.begin())),
471
+ e_(reinterpret_cast<unsigned char*>(other.end())) {}
472
+
473
+ template <
474
+ class OtherIter,
475
+ typename std::enable_if<
476
+ (std::is_same<Iter, const char*>::value &&
477
+ (std::is_same<OtherIter, const unsigned char*>::value ||
478
+ std::is_same<OtherIter, unsigned char*>::value)),
479
+ int>::type = 0>
480
+ explicit Range(const Range<OtherIter>& other)
481
+ : b_(reinterpret_cast<const char*>(other.begin())),
482
+ e_(reinterpret_cast<const char*>(other.end())) {}
483
+
484
+ template <
485
+ class OtherIter,
486
+ typename std::enable_if<
487
+ (std::is_same<Iter, char*>::value &&
488
+ std::is_same<OtherIter, unsigned char*>::value),
489
+ int>::type = 0>
490
+ explicit Range(const Range<OtherIter>& other)
491
+ : b_(reinterpret_cast<char*>(other.begin())),
492
+ e_(reinterpret_cast<char*>(other.end())) {}
493
+
494
+ /**
495
+ * Allow implicit conversion from Range<From> to Range<To> if From is
496
+ * implicitly convertible to To.
497
+ *
498
+ * @methodset Range
499
+ */
500
+ template <
501
+ class OtherIter,
502
+ typename std::enable_if<
503
+ (!std::is_same<Iter, OtherIter>::value &&
504
+ std::is_convertible<OtherIter, Iter>::value),
505
+ int>::type = 0>
506
+ constexpr /* implicit */ Range(const Range<OtherIter>& other)
507
+ : b_(other.begin()), e_(other.end()) {}
508
+ /**
509
+ * Allow explicit conversion from Range<From> to Range<To> if From is
510
+ * explicitly convertible to To.
511
+ *
512
+ * @methodset Range
513
+ */
514
+ template <
515
+ class OtherIter,
516
+ typename std::enable_if<
517
+ (!std::is_same<Iter, OtherIter>::value &&
518
+ !std::is_convertible<OtherIter, Iter>::value &&
519
+ std::is_constructible<Iter, const OtherIter&>::value),
520
+ int>::type = 0>
521
+ constexpr explicit Range(const Range<OtherIter>& other)
522
+ : b_(other.begin()), e_(other.end()) {}
523
+
524
+ /**
525
+ * Allow explicit construction of Range() from a std::array of a
526
+ * convertible type.
527
+ *
528
+ * For instance, this allows constructing StringPiece from a
529
+ * std::array<char, N> or a std::array<const char, N>
530
+ *
531
+ * @methodset Range
532
+ */
533
+ template <
534
+ class T,
535
+ size_t N,
536
+ typename = typename std::enable_if<
537
+ std::is_convertible<const T*, Iter>::value>::type>
538
+ constexpr explicit Range(const std::array<T, N>& array)
539
+ : b_{array.empty() ? nullptr : &array.at(0)},
540
+ e_{array.empty() ? nullptr : &array.at(0) + N} {}
541
+ template <
542
+ class T,
543
+ size_t N,
544
+ typename =
545
+ typename std::enable_if<std::is_convertible<T*, Iter>::value>::type>
546
+ constexpr explicit Range(std::array<T, N>& array)
547
+ : b_{array.empty() ? nullptr : &array.at(0)},
548
+ e_{array.empty() ? nullptr : &array.at(0) + N} {}
549
+
550
+ Range& operator=(const Range& rhs) & = default;
551
+ Range& operator=(Range&& rhs) & = default;
552
+
553
+ template <
554
+ class Alloc,
555
+ class T = Iter,
556
+ typename detail::IsCharPointer<T>::const_type = 0>
557
+ Range& operator=(string<Alloc>&& rhs) = delete;
558
+
559
+ /**
560
+ * Clear start and end iterators
561
+ */
562
+ void clear() {
563
+ b_ = Iter();
564
+ e_ = Iter();
565
+ }
566
+
567
+ /**
568
+ * Assign start and end iterators
569
+ */
570
+ void assign(Iter start, Iter end) {
571
+ b_ = start;
572
+ e_ = end;
573
+ }
574
+
575
+ /**
576
+ * Reset start and end interator based on size
577
+ */
578
+ void reset(Iter start, size_type size) {
579
+ b_ = start;
580
+ e_ = start + size;
581
+ }
582
+
583
+ // Works only for Range<const char*>
584
+ template <typename Alloc>
585
+ void reset(const string<Alloc>& str) {
586
+ reset(str.data(), str.size());
587
+ }
588
+
589
+ constexpr size_type size() const {
590
+ assert(b_ <= e_);
591
+ return size_type(e_ - b_);
592
+ }
593
+ constexpr size_type walk_size() const {
594
+ return size_type(std::distance(b_, e_));
595
+ }
596
+ constexpr bool empty() const { return b_ == e_; }
597
+ constexpr Iter data() const { return b_; }
598
+ constexpr Iter start() const { return b_; }
599
+ constexpr Iter begin() const { return b_; }
600
+ constexpr Iter end() const { return e_; }
601
+ constexpr Iter cbegin() const { return b_; }
602
+ constexpr Iter cend() const { return e_; }
603
+ reference front() {
604
+ assert(b_ < e_);
605
+ return *b_;
606
+ }
607
+ reference back() {
608
+ assert(b_ < e_);
609
+ return *std::prev(e_);
610
+ }
611
+ const_reference front() const {
612
+ assert(b_ < e_);
613
+ return *b_;
614
+ }
615
+ const_reference back() const {
616
+ assert(b_ < e_);
617
+ return *std::prev(e_);
618
+ }
619
+
620
+ private:
621
+ // It would be nice to be able to implicit convert to any target type
622
+ // T for which either an (Iter, Iter) or (Iter, size_type) noexcept
623
+ // constructor was available, and explicitly convert to any target
624
+ // type for which those signatures were available but not noexcept.
625
+ // The problem is that this creates ambiguity when there is also a
626
+ // T constructor that takes a type U that is implicitly convertible
627
+ // from Range.
628
+ //
629
+ // To avoid ambiguity, we need to avoid having explicit operator T
630
+ // and implicit operator U coexist when T is constructible from U.
631
+ // U cannot be deduced when searching for operator T (and C++ won't
632
+ // perform an existential search for it), so we must limit the implicit
633
+ // target types to a finite set that we can enumerate.
634
+ //
635
+ // At the moment the set of implicit target types consists of just
636
+ // std::string_view (when it is available).
637
+ struct NotStringView {};
638
+ template <typename ValueType>
639
+ struct StringViewType //
640
+ : std::conditional<
641
+ detail::range_is_char_type_v_<Iter>,
642
+ std::basic_string_view<ValueType>,
643
+ NotStringView> {};
644
+
645
+ template <typename Target>
646
+ struct IsConstructibleViaStringView
647
+ : Conjunction<
648
+ std::is_constructible<
649
+ _t<StringViewType<value_type>>,
650
+ Iter const&,
651
+ size_type>,
652
+ std::is_constructible<Target, _t<StringViewType<value_type>>>> {};
653
+
654
+ public:
655
+ /// explicit operator conversion to any compatible type
656
+ ///
657
+ /// A compatible type is one which is constructible with an iterator and a
658
+ /// size (preferred), or a pair of iterators (fallback), passed by const-ref.
659
+ ///
660
+ /// Participates in overload resolution precisely when the target type is
661
+ /// compatible. This allows std::is_constructible compile-time checks to work.
662
+ template <
663
+ typename Tgt,
664
+ std::enable_if_t<
665
+ std::is_constructible<Tgt, Iter const&, size_type>::value &&
666
+ !IsConstructibleViaStringView<Tgt>::value,
667
+ int> = 0>
668
+ constexpr explicit operator Tgt() const noexcept(
669
+ std::is_nothrow_constructible<Tgt, Iter const&, size_type>::value) {
670
+ return Tgt(b_, walk_size());
671
+ }
672
+ template <
673
+ typename Tgt,
674
+ std::enable_if_t<
675
+ !std::is_constructible<Tgt, Iter const&, size_type>::value &&
676
+ std::is_constructible<Tgt, Iter const&, Iter const&>::value &&
677
+ !IsConstructibleViaStringView<Tgt>::value,
678
+ int> = 0>
679
+ constexpr explicit operator Tgt() const noexcept(
680
+ std::is_nothrow_constructible<Tgt, Iter const&, Iter const&>::value) {
681
+ return Tgt(b_, e_);
682
+ }
683
+
684
+ /// implicit operator conversion to std::string_view
685
+ template <
686
+ typename Tgt,
687
+ typename ValueType = value_type,
688
+ std::enable_if_t<
689
+ StrictConjunction<
690
+ std::is_same<Tgt, _t<StringViewType<ValueType>>>,
691
+ std::is_constructible<
692
+ _t<StringViewType<ValueType>>,
693
+ Iter const&,
694
+ size_type>>::value,
695
+ int> = 0>
696
+ constexpr operator Tgt() const noexcept(
697
+ std::is_nothrow_constructible<Tgt, Iter const&, size_type>::value) {
698
+ return Tgt(b_, walk_size());
699
+ }
700
+
701
+ /// explicit non-operator conversion to any compatible type
702
+ ///
703
+ /// A compatible type is one which is constructible with an iterator and a
704
+ /// size (preferred), or a pair of iterators (fallback), passed by const-ref.
705
+ ///
706
+ /// Participates in overload resolution precisely when the target type is
707
+ /// compatible. This allows is_invocable compile-time checks to work.
708
+ ///
709
+ /// Provided in addition to the explicit operator conversion to permit passing
710
+ /// additional arguments to the target type constructor. A canonical example
711
+ /// of an additional argument might be an allocator, where the target type is
712
+ /// some specialization of std::vector or std::basic_string in a context which
713
+ /// requires a non-default-constructed allocator.
714
+ template <typename Tgt, typename... Args>
715
+ constexpr std::enable_if_t<
716
+ std::is_constructible<Tgt, Iter const&, size_type>::value,
717
+ Tgt>
718
+ to(Args&&... args) const noexcept(
719
+ std::is_nothrow_constructible<Tgt, Iter const&, size_type, Args&&...>::
720
+ value) {
721
+ return Tgt(b_, walk_size(), static_cast<Args&&>(args)...);
722
+ }
723
+ template <typename Tgt, typename... Args>
724
+ constexpr std::enable_if_t<
725
+ !std::is_constructible<Tgt, Iter const&, size_type>::value &&
726
+ std::is_constructible<Tgt, Iter const&, Iter const&>::value,
727
+ Tgt>
728
+ to(Args&&... args) const noexcept(
729
+ std::is_nothrow_constructible<Tgt, Iter const&, Iter const&, Args&&...>::
730
+ value) {
731
+ return Tgt(b_, e_, static_cast<Args&&>(args)...);
732
+ }
733
+
734
+ // Works only for Range<const char*> and Range<char*>
735
+ std::string str() const { return to<std::string>(); }
736
+ std::string toString() const { return to<std::string>(); }
737
+
738
+ const_range_type castToConst() const { return const_range_type(*this); }
739
+
740
+ int compare(const const_range_type& o) const {
741
+ const size_type tsize = this->size();
742
+ const size_type osize = o.size();
743
+ const size_type msize = std::min(tsize, osize);
744
+ int r = traits_type::compare(data(), o.data(), msize);
745
+ if (r == 0 && tsize != osize) {
746
+ // We check the signed bit of the subtraction and bit shift it
747
+ // to produce either 0 or 2. The subtraction yields the
748
+ // comparison values of either -1 or 1.
749
+ r = (static_cast<int>((osize - tsize) >> (CHAR_BIT * sizeof(size_t) - 1))
750
+ << 1) -
751
+ 1;
752
+ }
753
+ return r;
754
+ }
755
+
756
+ reference operator[](size_t i) {
757
+ assert(i < size());
758
+ return b_[i];
759
+ }
760
+
761
+ const_reference operator[](size_t i) const {
762
+ assert(i < size());
763
+ return b_[i];
764
+ }
765
+
766
+ reference at(size_t i) {
767
+ if (i >= size()) {
768
+ throw_exception<std::out_of_range>("index out of range");
769
+ }
770
+ return b_[i];
771
+ }
772
+
773
+ const_reference at(size_t i) const {
774
+ if (i >= size()) {
775
+ throw_exception<std::out_of_range>("index out of range");
776
+ }
777
+ return b_[i];
778
+ }
779
+
780
+ // Do NOT use this function, which was left behind for backwards
781
+ // compatibility. Use SpookyHashV2 instead -- it is faster, and produces
782
+ // a 64-bit hash, which means dramatically fewer collisions in large maps.
783
+ // (The above advice does not apply if you are targeting a 32-bit system.)
784
+ //
785
+ // Works only for Range<const char*> and Range<char*>
786
+ //
787
+ //
788
+ // ** WANT TO GET RID OF THIS LINT? **
789
+ //
790
+ // A) Use a better hash function (*cough*folly::Hash*cough*), but
791
+ // only if you don't serialize data in a format that depends on
792
+ // this formula (ie the writer and reader assume this exact hash
793
+ // function is used).
794
+ //
795
+ // B) If you have to use this exact function then make your own hasher
796
+ // object and copy the body over (see thrift example: D3972362).
797
+ // https://github.com/facebook/fbthrift/commit/f8ed502e24ab4a32a9d5f266580
798
+ [[deprecated(
799
+ "Replace with folly::Hash if the hash is not serialized")]] uint32_t
800
+ hash() const {
801
+ // Taken from fbi/nstring.h:
802
+ // Quick and dirty bernstein hash...fine for short ascii strings
803
+ uint32_t hash = 5381;
804
+ for (size_t ix = 0; ix < size(); ix++) {
805
+ hash = ((hash << 5) + hash) + b_[ix];
806
+ }
807
+ return hash;
808
+ }
809
+
810
+ void advance(size_type n) {
811
+ if (FOLLY_UNLIKELY(n > size())) {
812
+ throw_exception<std::out_of_range>("index out of range");
813
+ }
814
+ b_ += n;
815
+ }
816
+
817
+ void subtract(size_type n) {
818
+ if (FOLLY_UNLIKELY(n > size())) {
819
+ throw_exception<std::out_of_range>("index out of range");
820
+ }
821
+ e_ -= n;
822
+ }
823
+
824
+ // Returns a window into the current range, starting at first, and spans
825
+ // length characters (or until the end of the current range, whichever comes
826
+ // first). Throws if first is past the end of the current range.
827
+ Range subpiece(size_type first, size_type length = npos) const {
828
+ if (FOLLY_UNLIKELY(first > size())) {
829
+ throw_exception<std::out_of_range>("index out of range");
830
+ }
831
+
832
+ return Range(b_ + first, std::min(length, size() - first));
833
+ }
834
+
835
+ template <
836
+ typename...,
837
+ typename T = Iter,
838
+ std::enable_if_t<detail::range_is_char_type_v_<T>, int> = 0>
839
+ Range substr(size_type first, size_type length = npos) const {
840
+ return subpiece(first, length);
841
+ }
842
+
843
+ // unchecked versions
844
+ void uncheckedAdvance(size_type n) {
845
+ assert(n <= size());
846
+ b_ += n;
847
+ }
848
+
849
+ void uncheckedSubtract(size_type n) {
850
+ assert(n <= size());
851
+ e_ -= n;
852
+ }
853
+
854
+ Range uncheckedSubpiece(size_type first, size_type length = npos) const {
855
+ assert(first <= size());
856
+ return Range(b_ + first, std::min(length, size() - first));
857
+ }
858
+
859
+ void pop_front() {
860
+ assert(b_ < e_);
861
+ ++b_;
862
+ }
863
+
864
+ void pop_back() {
865
+ assert(b_ < e_);
866
+ --e_;
867
+ }
868
+
869
+ // string work-alike functions
870
+ size_type find(const_range_type str) const {
871
+ return qfind(castToConst(), str);
872
+ }
873
+
874
+ size_type find(const_range_type str, size_t pos) const {
875
+ if (pos > size()) {
876
+ return std::string::npos;
877
+ }
878
+ size_t ret = qfind(castToConst().subpiece(pos), str);
879
+ return ret == npos ? ret : ret + pos;
880
+ }
881
+
882
+ size_type find(Iter s, size_t pos, size_t n) const {
883
+ if (pos > size()) {
884
+ return std::string::npos;
885
+ }
886
+ auto forFinding = castToConst();
887
+ size_t ret = qfind(
888
+ pos ? forFinding.subpiece(pos) : forFinding, const_range_type(s, n));
889
+ return ret == npos ? ret : ret + pos;
890
+ }
891
+
892
+ // Works only for Range<(const) (unsigned) char*> which have Range(Iter) ctor
893
+ size_type find(const Iter s) const {
894
+ return qfind(castToConst(), const_range_type(s));
895
+ }
896
+
897
+ // Works only for Range<(const) (unsigned) char*> which have Range(Iter) ctor
898
+ size_type find(const Iter s, size_t pos) const {
899
+ if (pos > size()) {
900
+ return std::string::npos;
901
+ }
902
+ size_type ret = qfind(castToConst().subpiece(pos), const_range_type(s));
903
+ return ret == npos ? ret : ret + pos;
904
+ }
905
+
906
+ size_type find(const value_type& c) const { return qfind(castToConst(), c); }
907
+
908
+ size_type rfind(const value_type& c) const {
909
+ return folly::rfind(castToConst(), c);
910
+ }
911
+
912
+ size_type find(const value_type& c, size_t pos) const {
913
+ if (pos > size()) {
914
+ return std::string::npos;
915
+ }
916
+ size_type ret = qfind(castToConst().subpiece(pos), c);
917
+ return ret == npos ? ret : ret + pos;
918
+ }
919
+
920
+ size_type find_first_of(const_range_type needles) const {
921
+ return qfind_first_of(castToConst(), needles);
922
+ }
923
+
924
+ size_type find_first_of(const_range_type needles, size_t pos) const {
925
+ if (pos > size()) {
926
+ return std::string::npos;
927
+ }
928
+ size_type ret = qfind_first_of(castToConst().subpiece(pos), needles);
929
+ return ret == npos ? ret : ret + pos;
930
+ }
931
+
932
+ // Works only for Range<(const) (unsigned) char*> which have Range(Iter) ctor
933
+ size_type find_first_of(Iter needles) const {
934
+ return find_first_of(const_range_type(needles));
935
+ }
936
+
937
+ // Works only for Range<(const) (unsigned) char*> which have Range(Iter) ctor
938
+ size_type find_first_of(Iter needles, size_t pos) const {
939
+ return find_first_of(const_range_type(needles), pos);
940
+ }
941
+
942
+ size_type find_first_of(Iter needles, size_t pos, size_t n) const {
943
+ return find_first_of(const_range_type(needles, n), pos);
944
+ }
945
+
946
+ size_type find_first_of(const value_type& c) const { return find(c); }
947
+
948
+ size_type find_first_of(const value_type& c, size_t pos) const {
949
+ return find(c, pos);
950
+ }
951
+
952
+ /**
953
+ * Determine whether the range contains the given subrange or item.
954
+ *
955
+ * Note: Call find() directly if the index is needed.
956
+ */
957
+ bool contains(const const_range_type& other) const {
958
+ return find(other) != std::string::npos;
959
+ }
960
+
961
+ bool contains(const value_type& other) const {
962
+ return find(other) != std::string::npos;
963
+ }
964
+
965
+ void swap(Range& rhs) {
966
+ std::swap(b_, rhs.b_);
967
+ std::swap(e_, rhs.e_);
968
+ }
969
+
970
+ /**
971
+ * Does this Range start with another range?
972
+ */
973
+ bool startsWith(const const_range_type& other) const {
974
+ return size() >= other.size() &&
975
+ castToConst().subpiece(0, other.size()) == other;
976
+ }
977
+ bool startsWith(const value_type& c) const {
978
+ return !empty() && front() == c;
979
+ }
980
+
981
+ template <class Comp>
982
+ bool startsWith(const const_range_type& other, Comp&& eq) const {
983
+ if (size() < other.size()) {
984
+ return false;
985
+ }
986
+ auto const trunc = subpiece(0, other.size());
987
+ return std::equal(
988
+ trunc.begin(), trunc.end(), other.begin(), std::forward<Comp>(eq));
989
+ }
990
+
991
+ bool starts_with(const_range_type other) const noexcept {
992
+ return startsWith(other);
993
+ }
994
+ bool starts_with(const value_type& c) const noexcept { return startsWith(c); }
995
+ template <
996
+ typename...,
997
+ typename T = Iter,
998
+ std::enable_if_t<detail::range_is_char_type_v_<T>, int> = 0>
999
+ bool starts_with(const value_type* other) const {
1000
+ return startsWith(other);
1001
+ }
1002
+
1003
+ /**
1004
+ * Does this Range end with another range?
1005
+ */
1006
+ bool endsWith(const const_range_type& other) const {
1007
+ return size() >= other.size() &&
1008
+ castToConst().subpiece(size() - other.size()) == other;
1009
+ }
1010
+ bool endsWith(const value_type& c) const { return !empty() && back() == c; }
1011
+
1012
+ template <class Comp>
1013
+ bool endsWith(const const_range_type& other, Comp&& eq) const {
1014
+ if (size() < other.size()) {
1015
+ return false;
1016
+ }
1017
+ auto const trunc = subpiece(size() - other.size());
1018
+ return std::equal(
1019
+ trunc.begin(), trunc.end(), other.begin(), std::forward<Comp>(eq));
1020
+ }
1021
+
1022
+ template <class Comp>
1023
+ bool equals(const const_range_type& other, Comp&& eq) const {
1024
+ return size() == other.size() &&
1025
+ std::equal(begin(), end(), other.begin(), std::forward<Comp>(eq));
1026
+ }
1027
+
1028
+ bool ends_with(const_range_type other) const noexcept {
1029
+ return endsWith(other);
1030
+ }
1031
+ bool ends_with(const value_type& c) const noexcept { return endsWith(c); }
1032
+ template <
1033
+ typename...,
1034
+ typename T = Iter,
1035
+ std::enable_if_t<detail::range_is_char_type_v_<T>, int> = 0>
1036
+ bool ends_with(const value_type* other) const {
1037
+ return endsWith(other);
1038
+ }
1039
+
1040
+ /**
1041
+ * Remove the items in [b, e), as long as this subrange is at the beginning
1042
+ * or end of the Range.
1043
+ *
1044
+ * Required for boost::algorithm::trim()
1045
+ */
1046
+ void erase(Iter b, Iter e) {
1047
+ if (b == b_) {
1048
+ b_ = e;
1049
+ } else if (e == e_) {
1050
+ e_ = b;
1051
+ } else {
1052
+ throw_exception<std::out_of_range>("index out of range");
1053
+ }
1054
+ }
1055
+
1056
+ /**
1057
+ * Remove the given prefix and return true if the range starts with the given
1058
+ * prefix; return false otherwise.
1059
+ */
1060
+ bool removePrefix(const const_range_type& prefix) {
1061
+ return startsWith(prefix) && (b_ += prefix.size(), true);
1062
+ }
1063
+ bool removePrefix(const value_type& prefix) {
1064
+ return startsWith(prefix) && (++b_, true);
1065
+ }
1066
+
1067
+ /**
1068
+ * Remove the given suffix and return true if the range ends with the given
1069
+ * suffix; return false otherwise.
1070
+ */
1071
+ bool removeSuffix(const const_range_type& suffix) {
1072
+ return endsWith(suffix) && (e_ -= suffix.size(), true);
1073
+ }
1074
+ bool removeSuffix(const value_type& suffix) {
1075
+ return endsWith(suffix) && (--e_, true);
1076
+ }
1077
+
1078
+ /**
1079
+ * Replaces the content of the range, starting at position 'pos', with
1080
+ * contents of 'replacement'. Entire 'replacement' must fit into the
1081
+ * range. Returns false if 'replacements' does not fit. Example use:
1082
+ *
1083
+ * char in[] = "buffer";
1084
+ * auto msp = MutableStringPiece(input);
1085
+ * EXPECT_TRUE(msp.replaceAt(2, "tt"));
1086
+ * EXPECT_EQ(msp, "butter");
1087
+ *
1088
+ * // not enough space
1089
+ * EXPECT_FALSE(msp.replace(msp.size() - 1, "rr"));
1090
+ * EXPECT_EQ(msp, "butter"); // unchanged
1091
+ */
1092
+ bool replaceAt(size_t pos, const_range_type replacement) {
1093
+ if (size() < pos + replacement.size()) {
1094
+ return false;
1095
+ }
1096
+
1097
+ std::copy(replacement.begin(), replacement.end(), begin() + pos);
1098
+
1099
+ return true;
1100
+ }
1101
+
1102
+ /**
1103
+ * Replaces all occurrences of 'source' with 'dest'. Returns number
1104
+ * of replacements made. Source and dest have to have the same
1105
+ * length. Throws if the lengths are different. If 'source' is a
1106
+ * pattern that is overlapping with itself, we perform sequential
1107
+ * replacement: "aaaaaaa".replaceAll("aa", "ba") --> "bababaa"
1108
+ *
1109
+ * Example use:
1110
+ *
1111
+ * char in[] = "buffer";
1112
+ * auto msp = MutableStringPiece(input);
1113
+ * EXPECT_EQ(msp.replaceAll("ff","tt"), 1);
1114
+ * EXPECT_EQ(msp, "butter");
1115
+ */
1116
+ size_t replaceAll(const_range_type source, const_range_type dest) {
1117
+ if (source.size() != dest.size()) {
1118
+ throw_exception<std::invalid_argument>(
1119
+ "replacement must have the same size as source");
1120
+ }
1121
+
1122
+ if (dest.empty()) {
1123
+ return 0;
1124
+ }
1125
+
1126
+ size_t pos = 0;
1127
+ size_t num_replaced = 0;
1128
+ size_type found = std::string::npos;
1129
+ while ((found = find(source, pos)) != std::string::npos) {
1130
+ replaceAt(found, dest);
1131
+ pos += source.size();
1132
+ ++num_replaced;
1133
+ }
1134
+
1135
+ return num_replaced;
1136
+ }
1137
+
1138
+ /**
1139
+ * Splits this `Range` `[b, e)` in the position `i` dictated by the next
1140
+ * occurrence of `delimiter`.
1141
+ *
1142
+ * Returns a new `Range` `[b, i)` and adjusts this range to start right after
1143
+ * the delimiter's position. This range will be empty if the delimiter is not
1144
+ * found. If called on an empty `Range`, both this and the returned `Range`
1145
+ * will be empty.
1146
+ *
1147
+ * Example:
1148
+ *
1149
+ * folly::StringPiece s("sample string for split_next");
1150
+ * auto p = s.split_step(' ');
1151
+ *
1152
+ * // prints "string for split_next"
1153
+ * cout << s << endl;
1154
+ *
1155
+ * // prints "sample"
1156
+ * cout << p << endl;
1157
+ *
1158
+ * Example 2:
1159
+ *
1160
+ * void tokenize(StringPiece s, char delimiter) {
1161
+ * while (!s.empty()) {
1162
+ * cout << s.split_step(delimiter);
1163
+ * }
1164
+ * }
1165
+ *
1166
+ */
1167
+ Range split_step(const value_type& delimiter) {
1168
+ auto i = find(delimiter);
1169
+ Range result(b_, i == std::string::npos ? size() : i);
1170
+
1171
+ b_ = result.end() == e_ ? e_ : std::next(result.end());
1172
+
1173
+ return result;
1174
+ }
1175
+
1176
+ Range split_step(Range delimiter) {
1177
+ auto i = find(delimiter);
1178
+ Range result(b_, i == std::string::npos ? size() : i);
1179
+
1180
+ b_ = result.end() == e_
1181
+ ? e_
1182
+ : std::next(result.end(), difference_type(delimiter.size()));
1183
+
1184
+ return result;
1185
+ }
1186
+
1187
+ /**
1188
+ * Convenience method that calls `split_step()` and passes the result to a
1189
+ * functor, returning whatever the functor does. Any additional arguments
1190
+ * `args` passed to this function are perfectly forwarded to the functor.
1191
+ *
1192
+ * Say you have a functor with this signature:
1193
+ *
1194
+ * Foo fn(Range r) { }
1195
+ *
1196
+ * `split_step()`'s return type will be `Foo`. It works just like:
1197
+ *
1198
+ * auto result = fn(myRange.split_step(' '));
1199
+ *
1200
+ * A functor returning `void` is also supported.
1201
+ *
1202
+ * Example:
1203
+ *
1204
+ * void do_some_parsing(folly::StringPiece s) {
1205
+ * auto version = s.split_step(' ', [&](folly::StringPiece x) {
1206
+ * if (x.empty()) {
1207
+ * throw std::invalid_argument("empty string");
1208
+ * }
1209
+ * return std::strtoull(x.begin(), x.end(), 16);
1210
+ * });
1211
+ *
1212
+ * // ...
1213
+ * }
1214
+ *
1215
+ * struct Foo {
1216
+ * void parse(folly::StringPiece s) {
1217
+ * s.split_step(' ', parse_field, bar, 10);
1218
+ * s.split_step('\t', parse_field, baz, 20);
1219
+ *
1220
+ * auto const kludge = [](folly::StringPiece x, int &out, int def) {
1221
+ * if (x == "null") {
1222
+ * out = 0;
1223
+ * } else {
1224
+ * parse_field(x, out, def);
1225
+ * }
1226
+ * };
1227
+ *
1228
+ * s.split_step('\t', kludge, gaz);
1229
+ * s.split_step(' ', kludge, foo);
1230
+ * }
1231
+ *
1232
+ * private:
1233
+ * int bar;
1234
+ * int baz;
1235
+ * int gaz;
1236
+ * int foo;
1237
+ *
1238
+ * static parse_field(folly::StringPiece s, int &out, int def) {
1239
+ * try {
1240
+ * out = folly::to<int>(s);
1241
+ * } catch (std::exception const &) {
1242
+ * value = def;
1243
+ * }
1244
+ * }
1245
+ * };
1246
+ *
1247
+ */
1248
+ template <typename TProcess, typename... Args>
1249
+ auto split_step(
1250
+ const value_type& delimiter, TProcess&& process, Args&&... args)
1251
+ -> decltype(process(std::declval<Range>(), std::forward<Args>(args)...)) {
1252
+ return process(split_step(delimiter), std::forward<Args>(args)...);
1253
+ }
1254
+
1255
+ template <typename TProcess, typename... Args>
1256
+ auto split_step(Range delimiter, TProcess&& process, Args&&... args)
1257
+ -> decltype(process(std::declval<Range>(), std::forward<Args>(args)...)) {
1258
+ return process(split_step(delimiter), std::forward<Args>(args)...);
1259
+ }
1260
+
1261
+ private:
1262
+ Iter b_;
1263
+ Iter e_;
1264
+ };
1265
+
1266
+ template <class Iter>
1267
+ const typename Range<Iter>::size_type Range<Iter>::npos = std::string::npos;
1268
+
1269
+ template <class Iter>
1270
+ void swap(Range<Iter>& lhs, Range<Iter>& rhs) {
1271
+ lhs.swap(rhs);
1272
+ }
1273
+
1274
+ /**
1275
+ * Create a range from two iterators, with type deduction.
1276
+ */
1277
+ template <class Iter>
1278
+ constexpr Range<Iter> range(Iter first, Iter last) {
1279
+ return Range<Iter>(first, last);
1280
+ }
1281
+
1282
+ /*
1283
+ * Creates a range to reference the contents of a contiguous-storage container.
1284
+ */
1285
+ // Use pointers for types with '.data()' member
1286
+ template <class Collection>
1287
+ constexpr auto range(Collection& v) -> Range<decltype(v.data())> {
1288
+ return Range<decltype(v.data())>(v.data(), v.data() + v.size());
1289
+ }
1290
+ template <class Collection>
1291
+ constexpr auto range(Collection const& v) -> Range<decltype(v.data())> {
1292
+ return Range<decltype(v.data())>(v.data(), v.data() + v.size());
1293
+ }
1294
+ template <class Collection>
1295
+ constexpr auto crange(Collection const& v) -> Range<decltype(v.data())> {
1296
+ return Range<decltype(v.data())>(v.data(), v.data() + v.size());
1297
+ }
1298
+
1299
+ template <class T, size_t n>
1300
+ constexpr Range<T*> range(T (&array)[n]) {
1301
+ return Range<T*>(array, array + n);
1302
+ }
1303
+ template <class T, size_t n>
1304
+ constexpr Range<T const*> range(T const (&array)[n]) {
1305
+ return Range<T const*>(array, array + n);
1306
+ }
1307
+ template <class T, size_t n>
1308
+ constexpr Range<T const*> crange(T const (&array)[n]) {
1309
+ return Range<T const*>(array, array + n);
1310
+ }
1311
+
1312
+ template <class T, size_t n>
1313
+ constexpr Range<T*> range(std::array<T, n>& array) {
1314
+ return Range<T*>{array};
1315
+ }
1316
+ template <class T, size_t n>
1317
+ constexpr Range<T const*> range(std::array<T, n> const& array) {
1318
+ return Range<T const*>{array};
1319
+ }
1320
+ template <class T, size_t n>
1321
+ constexpr Range<T const*> crange(std::array<T, n> const& array) {
1322
+ return Range<T const*>{array};
1323
+ }
1324
+
1325
+ template <class T>
1326
+ constexpr Range<T const*> range(std::initializer_list<T> ilist) {
1327
+ return Range<T const*>(ilist.begin(), ilist.end());
1328
+ }
1329
+
1330
+ template <class T>
1331
+ constexpr Range<T const*> crange(std::initializer_list<T> ilist) {
1332
+ return Range<T const*>(ilist.begin(), ilist.end());
1333
+ }
1334
+
1335
+ using StringPiece = Range<const char*>;
1336
+ using MutableStringPiece = Range<char*>;
1337
+ using ByteRange = Range<const unsigned char*>;
1338
+ using MutableByteRange = Range<unsigned char*>;
1339
+
1340
+ template <class C>
1341
+ std::basic_ostream<C>& operator<<(
1342
+ std::basic_ostream<C>& os, Range<C const*> piece) {
1343
+ using StreamSize = decltype(os.width());
1344
+ os.write(piece.start(), static_cast<StreamSize>(piece.size()));
1345
+ return os;
1346
+ }
1347
+
1348
+ template <class C>
1349
+ std::basic_ostream<C>& operator<<(std::basic_ostream<C>& os, Range<C*> piece) {
1350
+ using StreamSize = decltype(os.width());
1351
+ os.write(piece.start(), static_cast<StreamSize>(piece.size()));
1352
+ return os;
1353
+ }
1354
+
1355
+ /**
1356
+ * Templated comparison operators
1357
+ */
1358
+
1359
+ template <class Iter>
1360
+ inline bool operator==(const Range<Iter>& lhs, const Range<Iter>& rhs) {
1361
+ using value_type = typename Range<Iter>::value_type;
1362
+ if (lhs.size() != rhs.size()) {
1363
+ return false;
1364
+ }
1365
+ if constexpr (
1366
+ std::is_pointer_v<Iter> &&
1367
+ (std::is_integral_v<value_type> || std::is_enum_v<value_type>)) {
1368
+ auto const size = lhs.size() * sizeof(value_type);
1369
+ return 0 == size || 0 == std::memcmp(lhs.data(), rhs.data(), size);
1370
+ } else {
1371
+ for (size_t i = 0; i < lhs.size(); ++i) {
1372
+ if (!Range<Iter>::traits_type::eq(lhs[i], rhs[i])) {
1373
+ return false;
1374
+ }
1375
+ }
1376
+ return true;
1377
+ }
1378
+ }
1379
+
1380
+ template <class Iter>
1381
+ inline bool operator!=(const Range<Iter>& lhs, const Range<Iter>& rhs) {
1382
+ return !(operator==(lhs, rhs));
1383
+ }
1384
+
1385
+ template <class Iter>
1386
+ inline bool operator<(const Range<Iter>& lhs, const Range<Iter>& rhs) {
1387
+ return lhs.compare(rhs) < 0;
1388
+ }
1389
+
1390
+ template <class Iter>
1391
+ inline bool operator<=(const Range<Iter>& lhs, const Range<Iter>& rhs) {
1392
+ return lhs.compare(rhs) <= 0;
1393
+ }
1394
+
1395
+ template <class Iter>
1396
+ inline bool operator>(const Range<Iter>& lhs, const Range<Iter>& rhs) {
1397
+ return lhs.compare(rhs) > 0;
1398
+ }
1399
+
1400
+ template <class Iter>
1401
+ inline bool operator>=(const Range<Iter>& lhs, const Range<Iter>& rhs) {
1402
+ return lhs.compare(rhs) >= 0;
1403
+ }
1404
+
1405
+ /**
1406
+ * Specializations of comparison operators for StringPiece
1407
+ */
1408
+
1409
+ namespace detail {
1410
+
1411
+ template <class A, class B>
1412
+ struct ComparableAsStringPiece {
1413
+ enum {
1414
+ value = (std::is_convertible<A, StringPiece>::value &&
1415
+ std::is_same<B, StringPiece>::value) ||
1416
+ (std::is_convertible<B, StringPiece>::value &&
1417
+ std::is_same<A, StringPiece>::value)
1418
+ };
1419
+ };
1420
+
1421
+ } // namespace detail
1422
+
1423
+ /**
1424
+ * operator== through conversion for Range<const char*>
1425
+ */
1426
+ template <class T, class U>
1427
+ std::enable_if_t<detail::ComparableAsStringPiece<T, U>::value, bool> operator==(
1428
+ const T& lhs, const U& rhs) {
1429
+ return StringPiece(lhs) == StringPiece(rhs);
1430
+ }
1431
+
1432
+ /**
1433
+ * operator!= through conversion for Range<const char*>
1434
+ */
1435
+ template <class T, class U>
1436
+ std::enable_if_t<detail::ComparableAsStringPiece<T, U>::value, bool> operator!=(
1437
+ const T& lhs, const U& rhs) {
1438
+ return StringPiece(lhs) != StringPiece(rhs);
1439
+ }
1440
+
1441
+ /**
1442
+ * operator< through conversion for Range<const char*>
1443
+ */
1444
+ template <class T, class U>
1445
+ std::enable_if_t<detail::ComparableAsStringPiece<T, U>::value, bool> operator<(
1446
+ const T& lhs, const U& rhs) {
1447
+ return StringPiece(lhs) < StringPiece(rhs);
1448
+ }
1449
+
1450
+ /**
1451
+ * operator> through conversion for Range<const char*>
1452
+ */
1453
+ template <class T, class U>
1454
+ std::enable_if_t<detail::ComparableAsStringPiece<T, U>::value, bool> operator>(
1455
+ const T& lhs, const U& rhs) {
1456
+ return StringPiece(lhs) > StringPiece(rhs);
1457
+ }
1458
+
1459
+ /**
1460
+ * operator< through conversion for Range<const char*>
1461
+ */
1462
+ template <class T, class U>
1463
+ std::enable_if_t<detail::ComparableAsStringPiece<T, U>::value, bool> operator<=(
1464
+ const T& lhs, const U& rhs) {
1465
+ return StringPiece(lhs) <= StringPiece(rhs);
1466
+ }
1467
+
1468
+ /**
1469
+ * operator> through conversion for Range<const char*>
1470
+ */
1471
+ template <class T, class U>
1472
+ std::enable_if_t<detail::ComparableAsStringPiece<T, U>::value, bool> operator>=(
1473
+ const T& lhs, const U& rhs) {
1474
+ return StringPiece(lhs) >= StringPiece(rhs);
1475
+ }
1476
+
1477
+ /**
1478
+ * Finds substrings faster than brute force by borrowing from Boyer-Moore
1479
+ */
1480
+ template <class Iter, class Comp>
1481
+ size_t qfind(const Range<Iter>& haystack, const Range<Iter>& needle, Comp eq) {
1482
+ // Don't use std::search, use a Boyer-Moore-like trick by comparing
1483
+ // the last characters first
1484
+ auto const nsize = needle.size();
1485
+ if (haystack.size() < nsize) {
1486
+ return std::string::npos;
1487
+ }
1488
+ if (!nsize) {
1489
+ return 0;
1490
+ }
1491
+ auto const nsize_1 = nsize - 1;
1492
+ auto const lastNeedle = needle[nsize_1];
1493
+
1494
+ // Boyer-Moore skip value for the last char in the needle. Zero is
1495
+ // not a valid value; skip will be computed the first time it's
1496
+ // needed.
1497
+ std::string::size_type skip = 0;
1498
+
1499
+ auto i = haystack.begin();
1500
+ auto iEnd = haystack.end() - nsize_1;
1501
+
1502
+ while (i < iEnd) {
1503
+ // Boyer-Moore: match the last element in the needle
1504
+ while (!eq(i[nsize_1], lastNeedle)) {
1505
+ if (++i == iEnd) {
1506
+ // not found
1507
+ return std::string::npos;
1508
+ }
1509
+ }
1510
+ // Here we know that the last char matches
1511
+ // Continue in pedestrian mode
1512
+ for (size_t j = 0;;) {
1513
+ assert(j < nsize);
1514
+ if (!eq(i[j], needle[j])) {
1515
+ // Not found, we can skip
1516
+ // Compute the skip value lazily
1517
+ if (skip == 0) {
1518
+ skip = 1;
1519
+ while (skip <= nsize_1 && !eq(needle[nsize_1 - skip], lastNeedle)) {
1520
+ ++skip;
1521
+ }
1522
+ }
1523
+ i += skip;
1524
+ break;
1525
+ }
1526
+ // Check if done searching
1527
+ if (++j == nsize) {
1528
+ // Yay
1529
+ return size_t(i - haystack.begin());
1530
+ }
1531
+ }
1532
+ }
1533
+ return std::string::npos;
1534
+ }
1535
+
1536
+ namespace detail {
1537
+
1538
+ inline size_t qfind_first_byte_of(
1539
+ const StringPiece haystack, const StringPiece needles) {
1540
+ static auto const qfind_first_byte_of_fn = folly::CpuId().sse42()
1541
+ ? qfind_first_byte_of_sse42
1542
+ : qfind_first_byte_of_nosse;
1543
+ return qfind_first_byte_of_fn(haystack, needles);
1544
+ }
1545
+
1546
+ } // namespace detail
1547
+
1548
+ template <class Iter, class Comp>
1549
+ size_t qfind_first_of(
1550
+ const Range<Iter>& haystack, const Range<Iter>& needles, Comp eq) {
1551
+ auto ret = std::find_first_of(
1552
+ haystack.begin(), haystack.end(), needles.begin(), needles.end(), eq);
1553
+ return ret == haystack.end() ? std::string::npos : ret - haystack.begin();
1554
+ }
1555
+
1556
+ struct AsciiCaseSensitive {
1557
+ bool operator()(char lhs, char rhs) const { return lhs == rhs; }
1558
+ };
1559
+
1560
+ /**
1561
+ * Check if two ascii characters are case insensitive equal.
1562
+ * The difference between the lower/upper case characters are the 6-th bit.
1563
+ * We also check they are alpha chars, in case of xor = 32.
1564
+ */
1565
+ struct AsciiCaseInsensitive {
1566
+ bool operator()(char lhs, char rhs) const {
1567
+ char k = lhs ^ rhs;
1568
+ if (k == 0) {
1569
+ return true;
1570
+ }
1571
+ if (k != 32) {
1572
+ return false;
1573
+ }
1574
+ k = lhs | rhs;
1575
+ return (k >= 'a' && k <= 'z');
1576
+ }
1577
+ };
1578
+
1579
+ template <class Iter>
1580
+ size_t qfind(
1581
+ const Range<Iter>& haystack,
1582
+ const typename Range<Iter>::value_type& needle) {
1583
+ auto pos = std::find(haystack.begin(), haystack.end(), needle);
1584
+ return pos == haystack.end() ? std::string::npos : pos - haystack.data();
1585
+ }
1586
+
1587
+ template <class Iter>
1588
+ size_t rfind(
1589
+ const Range<Iter>& haystack,
1590
+ const typename Range<Iter>::value_type& needle) {
1591
+ for (auto i = haystack.size(); i-- > 0;) {
1592
+ if (haystack[i] == needle) {
1593
+ return i;
1594
+ }
1595
+ }
1596
+ return std::string::npos;
1597
+ }
1598
+
1599
+ // specialization for StringPiece
1600
+ template <>
1601
+ inline size_t qfind(const Range<const char*>& haystack, const char& needle) {
1602
+ // memchr expects a not-null pointer, early return if the range is empty.
1603
+ if (haystack.empty()) {
1604
+ return std::string::npos;
1605
+ }
1606
+ auto pos = static_cast<const char*>(
1607
+ ::memchr(haystack.data(), needle, haystack.size()));
1608
+ return pos == nullptr ? std::string::npos : pos - haystack.data();
1609
+ }
1610
+
1611
+ template <>
1612
+ inline size_t rfind(const Range<const char*>& haystack, const char& needle) {
1613
+ // memchr expects a not-null pointer, early return if the range is empty.
1614
+ if (haystack.empty()) {
1615
+ return std::string::npos;
1616
+ }
1617
+ auto pos = static_cast<const char*>(
1618
+ memrchr(haystack.data(), needle, haystack.size()));
1619
+ return pos == nullptr ? std::string::npos : pos - haystack.data();
1620
+ }
1621
+
1622
+ // specialization for ByteRange
1623
+ template <>
1624
+ inline size_t qfind(
1625
+ const Range<const unsigned char*>& haystack, const unsigned char& needle) {
1626
+ // memchr expects a not-null pointer, early return if the range is empty.
1627
+ if (haystack.empty()) {
1628
+ return std::string::npos;
1629
+ }
1630
+ auto pos = static_cast<const unsigned char*>(
1631
+ ::memchr(haystack.data(), needle, haystack.size()));
1632
+ return pos == nullptr ? std::string::npos : pos - haystack.data();
1633
+ }
1634
+
1635
+ template <>
1636
+ inline size_t rfind(
1637
+ const Range<const unsigned char*>& haystack, const unsigned char& needle) {
1638
+ // memchr expects a not-null pointer, early return if the range is empty.
1639
+ if (haystack.empty()) {
1640
+ return std::string::npos;
1641
+ }
1642
+ auto pos = static_cast<const unsigned char*>(
1643
+ memrchr(haystack.data(), needle, haystack.size()));
1644
+ return pos == nullptr ? std::string::npos : pos - haystack.data();
1645
+ }
1646
+
1647
+ template <class Iter>
1648
+ size_t qfind_first_of(const Range<Iter>& haystack, const Range<Iter>& needles) {
1649
+ return qfind_first_of(haystack, needles, AsciiCaseSensitive());
1650
+ }
1651
+
1652
+ // specialization for StringPiece
1653
+ template <>
1654
+ inline size_t qfind_first_of(
1655
+ const Range<const char*>& haystack, const Range<const char*>& needles) {
1656
+ return detail::qfind_first_byte_of(haystack, needles);
1657
+ }
1658
+
1659
+ // specialization for ByteRange
1660
+ template <>
1661
+ inline size_t qfind_first_of(
1662
+ const Range<const unsigned char*>& haystack,
1663
+ const Range<const unsigned char*>& needles) {
1664
+ return detail::qfind_first_byte_of(
1665
+ StringPiece(haystack), StringPiece(needles));
1666
+ }
1667
+
1668
+ template <class Key, class Enable>
1669
+ struct hasher;
1670
+
1671
+ template <class T>
1672
+ struct hasher<
1673
+ folly::Range<T*>,
1674
+ std::enable_if_t<std::is_integral<T>::value, void>> {
1675
+ using folly_is_avalanching = std::true_type;
1676
+
1677
+ size_t operator()(folly::Range<T*> r) const {
1678
+ // std::is_integral<T> is too restrictive, but is sufficient to
1679
+ // guarantee we can just hash all of the underlying bytes to get a
1680
+ // suitable hash of T. Something like absl::is_uniquely_represented<T>
1681
+ // would be better. std::is_pod is not enough, because POD types
1682
+ // can contain pointers and padding. Also, floating point numbers
1683
+ // may be == without being bit-identical. size_t is less than 64
1684
+ // bits on some platforms.
1685
+ return static_cast<size_t>(
1686
+ hash::SpookyHashV2::Hash64(r.begin(), r.size() * sizeof(T), 0));
1687
+ }
1688
+ };
1689
+
1690
+ /**
1691
+ * _sp is a user-defined literal suffix to make an appropriate Range
1692
+ * specialization from a literal string.
1693
+ *
1694
+ * Modeled after C++17's `sv` suffix.
1695
+ */
1696
+ inline namespace literals {
1697
+ inline namespace string_piece_literals {
1698
+ constexpr Range<char const*> operator""_sp(
1699
+ char const* str, size_t len) noexcept {
1700
+ return Range<char const*>(str, len);
1701
+ }
1702
+
1703
+ #if defined(__cpp_char8_t) && __cpp_char8_t >= 201811L
1704
+ constexpr Range<char8_t const*> operator""_sp(
1705
+ char8_t const* str, size_t len) noexcept {
1706
+ return Range<char8_t const*>(str, len);
1707
+ }
1708
+ #endif
1709
+
1710
+ constexpr Range<char16_t const*> operator""_sp(
1711
+ char16_t const* str, size_t len) noexcept {
1712
+ return Range<char16_t const*>(str, len);
1713
+ }
1714
+
1715
+ constexpr Range<char32_t const*> operator""_sp(
1716
+ char32_t const* str, size_t len) noexcept {
1717
+ return Range<char32_t const*>(str, len);
1718
+ }
1719
+
1720
+ constexpr Range<wchar_t const*> operator""_sp(
1721
+ wchar_t const* str, size_t len) noexcept {
1722
+ return Range<wchar_t const*>(str, len);
1723
+ }
1724
+ } // namespace string_piece_literals
1725
+ } // namespace literals
1726
+
1727
+ } // namespace folly
1728
+
1729
+ // Avoid ambiguity in older fmt versions due to StringPiece's conversions.
1730
+ #if FMT_VERSION >= 70000
1731
+ namespace fmt {
1732
+ template <>
1733
+ struct formatter<folly::StringPiece> : private formatter<string_view> {
1734
+ using formatter<string_view>::parse;
1735
+
1736
+ #if FMT_VERSION >= 80000
1737
+ template <typename Context>
1738
+ typename Context::iterator format(folly::StringPiece s, Context& ctx) const {
1739
+ return formatter<string_view>::format({s.data(), s.size()}, ctx);
1740
+ }
1741
+ #else
1742
+ template <typename Context>
1743
+ typename Context::iterator format(folly::StringPiece s, Context& ctx) {
1744
+ return formatter<string_view>::format({s.data(), s.size()}, ctx);
1745
+ }
1746
+ #endif
1747
+ };
1748
+ } // namespace fmt
1749
+ #endif
1750
+
1751
+ FOLLY_POP_WARNING
1752
+
1753
+ FOLLY_ASSUME_FBVECTOR_COMPATIBLE_1(folly::Range)
1754
+
1755
+ // Unfortunately it is not possible to forward declare enable_view under
1756
+ // MSVC 2019.8 due to compiler bugs, so we need to include the actual
1757
+ // definition if available.
1758
+ #if __has_include(<range/v3/range/concepts.hpp>) && defined(_MSC_VER)
1759
+ #include <range/v3/range/concepts.hpp> // @manual
1760
+ #else
1761
+ namespace ranges {
1762
+ template <class T>
1763
+ extern const bool enable_view;
1764
+ } // namespace ranges
1765
+ #endif
1766
+
1767
+ // Tell the range-v3 library that this type should satisfy
1768
+ // the view concept (a lightweight, non-owning range).
1769
+ namespace ranges {
1770
+ template <class Iter>
1771
+ inline constexpr bool enable_view<::folly::Range<Iter>> = true;
1772
+ } // namespace ranges