react-native-windows 0.83.0 → 0.83.3

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 (954) hide show
  1. package/Common/unicode.cpp +36 -0
  2. package/Common/unicode.h +8 -0
  3. package/Directory.Build.props +2 -17
  4. package/Folly/ThreadNameStub.cpp +4 -6
  5. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +17 -4
  6. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +6 -4
  7. package/Microsoft.ReactNative/Fabric/Composition/TextDrawing.cpp +1 -1
  8. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +8 -4
  9. package/Microsoft.ReactNative/Fabric/platform/react/renderer/textlayoutmanager/WindowsTextLayoutManager.cpp +1 -1
  10. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +4 -9
  11. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -3
  12. package/Microsoft.ReactNative/ReactNativeAppBuilder.idl +3 -0
  13. package/Microsoft.ReactNative/Utils/LocalBundleReader.cpp +33 -25
  14. package/Microsoft.ReactNative/Utils/LocalBundleReader.h +5 -3
  15. package/Microsoft.ReactNative/Utils/UwpScriptStore.cpp +2 -2
  16. package/Microsoft.ReactNative/Utils/UwpScriptStore.h +3 -2
  17. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +16 -0
  18. package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +3 -3
  19. package/Microsoft.ReactNative.Managed.CodeGen/Microsoft.ReactNative.Managed.CodeGen.csproj +10 -10
  20. package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Debug.pubxml +1 -1
  21. package/Microsoft.ReactNative.Managed.CodeGen/Properties/PublishProfiles/DeployAsTool-Release.pubxml +1 -1
  22. package/PropertySheets/CIBuildOptimizations.props +2 -2
  23. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  24. package/PropertySheets/JSEngine.props +1 -1
  25. package/PropertySheets/NuGet.LockFile.props +9 -1
  26. package/PropertySheets/React.Cpp.props +7 -6
  27. package/PropertySheets/WinUI.props +4 -3
  28. package/ReactCommon/ReactCommon.vcxproj +0 -5
  29. package/Scripts/ConfigureYarnPackageAgeGate.ps1 +25 -0
  30. package/Scripts/EnableInternalWinAppSDKFeed.ps1 +12 -5
  31. package/Scripts/JustMyXaml.ps1 +8 -8
  32. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +103 -6
  33. package/Scripts/RunRnwInitWindows.js +37 -0
  34. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -37
  35. package/Scripts/UnitTest.ps1 +3 -1
  36. package/Scripts/UpdateNightlyDependencies.ps1 +47 -0
  37. package/Scripts/creaternwapp.cmd +35 -12
  38. package/Scripts/creaternwlib.cmd +41 -18
  39. package/Scripts/rnw-dependencies.ps1 +15 -16
  40. package/Shared/DevSupportManager.cpp +55 -48
  41. package/Shared/DevSupportManager.h +0 -1
  42. package/Shared/Modules/IWebSocketModuleContentHandler.h +15 -0
  43. package/Shared/Modules/WebSocketModule.cpp +8 -3
  44. package/Shared/Networking/DefaultBlobResource.cpp +37 -0
  45. package/Shared/Networking/DefaultBlobResource.h +12 -0
  46. package/Shared/Networking/WinRTWebSocketResource.h +5 -1
  47. package/Shared/Shared.vcxitems +2 -0
  48. package/{Folly → external}/.clang-format +0 -1
  49. package/external/External.vcxitems +10 -0
  50. package/external/fast-float/.syncignore +10 -0
  51. package/external/fast-float/LICENSE-APACHE +190 -0
  52. package/external/fast-float/LICENSE-BOOST +23 -0
  53. package/external/fast-float/LICENSE-MIT +27 -0
  54. package/external/fast-float/README.md +545 -0
  55. package/external/fast-float/cgmanifest.json +15 -0
  56. package/external/fast-float/fast-float.vcxitems +14 -0
  57. package/external/fast-float/include/fast_float/ascii_number.h +588 -0
  58. package/external/fast-float/include/fast_float/bigint.h +638 -0
  59. package/external/fast-float/include/fast_float/constexpr_feature_detect.h +46 -0
  60. package/external/fast-float/include/fast_float/decimal_to_binary.h +212 -0
  61. package/external/fast-float/include/fast_float/digit_comparison.h +457 -0
  62. package/external/fast-float/include/fast_float/fast_float.h +59 -0
  63. package/external/fast-float/include/fast_float/fast_table.h +708 -0
  64. package/external/fast-float/include/fast_float/float_common.h +1240 -0
  65. package/external/fast-float/include/fast_float/parse_number.h +399 -0
  66. package/external/fast-float/sync-config.json +8 -0
  67. package/external/fmt/.syncignore +10 -0
  68. package/external/fmt/CONTRIBUTING.md +20 -0
  69. package/external/fmt/LICENSE +27 -0
  70. package/external/fmt/README.md +484 -0
  71. package/external/fmt/doc/ChangeLog-old.md +3290 -0
  72. package/external/fmt/doc/api.md +650 -0
  73. package/external/fmt/doc/fmt.css +61 -0
  74. package/external/fmt/doc/fmt.js +4 -0
  75. package/external/fmt/doc/get-started.md +222 -0
  76. package/external/fmt/doc/index.md +151 -0
  77. package/external/fmt/doc/perf.svg +1 -0
  78. package/external/fmt/doc/python-license.txt +290 -0
  79. package/external/fmt/doc/syntax.md +887 -0
  80. package/external/fmt/fmt.vcxitems +28 -0
  81. package/external/fmt/include/fmt/args.h +228 -0
  82. package/external/fmt/include/fmt/base.h +3077 -0
  83. package/external/fmt/include/fmt/chrono.h +2432 -0
  84. package/external/fmt/include/fmt/color.h +612 -0
  85. package/external/fmt/include/fmt/compile.h +529 -0
  86. package/external/fmt/include/fmt/core.h +5 -0
  87. package/external/fmt/include/fmt/format-inl.h +1928 -0
  88. package/external/fmt/include/fmt/format.h +4427 -0
  89. package/external/fmt/include/fmt/os.h +439 -0
  90. package/external/fmt/include/fmt/ostream.h +211 -0
  91. package/external/fmt/include/fmt/printf.h +656 -0
  92. package/external/fmt/include/fmt/ranges.h +882 -0
  93. package/external/fmt/include/fmt/std.h +699 -0
  94. package/external/fmt/include/fmt/xchar.h +322 -0
  95. package/external/fmt/src/fmt.cc +135 -0
  96. package/external/fmt/src/format.cc +43 -0
  97. package/external/fmt/src/os.cc +403 -0
  98. package/external/fmt/sync-config.json +8 -0
  99. package/external/folly/.syncignore +60 -0
  100. package/external/folly/LICENSE +200 -0
  101. package/external/folly/README.md +263 -0
  102. package/{fmt → external/folly/folly}/.clang-format +0 -1
  103. package/external/folly/folly/AtomicHashArray-inl.h +546 -0
  104. package/external/folly/folly/AtomicHashArray.h +431 -0
  105. package/external/folly/folly/AtomicHashMap-inl.h +653 -0
  106. package/external/folly/folly/AtomicHashMap.h +484 -0
  107. package/external/folly/folly/AtomicIntrusiveLinkedList.h +206 -0
  108. package/external/folly/folly/AtomicLinkedList.h +110 -0
  109. package/external/folly/folly/AtomicUnorderedMap.h +522 -0
  110. package/external/folly/folly/BUCK +1631 -0
  111. package/external/folly/folly/BUILD_MODE.bzl +72 -0
  112. package/external/folly/folly/Benchmark.cpp +986 -0
  113. package/external/folly/folly/Benchmark.h +680 -0
  114. package/external/folly/folly/BenchmarkUtil.h +47 -0
  115. package/external/folly/folly/Bits.h +17 -0
  116. package/external/folly/folly/CMakeLists.txt +110 -0
  117. package/external/folly/folly/CPortability.h +338 -0
  118. package/external/folly/folly/CancellationToken-inl.h +449 -0
  119. package/external/folly/folly/CancellationToken.cpp +250 -0
  120. package/external/folly/folly/CancellationToken.h +365 -0
  121. package/external/folly/folly/Chrono.h +132 -0
  122. package/external/folly/folly/ClockGettimeWrappers.cpp +93 -0
  123. package/external/folly/folly/ClockGettimeWrappers.h +29 -0
  124. package/external/folly/folly/ConcurrentBitSet.h +157 -0
  125. package/external/folly/folly/ConcurrentLazy.h +74 -0
  126. package/external/folly/folly/ConcurrentSkipList-inl.h +341 -0
  127. package/external/folly/folly/ConcurrentSkipList.h +824 -0
  128. package/external/folly/folly/ConstructorCallbackList.h +158 -0
  129. package/external/folly/folly/Conv.h +2026 -0
  130. package/external/folly/folly/CppAttributes.h +170 -0
  131. package/external/folly/folly/CpuId.h +297 -0
  132. package/external/folly/folly/DefaultKeepAliveExecutor.h +172 -0
  133. package/external/folly/folly/Demangle.cpp +255 -0
  134. package/external/folly/folly/Demangle.h +73 -0
  135. package/external/folly/folly/DiscriminatedPtr.h +236 -0
  136. package/external/folly/folly/DynamicConverter.h +17 -0
  137. package/external/folly/folly/Exception.h +150 -0
  138. package/external/folly/folly/ExceptionString.cpp +51 -0
  139. package/external/folly/folly/ExceptionString.h +33 -0
  140. package/external/folly/folly/ExceptionWrapper-inl.h +264 -0
  141. package/external/folly/folly/ExceptionWrapper.cpp +37 -0
  142. package/external/folly/folly/ExceptionWrapper.h +377 -0
  143. package/external/folly/folly/Executor.cpp +111 -0
  144. package/external/folly/folly/Executor.h +351 -0
  145. package/external/folly/folly/Expected.h +1725 -0
  146. package/external/folly/folly/FBString.h +2888 -0
  147. package/external/folly/folly/FBVector.h +17 -0
  148. package/external/folly/folly/File.cpp +180 -0
  149. package/external/folly/folly/File.h +177 -0
  150. package/external/folly/folly/FileUtil.cpp +378 -0
  151. package/external/folly/folly/FileUtil.h +332 -0
  152. package/external/folly/folly/Fingerprint.cpp +135 -0
  153. package/external/folly/folly/Fingerprint.h +289 -0
  154. package/external/folly/folly/FixedString.h +2965 -0
  155. package/external/folly/folly/FollyMemcpy.cpp +30 -0
  156. package/external/folly/folly/FollyMemcpy.h +23 -0
  157. package/external/folly/folly/FollyMemset.cpp +29 -0
  158. package/external/folly/folly/FollyMemset.h +25 -0
  159. package/external/folly/folly/Format-inl.h +1152 -0
  160. package/external/folly/folly/Format.cpp +429 -0
  161. package/external/folly/folly/Format.h +463 -0
  162. package/external/folly/folly/FormatArg.h +285 -0
  163. package/external/folly/folly/FormatTraits.h +65 -0
  164. package/external/folly/folly/Function.h +1159 -0
  165. package/external/folly/folly/GLog.h +85 -0
  166. package/external/folly/folly/GroupVarint.cpp +153 -0
  167. package/external/folly/folly/GroupVarint.h +630 -0
  168. package/external/folly/folly/Hash.h +20 -0
  169. package/external/folly/folly/IPAddress.cpp +490 -0
  170. package/external/folly/folly/IPAddress.h +667 -0
  171. package/external/folly/folly/IPAddressException.h +82 -0
  172. package/external/folly/folly/IPAddressV4.cpp +305 -0
  173. package/external/folly/folly/IPAddressV4.h +495 -0
  174. package/external/folly/folly/IPAddressV6.cpp +541 -0
  175. package/external/folly/folly/IPAddressV6.h +627 -0
  176. package/external/folly/folly/Indestructible.h +164 -0
  177. package/external/folly/folly/IndexedMemPool.h +550 -0
  178. package/external/folly/folly/IntrusiveList.h +17 -0
  179. package/external/folly/folly/Lazy.h +142 -0
  180. package/external/folly/folly/Likely.h +76 -0
  181. package/external/folly/folly/MPMCPipeline.h +280 -0
  182. package/external/folly/folly/MPMCQueue.h +1556 -0
  183. package/external/folly/folly/MacAddress.cpp +188 -0
  184. package/external/folly/folly/MacAddress.h +260 -0
  185. package/external/folly/folly/MapUtil.h +17 -0
  186. package/external/folly/folly/Math.h +258 -0
  187. package/external/folly/folly/MaybeManagedPtr.h +120 -0
  188. package/external/folly/folly/Memory.h +900 -0
  189. package/external/folly/folly/MicroLock.cpp +76 -0
  190. package/external/folly/folly/MicroLock.h +354 -0
  191. package/external/folly/folly/MicroSpinLock.h +17 -0
  192. package/external/folly/folly/MoveWrapper.h +76 -0
  193. package/external/folly/folly/ObserverContainer.h +1026 -0
  194. package/external/folly/folly/Optional.h +743 -0
  195. package/external/folly/folly/Overload.h +325 -0
  196. package/external/folly/folly/PackedSyncPtr.h +147 -0
  197. package/external/folly/folly/Padded.h +464 -0
  198. package/external/folly/folly/Poly-inl.h +230 -0
  199. package/external/folly/folly/Poly.h +1095 -0
  200. package/external/folly/folly/PolyException.h +43 -0
  201. package/external/folly/folly/Portability.h +644 -0
  202. package/external/folly/folly/Preprocessor.h +236 -0
  203. package/external/folly/folly/ProducerConsumerQueue.h +182 -0
  204. package/external/folly/folly/RWSpinLock.h +17 -0
  205. package/external/folly/folly/Random-inl.h +86 -0
  206. package/external/folly/folly/Random.cpp +184 -0
  207. package/external/folly/folly/Random.h +434 -0
  208. package/external/folly/folly/Range.h +1772 -0
  209. package/external/folly/folly/Replaceable.h +636 -0
  210. package/external/folly/folly/ScopeGuard.cpp +29 -0
  211. package/external/folly/folly/ScopeGuard.h +420 -0
  212. package/external/folly/folly/SharedMutex.cpp +81 -0
  213. package/external/folly/folly/SharedMutex.h +1751 -0
  214. package/external/folly/folly/Singleton-inl.h +332 -0
  215. package/external/folly/folly/Singleton.cpp +512 -0
  216. package/external/folly/folly/Singleton.h +891 -0
  217. package/external/folly/folly/SingletonThreadLocal.cpp +53 -0
  218. package/external/folly/folly/SingletonThreadLocal.h +263 -0
  219. package/external/folly/folly/SocketAddress.cpp +786 -0
  220. package/external/folly/folly/SocketAddress.h +768 -0
  221. package/external/folly/folly/SpinLock.h +55 -0
  222. package/external/folly/folly/String-inl.h +668 -0
  223. package/external/folly/folly/String.cpp +777 -0
  224. package/external/folly/folly/String.h +767 -0
  225. package/external/folly/folly/Subprocess.cpp +1142 -0
  226. package/external/folly/folly/Subprocess.h +1055 -0
  227. package/external/folly/folly/Synchronized.h +1833 -0
  228. package/external/folly/folly/SynchronizedPtr.h +106 -0
  229. package/external/folly/folly/ThreadCachedInt.h +175 -0
  230. package/external/folly/folly/ThreadLocal.h +478 -0
  231. package/external/folly/folly/TimeoutQueue.cpp +78 -0
  232. package/external/folly/folly/TimeoutQueue.h +123 -0
  233. package/external/folly/folly/TokenBucket.h +673 -0
  234. package/external/folly/folly/Traits.h +1442 -0
  235. package/external/folly/folly/Try-inl.h +372 -0
  236. package/external/folly/folly/Try.cpp +23 -0
  237. package/external/folly/folly/Try.h +728 -0
  238. package/external/folly/folly/UTF8String.h +56 -0
  239. package/external/folly/folly/Unicode.cpp +201 -0
  240. package/external/folly/folly/Unicode.h +94 -0
  241. package/external/folly/folly/Unit.h +65 -0
  242. package/external/folly/folly/Uri-inl.h +101 -0
  243. package/external/folly/folly/Uri.cpp +190 -0
  244. package/external/folly/folly/Uri.h +142 -0
  245. package/external/folly/folly/Utility.h +932 -0
  246. package/external/folly/folly/VERSION +1 -0
  247. package/external/folly/folly/Varint.h +230 -0
  248. package/external/folly/folly/VirtualExecutor.h +17 -0
  249. package/external/folly/folly/algorithm/simd/BUCK +47 -0
  250. package/external/folly/folly/algorithm/simd/Contains.cpp +42 -0
  251. package/external/folly/folly/algorithm/simd/Contains.h +116 -0
  252. package/external/folly/folly/algorithm/simd/FindFixed.h +301 -0
  253. package/external/folly/folly/algorithm/simd/Ignore.h +52 -0
  254. package/external/folly/folly/algorithm/simd/Movemask.h +207 -0
  255. package/external/folly/folly/algorithm/simd/detail/BUCK +70 -0
  256. package/external/folly/folly/algorithm/simd/detail/ContainsImpl.h +91 -0
  257. package/external/folly/folly/algorithm/simd/detail/SimdAnyOf.h +83 -0
  258. package/external/folly/folly/algorithm/simd/detail/SimdForEach.h +209 -0
  259. package/external/folly/folly/algorithm/simd/detail/SimdPlatform.h +445 -0
  260. package/external/folly/folly/algorithm/simd/detail/Traits.h +125 -0
  261. package/external/folly/folly/algorithm/simd/detail/UnrollUtils.h +126 -0
  262. package/external/folly/folly/base64.h +264 -0
  263. package/external/folly/folly/chrono/BUCK +29 -0
  264. package/external/folly/folly/chrono/Clock.h +65 -0
  265. package/external/folly/folly/chrono/Conv.h +712 -0
  266. package/external/folly/folly/chrono/test/BUCK +26 -0
  267. package/external/folly/folly/chrono/test/ClockTest.cpp +68 -0
  268. package/external/folly/folly/chrono/test/ConvTest.cpp +652 -0
  269. package/external/folly/folly/concurrency/AtomicSharedPtr.h +387 -0
  270. package/external/folly/folly/concurrency/BUCK +170 -0
  271. package/external/folly/folly/concurrency/CacheLocality.h +460 -0
  272. package/external/folly/folly/concurrency/ConcurrentHashMap.h +822 -0
  273. package/external/folly/folly/concurrency/CoreCachedSharedPtr.h +232 -0
  274. package/external/folly/folly/concurrency/DeadlockDetector.cpp +27 -0
  275. package/external/folly/folly/concurrency/DeadlockDetector.h +44 -0
  276. package/external/folly/folly/concurrency/DynamicBoundedQueue.h +751 -0
  277. package/external/folly/folly/concurrency/PriorityUnboundedQueueSet.h +207 -0
  278. package/external/folly/folly/concurrency/ProcessLocalUniqueId.cpp +46 -0
  279. package/external/folly/folly/concurrency/ProcessLocalUniqueId.h +38 -0
  280. package/external/folly/folly/concurrency/SingletonRelaxedCounter.h +325 -0
  281. package/external/folly/folly/concurrency/ThreadCachedSynchronized.h +227 -0
  282. package/external/folly/folly/concurrency/UnboundedQueue.h +891 -0
  283. package/external/folly/folly/concurrency/container/BUCK +77 -0
  284. package/external/folly/folly/concurrency/container/FlatCombiningPriorityQueue.h +426 -0
  285. package/external/folly/folly/concurrency/container/LockFreeRingBuffer.h +306 -0
  286. package/external/folly/folly/concurrency/container/RelaxedConcurrentPriorityQueue.h +1212 -0
  287. package/external/folly/folly/concurrency/container/SingleWriterFixedHashMap.h +322 -0
  288. package/external/folly/folly/concurrency/container/atomic_grow_array.h +564 -0
  289. package/external/folly/folly/concurrency/container/test/BUCK +75 -0
  290. package/external/folly/folly/concurrency/container/test/FlatCombiningPriorityQueueTest.cpp +570 -0
  291. package/external/folly/folly/concurrency/container/test/LockFreeRingBufferTest.cpp +276 -0
  292. package/external/folly/folly/concurrency/container/test/RelaxedConcurrentPriorityQueueTest.cpp +1570 -0
  293. package/external/folly/folly/concurrency/container/test/SingleWriterFixedHashMapTest.cpp +401 -0
  294. package/external/folly/folly/concurrency/container/test/atomic_grow_array_test.cpp +187 -0
  295. package/external/folly/folly/concurrency/detail/AtomicSharedPtr-detail.h +212 -0
  296. package/external/folly/folly/concurrency/detail/ConcurrentHashMap-detail.h +1911 -0
  297. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.cpp +43 -0
  298. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.h +190 -0
  299. package/external/folly/folly/concurrency/memory/BUCK +53 -0
  300. package/external/folly/folly/concurrency/memory/PrimaryPtr.h +338 -0
  301. package/external/folly/folly/concurrency/memory/ReadMostlySharedPtr.h +511 -0
  302. package/external/folly/folly/concurrency/memory/TLRefCount.h +228 -0
  303. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrBenchmark.cpp +56 -0
  304. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrTest.cpp +454 -0
  305. package/external/folly/folly/concurrency/memory/test/BUCK +95 -0
  306. package/external/folly/folly/concurrency/memory/test/PrimaryPtrTest.cpp +303 -0
  307. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrBenchmark.cpp +138 -0
  308. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrStressTest.cpp +75 -0
  309. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrTest.cpp +378 -0
  310. package/external/folly/folly/concurrency/memory/test/RefCountBenchmark.cpp +90 -0
  311. package/external/folly/folly/concurrency/memory/test/RefCountTest.cpp +168 -0
  312. package/external/folly/folly/concurrency/test/AtomicSharedPtrCounted.h +156 -0
  313. package/external/folly/folly/concurrency/test/AtomicSharedPtrPerformance.cpp +255 -0
  314. package/external/folly/folly/concurrency/test/AtomicSharedPtrTest.cpp +257 -0
  315. package/external/folly/folly/concurrency/test/BUCK +229 -0
  316. package/external/folly/folly/concurrency/test/CacheLocalityBenchmark.cpp +392 -0
  317. package/external/folly/folly/concurrency/test/CacheLocalityTest.cpp +1229 -0
  318. package/external/folly/folly/concurrency/test/ConcurrentHashMapBench.cpp +260 -0
  319. package/external/folly/folly/concurrency/test/ConcurrentHashMapTest.cpp +1242 -0
  320. package/external/folly/folly/concurrency/test/CoreCachedSharedPtrTest.cpp +408 -0
  321. package/external/folly/folly/concurrency/test/DynamicBoundedQueueTest.cpp +984 -0
  322. package/external/folly/folly/concurrency/test/PriorityUnboundedQueueSetTest.cpp +73 -0
  323. package/external/folly/folly/concurrency/test/ProcessLocalUniqueIdTest.cpp +66 -0
  324. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterBench.cpp +101 -0
  325. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterTest.cpp +185 -0
  326. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedBench.cpp +76 -0
  327. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedTest.cpp +93 -0
  328. package/external/folly/folly/concurrency/test/UnboundedQueueTest.cpp +1302 -0
  329. package/external/folly/folly/container/Access.h +57 -0
  330. package/external/folly/folly/container/Array.h +87 -0
  331. package/external/folly/folly/container/BUCK +353 -0
  332. package/external/folly/folly/container/BitIterator.h +203 -0
  333. package/external/folly/folly/container/Enumerate.h +162 -0
  334. package/external/folly/folly/container/EvictingCacheMap.h +730 -0
  335. package/external/folly/folly/container/F14.md +300 -0
  336. package/external/folly/folly/container/F14Map-fwd.h +113 -0
  337. package/external/folly/folly/container/F14Map.h +2108 -0
  338. package/external/folly/folly/container/F14Set-fwd.h +95 -0
  339. package/external/folly/folly/container/F14Set.h +1603 -0
  340. package/external/folly/folly/container/FBVector.h +1711 -0
  341. package/external/folly/folly/container/Foreach-inl.h +316 -0
  342. package/external/folly/folly/container/Foreach.h +209 -0
  343. package/external/folly/folly/container/HeterogeneousAccess-fwd.h +33 -0
  344. package/external/folly/folly/container/HeterogeneousAccess.h +171 -0
  345. package/external/folly/folly/container/IntrusiveHeap.h +268 -0
  346. package/external/folly/folly/container/IntrusiveList.h +131 -0
  347. package/external/folly/folly/container/Iterator.h +843 -0
  348. package/external/folly/folly/container/MapUtil.h +376 -0
  349. package/external/folly/folly/container/Merge.h +90 -0
  350. package/external/folly/folly/container/RegexMatchCache.cpp +521 -0
  351. package/external/folly/folly/container/RegexMatchCache.h +699 -0
  352. package/external/folly/folly/container/Reserve.h +109 -0
  353. package/external/folly/folly/container/SparseByteSet.h +123 -0
  354. package/external/folly/folly/container/View.h +81 -0
  355. package/external/folly/folly/container/WeightedEvictingCacheMap.h +651 -0
  356. package/external/folly/folly/container/detail/BUCK +115 -0
  357. package/external/folly/folly/container/detail/BitIteratorDetail.h +87 -0
  358. package/external/folly/folly/container/detail/F14Defaults.h +34 -0
  359. package/external/folly/folly/container/detail/F14IntrinsicsAvailability.h +67 -0
  360. package/external/folly/folly/container/detail/F14MapFallback.h +717 -0
  361. package/external/folly/folly/container/detail/F14Mask.h +235 -0
  362. package/external/folly/folly/container/detail/F14Policy.h +1523 -0
  363. package/external/folly/folly/container/detail/F14SetFallback.h +528 -0
  364. package/external/folly/folly/container/detail/F14Table.cpp +71 -0
  365. package/external/folly/folly/container/detail/F14Table.h +2680 -0
  366. package/external/folly/folly/container/detail/Util.h +303 -0
  367. package/external/folly/folly/container/detail/tape_detail.h +135 -0
  368. package/external/folly/folly/container/detail/test/BUCK +14 -0
  369. package/external/folly/folly/container/detail/test/F14DetailTest.cpp +47 -0
  370. package/external/folly/folly/container/heap_vector_types.h +1683 -0
  371. package/external/folly/folly/container/range_traits.h +81 -0
  372. package/external/folly/folly/container/small_vector.h +1476 -0
  373. package/external/folly/folly/container/sorted_vector_types.h +1652 -0
  374. package/external/folly/folly/container/span.h +408 -0
  375. package/external/folly/folly/container/tape.h +608 -0
  376. package/external/folly/folly/container/test/.clang-tidy +12 -0
  377. package/external/folly/folly/container/test/AccessTest.cpp +138 -0
  378. package/external/folly/folly/container/test/ArrayTest.cpp +84 -0
  379. package/external/folly/folly/container/test/BUCK +568 -0
  380. package/external/folly/folly/container/test/BitIteratorBench.cpp +112 -0
  381. package/external/folly/folly/container/test/BitIteratorTest.cpp +109 -0
  382. package/external/folly/folly/container/test/EnumerateTest.cpp +294 -0
  383. package/external/folly/folly/container/test/EvictingCacheMapBench.cpp +80 -0
  384. package/external/folly/folly/container/test/EvictingCacheMapTest.cpp +842 -0
  385. package/external/folly/folly/container/test/F14AsanSupportTest.cpp +143 -0
  386. package/external/folly/folly/container/test/F14FwdTest.cpp +37 -0
  387. package/external/folly/folly/container/test/F14InterprocessTest.cpp +404 -0
  388. package/external/folly/folly/container/test/F14MapTest.cpp +2543 -0
  389. package/external/folly/folly/container/test/F14PolicyTest.cpp +49 -0
  390. package/external/folly/folly/container/test/F14SetTest.cpp +1738 -0
  391. package/external/folly/folly/container/test/F14SmallOverheads.cpp +215 -0
  392. package/external/folly/folly/container/test/F14TestUtil.h +117 -0
  393. package/external/folly/folly/container/test/FBVectorBenchmark.cpp +380 -0
  394. package/external/folly/folly/container/test/FBVectorBenchmarks.cpp.h +100 -0
  395. package/external/folly/folly/container/test/FBVectorTest.cpp +326 -0
  396. package/external/folly/folly/container/test/FBVectorTests.cpp.h +304 -0
  397. package/external/folly/folly/container/test/ForeachBenchmark.cpp +388 -0
  398. package/external/folly/folly/container/test/ForeachTest.cpp +338 -0
  399. package/external/folly/folly/container/test/HashMapsBench.cpp +458 -0
  400. package/external/folly/folly/container/test/HeterogeneousAccessTest.cpp +242 -0
  401. package/external/folly/folly/container/test/IntrusiveHeapTest.cpp +262 -0
  402. package/external/folly/folly/container/test/IteratorTest.cpp +989 -0
  403. package/external/folly/folly/container/test/MapUtilTest.cpp +365 -0
  404. package/external/folly/folly/container/test/MergeTest.cpp +66 -0
  405. package/external/folly/folly/container/test/RegexMatchCacheTest.cpp +634 -0
  406. package/external/folly/folly/container/test/ReserveTest.cpp +173 -0
  407. package/external/folly/folly/container/test/SparseByteSetBenchmark.cpp +153 -0
  408. package/external/folly/folly/container/test/SparseByteSetTest.cpp +117 -0
  409. package/external/folly/folly/container/test/TrackingTypes.h +584 -0
  410. package/external/folly/folly/container/test/UtilTest.cpp +609 -0
  411. package/external/folly/folly/container/test/WeightedEvictingCacheMapTest.cpp +800 -0
  412. package/external/folly/folly/container/test/heap_vector_types_test.cpp +1774 -0
  413. package/external/folly/folly/container/test/range_traits_test.cpp +59 -0
  414. package/external/folly/folly/container/test/small_vector_test.cpp +1571 -0
  415. package/external/folly/folly/container/test/sorted_vector_test.cpp +1589 -0
  416. package/external/folly/folly/container/test/span_test.cpp +520 -0
  417. package/external/folly/folly/container/test/tape_bench.cpp +200 -0
  418. package/external/folly/folly/container/test/tape_test.cpp +590 -0
  419. package/external/folly/folly/defs.bzl +238 -0
  420. package/external/folly/folly/detail/AsyncTrace.cpp +36 -0
  421. package/external/folly/folly/detail/AsyncTrace.h +44 -0
  422. package/external/folly/folly/detail/AtomicHashUtils.h +42 -0
  423. package/external/folly/folly/detail/AtomicUnorderedMapUtils.h +80 -0
  424. package/external/folly/folly/detail/BUCK +406 -0
  425. package/external/folly/folly/detail/DiscriminatedPtrDetail.h +172 -0
  426. package/external/folly/folly/detail/FileUtilDetail.cpp +63 -0
  427. package/external/folly/folly/detail/FileUtilDetail.h +85 -0
  428. package/external/folly/folly/detail/FileUtilVectorDetail.h +81 -0
  429. package/external/folly/folly/detail/FingerprintPolynomial.h +132 -0
  430. package/external/folly/folly/detail/Futex-inl.h +123 -0
  431. package/external/folly/folly/detail/Futex.cpp +273 -0
  432. package/external/folly/folly/detail/Futex.h +109 -0
  433. package/external/folly/folly/detail/GroupVarintDetail.h +101 -0
  434. package/external/folly/folly/detail/IPAddress.cpp +37 -0
  435. package/external/folly/folly/detail/IPAddress.h +57 -0
  436. package/external/folly/folly/detail/IPAddressSource.h +278 -0
  437. package/external/folly/folly/detail/Iterators.h +156 -0
  438. package/external/folly/folly/detail/MPMCPipelineDetail.h +122 -0
  439. package/external/folly/folly/detail/MemoryIdler.cpp +233 -0
  440. package/external/folly/folly/detail/MemoryIdler.h +216 -0
  441. package/external/folly/folly/detail/PerfScoped.cpp +112 -0
  442. package/external/folly/folly/detail/PerfScoped.h +70 -0
  443. package/external/folly/folly/detail/PolyDetail.h +921 -0
  444. package/external/folly/folly/detail/RangeCommon.cpp +55 -0
  445. package/external/folly/folly/detail/RangeCommon.h +93 -0
  446. package/external/folly/folly/detail/RangeSse42.cpp +198 -0
  447. package/external/folly/folly/detail/RangeSse42.h +30 -0
  448. package/external/folly/folly/detail/SimpleSimdStringUtils.cpp +31 -0
  449. package/external/folly/folly/detail/SimpleSimdStringUtils.h +27 -0
  450. package/external/folly/folly/detail/SimpleSimdStringUtilsImpl.h +63 -0
  451. package/external/folly/folly/detail/Singleton.h +34 -0
  452. package/external/folly/folly/detail/SlowFingerprint.h +90 -0
  453. package/external/folly/folly/detail/SocketFastOpen.cpp +175 -0
  454. package/external/folly/folly/detail/SocketFastOpen.h +89 -0
  455. package/external/folly/folly/detail/SplitStringSimd.cpp +84 -0
  456. package/external/folly/folly/detail/SplitStringSimd.h +151 -0
  457. package/external/folly/folly/detail/SplitStringSimdImpl.h +149 -0
  458. package/external/folly/folly/detail/Sse.cpp +35 -0
  459. package/external/folly/folly/detail/Sse.h +45 -0
  460. package/external/folly/folly/detail/StaticSingletonManager.cpp +119 -0
  461. package/external/folly/folly/detail/StaticSingletonManager.h +298 -0
  462. package/external/folly/folly/detail/ThreadLocalDetail.cpp +492 -0
  463. package/external/folly/folly/detail/ThreadLocalDetail.h +800 -0
  464. package/external/folly/folly/detail/TrapOnAvx512.cpp +41 -0
  465. package/external/folly/folly/detail/TrapOnAvx512.h +21 -0
  466. package/external/folly/folly/detail/TurnSequencer.h +295 -0
  467. package/external/folly/folly/detail/TypeList.h +551 -0
  468. package/external/folly/folly/detail/UniqueInstance.cpp +136 -0
  469. package/external/folly/folly/detail/UniqueInstance.h +68 -0
  470. package/external/folly/folly/detail/base64_detail/BUCK +102 -0
  471. package/external/folly/folly/detail/base64_detail/Base64Api.cpp +40 -0
  472. package/external/folly/folly/detail/base64_detail/Base64Api.h +101 -0
  473. package/external/folly/folly/detail/base64_detail/Base64Common.h +80 -0
  474. package/external/folly/folly/detail/base64_detail/Base64Constants.h +79 -0
  475. package/external/folly/folly/detail/base64_detail/Base64HiddenConstants.h +129 -0
  476. package/external/folly/folly/detail/base64_detail/Base64SWAR.cpp +161 -0
  477. package/external/folly/folly/detail/base64_detail/Base64SWAR.h +32 -0
  478. package/external/folly/folly/detail/base64_detail/Base64Scalar.h +262 -0
  479. package/external/folly/folly/detail/base64_detail/Base64Simd.h +102 -0
  480. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.cpp +42 -0
  481. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.h +33 -0
  482. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2_Platform.h +167 -0
  483. package/external/folly/folly/detail/base64_detail/README.md +392 -0
  484. package/external/folly/folly/detail/base64_detail/tests/BUCK +36 -0
  485. package/external/folly/folly/detail/base64_detail/tests/Base64AgainstScalarTest.cpp +141 -0
  486. package/external/folly/folly/detail/base64_detail/tests/Base64PlatformTest.cpp +273 -0
  487. package/external/folly/folly/detail/base64_detail/tests/Base64SpecialCasesTest.cpp +555 -0
  488. package/external/folly/folly/detail/test/AsyncTraceTest.cpp +43 -0
  489. package/external/folly/folly/detail/test/BUCK +118 -0
  490. package/external/folly/folly/detail/test/FileUtilDetailTest.cpp +56 -0
  491. package/external/folly/folly/detail/test/PerfScopedTest.cpp +107 -0
  492. package/external/folly/folly/detail/test/SimpleSimdStringUtilsTest.cpp +92 -0
  493. package/external/folly/folly/detail/test/SplitStringSimdTest.cpp +242 -0
  494. package/external/folly/folly/detail/test/StaticSingletonManagerTest.cpp +121 -0
  495. package/external/folly/folly/detail/test/ThreadLocalBenchmark.cpp +116 -0
  496. package/external/folly/folly/detail/test/ThreadLocalDetailTest.cpp +194 -0
  497. package/external/folly/folly/detail/test/TrapOnAvx512TestNegative.cpp +29 -0
  498. package/external/folly/folly/detail/test/UniqueInstanceTest.cpp +60 -0
  499. package/external/folly/folly/detail/thread_local_globals.cpp +69 -0
  500. package/external/folly/folly/detail/thread_local_globals.h +36 -0
  501. package/external/folly/folly/docs/AtomicHashMap.md +134 -0
  502. package/external/folly/folly/docs/Benchmark.md +310 -0
  503. package/external/folly/folly/docs/Conv.md +291 -0
  504. package/external/folly/folly/docs/Dynamic.md +220 -0
  505. package/external/folly/folly/docs/DynamicConverter.md +71 -0
  506. package/external/folly/folly/docs/Executors.md +63 -0
  507. package/external/folly/folly/docs/FBString.md +46 -0
  508. package/external/folly/folly/docs/FBVector.md +200 -0
  509. package/external/folly/folly/docs/Fbvector--graphical_solutions.png +0 -0
  510. package/external/folly/folly/docs/Format.md +177 -0
  511. package/external/folly/folly/docs/Function.md +92 -0
  512. package/external/folly/folly/docs/Futures.md +263 -0
  513. package/external/folly/folly/docs/GroupVarint.md +46 -0
  514. package/external/folly/folly/docs/Histogram.md +104 -0
  515. package/external/folly/folly/docs/MapUtils.md +80 -0
  516. package/external/folly/folly/docs/Overview.md +263 -0
  517. package/external/folly/folly/docs/PackedSyncPtr.md +77 -0
  518. package/external/folly/folly/docs/Poly.md +500 -0
  519. package/external/folly/folly/docs/ProducerConsumerQueue.md +82 -0
  520. package/external/folly/folly/docs/Rcu.md +218 -0
  521. package/external/folly/folly/docs/SmallLocks.md +24 -0
  522. package/external/folly/folly/docs/Synchronized.md +793 -0
  523. package/external/folly/folly/docs/ThreadCachedInt.md +98 -0
  524. package/external/folly/folly/docs/ThreadLocal.md +105 -0
  525. package/external/folly/folly/docs/Traits.md +161 -0
  526. package/external/folly/folly/docs/small_vector.md +64 -0
  527. package/external/folly/folly/docs/style.css +23 -0
  528. package/external/folly/folly/dynamic-inl.h +17 -0
  529. package/external/folly/folly/dynamic.h +17 -0
  530. package/external/folly/folly/folly_extended_library.bzl +28 -0
  531. package/external/folly/folly/functional/ApplyTuple.h +204 -0
  532. package/external/folly/folly/functional/BUCK +57 -0
  533. package/external/folly/folly/functional/Invoke.h +880 -0
  534. package/external/folly/folly/functional/Partial.h +130 -0
  535. package/external/folly/folly/functional/protocol.h +203 -0
  536. package/external/folly/folly/functional/test/ApplyTupleTest.cpp +549 -0
  537. package/external/folly/folly/functional/test/BUCK +57 -0
  538. package/external/folly/folly/functional/test/InvokeTest.cpp +483 -0
  539. package/external/folly/folly/functional/test/PartialTest.cpp +141 -0
  540. package/external/folly/folly/functional/test/protocol_test.cpp +177 -0
  541. package/external/folly/folly/functional/test/traits_test.cpp +551 -0
  542. package/external/folly/folly/functional/traits.h +675 -0
  543. package/external/folly/folly/hash/BUCK +86 -0
  544. package/external/folly/folly/hash/Checksum.cpp +275 -0
  545. package/external/folly/folly/hash/Checksum.h +94 -0
  546. package/external/folly/folly/hash/FarmHash.h +46 -0
  547. package/external/folly/folly/hash/Hash.h +1045 -0
  548. package/external/folly/folly/hash/MurmurHash.h +86 -0
  549. package/external/folly/folly/hash/SpookyHashV1.cpp +391 -0
  550. package/external/folly/folly/hash/SpookyHashV1.h +307 -0
  551. package/external/folly/folly/hash/SpookyHashV2.cpp +392 -0
  552. package/external/folly/folly/hash/SpookyHashV2.h +339 -0
  553. package/external/folly/folly/hash/detail/BUCK +26 -0
  554. package/external/folly/folly/hash/detail/ChecksumDetail.cpp +296 -0
  555. package/external/folly/folly/hash/detail/ChecksumDetail.h +137 -0
  556. package/external/folly/folly/hash/detail/Crc32CombineDetail.cpp +191 -0
  557. package/external/folly/folly/hash/detail/Crc32cDetail.cpp +303 -0
  558. package/external/folly/folly/hash/test/BUCK +132 -0
  559. package/external/folly/folly/hash/test/ChecksumBenchmark.cpp +91 -0
  560. package/external/folly/folly/hash/test/ChecksumTest.cpp +587 -0
  561. package/external/folly/folly/hash/test/FarmHashTest.cpp +41 -0
  562. package/external/folly/folly/hash/test/HashBenchmark.cpp +238 -0
  563. package/external/folly/folly/hash/test/HashTest.cpp +997 -0
  564. package/external/folly/folly/hash/test/MurmurHashTest.cpp +76 -0
  565. package/external/folly/folly/hash/test/SpookyHashV1Test.cpp +559 -0
  566. package/external/folly/folly/hash/test/SpookyHashV2Test.cpp +549 -0
  567. package/external/folly/folly/hash/test/traits_test.cpp +69 -0
  568. package/external/folly/folly/hash/traits.h +115 -0
  569. package/external/folly/folly/json/BUCK +155 -0
  570. package/external/folly/folly/json/DynamicConverter.h +464 -0
  571. package/external/folly/folly/json/DynamicParser-inl.h +316 -0
  572. package/external/folly/folly/json/DynamicParser.cpp +198 -0
  573. package/external/folly/folly/json/DynamicParser.h +394 -0
  574. package/external/folly/folly/json/JSONSchema.cpp +1030 -0
  575. package/external/folly/folly/json/JSONSchema.h +73 -0
  576. package/external/folly/folly/json/JsonMockUtil.h +73 -0
  577. package/external/folly/folly/json/JsonTestUtil.cpp +167 -0
  578. package/external/folly/folly/json/JsonTestUtil.h +88 -0
  579. package/external/folly/folly/json/bser/BUCK +24 -0
  580. package/external/folly/folly/json/bser/Bser.h +107 -0
  581. package/external/folly/folly/json/bser/Dump.cpp +253 -0
  582. package/external/folly/folly/json/bser/Load.cpp +246 -0
  583. package/external/folly/folly/json/bser/test/BUCK +14 -0
  584. package/external/folly/folly/json/bser/test/BserTest.cpp +149 -0
  585. package/external/folly/folly/json/dynamic.cpp +552 -0
  586. package/external/folly/folly/json/dynamic.h +1346 -0
  587. package/external/folly/folly/json/json.h +238 -0
  588. package/external/folly/folly/json/json_patch.cpp +325 -0
  589. package/external/folly/folly/json/json_patch.h +126 -0
  590. package/external/folly/folly/json/json_pointer.cpp +114 -0
  591. package/external/folly/folly/json/json_pointer.h +87 -0
  592. package/external/folly/folly/json/test/BUCK +147 -0
  593. package/external/folly/folly/json/test/DynamicBenchmark.cpp +146 -0
  594. package/external/folly/folly/json/test/DynamicConverterTest.cpp +518 -0
  595. package/external/folly/folly/json/test/DynamicOtherTest.cpp +344 -0
  596. package/external/folly/folly/json/test/DynamicParserTest.cpp +443 -0
  597. package/external/folly/folly/json/test/DynamicTest.cpp +1647 -0
  598. package/external/folly/folly/json/test/JSONSchemaTest.cpp +450 -0
  599. package/external/folly/folly/json/test/JsonBenchmark.cpp +264 -0
  600. package/external/folly/folly/json/test/JsonOtherTest.cpp +51 -0
  601. package/external/folly/folly/json/test/JsonTest.cpp +1153 -0
  602. package/external/folly/folly/json/test/JsonTestUtilTest.cpp +97 -0
  603. package/external/folly/folly/json/test/json_patch_test.cpp +361 -0
  604. package/external/folly/folly/json/test/json_pointer_test.cpp +58 -0
  605. package/external/folly/folly/json/tool/BUCK +13 -0
  606. package/external/folly/folly/json/tool/JSONSchemaTester.cpp +58 -0
  607. package/external/folly/folly/json.h +17 -0
  608. package/external/folly/folly/json_patch.h +17 -0
  609. package/external/folly/folly/json_pointer.h +17 -0
  610. package/external/folly/folly/lang/Access.h +29 -0
  611. package/external/folly/folly/lang/Align.h +240 -0
  612. package/external/folly/folly/lang/Aligned.h +92 -0
  613. package/external/folly/folly/lang/Assume.h +82 -0
  614. package/external/folly/folly/lang/BUCK +287 -0
  615. package/external/folly/folly/lang/Badge.h +108 -0
  616. package/external/folly/folly/lang/Bits.h +570 -0
  617. package/external/folly/folly/lang/BitsClass.h +312 -0
  618. package/external/folly/folly/lang/Builtin.h +74 -0
  619. package/external/folly/folly/lang/CArray.h +34 -0
  620. package/external/folly/folly/lang/CString.cpp +86 -0
  621. package/external/folly/folly/lang/CString.h +55 -0
  622. package/external/folly/folly/lang/Cast.h +51 -0
  623. package/external/folly/folly/lang/CheckedMath.h +253 -0
  624. package/external/folly/folly/lang/CustomizationPoint.h +58 -0
  625. package/external/folly/folly/lang/Exception.cpp +822 -0
  626. package/external/folly/folly/lang/Exception.h +716 -0
  627. package/external/folly/folly/lang/Extern.h +55 -0
  628. package/external/folly/folly/lang/Hint-inl.h +144 -0
  629. package/external/folly/folly/lang/Hint.h +238 -0
  630. package/external/folly/folly/lang/Keep.h +98 -0
  631. package/external/folly/folly/lang/New.h +124 -0
  632. package/external/folly/folly/lang/Ordering.h +140 -0
  633. package/external/folly/folly/lang/Pretty.h +159 -0
  634. package/external/folly/folly/lang/PropagateConst.h +413 -0
  635. package/external/folly/folly/lang/RValueReferenceWrapper.h +152 -0
  636. package/external/folly/folly/lang/SafeAssert.cpp +589 -0
  637. package/external/folly/folly/lang/StaticConst.h +33 -0
  638. package/external/folly/folly/lang/Thunk.h +100 -0
  639. package/external/folly/folly/lang/TypeInfo.h +58 -0
  640. package/external/folly/folly/lang/UncaughtExceptions.cpp +17 -0
  641. package/external/folly/folly/lang/UncaughtExceptions.h +19 -0
  642. package/external/folly/folly/lang/test/AlignTest.cpp +87 -0
  643. package/external/folly/folly/lang/test/AlignedTest.cpp +130 -0
  644. package/external/folly/folly/lang/test/BUCK +258 -0
  645. package/external/folly/folly/lang/test/BadgeTest.cpp +89 -0
  646. package/external/folly/folly/lang/test/BitsBenchmark.cpp +164 -0
  647. package/external/folly/folly/lang/test/BitsClassBenchmark.cpp +122 -0
  648. package/external/folly/folly/lang/test/BitsClassTest.cpp +379 -0
  649. package/external/folly/folly/lang/test/BitsTest.cpp +577 -0
  650. package/external/folly/folly/lang/test/CStringTest.cpp +60 -0
  651. package/external/folly/folly/lang/test/CastTest.cpp +47 -0
  652. package/external/folly/folly/lang/test/CheckedMathTest.cpp +394 -0
  653. package/external/folly/folly/lang/test/ExceptionBench.cpp +427 -0
  654. package/external/folly/folly/lang/test/ExceptionTest.cpp +413 -0
  655. package/external/folly/folly/lang/test/ExternTest.cpp +39 -0
  656. package/external/folly/folly/lang/test/HintTest.cpp +100 -0
  657. package/external/folly/folly/lang/test/NewTest.cpp +38 -0
  658. package/external/folly/folly/lang/test/OrderingTest.cpp +105 -0
  659. package/external/folly/folly/lang/test/PrettyTest.cpp +44 -0
  660. package/external/folly/folly/lang/test/PropagateConstTest.cpp +356 -0
  661. package/external/folly/folly/lang/test/RValueReferenceWrapperTest.cpp +85 -0
  662. package/external/folly/folly/lang/test/SafeAssertTest.cpp +75 -0
  663. package/external/folly/folly/lang/test/ThunkTest.cpp +105 -0
  664. package/external/folly/folly/lang/test/ToAsciiBench.cpp +466 -0
  665. package/external/folly/folly/lang/test/ToAsciiTest.cpp +266 -0
  666. package/external/folly/folly/lang/test/TypeInfoTest.cpp +56 -0
  667. package/external/folly/folly/memcpy.S +292 -0
  668. package/external/folly/folly/memcpy_select_aarch64.cpp +145 -0
  669. package/external/folly/folly/memory/Arena-inl.h +83 -0
  670. package/external/folly/folly/memory/Arena.h +325 -0
  671. package/external/folly/folly/memory/BUCK +191 -0
  672. package/external/folly/folly/memory/JemallocHugePageAllocator.cpp +449 -0
  673. package/external/folly/folly/memory/JemallocHugePageAllocator.h +105 -0
  674. package/external/folly/folly/memory/JemallocHugePageAllocatorTest.cpp +341 -0
  675. package/external/folly/folly/memory/JemallocNodumpAllocator.cpp +176 -0
  676. package/external/folly/folly/memory/JemallocNodumpAllocator.h +119 -0
  677. package/external/folly/folly/memory/JemallocNodumpAllocatorTest.cpp +61 -0
  678. package/external/folly/folly/memory/MallctlHelper.cpp +37 -0
  679. package/external/folly/folly/memory/MallctlHelper.h +167 -0
  680. package/external/folly/folly/memory/Malloc.h +551 -0
  681. package/external/folly/folly/memory/MemoryResource.h +57 -0
  682. package/external/folly/folly/memory/ReentrantAllocator.cpp +162 -0
  683. package/external/folly/folly/memory/ReentrantAllocator.h +261 -0
  684. package/external/folly/folly/memory/SanitizeAddress.cpp +75 -0
  685. package/external/folly/folly/memory/SanitizeAddress.h +117 -0
  686. package/external/folly/folly/memory/SanitizeLeak.cpp +119 -0
  687. package/external/folly/folly/memory/SanitizeLeak.h +108 -0
  688. package/external/folly/folly/memory/ThreadCachedArena.cpp +53 -0
  689. package/external/folly/folly/memory/ThreadCachedArena.h +90 -0
  690. package/external/folly/folly/memory/UninitializedMemoryHacks.h +426 -0
  691. package/external/folly/folly/memory/detail/BUCK +10 -0
  692. package/external/folly/folly/memory/detail/MallocImpl.cpp +52 -0
  693. package/external/folly/folly/memory/detail/MallocImpl.h +97 -0
  694. package/external/folly/folly/memory/not_null-inl.h +522 -0
  695. package/external/folly/folly/memory/not_null.h +449 -0
  696. package/external/folly/folly/memory/test/ArenaTest.cpp +354 -0
  697. package/external/folly/folly/memory/test/BUCK +146 -0
  698. package/external/folly/folly/memory/test/MallctlHelperTest.cpp +169 -0
  699. package/external/folly/folly/memory/test/MallocBenchmark.cpp +91 -0
  700. package/external/folly/folly/memory/test/MallocTest.cpp +78 -0
  701. package/external/folly/folly/memory/test/MemoryResourceTest.cpp +31 -0
  702. package/external/folly/folly/memory/test/ReentrantAllocatorTest.cpp +144 -0
  703. package/external/folly/folly/memory/test/SanitizeAddressTest.cpp +67 -0
  704. package/external/folly/folly/memory/test/SanitizeLeakTest.cpp +139 -0
  705. package/external/folly/folly/memory/test/ThreadCachedArenaTest.cpp +276 -0
  706. package/external/folly/folly/memory/test/UninitializedMemoryHacksODR.cpp +21 -0
  707. package/external/folly/folly/memory/test/UninitializedMemoryHacksTest.cpp +327 -0
  708. package/external/folly/folly/memory/test/not_null_test.cpp +608 -0
  709. package/external/folly/folly/memset.S +245 -0
  710. package/external/folly/folly/memset_select_aarch64.cpp +72 -0
  711. package/external/folly/folly/portability/Asm.h +50 -0
  712. package/external/folly/folly/portability/Atomic.h +31 -0
  713. package/external/folly/folly/portability/BUCK +456 -0
  714. package/external/folly/folly/portability/Builtins.cpp +31 -0
  715. package/external/folly/folly/portability/Builtins.h +161 -0
  716. package/external/folly/folly/portability/Config.h +43 -0
  717. package/external/folly/folly/portability/Constexpr.h +145 -0
  718. package/external/folly/folly/portability/Dirent.cpp +140 -0
  719. package/external/folly/folly/portability/Dirent.h +41 -0
  720. package/external/folly/folly/portability/Event.h +44 -0
  721. package/external/folly/folly/portability/Fcntl.cpp +120 -0
  722. package/external/folly/folly/portability/Fcntl.h +67 -0
  723. package/external/folly/folly/portability/Filesystem.cpp +67 -0
  724. package/external/folly/folly/portability/Filesystem.h +114 -0
  725. package/external/folly/folly/portability/FmtCompile.h +40 -0
  726. package/external/folly/folly/portability/GFlags.h +139 -0
  727. package/external/folly/folly/portability/GMock.h +35 -0
  728. package/external/folly/folly/portability/GTest.h +35 -0
  729. package/external/folly/folly/portability/IOVec.h +34 -0
  730. package/external/folly/folly/portability/Libgen.cpp +59 -0
  731. package/external/folly/folly/portability/Libgen.h +29 -0
  732. package/external/folly/folly/portability/Libunwind.h +21 -0
  733. package/external/folly/folly/portability/Malloc.cpp +31 -0
  734. package/external/folly/folly/portability/Malloc.h +53 -0
  735. package/external/folly/folly/portability/Math.h +90 -0
  736. package/external/folly/folly/portability/Memory.h +26 -0
  737. package/external/folly/folly/portability/OpenSSL.cpp +17 -0
  738. package/external/folly/folly/portability/OpenSSL.h +102 -0
  739. package/external/folly/folly/portability/PThread.cpp +697 -0
  740. package/external/folly/folly/portability/PThread.h +148 -0
  741. package/external/folly/folly/portability/README.md +21 -0
  742. package/external/folly/folly/portability/Sched.cpp +41 -0
  743. package/external/folly/folly/portability/Sched.h +45 -0
  744. package/external/folly/folly/portability/Sockets.cpp +245 -0
  745. package/external/folly/folly/portability/Sockets.h +155 -0
  746. package/external/folly/folly/portability/SourceLocation.h +49 -0
  747. package/external/folly/folly/portability/Stdio.cpp +77 -0
  748. package/external/folly/folly/portability/Stdio.h +32 -0
  749. package/external/folly/folly/portability/Stdlib.cpp +172 -0
  750. package/external/folly/folly/portability/Stdlib.h +64 -0
  751. package/external/folly/folly/portability/String.cpp +53 -0
  752. package/external/folly/folly/portability/String.h +39 -0
  753. package/external/folly/folly/portability/SysFile.cpp +46 -0
  754. package/external/folly/folly/portability/SysFile.h +27 -0
  755. package/external/folly/folly/portability/SysMembarrier.cpp +104 -0
  756. package/external/folly/folly/portability/SysMembarrier.h +26 -0
  757. package/external/folly/folly/portability/SysMman.cpp +242 -0
  758. package/external/folly/folly/portability/SysMman.h +68 -0
  759. package/external/folly/folly/portability/SysResource.cpp +108 -0
  760. package/external/folly/folly/portability/SysResource.h +71 -0
  761. package/external/folly/folly/portability/SysStat.cpp +66 -0
  762. package/external/folly/folly/portability/SysStat.h +52 -0
  763. package/external/folly/folly/portability/SysSyscall.h +73 -0
  764. package/external/folly/folly/portability/SysTime.cpp +62 -0
  765. package/external/folly/folly/portability/SysTime.h +50 -0
  766. package/external/folly/folly/portability/SysTypes.h +44 -0
  767. package/external/folly/folly/portability/SysUio.cpp +179 -0
  768. package/external/folly/folly/portability/SysUio.h +51 -0
  769. package/external/folly/folly/portability/Syslog.h +39 -0
  770. package/external/folly/folly/portability/Time.cpp +357 -0
  771. package/external/folly/folly/portability/Time.h +74 -0
  772. package/external/folly/folly/portability/Unistd.h +111 -0
  773. package/external/folly/folly/portability/Windows.h +108 -0
  774. package/external/folly/folly/portability/openat2.c +30 -0
  775. package/external/folly/folly/portability/openat2.h +39 -0
  776. package/external/folly/folly/portability/test/BUCK +59 -0
  777. package/external/folly/folly/portability/test/ConstexprTest.cpp +102 -0
  778. package/external/folly/folly/portability/test/FilesystemTest.cpp +35 -0
  779. package/external/folly/folly/portability/test/LibgenTest.cpp +35 -0
  780. package/external/folly/folly/portability/test/OpenSSLPortabilityTest.cpp +108 -0
  781. package/external/folly/folly/portability/test/PThreadTest.cpp +80 -0
  782. package/external/folly/folly/portability/test/TimeTest.cpp +90 -0
  783. package/external/folly/folly/small_vector.h +17 -0
  784. package/external/folly/folly/somerge_defs.bzl +399 -0
  785. package/external/folly/folly/sorted_vector_types.h +17 -0
  786. package/external/folly/folly/stop_watch.h +317 -0
  787. package/external/folly/folly/synchronization/AsymmetricThreadFence.cpp +91 -0
  788. package/external/folly/folly/synchronization/AsymmetricThreadFence.h +60 -0
  789. package/external/folly/folly/synchronization/AtomicNotification-inl.h +146 -0
  790. package/external/folly/folly/synchronization/AtomicNotification.cpp +34 -0
  791. package/external/folly/folly/synchronization/AtomicNotification.h +117 -0
  792. package/external/folly/folly/synchronization/AtomicRef.h +181 -0
  793. package/external/folly/folly/synchronization/AtomicStruct.h +150 -0
  794. package/external/folly/folly/synchronization/AtomicUtil-inl.h +482 -0
  795. package/external/folly/folly/synchronization/AtomicUtil.h +179 -0
  796. package/external/folly/folly/synchronization/BUCK +418 -0
  797. package/external/folly/folly/synchronization/Baton.h +419 -0
  798. package/external/folly/folly/synchronization/CallOnce.h +263 -0
  799. package/external/folly/folly/synchronization/DelayedInit.h +179 -0
  800. package/external/folly/folly/synchronization/DistributedMutex-inl.h +1744 -0
  801. package/external/folly/folly/synchronization/DistributedMutex.cpp +27 -0
  802. package/external/folly/folly/synchronization/DistributedMutex.h +342 -0
  803. package/external/folly/folly/synchronization/EventCount.h +200 -0
  804. package/external/folly/folly/synchronization/FlatCombining.h +629 -0
  805. package/external/folly/folly/synchronization/Hazptr-fwd.h +217 -0
  806. package/external/folly/folly/synchronization/Hazptr.cpp +36 -0
  807. package/external/folly/folly/synchronization/Hazptr.h +209 -0
  808. package/external/folly/folly/synchronization/HazptrDomain.cpp +68 -0
  809. package/external/folly/folly/synchronization/HazptrDomain.h +832 -0
  810. package/external/folly/folly/synchronization/HazptrHolder.h +431 -0
  811. package/external/folly/folly/synchronization/HazptrObj.h +533 -0
  812. package/external/folly/folly/synchronization/HazptrObjLinked.h +315 -0
  813. package/external/folly/folly/synchronization/HazptrRec.h +68 -0
  814. package/external/folly/folly/synchronization/HazptrThrLocal.h +180 -0
  815. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.cpp +46 -0
  816. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.h +25 -0
  817. package/external/folly/folly/synchronization/Latch.h +160 -0
  818. package/external/folly/folly/synchronization/LifoSem.h +767 -0
  819. package/external/folly/folly/synchronization/Lock.h +887 -0
  820. package/external/folly/folly/synchronization/MicroSpinLock.h +154 -0
  821. package/external/folly/folly/synchronization/NativeSemaphore.h +187 -0
  822. package/external/folly/folly/synchronization/ParkingLot.cpp +37 -0
  823. package/external/folly/folly/synchronization/ParkingLot.h +330 -0
  824. package/external/folly/folly/synchronization/PicoSpinLock.h +167 -0
  825. package/external/folly/folly/synchronization/RWSpinLock.h +549 -0
  826. package/external/folly/folly/synchronization/Rcu.cpp +26 -0
  827. package/external/folly/folly/synchronization/Rcu.h +553 -0
  828. package/external/folly/folly/synchronization/RelaxedAtomic.h +336 -0
  829. package/external/folly/folly/synchronization/SanitizeThread.cpp +141 -0
  830. package/external/folly/folly/synchronization/SanitizeThread.h +166 -0
  831. package/external/folly/folly/synchronization/SaturatingSemaphore.h +324 -0
  832. package/external/folly/folly/synchronization/SmallLocks.h +36 -0
  833. package/external/folly/folly/synchronization/ThrottledLifoSem.h +362 -0
  834. package/external/folly/folly/synchronization/WaitOptions.cpp +25 -0
  835. package/external/folly/folly/synchronization/WaitOptions.h +75 -0
  836. package/external/folly/folly/synchronization/detail/AtomicUtils.h +59 -0
  837. package/external/folly/folly/synchronization/detail/BUCK +104 -0
  838. package/external/folly/folly/synchronization/detail/Hardware.cpp +192 -0
  839. package/external/folly/folly/synchronization/detail/Hardware.h +75 -0
  840. package/external/folly/folly/synchronization/detail/HazptrUtils.h +339 -0
  841. package/external/folly/folly/synchronization/detail/InlineFunctionRef.h +229 -0
  842. package/external/folly/folly/synchronization/detail/Sleeper.cpp +27 -0
  843. package/external/folly/folly/synchronization/detail/Sleeper.h +62 -0
  844. package/external/folly/folly/synchronization/detail/Spin.h +96 -0
  845. package/external/folly/folly/synchronization/detail/ThreadCachedLists.h +174 -0
  846. package/external/folly/folly/synchronization/detail/ThreadCachedReaders.h +189 -0
  847. package/external/folly/folly/synchronization/detail/ThreadCachedTag.h +26 -0
  848. package/external/folly/folly/synchronization/detail/test/BUCK +28 -0
  849. package/external/folly/folly/synchronization/detail/test/HardwareTest.cpp +74 -0
  850. package/external/folly/folly/synchronization/detail/test/InlineFunctionRefTest.cpp +286 -0
  851. package/external/folly/folly/synchronization/example/BUCK +27 -0
  852. package/external/folly/folly/synchronization/example/HazptrLockFreeLIFO.h +88 -0
  853. package/external/folly/folly/synchronization/example/HazptrSWMRSet.h +133 -0
  854. package/external/folly/folly/synchronization/example/HazptrWideCAS.h +62 -0
  855. package/external/folly/folly/synchronization/test/AtomicNotificationTest.cpp +236 -0
  856. package/external/folly/folly/synchronization/test/AtomicRefTest.cpp +170 -0
  857. package/external/folly/folly/synchronization/test/AtomicStructTest.cpp +65 -0
  858. package/external/folly/folly/synchronization/test/AtomicUtilBench.cpp +457 -0
  859. package/external/folly/folly/synchronization/test/AtomicUtilTest.cpp +650 -0
  860. package/external/folly/folly/synchronization/test/BUCK +495 -0
  861. package/external/folly/folly/synchronization/test/Barrier.h +52 -0
  862. package/external/folly/folly/synchronization/test/BarrierTest.cpp +56 -0
  863. package/external/folly/folly/synchronization/test/BatonBenchmark.cpp +77 -0
  864. package/external/folly/folly/synchronization/test/BatonTest.cpp +164 -0
  865. package/external/folly/folly/synchronization/test/BatonTestHelpers.h +118 -0
  866. package/external/folly/folly/synchronization/test/CallOnceBenchmark.cpp +72 -0
  867. package/external/folly/folly/synchronization/test/CallOnceTest.cpp +153 -0
  868. package/external/folly/folly/synchronization/test/DelayedInitTest.cpp +281 -0
  869. package/external/folly/folly/synchronization/test/DistributedMutexTest.cpp +2074 -0
  870. package/external/folly/folly/synchronization/test/EventCountTest.cpp +124 -0
  871. package/external/folly/folly/synchronization/test/FlatCombiningBenchmark.cpp +1789 -0
  872. package/external/folly/folly/synchronization/test/FlatCombiningExamples.h +222 -0
  873. package/external/folly/folly/synchronization/test/FlatCombiningTest.cpp +121 -0
  874. package/external/folly/folly/synchronization/test/FlatCombiningTestHelpers.h +227 -0
  875. package/external/folly/folly/synchronization/test/HazptrTest.cpp +1689 -0
  876. package/external/folly/folly/synchronization/test/LatchTest.cpp +224 -0
  877. package/external/folly/folly/synchronization/test/LifoSemBench.cpp +185 -0
  878. package/external/folly/folly/synchronization/test/LifoSemTests.cpp +353 -0
  879. package/external/folly/folly/synchronization/test/LockTest.cpp +1239 -0
  880. package/external/folly/folly/synchronization/test/NativeSemaphoreTest.cpp +37 -0
  881. package/external/folly/folly/synchronization/test/ParkingLotBenchmark.cpp +239 -0
  882. package/external/folly/folly/synchronization/test/ParkingLotTest.cpp +170 -0
  883. package/external/folly/folly/synchronization/test/RWSpinLockTest.cpp +235 -0
  884. package/external/folly/folly/synchronization/test/RcuBench.cpp +66 -0
  885. package/external/folly/folly/synchronization/test/RcuTest.cpp +330 -0
  886. package/external/folly/folly/synchronization/test/RelaxedAtomicTest.cpp +389 -0
  887. package/external/folly/folly/synchronization/test/SaturatingSemaphoreTest.cpp +166 -0
  888. package/external/folly/folly/synchronization/test/Semaphore.h +242 -0
  889. package/external/folly/folly/synchronization/test/SemaphoreTest.cpp +271 -0
  890. package/external/folly/folly/synchronization/test/SmallLocksBenchmark.cpp +1296 -0
  891. package/external/folly/folly/synchronization/test/SmallLocksTest.cpp +510 -0
  892. package/external/folly/folly/synchronization/test/ThreadCachedEpochBench.h +67 -0
  893. package/external/folly/folly/synchronization/test/ThreadCachedReadersBench.cpp +42 -0
  894. package/external/folly/folly/synchronization/test/ThreadCachedReadersTest.cpp +52 -0
  895. package/external/folly/folly/synchronization/test/ThrottledLifoSemTest.cpp +243 -0
  896. package/external/folly/folly/system/AtFork.cpp +205 -0
  897. package/external/folly/folly/system/AtFork.h +116 -0
  898. package/external/folly/folly/system/AuxVector.h +198 -0
  899. package/external/folly/folly/system/BUCK +144 -0
  900. package/external/folly/folly/system/EnvUtil.cpp +93 -0
  901. package/external/folly/folly/system/EnvUtil.h +113 -0
  902. package/external/folly/folly/system/HardwareConcurrency.cpp +39 -0
  903. package/external/folly/folly/system/HardwareConcurrency.h +23 -0
  904. package/external/folly/folly/system/MemoryMapping.cpp +477 -0
  905. package/external/folly/folly/system/MemoryMapping.h +287 -0
  906. package/external/folly/folly/system/Pid.cpp +87 -0
  907. package/external/folly/folly/system/Pid.h +34 -0
  908. package/external/folly/folly/system/Shell.cpp +33 -0
  909. package/external/folly/folly/system/Shell.h +93 -0
  910. package/external/folly/folly/system/ThreadId.cpp +89 -0
  911. package/external/folly/folly/system/ThreadId.h +62 -0
  912. package/external/folly/folly/system/ThreadName.cpp +330 -0
  913. package/external/folly/folly/system/ThreadName.h +72 -0
  914. package/external/folly/folly/system/test/AtForkTest.cpp +309 -0
  915. package/external/folly/folly/system/test/AuxVectorTest.cpp +55 -0
  916. package/external/folly/folly/system/test/BUCK +120 -0
  917. package/external/folly/folly/system/test/EnvUtilSubprocess.cpp +26 -0
  918. package/external/folly/folly/system/test/EnvUtilTest.cpp +197 -0
  919. package/external/folly/folly/system/test/MemoryMappingTest.cpp +179 -0
  920. package/external/folly/folly/system/test/PidTest.cpp +46 -0
  921. package/external/folly/folly/system/test/ShellTest.cpp +66 -0
  922. package/external/folly/folly/system/test/ThreadIdTest.cpp +114 -0
  923. package/external/folly/folly/system/test/ThreadNameTest.cpp +85 -0
  924. package/external/folly/folly.vcxitems +164 -0
  925. package/external/folly/static/logo.svg +1 -0
  926. package/external/folly/sync-config.json +8 -0
  927. package/just-task.js +13 -2
  928. package/package.json +6 -6
  929. package/template/cpp-lib/proj/MyLib.sln +0 -33
  930. package/template/cs-lib/proj/MyLib.sln +0 -33
  931. package/templates/cpp-app/windows/MyApp/MyApp.vcxproj +1 -1
  932. package/templates/cpp-app/windows/MyApp.sln +0 -33
  933. package/templates/cpp-lib/example/metro.config.js +30 -4
  934. package/templates/cpp-lib/windows/MyLib/MyLib.vcxproj +1 -1
  935. package/templates/cpp-lib/windows/MyLib.sln +0 -33
  936. package/Folly/Folly.vcxproj +0 -376
  937. package/Folly/Folly.vcxproj.filters +0 -558
  938. package/fmt/fmt.vcxproj +0 -153
  939. package/fmt/fmt.vcxproj.filters +0 -59
  940. package/fmt/pch.cpp +0 -4
  941. package/fmt/pch.h +0 -2
  942. /package/{fmt → external/fmt}/cgmanifest.json +0 -0
  943. /package/{Folly → external/folly}/Folly.natvis +0 -0
  944. /package/{Folly → external/folly}/cgmanifest.json +0 -0
  945. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/ConstexprMath.h +0 -0
  946. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/Conv.cpp +0 -0
  947. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/chrono/Hardware.h +0 -0
  948. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/concurrency/CacheLocality.cpp +0 -0
  949. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/dynamic-inl.h +0 -0
  950. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/json.cpp +0 -0
  951. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/SafeAssert.h +0 -0
  952. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.cpp +0 -0
  953. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.h +0 -0
  954. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/portability/Unistd.cpp +0 -0
