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,1652 @@
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
+ * This header defines two classes that very nearly model
19
+ * AssociativeContainer (but not quite). These implement set-like and
20
+ * map-like behavior on top of a sorted vector, instead of using
21
+ * rb-trees like std::set and std::map.
22
+ *
23
+ * This is potentially useful in cases where the number of elements in
24
+ * the set or map is small, or when you want to avoid using more
25
+ * memory than necessary and insertions/deletions are much more rare
26
+ * than lookups (these classes have O(N) insertions/deletions).
27
+ *
28
+ * In the interest of using these in conditions where the goal is to
29
+ * minimize memory usage, they support a GrowthPolicy parameter, which
30
+ * is a class defining a single function called increase_capacity,
31
+ * which will be called whenever we are about to insert something: you
32
+ * can then decide to call reserve() based on the current capacity()
33
+ * and size() of the passed in vector-esque Container type. An
34
+ * example growth policy that grows one element at a time:
35
+ *
36
+ * struct OneAtATimePolicy {
37
+ * template <class Container>
38
+ * void increase_capacity(Container& c) {
39
+ * if (c.size() == c.capacity()) {
40
+ * c.reserve(c.size() + 1);
41
+ * }
42
+ * }
43
+ * };
44
+ *
45
+ * typedef sorted_vector_set<int,
46
+ * std::less<int>,
47
+ * std::allocator<int>,
48
+ * OneAtATimePolicy>
49
+ * OneAtATimeIntSet;
50
+ *
51
+ * Important differences from std::set and std::map:
52
+ * - insert() and erase() invalidate iterators and references.
53
+ erase(iterator) returns an iterator pointing to the next valid element.
54
+ * - insert() and erase() are O(N)
55
+ * - our iterators model RandomAccessIterator
56
+ * - sorted_vector_map::value_type is pair<K,V>, not pair<const K,V>.
57
+ * (This is basically because we want to store the value_type in
58
+ * std::vector<>, which requires it to be Assignable.)
59
+ * - insert() single key variants, emplace(), and emplace_hint() only provide
60
+ * the strong exception guarantee (unchanged when exception is thrown) when
61
+ * std::is_nothrow_move_constructible<value_type>::value is true.
62
+ */
63
+
64
+ #pragma once
65
+
66
+ #include <algorithm>
67
+ #include <cassert>
68
+ #include <initializer_list>
69
+ #include <iterator>
70
+ #include <memory>
71
+ #include <stdexcept>
72
+ #include <type_traits>
73
+ #include <utility>
74
+ #include <vector>
75
+
76
+ #include <folly/ScopeGuard.h>
77
+ #include <folly/Traits.h>
78
+ #include <folly/Utility.h>
79
+ #include <folly/lang/Access.h>
80
+ #include <folly/lang/Exception.h>
81
+ #include <folly/memory/MemoryResource.h>
82
+
83
+ namespace folly {
84
+
85
+ //////////////////////////////////////////////////////////////////////
86
+
87
+ namespace detail {
88
+
89
+ template <typename, typename Compare, typename Key, typename T>
90
+ struct sorted_vector_enable_if_is_transparent {};
91
+
92
+ template <typename Compare, typename Key, typename T>
93
+ struct sorted_vector_enable_if_is_transparent<
94
+ void_t<typename Compare::is_transparent>,
95
+ Compare,
96
+ Key,
97
+ T> {
98
+ using type = T;
99
+ };
100
+
101
+ // This wrapper goes around a GrowthPolicy and provides iterator
102
+ // preservation semantics, but only if the growth policy is not the
103
+ // default (i.e. nothing).
104
+ template <class Policy>
105
+ struct growth_policy_wrapper : private Policy {
106
+ template <class Container, class Iterator>
107
+ Iterator increase_capacity(Container& c, Iterator desired_insertion) {
108
+ typedef typename Container::difference_type diff_t;
109
+ diff_t d = desired_insertion - c.begin();
110
+ Policy::increase_capacity(c);
111
+ return c.begin() + d;
112
+ }
113
+ };
114
+ template <>
115
+ struct growth_policy_wrapper<void> {
116
+ template <class Container, class Iterator>
117
+ Iterator increase_capacity(Container&, Iterator it) {
118
+ return it;
119
+ }
120
+ };
121
+
122
+ template <class OurContainer, class Vector, class GrowthPolicy, class Value>
123
+ typename OurContainer::iterator insert_with_hint(
124
+ OurContainer& sorted,
125
+ Vector& cont,
126
+ typename OurContainer::const_iterator hint,
127
+ Value&& value,
128
+ GrowthPolicy& po) {
129
+ const typename OurContainer::value_compare& cmp(sorted.value_comp());
130
+ if (hint == cont.end() || cmp(value, *hint)) {
131
+ if (hint == cont.begin() || cmp(*(hint - 1), value)) {
132
+ hint = po.increase_capacity(cont, hint);
133
+ return cont.emplace(hint, std::forward<Value>(value));
134
+ } else {
135
+ return sorted.emplace(std::forward<Value>(value)).first;
136
+ }
137
+ }
138
+
139
+ if (cmp(*hint, value)) {
140
+ if (hint + 1 == cont.end() || cmp(value, *(hint + 1))) {
141
+ hint = po.increase_capacity(cont, hint + 1);
142
+ return cont.emplace(hint, std::forward<Value>(value));
143
+ } else {
144
+ return sorted.emplace(std::forward<Value>(value)).first;
145
+ }
146
+ }
147
+
148
+ // Value and *hint did not compare, so they are equal keys.
149
+ return sorted.begin() + std::distance(sorted.cbegin(), hint);
150
+ }
151
+
152
+ template <typename Iterator, typename Compare>
153
+ bool is_sorted_unique(Iterator begin, Iterator end, Compare const& comp) {
154
+ if (begin == end) {
155
+ return true;
156
+ }
157
+ for (auto next = std::next(begin); next != end; ++begin, ++next) {
158
+ if (!comp(*begin, *next)) {
159
+ return false;
160
+ }
161
+ }
162
+ return true;
163
+ }
164
+
165
+ template <typename Container, typename Compare>
166
+ Container&& as_sorted_unique(Container&& container, Compare const& comp) {
167
+ std::sort(container.begin(), container.end(), comp);
168
+ container.erase(
169
+ std::unique(
170
+ container.begin(),
171
+ container.end(),
172
+ [&](auto const& a, auto const& b) {
173
+ return !comp(a, b) && !comp(b, a);
174
+ }),
175
+ container.end());
176
+ return static_cast<Container&&>(container);
177
+ }
178
+
179
+ template <typename Container, typename Compare>
180
+ class DirectMutationGuard {
181
+ public:
182
+ DirectMutationGuard(
183
+ Container& container, const Compare& comp, bool isSortedUnique)
184
+ : container_(container), comp_(comp), isSortedUnique_(isSortedUnique) {}
185
+
186
+ ~DirectMutationGuard() noexcept(false) {
187
+ if (isSortedUnique_) {
188
+ assert(detail::is_sorted_unique(
189
+ container_.begin(), container_.end(), comp_));
190
+ return;
191
+ }
192
+ as_sorted_unique(container_, comp_);
193
+ }
194
+
195
+ Container& get() { return container_; }
196
+
197
+ private:
198
+ Container& container_;
199
+ const Compare comp_;
200
+ const bool isSortedUnique_;
201
+ };
202
+
203
+ template <class OurContainer, class Vector, class InputIterator>
204
+ void bulk_insert(
205
+ OurContainer& sorted,
206
+ Vector& cont,
207
+ InputIterator first,
208
+ InputIterator last,
209
+ bool range_is_sorted_unique = false) {
210
+ // Prevent deref of middle where middle == cont.end().
211
+ if (first == last) {
212
+ return;
213
+ }
214
+
215
+ auto const prev_size = cont.size();
216
+ cont.insert(cont.end(), first, last);
217
+ auto const middle = cont.begin() + prev_size;
218
+
219
+ auto const& cmp(sorted.value_comp());
220
+ if (range_is_sorted_unique) {
221
+ assert(is_sorted_unique(middle, cont.end(), cmp));
222
+ } else if (!std::is_sorted(middle, cont.end(), cmp)) {
223
+ std::sort(middle, cont.end(), cmp);
224
+ }
225
+
226
+ // We do not need to consider elements strictly smaller than the smallest new
227
+ // element in merge/unique.
228
+ auto merge_begin = middle;
229
+ while (merge_begin != cont.begin() && !cmp(*(merge_begin - 1), *middle)) {
230
+ --merge_begin;
231
+ }
232
+
233
+ if (merge_begin != middle) {
234
+ std::inplace_merge(cont.begin(), middle, cont.end(), cmp);
235
+ } else if (range_is_sorted_unique) {
236
+ // Old and new elements are already disjoint and unique. This includes the
237
+ // case when cont is initially empty.
238
+ return;
239
+ }
240
+
241
+ cont.erase(
242
+ std::unique(
243
+ merge_begin,
244
+ cont.end(),
245
+ [&](typename OurContainer::value_type const& a,
246
+ typename OurContainer::value_type const& b) {
247
+ return !cmp(a, b);
248
+ }),
249
+ cont.end());
250
+ }
251
+
252
+ } // namespace detail
253
+
254
+ //////////////////////////////////////////////////////////////////////
255
+
256
+ /**
257
+ * A sorted_vector_set is a container similar to std::set<>, but
258
+ * implemented as a sorted array with std::vector<>.
259
+ *
260
+ * @tparam T Data type to store
261
+ * @tparam Compare Comparison function that imposes a
262
+ * strict weak ordering over instances of T
263
+ * @tparam Allocator allocation policy
264
+ * @tparam GrowthPolicy policy object to control growth
265
+ */
266
+ template <
267
+ class T,
268
+ class Compare = std::less<T>,
269
+ class Allocator = std::allocator<T>,
270
+ class GrowthPolicy = void,
271
+ class Container = std::vector<T, Allocator>>
272
+ class sorted_vector_set : detail::growth_policy_wrapper<GrowthPolicy> {
273
+ detail::growth_policy_wrapper<GrowthPolicy>& get_growth_policy() {
274
+ return *this;
275
+ }
276
+
277
+ template <typename K, typename V, typename C = Compare>
278
+ using if_is_transparent =
279
+ _t<detail::sorted_vector_enable_if_is_transparent<void, C, K, V>>;
280
+
281
+ struct EBO;
282
+
283
+ public:
284
+ typedef T value_type;
285
+ typedef T key_type;
286
+ typedef Compare key_compare;
287
+ typedef Compare value_compare;
288
+ typedef Allocator allocator_type;
289
+ typedef Container container_type;
290
+
291
+ typedef typename Container::pointer pointer;
292
+ typedef typename Container::reference reference;
293
+ typedef typename Container::const_reference const_reference;
294
+ typedef typename Container::const_pointer const_pointer;
295
+ /*
296
+ * XXX: Our normal iterator ought to also be a constant iterator
297
+ * (cf. Defect Report 103 for std::set), but this is a bit more of a
298
+ * pain.
299
+ */
300
+ typedef typename Container::iterator iterator;
301
+ typedef typename Container::const_iterator const_iterator;
302
+ typedef typename Container::difference_type difference_type;
303
+ typedef typename Container::size_type size_type;
304
+ typedef typename Container::reverse_iterator reverse_iterator;
305
+ typedef typename Container::const_reverse_iterator const_reverse_iterator;
306
+ typedef detail::DirectMutationGuard<Container, value_compare>
307
+ direct_mutation_guard;
308
+
309
+ sorted_vector_set() : m_(Compare(), Allocator()) {}
310
+
311
+ sorted_vector_set(const sorted_vector_set&) = default;
312
+
313
+ sorted_vector_set(const sorted_vector_set& other, const Allocator& alloc)
314
+ : m_(other.m_, alloc) {}
315
+
316
+ sorted_vector_set(sorted_vector_set&&) = default;
317
+
318
+ sorted_vector_set(sorted_vector_set&& other, const Allocator& alloc) noexcept(
319
+ std::is_nothrow_constructible<EBO, EBO&&, const Allocator&>::value)
320
+ : m_(std::move(other.m_), alloc) {}
321
+
322
+ explicit sorted_vector_set(const Allocator& alloc) : m_(Compare(), alloc) {}
323
+
324
+ explicit sorted_vector_set(
325
+ const Compare& comp, const Allocator& alloc = Allocator())
326
+ : m_(comp, alloc) {}
327
+
328
+ template <class InputIterator>
329
+ sorted_vector_set(
330
+ InputIterator first,
331
+ InputIterator last,
332
+ const Compare& comp = Compare(),
333
+ const Allocator& alloc = Allocator())
334
+ : m_(comp, alloc) {
335
+ // This is linear if [first, last) is already sorted (and if we
336
+ // can figure out the distance between the two iterators).
337
+ insert(first, last);
338
+ }
339
+
340
+ template <class InputIterator>
341
+ sorted_vector_set(
342
+ InputIterator first, InputIterator last, const Allocator& alloc)
343
+ : m_(Compare(), alloc) {
344
+ // This is linear if [first, last) is already sorted (and if we
345
+ // can figure out the distance between the two iterators).
346
+ insert(first, last);
347
+ }
348
+
349
+ /* implicit */ sorted_vector_set(
350
+ std::initializer_list<value_type> list,
351
+ const Compare& comp = Compare(),
352
+ const Allocator& alloc = Allocator())
353
+ : m_(comp, alloc) {
354
+ insert(list.begin(), list.end());
355
+ }
356
+
357
+ sorted_vector_set(
358
+ std::initializer_list<value_type> list, const Allocator& alloc)
359
+ : m_(Compare(), alloc) {
360
+ insert(list.begin(), list.end());
361
+ }
362
+
363
+ // Construct a sorted_vector_set by stealing the storage of a prefilled
364
+ // container. The container need not be sorted already. This supports
365
+ // bulk construction of sorted_vector_set with zero allocations, not counting
366
+ // those performed by the caller. (The iterator range constructor performs at
367
+ // least one allocation).
368
+ //
369
+ // Note that `sorted_vector_set(const Container& container)` is not provided,
370
+ // since the purpose of this constructor is to avoid an unnecessary copy.
371
+ explicit sorted_vector_set(
372
+ Container&& container, const Compare& comp = Compare())
373
+ : sorted_vector_set(
374
+ sorted_unique,
375
+ detail::as_sorted_unique(std::move(container), comp),
376
+ comp) {}
377
+
378
+ // Construct a sorted_vector_set by stealing the storage of a prefilled
379
+ // container. Its elements must be sorted and unique, as sorted_unique_t
380
+ // hints. Supports bulk construction of sorted_vector_set with zero
381
+ // allocations, not counting those performed by the caller. (The iterator
382
+ // range constructor performs at least one allocation).
383
+ //
384
+ // Note that `sorted_vector_set(sorted_unique_t, const Container& container)`
385
+ // is not provided, since the purpose of this constructor is to avoid an extra
386
+ // copy.
387
+ sorted_vector_set(
388
+ sorted_unique_t,
389
+ Container&& container,
390
+ const Compare& comp = Compare()) noexcept(std::
391
+ is_nothrow_constructible<
392
+ EBO,
393
+ const Compare&,
394
+ Container&&>::value)
395
+ : m_(comp, std::move(container)) {
396
+ assert(detail::is_sorted_unique(
397
+ m_.cont_.begin(), m_.cont_.end(), value_comp()));
398
+ }
399
+
400
+ Allocator get_allocator() const { return m_.cont_.get_allocator(); }
401
+
402
+ const Container& get_container() const noexcept { return m_.cont_; }
403
+
404
+ /**
405
+ * Directly mutate the container.
406
+ *
407
+ * Get a guarded reference to the underlying container for direct mutation.
408
+ * sorted_unique_t signals that user will make sure that after the
409
+ * modification the container will have its values as sorted-unique
410
+ * (conforming to container's value_comp). Violating this assumption will
411
+ * result in undefined behavior.
412
+ *
413
+ * This function is not safe to use concurrently with other functions.
414
+ */
415
+ direct_mutation_guard get_container_for_direct_mutation(
416
+ sorted_unique_t) noexcept {
417
+ return direct_mutation_guard{
418
+ m_.cont_, value_comp(), /* range_is_sorted_unique */ true};
419
+ }
420
+
421
+ /**
422
+ * Directly mutate the container.
423
+ *
424
+ * Get a guarded reference to the underlying container for direct mutation.
425
+ * The container will initially be sorted and unique. You are not required to
426
+ * maintain the sorted-unique invariant while mutating. When the guard is
427
+ * released, it will sort and unique-ify the container.
428
+ *
429
+ * This function is not safe to use concurrently with other functions.
430
+ */
431
+ direct_mutation_guard get_container_for_direct_mutation() noexcept {
432
+ return direct_mutation_guard{
433
+ m_.cont_, value_comp(), /* range_is_sorted_unique */ false};
434
+ }
435
+
436
+ sorted_vector_set& operator=(const sorted_vector_set& other) = default;
437
+
438
+ sorted_vector_set& operator=(sorted_vector_set&& other) = default;
439
+
440
+ sorted_vector_set& operator=(std::initializer_list<value_type> ilist) {
441
+ clear();
442
+ insert(ilist.begin(), ilist.end());
443
+ return *this;
444
+ }
445
+
446
+ key_compare key_comp() const { return m_; }
447
+ value_compare value_comp() const { return m_; }
448
+
449
+ iterator begin() { return m_.cont_.begin(); }
450
+ iterator end() { return m_.cont_.end(); }
451
+ const_iterator cbegin() const { return m_.cont_.cbegin(); }
452
+ const_iterator begin() const { return m_.cont_.begin(); }
453
+ const_iterator cend() const { return m_.cont_.cend(); }
454
+ const_iterator end() const { return m_.cont_.end(); }
455
+ reverse_iterator rbegin() { return m_.cont_.rbegin(); }
456
+ reverse_iterator rend() { return m_.cont_.rend(); }
457
+ const_reverse_iterator rbegin() const { return m_.cont_.rbegin(); }
458
+ const_reverse_iterator rend() const { return m_.cont_.rend(); }
459
+
460
+ void clear() { return m_.cont_.clear(); }
461
+ size_type size() const { return m_.cont_.size(); }
462
+ size_type max_size() const { return m_.cont_.max_size(); }
463
+ bool empty() const { return m_.cont_.empty(); }
464
+ void reserve(size_type s) { return m_.cont_.reserve(s); }
465
+ void shrink_to_fit() { m_.cont_.shrink_to_fit(); }
466
+ size_type capacity() const { return m_.cont_.capacity(); }
467
+
468
+ std::pair<iterator, bool> insert(const value_type& value) {
469
+ iterator it = lower_bound(value);
470
+ if (it == end() || value_comp()(value, *it)) {
471
+ it = get_growth_policy().increase_capacity(m_.cont_, it);
472
+ return std::make_pair(m_.cont_.emplace(it, value), true);
473
+ }
474
+ return std::make_pair(it, false);
475
+ }
476
+
477
+ std::pair<iterator, bool> insert(value_type&& value) {
478
+ iterator it = lower_bound(value);
479
+ if (it == end() || value_comp()(value, *it)) {
480
+ it = get_growth_policy().increase_capacity(m_.cont_, it);
481
+ return std::make_pair(m_.cont_.emplace(it, std::move(value)), true);
482
+ }
483
+ return std::make_pair(it, false);
484
+ }
485
+
486
+ iterator insert(const_iterator hint, const value_type& value) {
487
+ return detail::insert_with_hint(
488
+ *this, m_.cont_, hint, value, get_growth_policy());
489
+ }
490
+
491
+ iterator insert(const_iterator hint, value_type&& value) {
492
+ return detail::insert_with_hint(
493
+ *this, m_.cont_, hint, std::move(value), get_growth_policy());
494
+ }
495
+
496
+ template <class InputIterator>
497
+ void insert(InputIterator first, InputIterator last) {
498
+ detail::bulk_insert(*this, m_.cont_, first, last);
499
+ }
500
+
501
+ // If [first, last) is known to be sorted and unique according to the
502
+ // comparator (for example if the range comes from a sorted container of the
503
+ // same type) this version can save unnecessary operations, especially if
504
+ // *this is empty.
505
+ template <class InputIterator>
506
+ void insert(sorted_unique_t, InputIterator first, InputIterator last) {
507
+ detail::bulk_insert(
508
+ *this, m_.cont_, first, last, /* range_is_sorted_unique */ true);
509
+ }
510
+
511
+ void insert(std::initializer_list<value_type> ilist) {
512
+ insert(ilist.begin(), ilist.end());
513
+ }
514
+
515
+ // emplace isn't better than insert for sorted_vector_set, but aids
516
+ // compatibility
517
+ template <typename... Args>
518
+ std::pair<iterator, bool> emplace(Args&&... args) {
519
+ folly::aligned_storage_for_t<value_type> b;
520
+ value_type* p = static_cast<value_type*>(static_cast<void*>(&b));
521
+ auto a = get_allocator();
522
+ std::allocator_traits<allocator_type>::construct(
523
+ a, p, std::forward<Args>(args)...);
524
+ auto g = makeGuard(
525
+ [&]() { std::allocator_traits<allocator_type>::destroy(a, p); });
526
+ return insert(std::move(*p));
527
+ }
528
+
529
+ std::pair<iterator, bool> emplace(const value_type& value) {
530
+ return insert(value);
531
+ }
532
+
533
+ std::pair<iterator, bool> emplace(value_type&& value) {
534
+ return insert(std::move(value));
535
+ }
536
+
537
+ // emplace_hint isn't better than insert for sorted_vector_set, but aids
538
+ // compatibility
539
+ template <typename... Args>
540
+ iterator emplace_hint(const_iterator hint, Args&&... args) {
541
+ folly::aligned_storage_for_t<value_type> b;
542
+ value_type* p = static_cast<value_type*>(static_cast<void*>(&b));
543
+ auto a = get_allocator();
544
+ std::allocator_traits<allocator_type>::construct(
545
+ a, p, std::forward<Args>(args)...);
546
+ auto g = makeGuard(
547
+ [&]() { std::allocator_traits<allocator_type>::destroy(a, p); });
548
+ return insert(hint, std::move(*p));
549
+ }
550
+
551
+ iterator emplace_hint(const_iterator hint, const value_type& value) {
552
+ return insert(hint, value);
553
+ }
554
+
555
+ iterator emplace_hint(const_iterator hint, value_type&& value) {
556
+ return insert(hint, std::move(value));
557
+ }
558
+
559
+ size_type erase(const key_type& key) {
560
+ iterator it = find(key);
561
+ if (it == end()) {
562
+ return 0;
563
+ }
564
+ m_.cont_.erase(it);
565
+ return 1;
566
+ }
567
+
568
+ iterator erase(const_iterator it) { return m_.cont_.erase(it); }
569
+
570
+ iterator erase(const_iterator first, const_iterator last) {
571
+ return m_.cont_.erase(first, last);
572
+ }
573
+
574
+ template <class Predicate>
575
+ friend size_type erase_if(sorted_vector_set& container, Predicate predicate) {
576
+ auto& c = container.m_.cont_;
577
+ const auto preEraseSize = c.size();
578
+ c.erase(std::remove_if(c.begin(), c.end(), std::ref(predicate)), c.end());
579
+ return preEraseSize - c.size();
580
+ }
581
+
582
+ iterator find(const key_type& key) { return find_(*this, key); }
583
+
584
+ const_iterator find(const key_type& key) const { return find_(*this, key); }
585
+
586
+ template <typename K>
587
+ if_is_transparent<K, iterator> find(const K& key) {
588
+ return find_(*this, key);
589
+ }
590
+
591
+ template <typename K>
592
+ if_is_transparent<K, const_iterator> find(const K& key) const {
593
+ return find_(*this, key);
594
+ }
595
+
596
+ size_type count(const key_type& key) const {
597
+ return find(key) == end() ? 0 : 1;
598
+ }
599
+
600
+ std::pair<iterator, iterator> find(
601
+ const key_type& key1, const key_type& key2) {
602
+ if (key_comp()(key2, key1)) {
603
+ auto iterators = find2_(*this, key2, key1);
604
+ access::swap(iterators.first, iterators.second);
605
+ return iterators;
606
+ } else {
607
+ return find2_(*this, key1, key2);
608
+ }
609
+ }
610
+
611
+ std::pair<const_iterator, const_iterator> find(
612
+ const key_type& key1, const key_type& key2) const {
613
+ if (key_comp()(key2, key1)) {
614
+ auto iterators = find2_(*this, key2, key1);
615
+ access::swap(iterators.first, iterators.second);
616
+ return iterators;
617
+ } else {
618
+ return find2_(*this, key1, key2);
619
+ }
620
+ }
621
+
622
+ template <typename K>
623
+ std::pair<if_is_transparent<K, iterator>, if_is_transparent<K, iterator>>
624
+ find(const K& key1, const K& key2) {
625
+ if (key_comp()(key2, key1)) {
626
+ auto iterators = find2_(*this, key2, key1);
627
+ access::swap(iterators.first, iterators.second);
628
+ return iterators;
629
+ } else {
630
+ return find2_(*this, key1, key2);
631
+ }
632
+ }
633
+
634
+ template <typename K>
635
+ std::pair<
636
+ if_is_transparent<K, const_iterator>,
637
+ if_is_transparent<K, const_iterator>>
638
+ find(const K& key1, const K& key2) const {
639
+ if (key_comp()(key2, key1)) {
640
+ auto iterators = find2_(*this, key2, key1);
641
+ access::swap(iterators.first, iterators.second);
642
+ return iterators;
643
+ } else {
644
+ return find2_(*this, key1, key2);
645
+ }
646
+ }
647
+
648
+ template <typename K>
649
+ if_is_transparent<K, size_type> count(const K& key) const {
650
+ return find(key) == end() ? 0 : 1;
651
+ }
652
+
653
+ bool contains(const key_type& key) const { return find(key) != end(); }
654
+
655
+ template <typename K>
656
+ if_is_transparent<K, bool> contains(const K& key) const {
657
+ return find(key) != end();
658
+ }
659
+
660
+ iterator lower_bound(const key_type& key) {
661
+ return std::lower_bound(begin(), end(), key, key_comp());
662
+ }
663
+
664
+ const_iterator lower_bound(const key_type& key) const {
665
+ return std::lower_bound(begin(), end(), key, key_comp());
666
+ }
667
+
668
+ template <typename K>
669
+ if_is_transparent<K, iterator> lower_bound(const K& key) {
670
+ return std::lower_bound(begin(), end(), key, key_comp());
671
+ }
672
+
673
+ template <typename K>
674
+ if_is_transparent<K, const_iterator> lower_bound(const K& key) const {
675
+ return std::lower_bound(begin(), end(), key, key_comp());
676
+ }
677
+
678
+ iterator upper_bound(const key_type& key) {
679
+ return std::upper_bound(begin(), end(), key, key_comp());
680
+ }
681
+
682
+ const_iterator upper_bound(const key_type& key) const {
683
+ return std::upper_bound(begin(), end(), key, key_comp());
684
+ }
685
+
686
+ template <typename K>
687
+ if_is_transparent<K, iterator> upper_bound(const K& key) {
688
+ return std::upper_bound(begin(), end(), key, key_comp());
689
+ }
690
+
691
+ template <typename K>
692
+ if_is_transparent<K, const_iterator> upper_bound(const K& key) const {
693
+ return std::upper_bound(begin(), end(), key, key_comp());
694
+ }
695
+
696
+ std::pair<iterator, iterator> equal_range(const key_type& key) {
697
+ return std::equal_range(begin(), end(), key, key_comp());
698
+ }
699
+
700
+ std::pair<const_iterator, const_iterator> equal_range(
701
+ const key_type& key) const {
702
+ return std::equal_range(begin(), end(), key, key_comp());
703
+ }
704
+
705
+ template <typename K>
706
+ if_is_transparent<K, std::pair<iterator, iterator>> equal_range(
707
+ const K& key) {
708
+ return std::equal_range(begin(), end(), key, key_comp());
709
+ }
710
+
711
+ template <typename K>
712
+ if_is_transparent<K, std::pair<const_iterator, const_iterator>> equal_range(
713
+ const K& key) const {
714
+ return std::equal_range(begin(), end(), key, key_comp());
715
+ }
716
+
717
+ void swap(sorted_vector_set& o) noexcept(
718
+ std::is_nothrow_swappable_v<Compare> &&
719
+ noexcept(std::declval<Container&>().swap(o.m_.cont_))) {
720
+ using std::swap; // Allow ADL for swap(); fall back to std::swap().
721
+ Compare& a = m_;
722
+ Compare& b = o.m_;
723
+ swap(a, b);
724
+ m_.cont_.swap(o.m_.cont_);
725
+ }
726
+
727
+ bool operator==(const sorted_vector_set& other) const {
728
+ return other.m_.cont_ == m_.cont_;
729
+ }
730
+ bool operator!=(const sorted_vector_set& other) const {
731
+ return !operator==(other);
732
+ }
733
+
734
+ bool operator<(const sorted_vector_set& other) const {
735
+ return m_.cont_ < other.m_.cont_;
736
+ }
737
+ bool operator>(const sorted_vector_set& other) const { return other < *this; }
738
+ bool operator<=(const sorted_vector_set& other) const {
739
+ return !operator>(other);
740
+ }
741
+ bool operator>=(const sorted_vector_set& other) const {
742
+ return !operator<(other);
743
+ }
744
+
745
+ const value_type* data() const noexcept { return m_.cont_.data(); }
746
+
747
+ private:
748
+ /*
749
+ * This structure derives from the comparison object in order to
750
+ * make use of the empty base class optimization if our comparison
751
+ * functor is an empty class (usual case).
752
+ *
753
+ * Wrapping up this member like this is better than deriving from
754
+ * the Compare object ourselves (there are some perverse edge cases
755
+ * involving virtual functions).
756
+ *
757
+ * More info: http://www.cantrip.org/emptyopt.html
758
+ */
759
+ struct EBO : Compare {
760
+ explicit EBO(const Compare& c, const Allocator& alloc) noexcept(
761
+ std::is_nothrow_default_constructible<Container>::value)
762
+ : Compare(c), cont_(alloc) {}
763
+ EBO(const EBO& other, const Allocator& alloc) noexcept(
764
+ std::is_nothrow_constructible<
765
+ Container,
766
+ const Container&,
767
+ const Allocator&>::value)
768
+ : Compare(static_cast<const Compare&>(other)),
769
+ cont_(other.cont_, alloc) {}
770
+ EBO(EBO&& other, const Allocator& alloc) noexcept(
771
+ std::is_nothrow_constructible<
772
+ Container,
773
+ Container&&,
774
+ const Allocator&>::value)
775
+ : Compare(static_cast<Compare&&>(other)),
776
+ cont_(std::move(other.cont_), alloc) {}
777
+ EBO(const Compare& c, Container&& cont) noexcept(
778
+ std::is_nothrow_move_constructible<Container>::value)
779
+ : Compare(c), cont_(std::move(cont)) {}
780
+ Container cont_;
781
+ } m_;
782
+
783
+ template <typename Self>
784
+ using self_iterator_t = _t<
785
+ std::conditional<std::is_const<Self>::value, const_iterator, iterator>>;
786
+
787
+ template <typename Self, typename K>
788
+ static self_iterator_t<Self> find_(Self& self, K const& key) {
789
+ auto end = self.end();
790
+ auto it = self.lower_bound(key);
791
+ if (it == end || !self.key_comp()(key, *it)) {
792
+ return it;
793
+ }
794
+ return end;
795
+ }
796
+ template <typename Self, typename K>
797
+ static std::pair<self_iterator_t<Self>, self_iterator_t<Self>> lower_bound2_(
798
+ Self& self, K const& key1, K const& key2) {
799
+ auto len = self.size();
800
+ auto first = self.begin(), second = self.begin();
801
+ auto c = self.key_comp();
802
+ assert(!c(key2, key1));
803
+ while (true) {
804
+ if (len == 0) {
805
+ return std::make_pair(first, first);
806
+ }
807
+ auto half = len / 2;
808
+ auto middle = first + half;
809
+ if (c(*middle, key1)) {
810
+ first = middle + 1;
811
+ half = len - half - 1;
812
+ } else if (c(*middle, key2)) {
813
+ second = middle + (len & 1);
814
+ len = half;
815
+ break;
816
+ }
817
+ len = half;
818
+ }
819
+ while (len) {
820
+ auto half = len / 2;
821
+ auto middle1 = first + half;
822
+ auto middle2 = second + half;
823
+ if (c(*middle1, key1)) {
824
+ first = middle1 + (len & 1);
825
+ }
826
+ if (c(*middle2, key2)) {
827
+ second = middle2 + (len & 1);
828
+ }
829
+ len = half;
830
+ }
831
+ return std::make_pair(first, second);
832
+ }
833
+
834
+ template <typename Self, typename K>
835
+ static std::pair<self_iterator_t<Self>, self_iterator_t<Self>> find2_(
836
+ Self& self, K const& key1, K const& key2) {
837
+ auto end = self.end();
838
+ auto its = lower_bound2_(self, key1, key2);
839
+ if (its.second != end) {
840
+ if (self.key_comp()(key1, *its.first)) {
841
+ its.first = end;
842
+ }
843
+ if (self.key_comp()(key2, *its.second)) {
844
+ its.second = end;
845
+ }
846
+ } else if (its.first != end && self.key_comp()(key1, *its.first)) {
847
+ its.first = end;
848
+ }
849
+ return its;
850
+ }
851
+ };
852
+
853
+ // Swap function that can be found using ADL.
854
+ template <class T, class C, class A, class G>
855
+ inline void swap(
856
+ sorted_vector_set<T, C, A, G>& a, sorted_vector_set<T, C, A, G>& b) {
857
+ return a.swap(b);
858
+ }
859
+
860
+ template <typename T>
861
+ inline constexpr bool is_sorted_vector_set_v =
862
+ is_instantiation_of_v<sorted_vector_set, T>;
863
+
864
+ template <typename T>
865
+ struct is_sorted_vector_set : std::bool_constant<is_sorted_vector_set_v<T>> {};
866
+
867
+ #if FOLLY_HAS_MEMORY_RESOURCE
868
+
869
+ namespace pmr {
870
+
871
+ template <
872
+ class T,
873
+ class Compare = std::less<T>,
874
+ class GrowthPolicy = void,
875
+ class Container =
876
+ std::vector<T, folly::detail::std_pmr::polymorphic_allocator<T>>>
877
+ using sorted_vector_set = folly::sorted_vector_set<
878
+ T,
879
+ Compare,
880
+ folly::detail::std_pmr::polymorphic_allocator<T>,
881
+ GrowthPolicy,
882
+ Container>;
883
+
884
+ } // namespace pmr
885
+
886
+ #endif
887
+
888
+ //////////////////////////////////////////////////////////////////////
889
+
890
+ /**
891
+ * A sorted_vector_map is similar to a sorted_vector_set but stores
892
+ * <key,value> pairs instead of single elements.
893
+ *
894
+ * @tparam Key Key type
895
+ * @tparam Value Value type
896
+ * @tparam Compare Function that can compare key types and impose
897
+ * a strict weak ordering over them.
898
+ * @tparam Allocator allocation policy
899
+ * @tparam GrowthPolicy policy object to control growth
900
+ */
901
+ template <
902
+ class Key,
903
+ class Value,
904
+ class Compare = std::less<Key>,
905
+ class Allocator = std::allocator<std::pair<Key, Value>>,
906
+ class GrowthPolicy = void,
907
+ class Container = std::vector<std::pair<Key, Value>, Allocator>>
908
+ class sorted_vector_map : detail::growth_policy_wrapper<GrowthPolicy> {
909
+ detail::growth_policy_wrapper<GrowthPolicy>& get_growth_policy() {
910
+ return *this;
911
+ }
912
+
913
+ template <typename K, typename V, typename C = Compare>
914
+ using if_is_transparent =
915
+ _t<detail::sorted_vector_enable_if_is_transparent<void, C, K, V>>;
916
+
917
+ struct EBO;
918
+
919
+ public:
920
+ typedef Key key_type;
921
+ typedef Value mapped_type;
922
+ typedef typename Container::value_type value_type;
923
+ typedef Compare key_compare;
924
+ typedef Allocator allocator_type;
925
+ typedef Container container_type;
926
+
927
+ struct value_compare : private Compare {
928
+ bool operator()(const value_type& a, const value_type& b) const {
929
+ return Compare::operator()(a.first, b.first);
930
+ }
931
+
932
+ protected:
933
+ friend class sorted_vector_map;
934
+ explicit value_compare(const Compare& c) : Compare(c) {}
935
+ };
936
+
937
+ typedef typename Container::pointer pointer;
938
+ typedef typename Container::const_pointer const_pointer;
939
+ typedef typename Container::reference reference;
940
+ typedef typename Container::const_reference const_reference;
941
+ typedef typename Container::iterator iterator;
942
+ typedef typename Container::const_iterator const_iterator;
943
+ typedef typename Container::difference_type difference_type;
944
+ typedef typename Container::size_type size_type;
945
+ typedef typename Container::reverse_iterator reverse_iterator;
946
+ typedef typename Container::const_reverse_iterator const_reverse_iterator;
947
+ typedef detail::DirectMutationGuard<Container, value_compare>
948
+ direct_mutation_guard;
949
+
950
+ sorted_vector_map() noexcept(
951
+ std::is_nothrow_constructible<EBO, value_compare, Allocator>::value)
952
+ : m_(value_compare(Compare()), Allocator()) {}
953
+
954
+ sorted_vector_map(const sorted_vector_map&) = default;
955
+
956
+ sorted_vector_map(const sorted_vector_map& other, const Allocator& alloc)
957
+ : m_(other.m_, alloc) {}
958
+
959
+ sorted_vector_map(sorted_vector_map&&) = default;
960
+
961
+ sorted_vector_map(sorted_vector_map&& other, const Allocator& alloc) noexcept(
962
+ std::is_nothrow_constructible<EBO, EBO&&, const Allocator&>::value)
963
+ : m_(std::move(other.m_), alloc) {}
964
+
965
+ explicit sorted_vector_map(const Allocator& alloc)
966
+ : m_(value_compare(Compare()), alloc) {}
967
+
968
+ explicit sorted_vector_map(
969
+ const Compare& comp, const Allocator& alloc = Allocator())
970
+ : m_(value_compare(comp), alloc) {}
971
+
972
+ template <class InputIterator>
973
+ explicit sorted_vector_map(
974
+ InputIterator first,
975
+ InputIterator last,
976
+ const Compare& comp = Compare(),
977
+ const Allocator& alloc = Allocator())
978
+ : m_(value_compare(comp), alloc) {
979
+ insert(first, last);
980
+ }
981
+
982
+ template <class InputIterator>
983
+ sorted_vector_map(
984
+ InputIterator first, InputIterator last, const Allocator& alloc)
985
+ : m_(value_compare(Compare()), alloc) {
986
+ insert(first, last);
987
+ }
988
+
989
+ /* implicit */ sorted_vector_map(
990
+ std::initializer_list<value_type> list,
991
+ const Compare& comp = Compare(),
992
+ const Allocator& alloc = Allocator())
993
+ : m_(value_compare(comp), alloc) {
994
+ insert(list.begin(), list.end());
995
+ }
996
+
997
+ sorted_vector_map(
998
+ std::initializer_list<value_type> list, const Allocator& alloc)
999
+ : m_(value_compare(Compare()), alloc) {
1000
+ insert(list.begin(), list.end());
1001
+ }
1002
+
1003
+ // Construct a sorted_vector_map by stealing the storage of a prefilled
1004
+ // container. The container need not be sorted already. This supports
1005
+ // bulk construction of sorted_vector_map with zero allocations, not counting
1006
+ // those performed by the caller. (The iterator range constructor performs at
1007
+ // least one allocation).
1008
+ //
1009
+ // Note that `sorted_vector_map(const Container& container)` is not provided,
1010
+ // since the purpose of this constructor is to avoid an unnecessary copy.
1011
+ explicit sorted_vector_map(
1012
+ Container&& container, const Compare& comp = Compare())
1013
+ : sorted_vector_map(
1014
+ sorted_unique,
1015
+ detail::as_sorted_unique(std::move(container), value_compare(comp)),
1016
+ comp) {}
1017
+
1018
+ // Construct a sorted_vector_map by stealing the storage of a prefilled
1019
+ // container. Its elements must be sorted and unique, as sorted_unique_t
1020
+ // hints. Supports bulk construction of sorted_vector_map with zero
1021
+ // allocations, not counting those performed by the caller. (The iterator
1022
+ // range constructor performs at least one allocation).
1023
+ //
1024
+ // Note that `sorted_vector_map(sorted_unique_t, const Container& container)`
1025
+ // is not provided, since the purpose of this constructor is to avoid an extra
1026
+ // copy.
1027
+ sorted_vector_map(
1028
+ sorted_unique_t,
1029
+ Container&& container,
1030
+ const Compare& comp = Compare()) noexcept(std::
1031
+ is_nothrow_constructible<
1032
+ EBO,
1033
+ value_compare,
1034
+ Container&&>::value)
1035
+ : m_(value_compare(comp), std::move(container)) {
1036
+ assert(detail::is_sorted_unique(
1037
+ m_.cont_.begin(), m_.cont_.end(), value_comp()));
1038
+ }
1039
+
1040
+ Allocator get_allocator() const { return m_.cont_.get_allocator(); }
1041
+
1042
+ const Container& get_container() const noexcept { return m_.cont_; }
1043
+
1044
+ /**
1045
+ * Directly mutate the container.
1046
+ *
1047
+ * Get a guarded reference to the underlying container for direct mutation.
1048
+ * sorted_unique_t signals that user will make sure that after the
1049
+ * modification the container will have its values as sorted-unique
1050
+ * (conforming to container's value_comp). Violating this assumption will
1051
+ * result in undefined behavior.
1052
+ *
1053
+ * This function is not safe to use concurrently with other functions.
1054
+ */
1055
+ direct_mutation_guard get_container_for_direct_mutation(
1056
+ sorted_unique_t) noexcept {
1057
+ return direct_mutation_guard{
1058
+ m_.cont_, value_comp(), /* range_is_sorted_unique */ true};
1059
+ }
1060
+
1061
+ /**
1062
+ * Directly mutate the container.
1063
+ *
1064
+ * Get a guarded reference to the underlying container for direct mutation.
1065
+ * The container will initially be sorted and unique. You are not required to
1066
+ * maintain the sorted-unique invariant while mutating. When the guard is
1067
+ * released, it will sort and unique-ify the container.
1068
+ *
1069
+ * This function is not safe to use concurrently with other functions.
1070
+ */
1071
+ direct_mutation_guard get_container_for_direct_mutation() noexcept {
1072
+ return direct_mutation_guard{
1073
+ m_.cont_, value_comp(), /* range_is_sorted_unique */ false};
1074
+ }
1075
+
1076
+ sorted_vector_map& operator=(const sorted_vector_map& other) = default;
1077
+
1078
+ sorted_vector_map& operator=(sorted_vector_map&& other) = default;
1079
+
1080
+ sorted_vector_map& operator=(std::initializer_list<value_type> ilist) {
1081
+ clear();
1082
+ insert(ilist.begin(), ilist.end());
1083
+ return *this;
1084
+ }
1085
+
1086
+ key_compare key_comp() const { return m_; }
1087
+ value_compare value_comp() const { return m_; }
1088
+
1089
+ iterator begin() { return m_.cont_.begin(); }
1090
+ iterator end() { return m_.cont_.end(); }
1091
+ const_iterator cbegin() const { return m_.cont_.cbegin(); }
1092
+ const_iterator begin() const { return m_.cont_.begin(); }
1093
+ const_iterator cend() const { return m_.cont_.cend(); }
1094
+ const_iterator end() const { return m_.cont_.end(); }
1095
+ reverse_iterator rbegin() { return m_.cont_.rbegin(); }
1096
+ reverse_iterator rend() { return m_.cont_.rend(); }
1097
+ const_reverse_iterator crbegin() const { return m_.cont_.crbegin(); }
1098
+ const_reverse_iterator rbegin() const { return m_.cont_.rbegin(); }
1099
+ const_reverse_iterator crend() const { return m_.cont_.crend(); }
1100
+ const_reverse_iterator rend() const { return m_.cont_.rend(); }
1101
+
1102
+ void clear() { return m_.cont_.clear(); }
1103
+ size_type size() const { return m_.cont_.size(); }
1104
+ size_type max_size() const { return m_.cont_.max_size(); }
1105
+ bool empty() const { return m_.cont_.empty(); }
1106
+ void reserve(size_type s) { return m_.cont_.reserve(s); }
1107
+ void shrink_to_fit() { m_.cont_.shrink_to_fit(); }
1108
+ size_type capacity() const { return m_.cont_.capacity(); }
1109
+
1110
+ std::pair<iterator, bool> insert(const value_type& value) {
1111
+ iterator it = lower_bound(value.first);
1112
+ if (it == end() || value_comp()(value, *it)) {
1113
+ it = get_growth_policy().increase_capacity(m_.cont_, it);
1114
+ return std::make_pair(m_.cont_.emplace(it, value), true);
1115
+ }
1116
+ return std::make_pair(it, false);
1117
+ }
1118
+
1119
+ std::pair<iterator, bool> insert(value_type&& value) {
1120
+ iterator it = lower_bound(value.first);
1121
+ if (it == end() || value_comp()(value, *it)) {
1122
+ it = get_growth_policy().increase_capacity(m_.cont_, it);
1123
+ return std::make_pair(m_.cont_.emplace(it, std::move(value)), true);
1124
+ }
1125
+ return std::make_pair(it, false);
1126
+ }
1127
+
1128
+ iterator insert(const_iterator hint, const value_type& value) {
1129
+ return detail::insert_with_hint(
1130
+ *this, m_.cont_, hint, value, get_growth_policy());
1131
+ }
1132
+
1133
+ iterator insert(const_iterator hint, value_type&& value) {
1134
+ return detail::insert_with_hint(
1135
+ *this, m_.cont_, hint, std::move(value), get_growth_policy());
1136
+ }
1137
+
1138
+ template <class InputIterator>
1139
+ void insert(InputIterator first, InputIterator last) {
1140
+ detail::bulk_insert(*this, m_.cont_, first, last);
1141
+ }
1142
+
1143
+ // If [first, last) is known to be sorted and unique according to the
1144
+ // comparator (for example if the range comes from a sorted container of the
1145
+ // same type) this version can save unnecessary operations, especially if
1146
+ // *this is empty.
1147
+ template <class InputIterator>
1148
+ void insert(sorted_unique_t, InputIterator first, InputIterator last) {
1149
+ detail::bulk_insert(
1150
+ *this, m_.cont_, first, last, /* range_is_sorted_unique */ true);
1151
+ }
1152
+
1153
+ void insert(std::initializer_list<value_type> ilist) {
1154
+ insert(ilist.begin(), ilist.end());
1155
+ }
1156
+
1157
+ // emplace isn't better than insert for sorted_vector_map, but aids
1158
+ // compatibility
1159
+ template <typename... Args>
1160
+ std::pair<iterator, bool> emplace(Args&&... args) {
1161
+ folly::aligned_storage_for_t<value_type> b;
1162
+ value_type* p = static_cast<value_type*>(static_cast<void*>(&b));
1163
+ auto a = get_allocator();
1164
+ std::allocator_traits<allocator_type>::construct(
1165
+ a, p, std::forward<Args>(args)...);
1166
+ auto g = makeGuard(
1167
+ [&]() { std::allocator_traits<allocator_type>::destroy(a, p); });
1168
+ return insert(std::move(*p));
1169
+ }
1170
+
1171
+ std::pair<iterator, bool> emplace(const value_type& value) {
1172
+ return insert(value);
1173
+ }
1174
+
1175
+ std::pair<iterator, bool> emplace(value_type&& value) {
1176
+ return insert(std::move(value));
1177
+ }
1178
+
1179
+ // emplace_hint isn't better than insert for sorted_vector_set, but aids
1180
+ // compatibility
1181
+ template <typename... Args>
1182
+ iterator emplace_hint(const_iterator hint, Args&&... args) {
1183
+ folly::aligned_storage_for_t<value_type> b;
1184
+ value_type* p = static_cast<value_type*>(static_cast<void*>(&b));
1185
+ auto a = get_allocator();
1186
+ std::allocator_traits<allocator_type>::construct(
1187
+ a, p, std::forward<Args>(args)...);
1188
+ auto g = makeGuard(
1189
+ [&]() { std::allocator_traits<allocator_type>::destroy(a, p); });
1190
+ return insert(hint, std::move(*p));
1191
+ }
1192
+
1193
+ iterator emplace_hint(const_iterator hint, const value_type& value) {
1194
+ return insert(hint, value);
1195
+ }
1196
+
1197
+ iterator emplace_hint(const_iterator hint, value_type&& value) {
1198
+ return insert(hint, std::move(value));
1199
+ }
1200
+
1201
+ template <typename... Args>
1202
+ std::pair<iterator, bool> try_emplace(key_type&& k, Args&&... args) {
1203
+ return try_emplace_impl(std::move(k), std::forward<Args>(args)...);
1204
+ }
1205
+
1206
+ template <typename... Args>
1207
+ std::pair<iterator, bool> try_emplace(const key_type& k, Args&&... args) {
1208
+ return try_emplace_impl(k, std::forward<Args>(args)...);
1209
+ }
1210
+
1211
+ template <typename M>
1212
+ std::pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj) {
1213
+ auto itAndInserted = try_emplace(k, std::forward<M>(obj));
1214
+ if (!itAndInserted.second) {
1215
+ itAndInserted.first->second = std::forward<M>(obj);
1216
+ }
1217
+ return itAndInserted;
1218
+ }
1219
+
1220
+ template <typename M>
1221
+ std::pair<iterator, bool> insert_or_assign(key_type&& k, M&& obj) {
1222
+ auto itAndInserted = try_emplace(std::move(k), std::forward<M>(obj));
1223
+ if (!itAndInserted.second) {
1224
+ itAndInserted.first->second = std::forward<M>(obj);
1225
+ }
1226
+ return itAndInserted;
1227
+ }
1228
+
1229
+ template <class M>
1230
+ iterator insert_or_assign(const_iterator hint, const key_type& k, M&& obj) {
1231
+ return insert_or_assign_impl(hint, k, std::forward<M>(obj));
1232
+ }
1233
+
1234
+ template <class M>
1235
+ iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj) {
1236
+ return insert_or_assign_impl(hint, std::move(k), std::forward<M>(obj));
1237
+ }
1238
+
1239
+ size_type erase(const key_type& key) {
1240
+ iterator it = find(key);
1241
+ if (it == end()) {
1242
+ return 0;
1243
+ }
1244
+ m_.cont_.erase(it);
1245
+ return 1;
1246
+ }
1247
+
1248
+ iterator erase(const_iterator it) { return m_.cont_.erase(it); }
1249
+
1250
+ iterator erase(const_iterator first, const_iterator last) {
1251
+ return m_.cont_.erase(first, last);
1252
+ }
1253
+
1254
+ template <class Predicate>
1255
+ friend size_type erase_if(sorted_vector_map& container, Predicate predicate) {
1256
+ auto& c = container.m_.cont_;
1257
+ const auto preEraseSize = c.size();
1258
+ c.erase(std::remove_if(c.begin(), c.end(), std::ref(predicate)), c.end());
1259
+ return preEraseSize - c.size();
1260
+ }
1261
+
1262
+ iterator find(const key_type& key) { return find_(*this, key); }
1263
+
1264
+ const_iterator find(const key_type& key) const { return find_(*this, key); }
1265
+
1266
+ template <typename K>
1267
+ if_is_transparent<K, iterator> find(const K& key) {
1268
+ return find_(*this, key);
1269
+ }
1270
+
1271
+ template <typename K>
1272
+ if_is_transparent<K, const_iterator> find(const K& key) const {
1273
+ return find_(*this, key);
1274
+ }
1275
+
1276
+ std::pair<iterator, iterator> find(
1277
+ const key_type& key1, const key_type& key2) {
1278
+ if (key_comp()(key2, key1)) {
1279
+ auto iterators = find2_(*this, key2, key1);
1280
+ access::swap(iterators.first, iterators.second);
1281
+ return iterators;
1282
+ } else {
1283
+ return find2_(*this, key1, key2);
1284
+ }
1285
+ }
1286
+
1287
+ std::pair<const_iterator, const_iterator> find(
1288
+ const key_type& key1, const key_type& key2) const {
1289
+ if (key_comp()(key2, key1)) {
1290
+ auto iterators = find2_(*this, key2, key1);
1291
+ access::swap(iterators.first, iterators.second);
1292
+ return iterators;
1293
+ } else {
1294
+ return find2_(*this, key1, key2);
1295
+ }
1296
+ }
1297
+
1298
+ template <typename K>
1299
+ std::pair<if_is_transparent<K, iterator>, if_is_transparent<K, iterator>>
1300
+ find(const K& key1, const K& key2) {
1301
+ if (key_comp()(key2, key1)) {
1302
+ auto iterators = find2_(*this, key2, key1);
1303
+ access::swap(iterators.first, iterators.second);
1304
+ return iterators;
1305
+ } else {
1306
+ return find2_(*this, key1, key2);
1307
+ }
1308
+ }
1309
+
1310
+ template <typename K>
1311
+ std::pair<
1312
+ if_is_transparent<K, const_iterator>,
1313
+ if_is_transparent<K, const_iterator>>
1314
+ find(const K& key1, const K& key2) const {
1315
+ if (key_comp()(key2, key1)) {
1316
+ auto iterators = find2_(*this, key2, key1);
1317
+ access::swap(iterators.first, iterators.second);
1318
+ return iterators;
1319
+ } else {
1320
+ return find2_(*this, key1, key2);
1321
+ }
1322
+ }
1323
+
1324
+ mapped_type& at(const key_type& key) {
1325
+ iterator it = find(key);
1326
+ if (it != end()) {
1327
+ return it->second;
1328
+ }
1329
+ throw_exception<std::out_of_range>("sorted_vector_map::at");
1330
+ }
1331
+
1332
+ const mapped_type& at(const key_type& key) const {
1333
+ const_iterator it = find(key);
1334
+ if (it != end()) {
1335
+ return it->second;
1336
+ }
1337
+ throw_exception<std::out_of_range>("sorted_vector_map::at");
1338
+ }
1339
+
1340
+ size_type count(const key_type& key) const {
1341
+ return find(key) == end() ? 0 : 1;
1342
+ }
1343
+
1344
+ template <typename K>
1345
+ if_is_transparent<K, size_type> count(const K& key) const {
1346
+ return find(key) == end() ? 0 : 1;
1347
+ }
1348
+
1349
+ bool contains(const key_type& key) const { return find(key) != end(); }
1350
+
1351
+ template <typename K>
1352
+ if_is_transparent<K, bool> contains(const K& key) const {
1353
+ return find(key) != end();
1354
+ }
1355
+
1356
+ iterator lower_bound(const key_type& key) { return lower_bound(*this, key); }
1357
+
1358
+ const_iterator lower_bound(const key_type& key) const {
1359
+ return lower_bound(*this, key);
1360
+ }
1361
+
1362
+ template <typename K>
1363
+ if_is_transparent<K, iterator> lower_bound(const K& key) {
1364
+ return lower_bound(*this, key);
1365
+ }
1366
+
1367
+ template <typename K>
1368
+ if_is_transparent<K, const_iterator> lower_bound(const K& key) const {
1369
+ return lower_bound(*this, key);
1370
+ }
1371
+
1372
+ iterator upper_bound(const key_type& key) { return upper_bound(*this, key); }
1373
+
1374
+ const_iterator upper_bound(const key_type& key) const {
1375
+ return upper_bound(*this, key);
1376
+ }
1377
+
1378
+ template <typename K>
1379
+ if_is_transparent<K, iterator> upper_bound(const K& key) {
1380
+ return upper_bound(*this, key);
1381
+ }
1382
+
1383
+ template <typename K>
1384
+ if_is_transparent<K, const_iterator> upper_bound(const K& key) const {
1385
+ return upper_bound(*this, key);
1386
+ }
1387
+
1388
+ std::pair<iterator, iterator> equal_range(const key_type& key) {
1389
+ return equal_range(*this, key);
1390
+ }
1391
+
1392
+ std::pair<const_iterator, const_iterator> equal_range(
1393
+ const key_type& key) const {
1394
+ return equal_range(*this, key);
1395
+ }
1396
+
1397
+ template <typename K>
1398
+ if_is_transparent<K, std::pair<iterator, iterator>> equal_range(
1399
+ const K& key) {
1400
+ return equal_range(*this, key);
1401
+ }
1402
+
1403
+ template <typename K>
1404
+ if_is_transparent<K, std::pair<const_iterator, const_iterator>> equal_range(
1405
+ const K& key) const {
1406
+ return equal_range(*this, key);
1407
+ }
1408
+
1409
+ // Nothrow as long as swap() on the Compare type is nothrow.
1410
+ void swap(sorted_vector_map& o) {
1411
+ using std::swap; // Allow ADL for swap(); fall back to std::swap().
1412
+ Compare& a = m_;
1413
+ Compare& b = o.m_;
1414
+ swap(a, b);
1415
+ m_.cont_.swap(o.m_.cont_);
1416
+ }
1417
+
1418
+ mapped_type& operator[](const key_type& key) {
1419
+ iterator it = lower_bound(key);
1420
+ if (it == end() || key_comp()(key, it->first)) {
1421
+ return insert(it, value_type(key, mapped_type()))->second;
1422
+ }
1423
+ return it->second;
1424
+ }
1425
+
1426
+ bool operator==(const sorted_vector_map& other) const {
1427
+ return m_.cont_ == other.m_.cont_;
1428
+ }
1429
+ bool operator!=(const sorted_vector_map& other) const {
1430
+ return !operator==(other);
1431
+ }
1432
+
1433
+ bool operator<(const sorted_vector_map& other) const {
1434
+ return m_.cont_ < other.m_.cont_;
1435
+ }
1436
+ bool operator>(const sorted_vector_map& other) const { return other < *this; }
1437
+ bool operator<=(const sorted_vector_map& other) const {
1438
+ return !operator>(other);
1439
+ }
1440
+ bool operator>=(const sorted_vector_map& other) const {
1441
+ return !operator<(other);
1442
+ }
1443
+
1444
+ const value_type* data() const noexcept { return m_.cont_.data(); }
1445
+
1446
+ private:
1447
+ // This is to get the empty base optimization; see the comment in
1448
+ // sorted_vector_set.
1449
+ struct EBO : value_compare {
1450
+ explicit EBO(const value_compare& c, const Allocator& alloc) noexcept(
1451
+ std::is_nothrow_default_constructible<Container>::value)
1452
+ : value_compare(c), cont_(alloc) {}
1453
+ EBO(const EBO& other, const Allocator& alloc) noexcept(
1454
+ std::is_nothrow_constructible<
1455
+ Container,
1456
+ const Container&,
1457
+ const Allocator&>::value)
1458
+ : value_compare(static_cast<const value_compare&>(other)),
1459
+ cont_(other.cont_, alloc) {}
1460
+ EBO(EBO&& other, const Allocator& alloc) noexcept(
1461
+ std::is_nothrow_constructible<
1462
+ Container,
1463
+ Container&&,
1464
+ const Allocator&>::value)
1465
+ : value_compare(static_cast<value_compare&&>(other)),
1466
+ cont_(std::move(other.cont_), alloc) {}
1467
+ EBO(const Compare& c, Container&& cont) noexcept(
1468
+ std::is_nothrow_move_constructible<Container>::value)
1469
+ : value_compare(c), cont_(std::move(cont)) {}
1470
+ Container cont_;
1471
+ } m_;
1472
+
1473
+ template <typename Self>
1474
+ using self_iterator_t = _t<
1475
+ std::conditional<std::is_const<Self>::value, const_iterator, iterator>>;
1476
+
1477
+ template <typename Self, typename K>
1478
+ static self_iterator_t<Self> find_(Self& self, K const& key) {
1479
+ auto end = self.end();
1480
+ auto it = self.lower_bound(key);
1481
+ if (it == end || !self.key_comp()(key, it->first)) {
1482
+ return it;
1483
+ }
1484
+ return end;
1485
+ }
1486
+
1487
+ template <typename Self, typename K>
1488
+ static self_iterator_t<Self> lower_bound(Self& self, K const& key) {
1489
+ auto f = [c = self.key_comp()](auto const& a, K const& b) {
1490
+ return c(a.first, b);
1491
+ };
1492
+ return std::lower_bound(self.begin(), self.end(), key, f);
1493
+ }
1494
+
1495
+ template <typename Self, typename K>
1496
+ static self_iterator_t<Self> upper_bound(Self& self, K const& key) {
1497
+ auto f = [c = self.key_comp()](K const& a, auto const& b) {
1498
+ return c(a, b.first);
1499
+ };
1500
+ return std::upper_bound(self.begin(), self.end(), key, f);
1501
+ }
1502
+
1503
+ template <typename Self, typename K>
1504
+ static std::pair<self_iterator_t<Self>, self_iterator_t<Self>> equal_range(
1505
+ Self& self, K const& key) {
1506
+ // Note: std::equal_range can't be passed a functor that takes
1507
+ // argument types different from the iterator value_type, so we
1508
+ // have to do this.
1509
+ return {lower_bound(self, key), upper_bound(self, key)};
1510
+ }
1511
+
1512
+ template <typename Self, typename K>
1513
+ static std::pair<self_iterator_t<Self>, self_iterator_t<Self>> lower_bound2_(
1514
+ Self& self, K const& key1, K const& key2) {
1515
+ auto len = self.size();
1516
+ auto first = self.begin(), second = self.begin();
1517
+ auto c = self.key_comp();
1518
+ assert(!c(key2, key1));
1519
+ while (true) {
1520
+ if (len == 0) {
1521
+ return std::make_pair(first, first);
1522
+ }
1523
+ auto half = len / 2;
1524
+ auto middle = first + half;
1525
+ if (c(middle->first, key1)) {
1526
+ first = middle + 1;
1527
+ half = len - half - 1;
1528
+ } else if (c(middle->first, key2)) {
1529
+ second = middle + (len & 1);
1530
+ len = half;
1531
+ break;
1532
+ }
1533
+ len = half;
1534
+ }
1535
+ while (len) {
1536
+ auto half = len / 2;
1537
+ auto middle1 = first + half;
1538
+ auto middle2 = second + half;
1539
+ if (c(middle1->first, key1)) {
1540
+ first = middle1 + (len & 1);
1541
+ }
1542
+ if (c(middle2->first, key2)) {
1543
+ second = middle2 + (len & 1);
1544
+ }
1545
+ len = half;
1546
+ }
1547
+ return std::make_pair(first, second);
1548
+ }
1549
+
1550
+ template <typename Self, typename K>
1551
+ static std::pair<self_iterator_t<Self>, self_iterator_t<Self>> find2_(
1552
+ Self& self, K const& key1, K const& key2) {
1553
+ auto end = self.end();
1554
+ auto its = lower_bound2_(self, key1, key2);
1555
+ if (its.second != end) {
1556
+ if (self.key_comp()(key1, its.first->first)) {
1557
+ its.first = end;
1558
+ }
1559
+ if (self.key_comp()(key2, its.second->first)) {
1560
+ its.second = end;
1561
+ }
1562
+ } else if (its.first != end && self.key_comp()(key1, its.first->first)) {
1563
+ its.first = end;
1564
+ }
1565
+ return its;
1566
+ }
1567
+
1568
+ template <typename K, typename... Args>
1569
+ std::pair<iterator, bool> try_emplace_impl(K&& key, Args&&... args) {
1570
+ iterator it = lower_bound(key);
1571
+ if (it == end() || key_comp()(key, it->first)) {
1572
+ return std::make_pair(
1573
+ emplace_hint(
1574
+ it,
1575
+ std::piecewise_construct,
1576
+ std::forward_as_tuple(std::forward<K>(key)),
1577
+ std::forward_as_tuple(std::forward<Args>(args)...)),
1578
+ true);
1579
+ }
1580
+ return std::make_pair(it, false);
1581
+ }
1582
+
1583
+ template <class K, class M>
1584
+ iterator insert_or_assign_impl(const_iterator hint, K&& k, M&& obj) {
1585
+ if (hint == end() || key_comp()(k, hint->first)) {
1586
+ if (hint == begin() || key_comp()((hint - 1)->first, k)) {
1587
+ auto it = get_growth_policy().increase_capacity(m_.cont_, hint);
1588
+ return m_.cont_.emplace(
1589
+ it, std::make_pair(std::forward<K>(k), std::forward<M>(obj)));
1590
+ } else {
1591
+ return insert_or_assign(std::forward<K>(k), std::forward<M>(obj)).first;
1592
+ }
1593
+ }
1594
+
1595
+ if (key_comp()(hint->first, k)) {
1596
+ if (hint + 1 == end() || key_comp()(k, (hint + 1)->first)) {
1597
+ auto it = get_growth_policy().increase_capacity(m_.cont_, hint + 1);
1598
+ return m_.cont_.emplace(
1599
+ it, std::make_pair(std::forward<K>(k), std::forward<M>(obj)));
1600
+ } else {
1601
+ return insert_or_assign(std::forward<K>(k), std::forward<M>(obj)).first;
1602
+ }
1603
+ }
1604
+
1605
+ // Value and *hint did not compare, so they are equal keys.
1606
+ auto it = begin() + std::distance(cbegin(), hint);
1607
+ it->second = std::forward<M>(obj);
1608
+ return it;
1609
+ }
1610
+ };
1611
+
1612
+ // Swap function that can be found using ADL.
1613
+ template <class K, class V, class C, class A, class G>
1614
+ inline void swap(
1615
+ sorted_vector_map<K, V, C, A, G>& a, sorted_vector_map<K, V, C, A, G>& b) {
1616
+ return a.swap(b);
1617
+ }
1618
+
1619
+ template <typename T>
1620
+ inline constexpr bool is_sorted_vector_map_v =
1621
+ is_instantiation_of_v<sorted_vector_map, T>;
1622
+
1623
+ template <typename T>
1624
+ struct is_sorted_vector_map : std::bool_constant<is_sorted_vector_map_v<T>> {};
1625
+
1626
+ #if FOLLY_HAS_MEMORY_RESOURCE
1627
+
1628
+ namespace pmr {
1629
+
1630
+ template <
1631
+ class Key,
1632
+ class Value,
1633
+ class Compare = std::less<Key>,
1634
+ class GrowthPolicy = void,
1635
+ class Container = std::vector<
1636
+ std::pair<Key, Value>,
1637
+ folly::detail::std_pmr::polymorphic_allocator<std::pair<Key, Value>>>>
1638
+ using sorted_vector_map = folly::sorted_vector_map<
1639
+ Key,
1640
+ Value,
1641
+ Compare,
1642
+ folly::detail::std_pmr::polymorphic_allocator<std::pair<Key, Value>>,
1643
+ GrowthPolicy,
1644
+ Container>;
1645
+
1646
+ } // namespace pmr
1647
+
1648
+ #endif
1649
+
1650
+ //////////////////////////////////////////////////////////////////////
1651
+
1652
+ } // namespace folly