@@ -0,0 +1,1476 @@
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
+ * For high-level documentation and usage examples see
19
+ * folly/docs/small_vector.md
20
+ */
21
+
22
+ #pragma once
23
+
24
+ #include <algorithm>
25
+ #include <cassert>
26
+ #include <cstdlib>
27
+ #include <cstring>
28
+ #include <iterator>
29
+ #include <memory>
30
+ #include <stdexcept>
31
+ #include <type_traits>
32
+ #include <utility>
33
+
34
+ #include <boost/operators.hpp>
35
+
36
+ #include <folly/ConstexprMath.h>
37
+ #include <folly/FormatTraits.h>
38
+ #include <folly/Likely.h>
39
+ #include <folly/Portability.h>
40
+ #include <folly/ScopeGuard.h>
41
+ #include <folly/Traits.h>
42
+ #include <folly/functional/Invoke.h>
43
+ #include <folly/hash/Hash.h>
44
+ #include <folly/lang/Align.h>
45
+ #include <folly/lang/Assume.h>
46
+ #include <folly/lang/CheckedMath.h>
47
+ #include <folly/lang/Exception.h>
48
+ #include <folly/memory/Malloc.h>
49
+ #include <folly/memory/SanitizeLeak.h>
50
+ #include <folly/portability/Malloc.h>
51
+
52
+ #if (FOLLY_X64 || FOLLY_PPC64 || FOLLY_AARCH64 || FOLLY_RISCV64)
53
+ #define FOLLY_SV_PACK_ATTR FOLLY_PACK_ATTR
54
+ #define FOLLY_SV_PACK_PUSH FOLLY_PACK_PUSH
55
+ #define FOLLY_SV_PACK_POP FOLLY_PACK_POP
56
+ #else
57
+ #define FOLLY_SV_PACK_ATTR
58
+ #define FOLLY_SV_PACK_PUSH
59
+ #define FOLLY_SV_PACK_POP
60
+ #endif
61
+
62
+ // Ignore shadowing warnings within this file, so includers can use -Wshadow.
63
+ FOLLY_PUSH_WARNING
64
+ FOLLY_GNU_DISABLE_WARNING("-Wshadow")
65
+
66
+ namespace folly {
67
+
68
+ namespace small_vector_policy {
69
+
70
+ namespace detail {
71
+
72
+ struct item_size_type {
73
+ template <typename T>
74
+ using get = typename T::size_type;
75
+ template <typename T>
76
+ struct set {
77
+ using size_type = T;
78
+ };
79
+ };
80
+
81
+ struct item_in_situ_only {
82
+ template <typename T>
83
+ using get = typename T::in_situ_only;
84
+ template <typename T>
85
+ struct set {
86
+ using in_situ_only = T;
87
+ };
88
+ };
89
+
90
+ template <template <typename> class F, typename... T>
91
+ constexpr size_t last_matching_() {
92
+ bool const values[] = {is_detected_v<F, T>..., false};
93
+ for (size_t i = 0; i < sizeof...(T); ++i) {
94
+ auto const j = sizeof...(T) - 1 - i;
95
+ if (values[j]) {
96
+ return j;
97
+ }
98
+ }
99
+ return sizeof...(T);
100
+ }
101
+
102
+ template <size_t M, typename I, typename... P>
103
+ struct merge_ //
104
+ : I::template set<typename I::template get<
105
+ type_pack_element_t<sizeof...(P) - M, P...>>> {};
106
+ template <typename I, typename... P>
107
+ struct merge_<0, I, P...> {};
108
+ template <typename I, typename... P>
109
+ using merge =
110
+ merge_<sizeof...(P) - last_matching_<I::template get, P...>(), I, P...>;
111
+
112
+ } // namespace detail
113
+
114
+ template <typename... Policy>
115
+ struct merge //
116
+ : detail::merge<detail::item_size_type, Policy...>,
117
+ detail::merge<detail::item_in_situ_only, Policy...> {};
118
+
119
+ template <typename SizeType>
120
+ struct policy_size_type {
121
+ using size_type = SizeType;
122
+ };
123
+
124
+ template <bool Value>
125
+ struct policy_in_situ_only {
126
+ using in_situ_only = std::bool_constant<Value>;
127
+ };
128
+
129
+ } // namespace small_vector_policy
130
+
131
+ //////////////////////////////////////////////////////////////////////
132
+
133
+ template <class T, std::size_t M, class P>
134
+ class small_vector;
135
+
136
+ //////////////////////////////////////////////////////////////////////
137
+
138
+ namespace detail {
139
+
140
+ /*
141
+ * Move objects in memory to the right into some uninitialized memory, where
142
+ * the region overlaps. Then call create() for each hole in reverse order.
143
+ *
144
+ * This doesn't just use std::move_backward because move_backward only works
145
+ * if all the memory is initialized to type T already.
146
+ *
147
+ * The create function should return a reference type, to avoid
148
+ * extra copies and moves for non-trivial types.
149
+ */
150
+ template <class T, class Create>
151
+ typename std::enable_if<!std::is_trivially_copyable_v<T>>::type
152
+ moveObjectsRightAndCreate(
153
+ T* const first,
154
+ T* const lastConstructed,
155
+ T* const realLast,
156
+ Create&& create) {
157
+ if (lastConstructed == realLast) {
158
+ return;
159
+ }
160
+
161
+ T* out = realLast;
162
+ T* in = lastConstructed;
163
+ {
164
+ auto rollback = makeGuard([&] {
165
+ // We want to make sure the same stuff is uninitialized memory
166
+ // if we exit via an exception (this is to make sure we provide
167
+ // the basic exception safety guarantee for insert functions).
168
+ if (out < lastConstructed) {
169
+ out = lastConstructed - 1;
170
+ }
171
+ std::destroy(out + 1, realLast);
172
+ });
173
+ // Decrement the pointers only when it is known that the resulting pointer
174
+ // is within the boundaries of the object. Decrementing past the beginning
175
+ // of the object is UB. Note that this is asymmetric wrt forward iteration,
176
+ // as past-the-end pointers are explicitly allowed.
177
+ for (; in != first && out > lastConstructed;) {
178
+ // Out must be decremented before an exception can be thrown so that
179
+ // the rollback guard knows where to start.
180
+ --out;
181
+ new (out) T(std::move(*(--in)));
182
+ }
183
+ for (; in != first;) {
184
+ --out;
185
+ *out = std::move(*(--in));
186
+ }
187
+ for (; out > lastConstructed;) {
188
+ --out;
189
+ new (out) T(create());
190
+ }
191
+ for (; out != first;) {
192
+ --out;
193
+ *out = create();
194
+ }
195
+ rollback.dismiss();
196
+ }
197
+ }
198
+
199
+ // Specialization for trivially copyable types. The call to
200
+ // std::move_backward here will just turn into a memmove.
201
+ // This must only be used with trivially copyable types because some of the
202
+ // memory may be uninitialized, and std::move_backward() won't work when it
203
+ // can't memmove().
204
+ template <class T, class Create>
205
+ typename std::enable_if<std::is_trivially_copyable_v<T>>::type
206
+ moveObjectsRightAndCreate(
207
+ T* const first,
208
+ T* const lastConstructed,
209
+ T* const realLast,
210
+ Create&& create) {
211
+ std::move_backward(first, lastConstructed, realLast);
212
+ T* const end = first - 1;
213
+ T* out = first + (realLast - lastConstructed) - 1;
214
+ for (; out != end; --out) {
215
+ *out = create();
216
+ }
217
+ }
218
+
219
+ /*
220
+ * Populate a region of memory using `op' to construct elements. If
221
+ * anything throws, undo what we did.
222
+ */
223
+ template <class T, class Function>
224
+ void populateMemForward(T* mem, std::size_t n, Function const& op) {
225
+ std::size_t idx = 0;
226
+ {
227
+ auto rollback = makeGuard([&] { std::destroy_n(mem, idx); });
228
+ for (size_t i = 0; i < n; ++i) {
229
+ op(&mem[idx]);
230
+ ++idx;
231
+ }
232
+ rollback.dismiss();
233
+ }
234
+ }
235
+
236
+ /*
237
+ * Copies `fromSize` elements from `from' to `to', where `to' is only
238
+ * initialized up to `toSize`, but has enough storage for `fromSize'. If
239
+ * `toSize' > `fromSize', the extra elements are destructed.
240
+ */
241
+ template <class Iterator1, class Iterator2>
242
+ void partiallyUninitializedCopy(
243
+ Iterator1 from, size_t fromSize, Iterator2 to, size_t toSize) {
244
+ const size_t minSize = std::min(fromSize, toSize);
245
+ std::copy(from, from + minSize, to);
246
+ if (fromSize > toSize) {
247
+ std::uninitialized_copy(from + minSize, from + fromSize, to + minSize);
248
+ } else {
249
+ std::destroy(to + minSize, to + toSize);
250
+ }
251
+ }
252
+
253
+ template <class SizeType, bool ShouldUseHeap, bool AlwaysUseHeap>
254
+ struct IntegralSizePolicyBase {
255
+ typedef SizeType InternalSizeType;
256
+
257
+ IntegralSizePolicyBase() : size_(0) {}
258
+
259
+ protected:
260
+ static constexpr std::size_t policyMaxSize() { return SizeType(~kClearMask); }
261
+
262
+ std::size_t doSize() const {
263
+ return AlwaysUseHeap ? size_ : size_ & ~kClearMask;
264
+ }
265
+
266
+ std::size_t isExtern() const { return AlwaysUseHeap || kExternMask & size_; }
267
+
268
+ void setExtern(bool b) {
269
+ if (AlwaysUseHeap) {
270
+ return;
271
+ }
272
+ if (b) {
273
+ size_ |= kExternMask;
274
+ } else {
275
+ size_ &= ~kExternMask;
276
+ }
277
+ }
278
+
279
+ std::size_t isHeapifiedCapacity() const {
280
+ return AlwaysUseHeap || kCapacityMask & size_;
281
+ }
282
+
283
+ void setHeapifiedCapacity(bool b) {
284
+ if (AlwaysUseHeap) {
285
+ return;
286
+ }
287
+ if (b) {
288
+ size_ |= kCapacityMask;
289
+ } else {
290
+ size_ &= ~kCapacityMask;
291
+ }
292
+ }
293
+ void setSize(std::size_t sz) {
294
+ assert(sz <= policyMaxSize());
295
+ size_ = AlwaysUseHeap ? sz : (kClearMask & size_) | SizeType(sz);
296
+ }
297
+
298
+ void incrementSize(std::size_t n) {
299
+ // We can safely increment size without overflowing into mask bits because
300
+ // we always check new size is less than maxPolicySize (see
301
+ // makeSizeInternal). To be sure, added assertion to verify it.
302
+ assert(doSize() + n <= policyMaxSize());
303
+ size_ += SizeType(n);
304
+ }
305
+ std::size_t getInternalSize() { return size_; }
306
+
307
+ void swapSizePolicy(IntegralSizePolicyBase& o) { std::swap(size_, o.size_); }
308
+
309
+ void resetSizePolicy() { size_ = 0; }
310
+
311
+ protected:
312
+ static bool constexpr kShouldUseHeap = ShouldUseHeap || AlwaysUseHeap;
313
+ static bool constexpr kAlwaysUseHeap = AlwaysUseHeap;
314
+
315
+ private:
316
+ // We reserve two most significant bits of size_.
317
+ static SizeType constexpr kExternMask =
318
+ kShouldUseHeap ? SizeType(1) << (sizeof(SizeType) * 8 - 1) : 0;
319
+
320
+ static SizeType constexpr kCapacityMask =
321
+ kShouldUseHeap ? SizeType(1) << (sizeof(SizeType) * 8 - 2) : 0;
322
+
323
+ static SizeType constexpr kClearMask =
324
+ kShouldUseHeap ? SizeType(3) << (sizeof(SizeType) * 8 - 2) : 0;
325
+
326
+ SizeType size_;
327
+ };
328
+
329
+ template <class SizeType, bool ShouldUseHeap, bool AlwaysUseHeap>
330
+ struct IntegralSizePolicy;
331
+
332
+ template <class SizeType, bool AlwaysUseHeap>
333
+ struct IntegralSizePolicy<SizeType, true, AlwaysUseHeap>
334
+ : public IntegralSizePolicyBase<SizeType, true, AlwaysUseHeap> {
335
+ public:
336
+ /*
337
+ * Move a range to a range of uninitialized memory. Assumes the
338
+ * ranges don't overlap.
339
+ */
340
+ template <class T>
341
+ typename std::enable_if<!std::is_trivially_copyable_v<T>>::type
342
+ moveToUninitialized(T* first, T* last, T* out) {
343
+ std::size_t idx = 0;
344
+ {
345
+ auto rollback = makeGuard([&] {
346
+ // Even for callers trying to give the strong guarantee
347
+ // (e.g. push_back) it's ok to assume here that we don't have to
348
+ // move things back and that it was a copy constructor that
349
+ // threw: if someone throws from a move constructor the effects
350
+ // are unspecified.
351
+ std::destroy_n(out, idx);
352
+ });
353
+ for (; first != last; ++first, ++idx) {
354
+ new (&out[idx]) T(std::move(*first));
355
+ }
356
+ rollback.dismiss();
357
+ }
358
+ }
359
+
360
+ // Specialization for trivially copyable types.
361
+ template <class T>
362
+ typename std::enable_if<std::is_trivially_copyable_v<T>>::type
363
+ moveToUninitialized(T* first, T* last, T* out) {
364
+ std::memmove(
365
+ static_cast<void*>(out),
366
+ static_cast<void const*>(first),
367
+ (last - first) * sizeof *first);
368
+ }
369
+
370
+ /*
371
+ * Move a range to a range of uninitialized memory. Assumes the
372
+ * ranges don't overlap. Inserts an element at out + pos using
373
+ * emplaceFunc(). out will contain (end - begin) + 1 elements on success and
374
+ * none on failure. If emplaceFunc() throws [begin, end) is unmodified.
375
+ */
376
+ template <class T, class EmplaceFunc>
377
+ void moveToUninitializedEmplace(
378
+ T* begin, T* end, T* out, SizeType pos, EmplaceFunc&& emplaceFunc) {
379
+ // Must be called first so that if it throws [begin, end) is unmodified.
380
+ // We have to support the strong exception guarantee for emplace_back().
381
+ emplaceFunc(out + pos);
382
+ // move old elements to the left of the new one
383
+ FOLLY_PUSH_WARNING
384
+ FOLLY_MSVC_DISABLE_WARNING(4702) {
385
+ auto rollback = makeGuard([&] { //
386
+ std::destroy_at(out + pos);
387
+ });
388
+ if (begin) {
389
+ this->moveToUninitialized(begin, begin + pos, out);
390
+ }
391
+ rollback.dismiss();
392
+ }
393
+ // move old elements to the right of the new one
394
+ {
395
+ auto rollback = makeGuard([&] { std::destroy_n(out, pos + 1); });
396
+ if (begin + pos < end) {
397
+ this->moveToUninitialized(begin + pos, end, out + pos + 1);
398
+ }
399
+ rollback.dismiss();
400
+ }
401
+ FOLLY_POP_WARNING
402
+ }
403
+ };
404
+
405
+ template <class SizeType, bool AlwaysUseHeap>
406
+ struct IntegralSizePolicy<SizeType, false, AlwaysUseHeap>
407
+ : public IntegralSizePolicyBase<SizeType, false, AlwaysUseHeap> {
408
+ public:
409
+ template <class T>
410
+ void moveToUninitialized(T* /*first*/, T* /*last*/, T* /*out*/) {
411
+ assume_unreachable();
412
+ }
413
+ template <class T, class EmplaceFunc>
414
+ void moveToUninitializedEmplace(
415
+ T* /* begin */,
416
+ T* /* end */,
417
+ T* /* out */,
418
+ SizeType /* pos */,
419
+ EmplaceFunc&& /* emplaceFunc */) {
420
+ assume_unreachable();
421
+ }
422
+ };
423
+
424
+ /*
425
+ * If you're just trying to use this class, ignore everything about
426
+ * this next small_vector_base class thing.
427
+ *
428
+ * The purpose of this junk is to minimize sizeof(small_vector<>)
429
+ * and allow specifying the template parameters in whatever order is
430
+ * convenient for the user. There's a few extra steps here to try
431
+ * to keep the error messages at least semi-reasonable.
432
+ *
433
+ * Apologies for all the black magic.
434
+ */
435
+ template <class Value, std::size_t RequestedMaxInline, class InPolicy>
436
+ struct small_vector_base {
437
+ static_assert(!std::is_integral<InPolicy>::value, "legacy");
438
+ using Policy = small_vector_policy::merge<
439
+ small_vector_policy::policy_size_type<size_t>,
440
+ small_vector_policy::policy_in_situ_only<false>,
441
+ conditional_t<std::is_void<InPolicy>::value, tag_t<>, InPolicy>>;
442
+
443
+ /*
444
+ * Make the real policy base classes.
445
+ */
446
+ typedef IntegralSizePolicy<
447
+ typename Policy::size_type,
448
+ !Policy::in_situ_only::value,
449
+ RequestedMaxInline == 0>
450
+ ActualSizePolicy;
451
+
452
+ /*
453
+ * Now inherit from them all. This is done in such a convoluted
454
+ * way to make sure we get the empty base optimization on all these
455
+ * types to keep sizeof(small_vector<>) minimal.
456
+ */
457
+ typedef boost::totally_ordered1<
458
+ small_vector<Value, RequestedMaxInline, InPolicy>,
459
+ ActualSizePolicy>
460
+ type;
461
+ };
462
+
463
+ inline void* unshiftPointer(void* p, size_t sizeBytes) {
464
+ return static_cast<char*>(p) - sizeBytes;
465
+ }
466
+
467
+ inline void* shiftPointer(void* p, size_t sizeBytes) {
468
+ return static_cast<char*>(p) + sizeBytes;
469
+ }
470
+ } // namespace detail
471
+
472
+ //////////////////////////////////////////////////////////////////////
473
+ template <class Value, std::size_t RequestedMaxInline = 1, class Policy = void>
474
+ class small_vector
475
+ : public detail::small_vector_base<Value, RequestedMaxInline, Policy>::
476
+ type {
477
+ typedef typename detail::
478
+ small_vector_base<Value, RequestedMaxInline, Policy>::type BaseType;
479
+ typedef typename BaseType::InternalSizeType InternalSizeType;
480
+
481
+ /*
482
+ * Figure out the max number of elements we should inline. (If
483
+ * the user asks for less inlined elements than we can fit unioned
484
+ * into our value_type*, we will inline more than they asked.)
485
+ */
486
+ static constexpr auto kSizeOfValuePtr = sizeof(Value*);
487
+ static constexpr auto kSizeOfValue = sizeof(Value);
488
+ static constexpr std::size_t MaxInline{
489
+ RequestedMaxInline == 0
490
+ ? 0
491
+ : constexpr_max(kSizeOfValuePtr / kSizeOfValue, RequestedMaxInline)};
492
+
493
+ public:
494
+ typedef std::size_t size_type;
495
+ typedef Value value_type;
496
+ typedef std::allocator<Value> allocator_type;
497
+ typedef value_type& reference;
498
+ typedef value_type const& const_reference;
499
+ typedef value_type* iterator;
500
+ typedef value_type* pointer;
501
+ typedef value_type const* const_iterator;
502
+ typedef value_type const* const_pointer;
503
+ typedef std::ptrdiff_t difference_type;
504
+
505
+ typedef std::reverse_iterator<iterator> reverse_iterator;
506
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
507
+
508
+ small_vector() = default;
509
+ // Allocator is unused here. It is taken in for compatibility with std::vector
510
+ // interface, but it will be ignored.
511
+ small_vector(const std::allocator<Value>&) {}
512
+
513
+ small_vector(small_vector const& o) {
514
+ if constexpr (kShouldCopyWholeInlineStorageTrivial) {
515
+ if (!o.isExtern()) {
516
+ copyWholeInlineStorageTrivial(o);
517
+ return;
518
+ }
519
+ }
520
+
521
+ auto n = o.size();
522
+ makeSize(n);
523
+ {
524
+ auto rollback = makeGuard([&] { freeHeap(); });
525
+ std::uninitialized_copy(o.begin(), o.begin() + n, begin());
526
+ rollback.dismiss();
527
+ }
528
+ this->setSize(n);
529
+ }
530
+
531
+ small_vector(small_vector&& o) noexcept(
532
+ std::is_nothrow_move_constructible<Value>::value) {
533
+ if (o.isExtern()) {
534
+ this->u.pdata_.heap_ = o.u.pdata_.heap_;
535
+ o.u.pdata_.heap_ = nullptr;
536
+ this->swapSizePolicy(o);
537
+ if (kHasInlineCapacity) {
538
+ this->u.setCapacity(o.u.getCapacity());
539
+ }
540
+ } else {
541
+ if constexpr (kShouldCopyWholeInlineStorageTrivial) {
542
+ copyWholeInlineStorageTrivial(o);
543
+ o.resetSizePolicy();
544
+ } else if constexpr (IsRelocatable<Value>::value) {
545
+ moveInlineStorageRelocatable(std::move(o));
546
+ } else {
547
+ auto n = o.size();
548
+ std::uninitialized_copy(
549
+ std::make_move_iterator(o.begin()),
550
+ std::make_move_iterator(o.end()),
551
+ begin());
552
+ this->setSize(n);
553
+ o.clear();
554
+ }
555
+ }
556
+ }
557
+
558
+ small_vector(std::initializer_list<value_type> il) {
559
+ constructImpl(il.begin(), il.end(), std::false_type());
560
+ }
561
+
562
+ explicit small_vector(size_type n) {
563
+ doConstruct(n, [&](void* p) { new (p) value_type(); });
564
+ }
565
+
566
+ small_vector(size_type n, value_type const& t) {
567
+ doConstruct(n, [&](void* p) { new (p) value_type(t); });
568
+ }
569
+
570
+ template <class Arg>
571
+ explicit small_vector(Arg arg1, Arg arg2) {
572
+ // Forward using std::is_arithmetic to get to the proper
573
+ // implementation; this disambiguates between the iterators and
574
+ // (size_t, value_type) meaning for this constructor.
575
+ constructImpl(arg1, arg2, std::is_arithmetic<Arg>());
576
+ }
577
+
578
+ ~small_vector() { destroy(); }
579
+
580
+ small_vector& operator=(small_vector const& o) {
581
+ if (FOLLY_LIKELY(this != &o)) {
582
+ if constexpr (kShouldCopyWholeInlineStorageTrivial) {
583
+ if (!this->isExtern() && !o.isExtern()) {
584
+ copyWholeInlineStorageTrivial(o);
585
+ return *this;
586
+ }
587
+ }
588
+ if (o.size() < capacity()) {
589
+ const size_t oSize = o.size();
590
+ detail::partiallyUninitializedCopy(o.begin(), oSize, begin(), size());
591
+ this->setSize(oSize);
592
+ } else {
593
+ assign(o.begin(), o.end());
594
+ }
595
+ }
596
+ return *this;
597
+ }
598
+
599
+ small_vector& operator=(small_vector&& o) noexcept(
600
+ std::is_nothrow_move_constructible<Value>::value) {
601
+ if (FOLLY_LIKELY(this != &o)) {
602
+ // If either is external, reduce to the default-constructed case for this,
603
+ // since there is nothing that we can move in-place.
604
+ if (this->isExtern() || o.isExtern()) {
605
+ reset();
606
+ }
607
+
608
+ if (!o.isExtern()) {
609
+ if constexpr (kShouldCopyWholeInlineStorageTrivial) {
610
+ copyWholeInlineStorageTrivial(o);
611
+ o.resetSizePolicy();
612
+ } else if constexpr (IsRelocatable<Value>::value) {
613
+ std::destroy_n(u.buffer(), size());
614
+ moveInlineStorageRelocatable(std::move(o));
615
+ } else {
616
+ const size_t oSize = o.size();
617
+ detail::partiallyUninitializedCopy(
618
+ std::make_move_iterator(o.u.buffer()),
619
+ oSize,
620
+ this->u.buffer(),
621
+ size());
622
+ this->setSize(oSize);
623
+ o.clear();
624
+ }
625
+ } else {
626
+ this->u.pdata_.heap_ = o.u.pdata_.heap_;
627
+ o.u.pdata_.heap_ = nullptr;
628
+ // this was already reset above, so it's empty and internal.
629
+ this->swapSizePolicy(o);
630
+ if (kHasInlineCapacity) {
631
+ this->u.setCapacity(o.u.getCapacity());
632
+ }
633
+ }
634
+ }
635
+ return *this;
636
+ }
637
+
638
+ bool operator==(small_vector const& o) const {
639
+ return size() == o.size() && std::equal(begin(), end(), o.begin());
640
+ }
641
+
642
+ bool operator<(small_vector const& o) const {
643
+ return std::lexicographical_compare(begin(), end(), o.begin(), o.end());
644
+ }
645
+
646
+ static constexpr size_type max_size() {
647
+ return !BaseType::kShouldUseHeap ? static_cast<size_type>(MaxInline)
648
+ : BaseType::policyMaxSize();
649
+ }
650
+
651
+ allocator_type get_allocator() const { return {}; }
652
+
653
+ size_type size() const { return this->doSize(); }
654
+ bool empty() const { return !size(); }
655
+
656
+ iterator begin() { return data(); }
657
+ iterator end() { return data() + size(); }
658
+ const_iterator begin() const { return data(); }
659
+ const_iterator end() const { return data() + size(); }
660
+ const_iterator cbegin() const { return begin(); }
661
+ const_iterator cend() const { return end(); }
662
+
663
+ reverse_iterator rbegin() { return reverse_iterator(end()); }
664
+ reverse_iterator rend() { return reverse_iterator(begin()); }
665
+
666
+ const_reverse_iterator rbegin() const {
667
+ return const_reverse_iterator(end());
668
+ }
669
+
670
+ const_reverse_iterator rend() const {
671
+ return const_reverse_iterator(begin());
672
+ }
673
+
674
+ const_reverse_iterator crbegin() const { return rbegin(); }
675
+ const_reverse_iterator crend() const { return rend(); }
676
+
677
+ /*
678
+ * Usually one of the simplest functions in a Container-like class
679
+ * but a bit more complex here. We have to handle all combinations
680
+ * of in-place vs. heap between this and o.
681
+ */
682
+ void swap(small_vector& o) noexcept(
683
+ std::is_nothrow_move_constructible<Value>::value &&
684
+ std::is_nothrow_swappable_v<Value>) {
685
+ using std::swap; // Allow ADL on swap for our value_type.
686
+
687
+ if (this->isExtern() && o.isExtern()) {
688
+ this->swapSizePolicy(o);
689
+
690
+ // Cannot use std::swap() because pdata_ is packed.
691
+ auto* tmp = u.pdata_.heap_;
692
+ u.pdata_.heap_ = o.u.pdata_.heap_;
693
+ o.u.pdata_.heap_ = tmp;
694
+
695
+ if (kHasInlineCapacity) {
696
+ const auto currentCapacity = this->u.getCapacity();
697
+ this->setCapacity(o.u.getCapacity());
698
+ o.u.setCapacity(currentCapacity);
699
+ }
700
+
701
+ return;
702
+ }
703
+
704
+ if (!this->isExtern() && !o.isExtern()) {
705
+ auto& oldSmall = size() < o.size() ? *this : o;
706
+ auto& oldLarge = size() < o.size() ? o : *this;
707
+
708
+ for (size_type i = 0; i < oldSmall.size(); ++i) {
709
+ swap(oldSmall[i], oldLarge[i]);
710
+ }
711
+
712
+ size_type i = oldSmall.size();
713
+ const size_type ci = i;
714
+ {
715
+ auto rollback = makeGuard([&] {
716
+ oldSmall.setSize(i);
717
+ std::destroy(oldLarge.begin() + i, oldLarge.end());
718
+ oldLarge.setSize(ci);
719
+ });
720
+ for (; i < oldLarge.size(); ++i) {
721
+ auto addr = oldSmall.begin() + i;
722
+ new (addr) value_type(std::move(oldLarge[i]));
723
+ std::destroy_at(oldLarge.data() + i);
724
+ }
725
+ rollback.dismiss();
726
+ }
727
+ oldSmall.setSize(i);
728
+ oldLarge.setSize(ci);
729
+ return;
730
+ }
731
+
732
+ // isExtern != o.isExtern()
733
+ auto& oldExtern = o.isExtern() ? o : *this;
734
+ auto& oldIntern = o.isExtern() ? *this : o;
735
+
736
+ auto oldExternCapacity = oldExtern.capacity();
737
+ auto oldExternHeap = oldExtern.u.pdata_.heap_;
738
+
739
+ auto buff = oldExtern.u.buffer();
740
+ size_type i = 0;
741
+ {
742
+ auto rollback = makeGuard([&] {
743
+ std::destroy_n(buff, i);
744
+ std::destroy(oldIntern.begin() + i, oldIntern.end());
745
+ oldIntern.resetSizePolicy();
746
+ oldExtern.u.pdata_.heap_ = oldExternHeap;
747
+ oldExtern.setCapacity(oldExternCapacity);
748
+ });
749
+ for (; i < oldIntern.size(); ++i) {
750
+ new (&buff[i]) value_type(std::move(oldIntern[i]));
751
+ std::destroy_at(oldIntern.data() + i);
752
+ }
753
+ rollback.dismiss();
754
+ }
755
+ oldIntern.u.pdata_.heap_ = oldExternHeap;
756
+ this->swapSizePolicy(o);
757
+ oldIntern.setCapacity(oldExternCapacity);
758
+ }
759
+
760
+ void resize(size_type sz) {
761
+ if (sz <= size()) {
762
+ downsize(sz);
763
+ return;
764
+ }
765
+ auto extra = sz - size();
766
+ makeSize(sz);
767
+ detail::populateMemForward(
768
+ begin() + size(), extra, [&](void* p) { new (p) value_type(); });
769
+ this->incrementSize(extra);
770
+ }
771
+
772
+ void resize(size_type sz, value_type const& v) {
773
+ if (sz < size()) {
774
+ erase(begin() + sz, end());
775
+ return;
776
+ }
777
+ auto extra = sz - size();
778
+ makeSize(sz);
779
+ detail::populateMemForward(
780
+ begin() + size(), extra, [&](void* p) { new (p) value_type(v); });
781
+ this->incrementSize(extra);
782
+ }
783
+
784
+ value_type* data() noexcept {
785
+ return this->isExtern() ? u.heap() : u.buffer();
786
+ }
787
+
788
+ value_type const* data() const noexcept {
789
+ return this->isExtern() ? u.heap() : u.buffer();
790
+ }
791
+
792
+ template <class... Args>
793
+ iterator emplace(const_iterator p, Args&&... args) {
794
+ if (p == cend()) {
795
+ emplace_back(std::forward<Args>(args)...);
796
+ return end() - 1;
797
+ }
798
+
799
+ /*
800
+ * We implement emplace at places other than at the back with a
801
+ * temporary for exception safety reasons. It is possible to
802
+ * avoid having to do this, but it becomes hard to maintain the
803
+ * basic exception safety guarantee (unless you respond to a copy
804
+ * constructor throwing by clearing the whole vector).
805
+ *
806
+ * The reason for this is that otherwise you have to destruct an
807
+ * element before constructing this one in its place---if the
808
+ * constructor throws, you either need a nothrow default
809
+ * constructor or a nothrow copy/move to get something back in the
810
+ * "gap", and the vector requirements don't guarantee we have any
811
+ * of these. Clearing the whole vector is a legal response in
812
+ * this situation, but it seems like this implementation is easy
813
+ * enough and probably better.
814
+ */
815
+ return insert(p, value_type(std::forward<Args>(args)...));
816
+ }
817
+
818
+ void reserve(size_type sz) { makeSize(sz); }
819
+
820
+ size_type capacity() const {
821
+ struct Unreachable {
822
+ size_t operator()(void*) const { assume_unreachable(); }
823
+ };
824
+ using AllocationSizeOrUnreachable =
825
+ conditional_t<kMustTrackHeapifiedCapacity, Unreachable, AllocationSize>;
826
+ if (this->isExtern()) {
827
+ if (hasCapacity()) {
828
+ return u.getCapacity();
829
+ }
830
+ return AllocationSizeOrUnreachable{}(u.pdata_.heap_) / sizeof(value_type);
831
+ }
832
+ return MaxInline;
833
+ }
834
+
835
+ void shrink_to_fit() {
836
+ if (!this->isExtern()) {
837
+ return;
838
+ }
839
+
840
+ small_vector tmp(begin(), end());
841
+ tmp.swap(*this);
842
+ }
843
+
844
+ template <class... Args>
845
+ reference emplace_back(Args&&... args) {
846
+ auto isize_ = this->getInternalSize();
847
+ if (isize_ < MaxInline) {
848
+ new (u.buffer() + isize_) value_type(std::forward<Args>(args)...);
849
+ this->incrementSize(1);
850
+ return *(u.buffer() + isize_);
851
+ }
852
+ if (!BaseType::kShouldUseHeap) {
853
+ throw_exception<std::length_error>("max_size exceeded in small_vector");
854
+ }
855
+ auto currentSize = size();
856
+ auto currentCapacity = capacity();
857
+ if (currentCapacity == currentSize) {
858
+ // Any of args may be references into the vector.
859
+ // When we are reallocating, we have to be careful to construct the new
860
+ // element before modifying the data in the old buffer.
861
+ makeSize(
862
+ currentSize + 1,
863
+ [&](void* p) { new (p) value_type(std::forward<Args>(args)...); },
864
+ currentSize);
865
+ } else {
866
+ // We know the vector is stored in the heap.
867
+ new (u.heap() + currentSize) value_type(std::forward<Args>(args)...);
868
+ }
869
+ this->incrementSize(1);
870
+ return *(u.heap() + currentSize);
871
+ }
872
+
873
+ void push_back(value_type&& t) { emplace_back(std::move(t)); }
874
+
875
+ void push_back(value_type const& t) { emplace_back(t); }
876
+
877
+ void pop_back() {
878
+ // ideally this would be implemented in terms of erase(end() - 1) to reuse
879
+ // the higher-level abstraction, but neither Clang or GCC are able to
880
+ // optimize it away. if you change this, please verify (with disassembly)
881
+ // that the generated code on -O3 (and ideally -O2) stays short
882
+ downsize(size() - 1);
883
+ }
884
+
885
+ iterator insert(const_iterator constp, value_type&& t) {
886
+ iterator p = unconst(constp);
887
+ if (p == end()) {
888
+ push_back(std::move(t));
889
+ return end() - 1;
890
+ }
891
+
892
+ auto offset = p - begin();
893
+ auto currentSize = size();
894
+ if (capacity() == currentSize) {
895
+ makeSize(
896
+ currentSize + 1,
897
+ [&t](void* ptr) { new (ptr) value_type(std::move(t)); },
898
+ offset);
899
+ this->incrementSize(1);
900
+ } else {
901
+ detail::moveObjectsRightAndCreate(
902
+ data() + offset,
903
+ data() + currentSize,
904
+ data() + currentSize + 1,
905
+ [&]() mutable -> value_type&& { return std::move(t); });
906
+ this->incrementSize(1);
907
+ }
908
+ return begin() + offset;
909
+ }
910
+
911
+ iterator insert(const_iterator p, value_type const& t) {
912
+ // Make a copy and forward to the rvalue value_type&& overload
913
+ // above.
914
+ //
915
+ // std::move() is necessary to avoid an MSVC compiler bug which will
916
+ // issue this warning when used with unsigned int:
917
+ // warning C4717 : 'folly::small_vector<unsigned int,192,void>::insert':
918
+ // recursive on all control paths, function will cause runtime stack
919
+ // overflow
920
+ return insert(p, std::move(value_type(t)));
921
+ }
922
+
923
+ iterator insert(const_iterator pos, size_type n, value_type const& val) {
924
+ auto offset = pos - begin();
925
+ if (n != 0) {
926
+ auto currentSize = size();
927
+ makeSize(currentSize + n);
928
+ detail::moveObjectsRightAndCreate(
929
+ data() + offset,
930
+ data() + currentSize,
931
+ data() + currentSize + n,
932
+ [&]() mutable -> value_type const& { return val; });
933
+ this->incrementSize(n);
934
+ }
935
+ return begin() + offset;
936
+ }
937
+
938
+ template <class Arg>
939
+ iterator insert(const_iterator p, Arg arg1, Arg arg2) {
940
+ // Forward using std::is_arithmetic to get to the proper
941
+ // implementation; this disambiguates between the iterators and
942
+ // (size_t, value_type) meaning for this function.
943
+ return insertImpl(unconst(p), arg1, arg2, std::is_arithmetic<Arg>());
944
+ }
945
+
946
+ iterator insert(const_iterator p, std::initializer_list<value_type> il) {
947
+ return insert(p, il.begin(), il.end());
948
+ }
949
+
950
+ iterator erase(const_iterator q) {
951
+ // ideally this would be implemented in terms of erase(q, q + 1) to reuse
952
+ // the higher-level abstraction, but neither Clang or GCC are able to
953
+ // optimize it away. if you change this, please verify (with disassembly)
954
+ // that the generated code on -O3 (and ideally -O2) stays short
955
+ std::move(unconst(q) + 1, end(), unconst(q));
956
+ downsize(size() - 1);
957
+ return unconst(q);
958
+ }
959
+
960
+ iterator erase(const_iterator q1, const_iterator q2) {
961
+ if (q1 == q2) {
962
+ return unconst(q1);
963
+ }
964
+ std::move(unconst(q2), end(), unconst(q1));
965
+ downsize(size() - std::distance(q1, q2));
966
+ return unconst(q1);
967
+ }
968
+
969
+ void clear() {
970
+ // ideally this would be implemented in terms of erase(begin(), end()) to
971
+ // reuse the higher-level abstraction, but neither Clang or GCC are able to
972
+ // optimize it away. if you change this, please verify (with disassembly)
973
+ // that the generated code on -O3 (and ideally -O2) stays short
974
+ downsize(0);
975
+ }
976
+
977
+ template <class Arg>
978
+ void assign(Arg first, Arg last) {
979
+ clear();
980
+ insert(end(), first, last);
981
+ }
982
+
983
+ void assign(std::initializer_list<value_type> il) {
984
+ assign(il.begin(), il.end());
985
+ }
986
+
987
+ void assign(size_type n, const value_type& t) {
988
+ clear();
989
+ insert(end(), n, t);
990
+ }
991
+
992
+ reference front() {
993
+ assert(!empty());
994
+ return *begin();
995
+ }
996
+ reference back() {
997
+ assert(!empty());
998
+ return *(end() - 1);
999
+ }
1000
+ const_reference front() const {
1001
+ assert(!empty());
1002
+ return *begin();
1003
+ }
1004
+ const_reference back() const {
1005
+ assert(!empty());
1006
+ return *(end() - 1);
1007
+ }
1008
+
1009
+ reference operator[](size_type i) {
1010
+ assert(i < size());
1011
+ return *(begin() + i);
1012
+ }
1013
+
1014
+ const_reference operator[](size_type i) const {
1015
+ assert(i < size());
1016
+ return *(begin() + i);
1017
+ }
1018
+
1019
+ reference at(size_type i) {
1020
+ if (i >= size()) {
1021
+ throw_exception<std::out_of_range>("index out of range");
1022
+ }
1023
+ return (*this)[i];
1024
+ }
1025
+
1026
+ const_reference at(size_type i) const {
1027
+ if (i >= size()) {
1028
+ throw_exception<std::out_of_range>("index out of range");
1029
+ }
1030
+ return (*this)[i];
1031
+ }
1032
+
1033
+ private:
1034
+ static iterator unconst(const_iterator it) {
1035
+ return const_cast<iterator>(it);
1036
+ }
1037
+
1038
+ void downsize(size_type sz) {
1039
+ assert(sz <= size());
1040
+ std::destroy(begin() + sz, end());
1041
+ this->setSize(sz);
1042
+ }
1043
+
1044
+ void copyWholeInlineStorageTrivial(small_vector const& o) {
1045
+ static_assert(std::is_trivially_copyable_v<Value>);
1046
+ FOLLY_PUSH_WARNING
1047
+ FOLLY_GCC_DISABLE_WARNING("-Warray-bounds")
1048
+ std::copy(o.u.buffer(), o.u.buffer() + MaxInline, u.buffer());
1049
+ FOLLY_POP_WARNING
1050
+ this->setSize(o.size());
1051
+ }
1052
+
1053
+ void moveInlineStorageRelocatable(small_vector&& o) {
1054
+ static_assert(IsRelocatable<Value>::value);
1055
+ const auto n = o.size();
1056
+ FOLLY_PUSH_WARNING
1057
+ FOLLY_GCC_DISABLE_WARNING("-Wclass-memaccess")
1058
+ if constexpr (kMayCopyWholeInlineStorage) {
1059
+ std::memcpy(u.buffer(), o.u.buffer(), MaxInline * kSizeOfValue);
1060
+ } else {
1061
+ std::memcpy(u.buffer(), o.u.buffer(), n * kSizeOfValue);
1062
+ }
1063
+ FOLLY_POP_WARNING
1064
+ this->setSize(n);
1065
+ o.resetSizePolicy();
1066
+ }
1067
+
1068
+ void reset() {
1069
+ clear();
1070
+ freeHeap();
1071
+ this->resetSizePolicy();
1072
+ }
1073
+
1074
+ // The std::false_type argument is part of disambiguating the
1075
+ // iterator insert functions from integral types (see insert().)
1076
+ template <class It>
1077
+ iterator insertImpl(iterator pos, It first, It last, std::false_type) {
1078
+ if (first == last) {
1079
+ return pos;
1080
+ }
1081
+ using categ = typename std::iterator_traits<It>::iterator_category;
1082
+ using it_ref = typename std::iterator_traits<It>::reference;
1083
+ if (std::is_same<categ, std::input_iterator_tag>::value) {
1084
+ auto offset = pos - begin();
1085
+ while (first != last) {
1086
+ pos = insert(pos, *first++);
1087
+ ++pos;
1088
+ }
1089
+ return begin() + offset;
1090
+ }
1091
+
1092
+ auto const distance = std::distance(first, last);
1093
+ auto const offset = pos - begin();
1094
+ auto currentSize = size();
1095
+ assert(distance >= 0);
1096
+ assert(offset >= 0);
1097
+ makeSize(currentSize + distance);
1098
+ detail::moveObjectsRightAndCreate(
1099
+ data() + offset,
1100
+ data() + currentSize,
1101
+ data() + currentSize + distance,
1102
+ [&, in = last]() mutable -> it_ref { return *--in; });
1103
+ this->incrementSize(distance);
1104
+ return begin() + offset;
1105
+ }
1106
+
1107
+ iterator insertImpl(
1108
+ iterator pos, size_type n, const value_type& val, std::true_type) {
1109
+ // The true_type means this should call the size_t,value_type
1110
+ // overload. (See insert().)
1111
+ return insert(pos, n, val);
1112
+ }
1113
+
1114
+ void destroy() {
1115
+ std::destroy(begin(), end());
1116
+ freeHeap();
1117
+ }
1118
+
1119
+ // The std::false_type argument came from std::is_arithmetic as part
1120
+ // of disambiguating an overload (see the comment in the
1121
+ // constructor).
1122
+ template <class It>
1123
+ void constructImpl(It first, It last, std::false_type) {
1124
+ typedef typename std::iterator_traits<It>::iterator_category categ;
1125
+ if (std::is_same<categ, std::input_iterator_tag>::value) {
1126
+ // With iterators that only allow a single pass, we can't really
1127
+ // do anything sane here.
1128
+ auto rollback = makeGuard([&] { destroy(); });
1129
+ while (first != last) {
1130
+ emplace_back(*first++);
1131
+ }
1132
+ rollback.dismiss();
1133
+ return;
1134
+ }
1135
+ size_type distance = std::distance(first, last);
1136
+ if (distance <= MaxInline) {
1137
+ this->incrementSize(distance);
1138
+ detail::populateMemForward(
1139
+ u.buffer(), distance, [&](void* p) { new (p) value_type(*first++); });
1140
+ return;
1141
+ }
1142
+ makeSize(distance);
1143
+ this->incrementSize(distance);
1144
+ {
1145
+ auto rollback = makeGuard([&] { freeHeap(); });
1146
+ detail::populateMemForward(
1147
+ u.heap(), distance, [&](void* p) { new (p) value_type(*first++); });
1148
+ rollback.dismiss();
1149
+ }
1150
+ }
1151
+
1152
+ template <typename InitFunc>
1153
+ void doConstruct(size_type n, InitFunc&& func) {
1154
+ makeSize(n);
1155
+ assert(size() == 0);
1156
+ this->incrementSize(n);
1157
+ {
1158
+ auto rollback = makeGuard([&] { freeHeap(); });
1159
+ detail::populateMemForward(data(), n, std::forward<InitFunc>(func));
1160
+ rollback.dismiss();
1161
+ }
1162
+ }
1163
+
1164
+ // The true_type means we should forward to the size_t,value_type
1165
+ // overload.
1166
+ void constructImpl(size_type n, value_type const& val, std::true_type) {
1167
+ doConstruct(n, [&](void* p) { new (p) value_type(val); });
1168
+ }
1169
+
1170
+ /*
1171
+ * Compute the size after growth.
1172
+ */
1173
+ size_type computeNewSize() const {
1174
+ size_t c = capacity();
1175
+ if (!checked_mul(&c, c, size_t(3))) {
1176
+ throw_exception<std::length_error>(
1177
+ "Requested new size exceeds size representable by size_type");
1178
+ }
1179
+ c = (c / 2) + 1;
1180
+ return static_cast<size_type>(std::min<size_t>(c, max_size()));
1181
+ }
1182
+
1183
+ void makeSize(size_type newSize) {
1184
+ if (newSize <= capacity()) {
1185
+ return;
1186
+ }
1187
+ makeSizeInternal(newSize, false, [](void*) { assume_unreachable(); }, 0);
1188
+ }
1189
+
1190
+ template <typename EmplaceFunc>
1191
+ void makeSize(size_type newSize, EmplaceFunc&& emplaceFunc, size_type pos) {
1192
+ assert(size() == capacity());
1193
+ makeSizeInternal(
1194
+ newSize, true, std::forward<EmplaceFunc>(emplaceFunc), pos);
1195
+ }
1196
+
1197
+ /*
1198
+ * Ensure we have a large enough memory region to be size `newSize'.
1199
+ * Will move/copy elements if we are spilling to heap_ or needed to
1200
+ * allocate a new region, but if resized in place doesn't initialize
1201
+ * anything in the new region. In any case doesn't change size().
1202
+ * Supports insertion of new element during reallocation by given
1203
+ * pointer to new element and position of new element.
1204
+ * NOTE: If reallocation is not needed, insert must be false,
1205
+ * because we only know how to emplace elements into new memory.
1206
+ */
1207
+ template <typename EmplaceFunc>
1208
+ void makeSizeInternal(
1209
+ size_type newSize,
1210
+ bool insert,
1211
+ EmplaceFunc&& emplaceFunc,
1212
+ size_type pos) {
1213
+ if (newSize > max_size()) {
1214
+ throw_exception<std::length_error>("max_size exceeded in small_vector");
1215
+ }
1216
+ assert(this->kShouldUseHeap);
1217
+ // This branch isn't needed for correctness, but allows the optimizer to
1218
+ // skip generating code for the rest of this function in in-situ-only
1219
+ // small_vectors.
1220
+ if (!this->kShouldUseHeap) {
1221
+ return;
1222
+ }
1223
+
1224
+ newSize = std::max(newSize, computeNewSize());
1225
+
1226
+ size_t needBytes = newSize;
1227
+ if (!checked_mul(&needBytes, needBytes, sizeof(value_type))) {
1228
+ throw_exception<std::length_error>(
1229
+ "Requested new size exceeds size representable by size_type");
1230
+ }
1231
+ // If the capacity isn't explicitly stored inline, but the heap
1232
+ // allocation is grown to over some threshold, we should store
1233
+ // a capacity at the front of the heap allocation.
1234
+ const bool heapifyCapacity =
1235
+ !kHasInlineCapacity && needBytes >= kHeapifyCapacityThreshold;
1236
+ const size_t allocationExtraBytes =
1237
+ heapifyCapacity ? kHeapifyCapacitySize : 0;
1238
+ size_t needAllocSizeBytes = needBytes;
1239
+ if (!checked_add(
1240
+ &needAllocSizeBytes, needAllocSizeBytes, allocationExtraBytes)) {
1241
+ throw_exception<std::length_error>(
1242
+ "Requested new size exceeds size representable by size_type");
1243
+ }
1244
+ const size_t goodAllocationSizeBytes = goodMallocSize(needAllocSizeBytes);
1245
+ const size_t goodAllocationNewCapacity =
1246
+ (goodAllocationSizeBytes - allocationExtraBytes) / sizeof(value_type);
1247
+ const size_t newCapacity = std::min(goodAllocationNewCapacity, max_size());
1248
+ // Make sure that the allocation request has a size computable from the
1249
+ // capacity, instead of using goodAllocationSizeBytes, so that we can do
1250
+ // sized deallocation. If goodMallocSize() gives us extra bytes that are not
1251
+ // a multiple of the value size we cannot use them anyway.
1252
+ const size_t sizeBytes =
1253
+ newCapacity * sizeof(value_type) + allocationExtraBytes;
1254
+ void* newh = checkedMalloc(sizeBytes);
1255
+ value_type* newp = static_cast<value_type*>(
1256
+ heapifyCapacity ? detail::shiftPointer(newh, kHeapifyCapacitySize)
1257
+ : newh);
1258
+
1259
+ {
1260
+ auto rollback = makeGuard([&] { //
1261
+ sizedFree(newh, sizeBytes);
1262
+ });
1263
+ if (insert) {
1264
+ // move and insert the new element
1265
+ this->moveToUninitializedEmplace(
1266
+ begin(), end(), newp, pos, std::forward<EmplaceFunc>(emplaceFunc));
1267
+ } else {
1268
+ // move without inserting new element
1269
+ if (data()) {
1270
+ this->moveToUninitialized(begin(), end(), newp);
1271
+ }
1272
+ }
1273
+ rollback.dismiss();
1274
+ }
1275
+ annotate_object_leaked(newh);
1276
+ std::destroy(begin(), end());
1277
+ freeHeap();
1278
+ // Store shifted pointer if capacity is heapified
1279
+ u.pdata_.heap_ = newp;
1280
+ this->setHeapifiedCapacity(heapifyCapacity);
1281
+ this->setExtern(true);
1282
+ this->setCapacity(newCapacity);
1283
+ }
1284
+
1285
+ /*
1286
+ * This will set the capacity field, stored inline in the storage_ field
1287
+ * if there is sufficient room to store it.
1288
+ */
1289
+ void setCapacity(size_type newCapacity) {
1290
+ assert(this->isExtern());
1291
+ if (hasCapacity()) {
1292
+ assert(newCapacity < std::numeric_limits<InternalSizeType>::max());
1293
+ u.setCapacity(newCapacity);
1294
+ }
1295
+ }
1296
+
1297
+ private:
1298
+ // These internal classes are packed to minimize total memory usage,
1299
+ // however, it is important that we don't pack the class as a whole
1300
+ // otherwise the inline storage may not have the correct alignment
1301
+ // for the value type.
1302
+ FOLLY_SV_PACK_PUSH
1303
+ struct HeapPtrWithCapacity {
1304
+ value_type* heap_;
1305
+ InternalSizeType capacity_;
1306
+
1307
+ InternalSizeType getCapacity() const { return capacity_; }
1308
+ void setCapacity(InternalSizeType c) { capacity_ = c; }
1309
+ size_t allocationExtraBytes() const { return 0; }
1310
+ } FOLLY_SV_PACK_ATTR;
1311
+ FOLLY_SV_PACK_POP
1312
+
1313
+ FOLLY_SV_PACK_PUSH
1314
+ struct HeapPtr {
1315
+ // heap[-kHeapifyCapacitySize] contains capacity
1316
+ value_type* heap_;
1317
+
1318
+ InternalSizeType getCapacity() const {
1319
+ return heap_ ? *static_cast<InternalSizeType*>(
1320
+ detail::unshiftPointer(heap_, kHeapifyCapacitySize))
1321
+ : 0;
1322
+ }
1323
+ void setCapacity(InternalSizeType c) {
1324
+ *static_cast<InternalSizeType*>(
1325
+ detail::unshiftPointer(heap_, kHeapifyCapacitySize)) = c;
1326
+ }
1327
+ size_t allocationExtraBytes() const { return kHeapifyCapacitySize; }
1328
+ } FOLLY_SV_PACK_ATTR;
1329
+ FOLLY_SV_PACK_POP
1330
+
1331
+ static constexpr size_t kMaxInlineNonZero = MaxInline ? MaxInline : 1u;
1332
+ typedef aligned_storage_for_t<value_type[kMaxInlineNonZero]>
1333
+ InlineStorageDataType;
1334
+
1335
+ typedef typename std::conditional<
1336
+ sizeof(value_type) * MaxInline != 0,
1337
+ InlineStorageDataType,
1338
+ char>::type InlineStorageType;
1339
+
1340
+ // If the storage is small enough, it is usually faster to copy it entirely,
1341
+ // instead of just size() values, to make the loop fixed-size and
1342
+ // unrollable. Limit is half of a cache line, to minimize probability of
1343
+ // crossing a cache line and thus introducing an unnecessary cache miss.
1344
+ static constexpr bool kMayCopyWholeInlineStorage =
1345
+ sizeof(InlineStorageType) <= hardware_constructive_interference_size / 2;
1346
+
1347
+ static constexpr bool kShouldCopyWholeInlineStorageTrivial =
1348
+ std::is_trivially_copyable_v<Value> && kMayCopyWholeInlineStorage;
1349
+
1350
+ static bool constexpr kHasInlineCapacity = !BaseType::kAlwaysUseHeap &&
1351
+ sizeof(HeapPtrWithCapacity) < sizeof(InlineStorageType);
1352
+
1353
+ // This value should we multiple of word size.
1354
+ static size_t constexpr kHeapifyCapacitySize =
1355
+ sizeof(aligned_storage_t<sizeof(InternalSizeType), alignof(value_type)>);
1356
+
1357
+ struct AllocationSize {
1358
+ auto operator()(void* ptr) const {
1359
+ (void)ptr;
1360
+ #if defined(FOLLY_HAVE_MALLOC_USABLE_SIZE)
1361
+ return malloc_usable_size(ptr);
1362
+ #endif
1363
+ // it is important that this method not return a size_t if we can't call
1364
+ // malloc_usable_size! kMustTrackHeapifiedCapacity uses the deduced return
1365
+ // type of this function in order to decide whether small_vector must
1366
+ // track its own capacity or not.
1367
+ }
1368
+ };
1369
+
1370
+ static bool constexpr kMustTrackHeapifiedCapacity =
1371
+ BaseType::kAlwaysUseHeap ||
1372
+ !is_invocable_r_v<size_t, AllocationSize, void*>;
1373
+
1374
+ // Threshold to control capacity heapifying.
1375
+ static size_t constexpr kHeapifyCapacityThreshold =
1376
+ (kMustTrackHeapifiedCapacity ? 0 : 100) * kHeapifyCapacitySize;
1377
+
1378
+ static bool constexpr kAlwaysHasCapacity =
1379
+ kHasInlineCapacity || kMustTrackHeapifiedCapacity;
1380
+
1381
+ typedef typename std::
1382
+ conditional<kHasInlineCapacity, HeapPtrWithCapacity, HeapPtr>::type
1383
+ PointerType;
1384
+
1385
+ bool hasCapacity() const {
1386
+ return kAlwaysHasCapacity || !kHeapifyCapacityThreshold ||
1387
+ this->isHeapifiedCapacity();
1388
+ }
1389
+
1390
+ void freeHeap() {
1391
+ if (!this->isExtern() || !u.pdata_.heap_) {
1392
+ return;
1393
+ }
1394
+
1395
+ if (hasCapacity()) {
1396
+ auto extraBytes = u.pdata_.allocationExtraBytes();
1397
+ auto vp = detail::unshiftPointer(u.pdata_.heap_, extraBytes);
1398
+ annotate_object_collected(vp);
1399
+ sizedFree(vp, u.getCapacity() * sizeof(value_type) + extraBytes);
1400
+ } else {
1401
+ auto vp = u.pdata_.heap_;
1402
+ annotate_object_collected(vp);
1403
+ free(vp);
1404
+ }
1405
+ }
1406
+
1407
+ union Data {
1408
+ explicit Data() { pdata_.heap_ = nullptr; }
1409
+
1410
+ PointerType pdata_;
1411
+ InlineStorageType storage_;
1412
+
1413
+ value_type* buffer() noexcept {
1414
+ void* vp = &storage_;
1415
+ return static_cast<value_type*>(vp);
1416
+ }
1417
+ value_type const* buffer() const noexcept {
1418
+ return const_cast<Data*>(this)->buffer();
1419
+ }
1420
+ value_type* heap() noexcept { return pdata_.heap_; }
1421
+ value_type const* heap() const noexcept { return pdata_.heap_; }
1422
+
1423
+ InternalSizeType getCapacity() const { return pdata_.getCapacity(); }
1424
+ void setCapacity(InternalSizeType c) { pdata_.setCapacity(c); }
1425
+
1426
+ } u;
1427
+ };
1428
+
1429
+ //////////////////////////////////////////////////////////////////////
1430
+
1431
+ // Basic guarantee only, or provides the nothrow guarantee iff T has a
1432
+ // nothrow move or copy constructor.
1433
+ template <class T, std::size_t MaxInline, class P>
1434
+ void swap(small_vector<T, MaxInline, P>& a, small_vector<T, MaxInline, P>& b) {
1435
+ a.swap(b);
1436
+ }
1437
+
1438
+ template <class T, std::size_t MaxInline, class P, class U>
1439
+ void erase(small_vector<T, MaxInline, P>& v, U value) {
1440
+ v.erase(std::remove(v.begin(), v.end(), value), v.end());
1441
+ }
1442
+
1443
+ template <class T, std::size_t MaxInline, class P, class Predicate>
1444
+ void erase_if(small_vector<T, MaxInline, P>& v, Predicate predicate) {
1445
+ v.erase(std::remove_if(v.begin(), v.end(), std::ref(predicate)), v.end());
1446
+ }
1447
+
1448
+ //////////////////////////////////////////////////////////////////////
1449
+
1450
+ namespace detail {
1451
+
1452
+ // Format support.
1453
+ template <class T, size_t M, class P>
1454
+ struct IndexableTraits<small_vector<T, M, P>>
1455
+ : public IndexableTraitsSeq<small_vector<T, M, P>> {};
1456
+
1457
+ } // namespace detail
1458
+
1459
+ } // namespace folly
1460
+
1461
+ FOLLY_POP_WARNING
1462
+
1463
+ #undef FOLLY_SV_PACK_ATTR
1464
+ #undef FOLLY_SV_PACK_PUSH
1465
+ #undef FOLLY_SV_PACK_POP
1466
+
1467
+ namespace std {
1468
+
1469
+ template <class T, std::size_t M, class P>
1470
+ struct hash<folly::small_vector<T, M, P>> {
1471
+ size_t operator()(const folly::small_vector<T, M, P>& v) const {
1472
+ return folly::hash::hash_range(v.begin(), v.end());
1473
+ }
1474
+ };
1475
+
1476
+ } // namespace std