react-native-windows 0.84.0 → 0.84.1

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 (921) hide show
  1. package/Directory.Build.props +2 -17
  2. package/Folly/ThreadNameStub.cpp +4 -6
  3. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +1 -1
  4. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +1 -7
  5. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -3
  6. package/PropertySheets/CIBuildOptimizations.props +2 -2
  7. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  8. package/PropertySheets/JSEngine.props +1 -1
  9. package/PropertySheets/NuGet.LockFile.props +10 -1
  10. package/PropertySheets/React.Cpp.props +3 -3
  11. package/ReactCommon/ReactCommon.vcxproj +0 -5
  12. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +61 -6
  13. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -37
  14. package/Scripts/UpdateNightlyDependencies.ps1 +47 -0
  15. package/Scripts/creaternwapp.cmd +5 -8
  16. package/Scripts/creaternwlib.cmd +10 -23
  17. package/Shared/Shared.vcxitems +2 -0
  18. package/{Folly → external}/.clang-format +0 -1
  19. package/external/External.vcxitems +10 -0
  20. package/external/fast-float/.syncignore +10 -0
  21. package/external/fast-float/LICENSE-APACHE +190 -0
  22. package/external/fast-float/LICENSE-BOOST +23 -0
  23. package/external/fast-float/LICENSE-MIT +27 -0
  24. package/external/fast-float/README.md +545 -0
  25. package/external/fast-float/cgmanifest.json +15 -0
  26. package/external/fast-float/fast-float.vcxitems +14 -0
  27. package/external/fast-float/include/fast_float/ascii_number.h +588 -0
  28. package/external/fast-float/include/fast_float/bigint.h +638 -0
  29. package/external/fast-float/include/fast_float/constexpr_feature_detect.h +46 -0
  30. package/external/fast-float/include/fast_float/decimal_to_binary.h +212 -0
  31. package/external/fast-float/include/fast_float/digit_comparison.h +457 -0
  32. package/external/fast-float/include/fast_float/fast_float.h +59 -0
  33. package/external/fast-float/include/fast_float/fast_table.h +708 -0
  34. package/external/fast-float/include/fast_float/float_common.h +1240 -0
  35. package/external/fast-float/include/fast_float/parse_number.h +399 -0
  36. package/external/fast-float/sync-config.json +8 -0
  37. package/external/fmt/.syncignore +10 -0
  38. package/external/fmt/CONTRIBUTING.md +20 -0
  39. package/external/fmt/LICENSE +27 -0
  40. package/external/fmt/README.md +484 -0
  41. package/external/fmt/doc/ChangeLog-old.md +3290 -0
  42. package/external/fmt/doc/api.md +650 -0
  43. package/external/fmt/doc/fmt.css +61 -0
  44. package/external/fmt/doc/fmt.js +4 -0
  45. package/external/fmt/doc/get-started.md +222 -0
  46. package/external/fmt/doc/index.md +151 -0
  47. package/external/fmt/doc/perf.svg +1 -0
  48. package/external/fmt/doc/python-license.txt +290 -0
  49. package/external/fmt/doc/syntax.md +887 -0
  50. package/external/fmt/fmt.vcxitems +28 -0
  51. package/external/fmt/include/fmt/args.h +228 -0
  52. package/external/fmt/include/fmt/base.h +3077 -0
  53. package/external/fmt/include/fmt/chrono.h +2432 -0
  54. package/external/fmt/include/fmt/color.h +612 -0
  55. package/external/fmt/include/fmt/compile.h +529 -0
  56. package/external/fmt/include/fmt/core.h +5 -0
  57. package/external/fmt/include/fmt/format-inl.h +1928 -0
  58. package/external/fmt/include/fmt/format.h +4427 -0
  59. package/external/fmt/include/fmt/os.h +439 -0
  60. package/external/fmt/include/fmt/ostream.h +211 -0
  61. package/external/fmt/include/fmt/printf.h +656 -0
  62. package/external/fmt/include/fmt/ranges.h +882 -0
  63. package/external/fmt/include/fmt/std.h +699 -0
  64. package/external/fmt/include/fmt/xchar.h +322 -0
  65. package/external/fmt/src/fmt.cc +135 -0
  66. package/external/fmt/src/format.cc +43 -0
  67. package/external/fmt/src/os.cc +403 -0
  68. package/external/fmt/sync-config.json +8 -0
  69. package/external/folly/.syncignore +60 -0
  70. package/external/folly/LICENSE +200 -0
  71. package/external/folly/README.md +263 -0
  72. package/{fmt → external/folly/folly}/.clang-format +0 -1
  73. package/external/folly/folly/AtomicHashArray-inl.h +546 -0
  74. package/external/folly/folly/AtomicHashArray.h +431 -0
  75. package/external/folly/folly/AtomicHashMap-inl.h +653 -0
  76. package/external/folly/folly/AtomicHashMap.h +484 -0
  77. package/external/folly/folly/AtomicIntrusiveLinkedList.h +206 -0
  78. package/external/folly/folly/AtomicLinkedList.h +110 -0
  79. package/external/folly/folly/AtomicUnorderedMap.h +522 -0
  80. package/external/folly/folly/BUCK +1631 -0
  81. package/external/folly/folly/BUILD_MODE.bzl +72 -0
  82. package/external/folly/folly/Benchmark.cpp +986 -0
  83. package/external/folly/folly/Benchmark.h +680 -0
  84. package/external/folly/folly/BenchmarkUtil.h +47 -0
  85. package/external/folly/folly/Bits.h +17 -0
  86. package/external/folly/folly/CMakeLists.txt +110 -0
  87. package/external/folly/folly/CPortability.h +338 -0
  88. package/external/folly/folly/CancellationToken-inl.h +449 -0
  89. package/external/folly/folly/CancellationToken.cpp +250 -0
  90. package/external/folly/folly/CancellationToken.h +365 -0
  91. package/external/folly/folly/Chrono.h +132 -0
  92. package/external/folly/folly/ClockGettimeWrappers.cpp +93 -0
  93. package/external/folly/folly/ClockGettimeWrappers.h +29 -0
  94. package/external/folly/folly/ConcurrentBitSet.h +157 -0
  95. package/external/folly/folly/ConcurrentLazy.h +74 -0
  96. package/external/folly/folly/ConcurrentSkipList-inl.h +341 -0
  97. package/external/folly/folly/ConcurrentSkipList.h +824 -0
  98. package/external/folly/folly/ConstructorCallbackList.h +158 -0
  99. package/external/folly/folly/Conv.h +2026 -0
  100. package/external/folly/folly/CppAttributes.h +170 -0
  101. package/external/folly/folly/CpuId.h +297 -0
  102. package/external/folly/folly/DefaultKeepAliveExecutor.h +172 -0
  103. package/external/folly/folly/Demangle.cpp +255 -0
  104. package/external/folly/folly/Demangle.h +73 -0
  105. package/external/folly/folly/DiscriminatedPtr.h +236 -0
  106. package/external/folly/folly/DynamicConverter.h +17 -0
  107. package/external/folly/folly/Exception.h +150 -0
  108. package/external/folly/folly/ExceptionString.cpp +51 -0
  109. package/external/folly/folly/ExceptionString.h +33 -0
  110. package/external/folly/folly/ExceptionWrapper-inl.h +264 -0
  111. package/external/folly/folly/ExceptionWrapper.cpp +37 -0
  112. package/external/folly/folly/ExceptionWrapper.h +377 -0
  113. package/external/folly/folly/Executor.cpp +111 -0
  114. package/external/folly/folly/Executor.h +351 -0
  115. package/external/folly/folly/Expected.h +1725 -0
  116. package/external/folly/folly/FBString.h +2888 -0
  117. package/external/folly/folly/FBVector.h +17 -0
  118. package/external/folly/folly/File.cpp +180 -0
  119. package/external/folly/folly/File.h +177 -0
  120. package/external/folly/folly/FileUtil.cpp +378 -0
  121. package/external/folly/folly/FileUtil.h +332 -0
  122. package/external/folly/folly/Fingerprint.cpp +135 -0
  123. package/external/folly/folly/Fingerprint.h +289 -0
  124. package/external/folly/folly/FixedString.h +2965 -0
  125. package/external/folly/folly/FollyMemcpy.cpp +30 -0
  126. package/external/folly/folly/FollyMemcpy.h +23 -0
  127. package/external/folly/folly/FollyMemset.cpp +29 -0
  128. package/external/folly/folly/FollyMemset.h +25 -0
  129. package/external/folly/folly/Format-inl.h +1152 -0
  130. package/external/folly/folly/Format.cpp +429 -0
  131. package/external/folly/folly/Format.h +463 -0
  132. package/external/folly/folly/FormatArg.h +285 -0
  133. package/external/folly/folly/FormatTraits.h +65 -0
  134. package/external/folly/folly/Function.h +1159 -0
  135. package/external/folly/folly/GLog.h +85 -0
  136. package/external/folly/folly/GroupVarint.cpp +153 -0
  137. package/external/folly/folly/GroupVarint.h +630 -0
  138. package/external/folly/folly/Hash.h +20 -0
  139. package/external/folly/folly/IPAddress.cpp +490 -0
  140. package/external/folly/folly/IPAddress.h +667 -0
  141. package/external/folly/folly/IPAddressException.h +82 -0
  142. package/external/folly/folly/IPAddressV4.cpp +305 -0
  143. package/external/folly/folly/IPAddressV4.h +495 -0
  144. package/external/folly/folly/IPAddressV6.cpp +541 -0
  145. package/external/folly/folly/IPAddressV6.h +627 -0
  146. package/external/folly/folly/Indestructible.h +164 -0
  147. package/external/folly/folly/IndexedMemPool.h +550 -0
  148. package/external/folly/folly/IntrusiveList.h +17 -0
  149. package/external/folly/folly/Lazy.h +142 -0
  150. package/external/folly/folly/Likely.h +76 -0
  151. package/external/folly/folly/MPMCPipeline.h +280 -0
  152. package/external/folly/folly/MPMCQueue.h +1556 -0
  153. package/external/folly/folly/MacAddress.cpp +188 -0
  154. package/external/folly/folly/MacAddress.h +260 -0
  155. package/external/folly/folly/MapUtil.h +17 -0
  156. package/external/folly/folly/Math.h +258 -0
  157. package/external/folly/folly/MaybeManagedPtr.h +120 -0
  158. package/external/folly/folly/Memory.h +900 -0
  159. package/external/folly/folly/MicroLock.cpp +76 -0
  160. package/external/folly/folly/MicroLock.h +354 -0
  161. package/external/folly/folly/MicroSpinLock.h +17 -0
  162. package/external/folly/folly/MoveWrapper.h +76 -0
  163. package/external/folly/folly/ObserverContainer.h +1026 -0
  164. package/external/folly/folly/Optional.h +743 -0
  165. package/external/folly/folly/Overload.h +325 -0
  166. package/external/folly/folly/PackedSyncPtr.h +147 -0
  167. package/external/folly/folly/Padded.h +464 -0
  168. package/external/folly/folly/Poly-inl.h +230 -0
  169. package/external/folly/folly/Poly.h +1095 -0
  170. package/external/folly/folly/PolyException.h +43 -0
  171. package/external/folly/folly/Portability.h +644 -0
  172. package/external/folly/folly/Preprocessor.h +236 -0
  173. package/external/folly/folly/ProducerConsumerQueue.h +182 -0
  174. package/external/folly/folly/RWSpinLock.h +17 -0
  175. package/external/folly/folly/Random-inl.h +86 -0
  176. package/external/folly/folly/Random.cpp +184 -0
  177. package/external/folly/folly/Random.h +434 -0
  178. package/external/folly/folly/Range.h +1772 -0
  179. package/external/folly/folly/Replaceable.h +636 -0
  180. package/external/folly/folly/ScopeGuard.cpp +29 -0
  181. package/external/folly/folly/ScopeGuard.h +420 -0
  182. package/external/folly/folly/SharedMutex.cpp +81 -0
  183. package/external/folly/folly/SharedMutex.h +1751 -0
  184. package/external/folly/folly/Singleton-inl.h +332 -0
  185. package/external/folly/folly/Singleton.cpp +512 -0
  186. package/external/folly/folly/Singleton.h +891 -0
  187. package/external/folly/folly/SingletonThreadLocal.cpp +53 -0
  188. package/external/folly/folly/SingletonThreadLocal.h +263 -0
  189. package/external/folly/folly/SocketAddress.cpp +786 -0
  190. package/external/folly/folly/SocketAddress.h +768 -0
  191. package/external/folly/folly/SpinLock.h +55 -0
  192. package/external/folly/folly/String-inl.h +668 -0
  193. package/external/folly/folly/String.cpp +777 -0
  194. package/external/folly/folly/String.h +767 -0
  195. package/external/folly/folly/Subprocess.cpp +1142 -0
  196. package/external/folly/folly/Subprocess.h +1055 -0
  197. package/external/folly/folly/Synchronized.h +1833 -0
  198. package/external/folly/folly/SynchronizedPtr.h +106 -0
  199. package/external/folly/folly/ThreadCachedInt.h +175 -0
  200. package/external/folly/folly/ThreadLocal.h +478 -0
  201. package/external/folly/folly/TimeoutQueue.cpp +78 -0
  202. package/external/folly/folly/TimeoutQueue.h +123 -0
  203. package/external/folly/folly/TokenBucket.h +673 -0
  204. package/external/folly/folly/Traits.h +1442 -0
  205. package/external/folly/folly/Try-inl.h +372 -0
  206. package/external/folly/folly/Try.cpp +23 -0
  207. package/external/folly/folly/Try.h +728 -0
  208. package/external/folly/folly/UTF8String.h +56 -0
  209. package/external/folly/folly/Unicode.cpp +201 -0
  210. package/external/folly/folly/Unicode.h +94 -0
  211. package/external/folly/folly/Unit.h +65 -0
  212. package/external/folly/folly/Uri-inl.h +101 -0
  213. package/external/folly/folly/Uri.cpp +190 -0
  214. package/external/folly/folly/Uri.h +142 -0
  215. package/external/folly/folly/Utility.h +932 -0
  216. package/external/folly/folly/VERSION +1 -0
  217. package/external/folly/folly/Varint.h +230 -0
  218. package/external/folly/folly/VirtualExecutor.h +17 -0
  219. package/external/folly/folly/algorithm/simd/BUCK +47 -0
  220. package/external/folly/folly/algorithm/simd/Contains.cpp +42 -0
  221. package/external/folly/folly/algorithm/simd/Contains.h +116 -0
  222. package/external/folly/folly/algorithm/simd/FindFixed.h +301 -0
  223. package/external/folly/folly/algorithm/simd/Ignore.h +52 -0
  224. package/external/folly/folly/algorithm/simd/Movemask.h +207 -0
  225. package/external/folly/folly/algorithm/simd/detail/BUCK +70 -0
  226. package/external/folly/folly/algorithm/simd/detail/ContainsImpl.h +91 -0
  227. package/external/folly/folly/algorithm/simd/detail/SimdAnyOf.h +83 -0
  228. package/external/folly/folly/algorithm/simd/detail/SimdForEach.h +209 -0
  229. package/external/folly/folly/algorithm/simd/detail/SimdPlatform.h +445 -0
  230. package/external/folly/folly/algorithm/simd/detail/Traits.h +125 -0
  231. package/external/folly/folly/algorithm/simd/detail/UnrollUtils.h +126 -0
  232. package/external/folly/folly/base64.h +264 -0
  233. package/external/folly/folly/chrono/BUCK +29 -0
  234. package/external/folly/folly/chrono/Clock.h +65 -0
  235. package/external/folly/folly/chrono/Conv.h +712 -0
  236. package/external/folly/folly/chrono/test/BUCK +26 -0
  237. package/external/folly/folly/chrono/test/ClockTest.cpp +68 -0
  238. package/external/folly/folly/chrono/test/ConvTest.cpp +652 -0
  239. package/external/folly/folly/concurrency/AtomicSharedPtr.h +387 -0
  240. package/external/folly/folly/concurrency/BUCK +170 -0
  241. package/external/folly/folly/concurrency/CacheLocality.h +460 -0
  242. package/external/folly/folly/concurrency/ConcurrentHashMap.h +822 -0
  243. package/external/folly/folly/concurrency/CoreCachedSharedPtr.h +232 -0
  244. package/external/folly/folly/concurrency/DeadlockDetector.cpp +27 -0
  245. package/external/folly/folly/concurrency/DeadlockDetector.h +44 -0
  246. package/external/folly/folly/concurrency/DynamicBoundedQueue.h +751 -0
  247. package/external/folly/folly/concurrency/PriorityUnboundedQueueSet.h +207 -0
  248. package/external/folly/folly/concurrency/ProcessLocalUniqueId.cpp +46 -0
  249. package/external/folly/folly/concurrency/ProcessLocalUniqueId.h +38 -0
  250. package/external/folly/folly/concurrency/SingletonRelaxedCounter.h +325 -0
  251. package/external/folly/folly/concurrency/ThreadCachedSynchronized.h +227 -0
  252. package/external/folly/folly/concurrency/UnboundedQueue.h +891 -0
  253. package/external/folly/folly/concurrency/container/BUCK +77 -0
  254. package/external/folly/folly/concurrency/container/FlatCombiningPriorityQueue.h +426 -0
  255. package/external/folly/folly/concurrency/container/LockFreeRingBuffer.h +306 -0
  256. package/external/folly/folly/concurrency/container/RelaxedConcurrentPriorityQueue.h +1212 -0
  257. package/external/folly/folly/concurrency/container/SingleWriterFixedHashMap.h +322 -0
  258. package/external/folly/folly/concurrency/container/atomic_grow_array.h +564 -0
  259. package/external/folly/folly/concurrency/container/test/BUCK +75 -0
  260. package/external/folly/folly/concurrency/container/test/FlatCombiningPriorityQueueTest.cpp +570 -0
  261. package/external/folly/folly/concurrency/container/test/LockFreeRingBufferTest.cpp +276 -0
  262. package/external/folly/folly/concurrency/container/test/RelaxedConcurrentPriorityQueueTest.cpp +1570 -0
  263. package/external/folly/folly/concurrency/container/test/SingleWriterFixedHashMapTest.cpp +401 -0
  264. package/external/folly/folly/concurrency/container/test/atomic_grow_array_test.cpp +187 -0
  265. package/external/folly/folly/concurrency/detail/AtomicSharedPtr-detail.h +212 -0
  266. package/external/folly/folly/concurrency/detail/ConcurrentHashMap-detail.h +1911 -0
  267. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.cpp +43 -0
  268. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.h +190 -0
  269. package/external/folly/folly/concurrency/memory/BUCK +53 -0
  270. package/external/folly/folly/concurrency/memory/PrimaryPtr.h +338 -0
  271. package/external/folly/folly/concurrency/memory/ReadMostlySharedPtr.h +511 -0
  272. package/external/folly/folly/concurrency/memory/TLRefCount.h +228 -0
  273. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrBenchmark.cpp +56 -0
  274. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrTest.cpp +454 -0
  275. package/external/folly/folly/concurrency/memory/test/BUCK +95 -0
  276. package/external/folly/folly/concurrency/memory/test/PrimaryPtrTest.cpp +303 -0
  277. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrBenchmark.cpp +138 -0
  278. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrStressTest.cpp +75 -0
  279. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrTest.cpp +378 -0
  280. package/external/folly/folly/concurrency/memory/test/RefCountBenchmark.cpp +90 -0
  281. package/external/folly/folly/concurrency/memory/test/RefCountTest.cpp +168 -0
  282. package/external/folly/folly/concurrency/test/AtomicSharedPtrCounted.h +156 -0
  283. package/external/folly/folly/concurrency/test/AtomicSharedPtrPerformance.cpp +255 -0
  284. package/external/folly/folly/concurrency/test/AtomicSharedPtrTest.cpp +257 -0
  285. package/external/folly/folly/concurrency/test/BUCK +229 -0
  286. package/external/folly/folly/concurrency/test/CacheLocalityBenchmark.cpp +392 -0
  287. package/external/folly/folly/concurrency/test/CacheLocalityTest.cpp +1229 -0
  288. package/external/folly/folly/concurrency/test/ConcurrentHashMapBench.cpp +260 -0
  289. package/external/folly/folly/concurrency/test/ConcurrentHashMapTest.cpp +1242 -0
  290. package/external/folly/folly/concurrency/test/CoreCachedSharedPtrTest.cpp +408 -0
  291. package/external/folly/folly/concurrency/test/DynamicBoundedQueueTest.cpp +984 -0
  292. package/external/folly/folly/concurrency/test/PriorityUnboundedQueueSetTest.cpp +73 -0
  293. package/external/folly/folly/concurrency/test/ProcessLocalUniqueIdTest.cpp +66 -0
  294. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterBench.cpp +101 -0
  295. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterTest.cpp +185 -0
  296. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedBench.cpp +76 -0
  297. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedTest.cpp +93 -0
  298. package/external/folly/folly/concurrency/test/UnboundedQueueTest.cpp +1302 -0
  299. package/external/folly/folly/container/Access.h +57 -0
  300. package/external/folly/folly/container/Array.h +87 -0
  301. package/external/folly/folly/container/BUCK +353 -0
  302. package/external/folly/folly/container/BitIterator.h +203 -0
  303. package/external/folly/folly/container/Enumerate.h +162 -0
  304. package/external/folly/folly/container/EvictingCacheMap.h +730 -0
  305. package/external/folly/folly/container/F14.md +300 -0
  306. package/external/folly/folly/container/F14Map-fwd.h +113 -0
  307. package/external/folly/folly/container/F14Map.h +2108 -0
  308. package/external/folly/folly/container/F14Set-fwd.h +95 -0
  309. package/external/folly/folly/container/F14Set.h +1603 -0
  310. package/external/folly/folly/container/FBVector.h +1711 -0
  311. package/external/folly/folly/container/Foreach-inl.h +316 -0
  312. package/external/folly/folly/container/Foreach.h +209 -0
  313. package/external/folly/folly/container/HeterogeneousAccess-fwd.h +33 -0
  314. package/external/folly/folly/container/HeterogeneousAccess.h +171 -0
  315. package/external/folly/folly/container/IntrusiveHeap.h +268 -0
  316. package/external/folly/folly/container/IntrusiveList.h +131 -0
  317. package/external/folly/folly/container/Iterator.h +843 -0
  318. package/external/folly/folly/container/MapUtil.h +376 -0
  319. package/external/folly/folly/container/Merge.h +90 -0
  320. package/external/folly/folly/container/RegexMatchCache.cpp +521 -0
  321. package/external/folly/folly/container/RegexMatchCache.h +699 -0
  322. package/external/folly/folly/container/Reserve.h +109 -0
  323. package/external/folly/folly/container/SparseByteSet.h +123 -0
  324. package/external/folly/folly/container/View.h +81 -0
  325. package/external/folly/folly/container/WeightedEvictingCacheMap.h +651 -0
  326. package/external/folly/folly/container/detail/BUCK +115 -0
  327. package/external/folly/folly/container/detail/BitIteratorDetail.h +87 -0
  328. package/external/folly/folly/container/detail/F14Defaults.h +34 -0
  329. package/external/folly/folly/container/detail/F14IntrinsicsAvailability.h +67 -0
  330. package/external/folly/folly/container/detail/F14MapFallback.h +717 -0
  331. package/external/folly/folly/container/detail/F14Mask.h +235 -0
  332. package/external/folly/folly/container/detail/F14Policy.h +1523 -0
  333. package/external/folly/folly/container/detail/F14SetFallback.h +528 -0
  334. package/external/folly/folly/container/detail/F14Table.cpp +71 -0
  335. package/external/folly/folly/container/detail/F14Table.h +2680 -0
  336. package/external/folly/folly/container/detail/Util.h +303 -0
  337. package/external/folly/folly/container/detail/tape_detail.h +135 -0
  338. package/external/folly/folly/container/detail/test/BUCK +14 -0
  339. package/external/folly/folly/container/detail/test/F14DetailTest.cpp +47 -0
  340. package/external/folly/folly/container/heap_vector_types.h +1683 -0
  341. package/external/folly/folly/container/range_traits.h +81 -0
  342. package/external/folly/folly/container/small_vector.h +1476 -0
  343. package/external/folly/folly/container/sorted_vector_types.h +1652 -0
  344. package/external/folly/folly/container/span.h +408 -0
  345. package/external/folly/folly/container/tape.h +608 -0
  346. package/external/folly/folly/container/test/.clang-tidy +12 -0
  347. package/external/folly/folly/container/test/AccessTest.cpp +138 -0
  348. package/external/folly/folly/container/test/ArrayTest.cpp +84 -0
  349. package/external/folly/folly/container/test/BUCK +568 -0
  350. package/external/folly/folly/container/test/BitIteratorBench.cpp +112 -0
  351. package/external/folly/folly/container/test/BitIteratorTest.cpp +109 -0
  352. package/external/folly/folly/container/test/EnumerateTest.cpp +294 -0
  353. package/external/folly/folly/container/test/EvictingCacheMapBench.cpp +80 -0
  354. package/external/folly/folly/container/test/EvictingCacheMapTest.cpp +842 -0
  355. package/external/folly/folly/container/test/F14AsanSupportTest.cpp +143 -0
  356. package/external/folly/folly/container/test/F14FwdTest.cpp +37 -0
  357. package/external/folly/folly/container/test/F14InterprocessTest.cpp +404 -0
  358. package/external/folly/folly/container/test/F14MapTest.cpp +2543 -0
  359. package/external/folly/folly/container/test/F14PolicyTest.cpp +49 -0
  360. package/external/folly/folly/container/test/F14SetTest.cpp +1738 -0
  361. package/external/folly/folly/container/test/F14SmallOverheads.cpp +215 -0
  362. package/external/folly/folly/container/test/F14TestUtil.h +117 -0
  363. package/external/folly/folly/container/test/FBVectorBenchmark.cpp +380 -0
  364. package/external/folly/folly/container/test/FBVectorBenchmarks.cpp.h +100 -0
  365. package/external/folly/folly/container/test/FBVectorTest.cpp +326 -0
  366. package/external/folly/folly/container/test/FBVectorTests.cpp.h +304 -0
  367. package/external/folly/folly/container/test/ForeachBenchmark.cpp +388 -0
  368. package/external/folly/folly/container/test/ForeachTest.cpp +338 -0
  369. package/external/folly/folly/container/test/HashMapsBench.cpp +458 -0
  370. package/external/folly/folly/container/test/HeterogeneousAccessTest.cpp +242 -0
  371. package/external/folly/folly/container/test/IntrusiveHeapTest.cpp +262 -0
  372. package/external/folly/folly/container/test/IteratorTest.cpp +989 -0
  373. package/external/folly/folly/container/test/MapUtilTest.cpp +365 -0
  374. package/external/folly/folly/container/test/MergeTest.cpp +66 -0
  375. package/external/folly/folly/container/test/RegexMatchCacheTest.cpp +634 -0
  376. package/external/folly/folly/container/test/ReserveTest.cpp +173 -0
  377. package/external/folly/folly/container/test/SparseByteSetBenchmark.cpp +153 -0
  378. package/external/folly/folly/container/test/SparseByteSetTest.cpp +117 -0
  379. package/external/folly/folly/container/test/TrackingTypes.h +584 -0
  380. package/external/folly/folly/container/test/UtilTest.cpp +609 -0
  381. package/external/folly/folly/container/test/WeightedEvictingCacheMapTest.cpp +800 -0
  382. package/external/folly/folly/container/test/heap_vector_types_test.cpp +1774 -0
  383. package/external/folly/folly/container/test/range_traits_test.cpp +59 -0
  384. package/external/folly/folly/container/test/small_vector_test.cpp +1571 -0
  385. package/external/folly/folly/container/test/sorted_vector_test.cpp +1589 -0
  386. package/external/folly/folly/container/test/span_test.cpp +520 -0
  387. package/external/folly/folly/container/test/tape_bench.cpp +200 -0
  388. package/external/folly/folly/container/test/tape_test.cpp +590 -0
  389. package/external/folly/folly/defs.bzl +238 -0
  390. package/external/folly/folly/detail/AsyncTrace.cpp +36 -0
  391. package/external/folly/folly/detail/AsyncTrace.h +44 -0
  392. package/external/folly/folly/detail/AtomicHashUtils.h +42 -0
  393. package/external/folly/folly/detail/AtomicUnorderedMapUtils.h +80 -0
  394. package/external/folly/folly/detail/BUCK +406 -0
  395. package/external/folly/folly/detail/DiscriminatedPtrDetail.h +172 -0
  396. package/external/folly/folly/detail/FileUtilDetail.cpp +63 -0
  397. package/external/folly/folly/detail/FileUtilDetail.h +85 -0
  398. package/external/folly/folly/detail/FileUtilVectorDetail.h +81 -0
  399. package/external/folly/folly/detail/FingerprintPolynomial.h +132 -0
  400. package/external/folly/folly/detail/Futex-inl.h +123 -0
  401. package/external/folly/folly/detail/Futex.cpp +273 -0
  402. package/external/folly/folly/detail/Futex.h +109 -0
  403. package/external/folly/folly/detail/GroupVarintDetail.h +101 -0
  404. package/external/folly/folly/detail/IPAddress.cpp +37 -0
  405. package/external/folly/folly/detail/IPAddress.h +57 -0
  406. package/external/folly/folly/detail/IPAddressSource.h +278 -0
  407. package/external/folly/folly/detail/Iterators.h +156 -0
  408. package/external/folly/folly/detail/MPMCPipelineDetail.h +122 -0
  409. package/external/folly/folly/detail/MemoryIdler.cpp +233 -0
  410. package/external/folly/folly/detail/MemoryIdler.h +216 -0
  411. package/external/folly/folly/detail/PerfScoped.cpp +112 -0
  412. package/external/folly/folly/detail/PerfScoped.h +70 -0
  413. package/external/folly/folly/detail/PolyDetail.h +921 -0
  414. package/external/folly/folly/detail/RangeCommon.cpp +55 -0
  415. package/external/folly/folly/detail/RangeCommon.h +93 -0
  416. package/external/folly/folly/detail/RangeSse42.cpp +198 -0
  417. package/external/folly/folly/detail/RangeSse42.h +30 -0
  418. package/external/folly/folly/detail/SimpleSimdStringUtils.cpp +31 -0
  419. package/external/folly/folly/detail/SimpleSimdStringUtils.h +27 -0
  420. package/external/folly/folly/detail/SimpleSimdStringUtilsImpl.h +63 -0
  421. package/external/folly/folly/detail/Singleton.h +34 -0
  422. package/external/folly/folly/detail/SlowFingerprint.h +90 -0
  423. package/external/folly/folly/detail/SocketFastOpen.cpp +175 -0
  424. package/external/folly/folly/detail/SocketFastOpen.h +89 -0
  425. package/external/folly/folly/detail/SplitStringSimd.cpp +84 -0
  426. package/external/folly/folly/detail/SplitStringSimd.h +151 -0
  427. package/external/folly/folly/detail/SplitStringSimdImpl.h +149 -0
  428. package/external/folly/folly/detail/Sse.cpp +35 -0
  429. package/external/folly/folly/detail/Sse.h +45 -0
  430. package/external/folly/folly/detail/StaticSingletonManager.cpp +119 -0
  431. package/external/folly/folly/detail/StaticSingletonManager.h +298 -0
  432. package/external/folly/folly/detail/ThreadLocalDetail.cpp +492 -0
  433. package/external/folly/folly/detail/ThreadLocalDetail.h +800 -0
  434. package/external/folly/folly/detail/TrapOnAvx512.cpp +41 -0
  435. package/external/folly/folly/detail/TrapOnAvx512.h +21 -0
  436. package/external/folly/folly/detail/TurnSequencer.h +295 -0
  437. package/external/folly/folly/detail/TypeList.h +551 -0
  438. package/external/folly/folly/detail/UniqueInstance.cpp +136 -0
  439. package/external/folly/folly/detail/UniqueInstance.h +68 -0
  440. package/external/folly/folly/detail/base64_detail/BUCK +102 -0
  441. package/external/folly/folly/detail/base64_detail/Base64Api.cpp +40 -0
  442. package/external/folly/folly/detail/base64_detail/Base64Api.h +101 -0
  443. package/external/folly/folly/detail/base64_detail/Base64Common.h +80 -0
  444. package/external/folly/folly/detail/base64_detail/Base64Constants.h +79 -0
  445. package/external/folly/folly/detail/base64_detail/Base64HiddenConstants.h +129 -0
  446. package/external/folly/folly/detail/base64_detail/Base64SWAR.cpp +161 -0
  447. package/external/folly/folly/detail/base64_detail/Base64SWAR.h +32 -0
  448. package/external/folly/folly/detail/base64_detail/Base64Scalar.h +262 -0
  449. package/external/folly/folly/detail/base64_detail/Base64Simd.h +102 -0
  450. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.cpp +42 -0
  451. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.h +33 -0
  452. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2_Platform.h +167 -0
  453. package/external/folly/folly/detail/base64_detail/README.md +392 -0
  454. package/external/folly/folly/detail/base64_detail/tests/BUCK +36 -0
  455. package/external/folly/folly/detail/base64_detail/tests/Base64AgainstScalarTest.cpp +141 -0
  456. package/external/folly/folly/detail/base64_detail/tests/Base64PlatformTest.cpp +273 -0
  457. package/external/folly/folly/detail/base64_detail/tests/Base64SpecialCasesTest.cpp +555 -0
  458. package/external/folly/folly/detail/test/AsyncTraceTest.cpp +43 -0
  459. package/external/folly/folly/detail/test/BUCK +118 -0
  460. package/external/folly/folly/detail/test/FileUtilDetailTest.cpp +56 -0
  461. package/external/folly/folly/detail/test/PerfScopedTest.cpp +107 -0
  462. package/external/folly/folly/detail/test/SimpleSimdStringUtilsTest.cpp +92 -0
  463. package/external/folly/folly/detail/test/SplitStringSimdTest.cpp +242 -0
  464. package/external/folly/folly/detail/test/StaticSingletonManagerTest.cpp +121 -0
  465. package/external/folly/folly/detail/test/ThreadLocalBenchmark.cpp +116 -0
  466. package/external/folly/folly/detail/test/ThreadLocalDetailTest.cpp +194 -0
  467. package/external/folly/folly/detail/test/TrapOnAvx512TestNegative.cpp +29 -0
  468. package/external/folly/folly/detail/test/UniqueInstanceTest.cpp +60 -0
  469. package/external/folly/folly/detail/thread_local_globals.cpp +69 -0
  470. package/external/folly/folly/detail/thread_local_globals.h +36 -0
  471. package/external/folly/folly/docs/AtomicHashMap.md +134 -0
  472. package/external/folly/folly/docs/Benchmark.md +310 -0
  473. package/external/folly/folly/docs/Conv.md +291 -0
  474. package/external/folly/folly/docs/Dynamic.md +220 -0
  475. package/external/folly/folly/docs/DynamicConverter.md +71 -0
  476. package/external/folly/folly/docs/Executors.md +63 -0
  477. package/external/folly/folly/docs/FBString.md +46 -0
  478. package/external/folly/folly/docs/FBVector.md +200 -0
  479. package/external/folly/folly/docs/Fbvector--graphical_solutions.png +0 -0
  480. package/external/folly/folly/docs/Format.md +177 -0
  481. package/external/folly/folly/docs/Function.md +92 -0
  482. package/external/folly/folly/docs/Futures.md +263 -0
  483. package/external/folly/folly/docs/GroupVarint.md +46 -0
  484. package/external/folly/folly/docs/Histogram.md +104 -0
  485. package/external/folly/folly/docs/MapUtils.md +80 -0
  486. package/external/folly/folly/docs/Overview.md +263 -0
  487. package/external/folly/folly/docs/PackedSyncPtr.md +77 -0
  488. package/external/folly/folly/docs/Poly.md +500 -0
  489. package/external/folly/folly/docs/ProducerConsumerQueue.md +82 -0
  490. package/external/folly/folly/docs/Rcu.md +218 -0
  491. package/external/folly/folly/docs/SmallLocks.md +24 -0
  492. package/external/folly/folly/docs/Synchronized.md +793 -0
  493. package/external/folly/folly/docs/ThreadCachedInt.md +98 -0
  494. package/external/folly/folly/docs/ThreadLocal.md +105 -0
  495. package/external/folly/folly/docs/Traits.md +161 -0
  496. package/external/folly/folly/docs/small_vector.md +64 -0
  497. package/external/folly/folly/docs/style.css +23 -0
  498. package/external/folly/folly/dynamic-inl.h +17 -0
  499. package/external/folly/folly/dynamic.h +17 -0
  500. package/external/folly/folly/folly_extended_library.bzl +28 -0
  501. package/external/folly/folly/functional/ApplyTuple.h +204 -0
  502. package/external/folly/folly/functional/BUCK +57 -0
  503. package/external/folly/folly/functional/Invoke.h +880 -0
  504. package/external/folly/folly/functional/Partial.h +130 -0
  505. package/external/folly/folly/functional/protocol.h +203 -0
  506. package/external/folly/folly/functional/test/ApplyTupleTest.cpp +549 -0
  507. package/external/folly/folly/functional/test/BUCK +57 -0
  508. package/external/folly/folly/functional/test/InvokeTest.cpp +483 -0
  509. package/external/folly/folly/functional/test/PartialTest.cpp +141 -0
  510. package/external/folly/folly/functional/test/protocol_test.cpp +177 -0
  511. package/external/folly/folly/functional/test/traits_test.cpp +551 -0
  512. package/external/folly/folly/functional/traits.h +675 -0
  513. package/external/folly/folly/hash/BUCK +86 -0
  514. package/external/folly/folly/hash/Checksum.cpp +275 -0
  515. package/external/folly/folly/hash/Checksum.h +94 -0
  516. package/external/folly/folly/hash/FarmHash.h +46 -0
  517. package/external/folly/folly/hash/Hash.h +1045 -0
  518. package/external/folly/folly/hash/MurmurHash.h +86 -0
  519. package/external/folly/folly/hash/SpookyHashV1.cpp +391 -0
  520. package/external/folly/folly/hash/SpookyHashV1.h +307 -0
  521. package/external/folly/folly/hash/SpookyHashV2.cpp +392 -0
  522. package/external/folly/folly/hash/SpookyHashV2.h +339 -0
  523. package/external/folly/folly/hash/detail/BUCK +26 -0
  524. package/external/folly/folly/hash/detail/ChecksumDetail.cpp +296 -0
  525. package/external/folly/folly/hash/detail/ChecksumDetail.h +137 -0
  526. package/external/folly/folly/hash/detail/Crc32CombineDetail.cpp +191 -0
  527. package/external/folly/folly/hash/detail/Crc32cDetail.cpp +303 -0
  528. package/external/folly/folly/hash/test/BUCK +132 -0
  529. package/external/folly/folly/hash/test/ChecksumBenchmark.cpp +91 -0
  530. package/external/folly/folly/hash/test/ChecksumTest.cpp +587 -0
  531. package/external/folly/folly/hash/test/FarmHashTest.cpp +41 -0
  532. package/external/folly/folly/hash/test/HashBenchmark.cpp +238 -0
  533. package/external/folly/folly/hash/test/HashTest.cpp +997 -0
  534. package/external/folly/folly/hash/test/MurmurHashTest.cpp +76 -0
  535. package/external/folly/folly/hash/test/SpookyHashV1Test.cpp +559 -0
  536. package/external/folly/folly/hash/test/SpookyHashV2Test.cpp +549 -0
  537. package/external/folly/folly/hash/test/traits_test.cpp +69 -0
  538. package/external/folly/folly/hash/traits.h +115 -0
  539. package/external/folly/folly/json/BUCK +155 -0
  540. package/external/folly/folly/json/DynamicConverter.h +464 -0
  541. package/external/folly/folly/json/DynamicParser-inl.h +316 -0
  542. package/external/folly/folly/json/DynamicParser.cpp +198 -0
  543. package/external/folly/folly/json/DynamicParser.h +394 -0
  544. package/external/folly/folly/json/JSONSchema.cpp +1030 -0
  545. package/external/folly/folly/json/JSONSchema.h +73 -0
  546. package/external/folly/folly/json/JsonMockUtil.h +73 -0
  547. package/external/folly/folly/json/JsonTestUtil.cpp +167 -0
  548. package/external/folly/folly/json/JsonTestUtil.h +88 -0
  549. package/external/folly/folly/json/bser/BUCK +24 -0
  550. package/external/folly/folly/json/bser/Bser.h +107 -0
  551. package/external/folly/folly/json/bser/Dump.cpp +253 -0
  552. package/external/folly/folly/json/bser/Load.cpp +246 -0
  553. package/external/folly/folly/json/bser/test/BUCK +14 -0
  554. package/external/folly/folly/json/bser/test/BserTest.cpp +149 -0
  555. package/external/folly/folly/json/dynamic.cpp +552 -0
  556. package/external/folly/folly/json/dynamic.h +1346 -0
  557. package/external/folly/folly/json/json.h +238 -0
  558. package/external/folly/folly/json/json_patch.cpp +325 -0
  559. package/external/folly/folly/json/json_patch.h +126 -0
  560. package/external/folly/folly/json/json_pointer.cpp +114 -0
  561. package/external/folly/folly/json/json_pointer.h +87 -0
  562. package/external/folly/folly/json/test/BUCK +147 -0
  563. package/external/folly/folly/json/test/DynamicBenchmark.cpp +146 -0
  564. package/external/folly/folly/json/test/DynamicConverterTest.cpp +518 -0
  565. package/external/folly/folly/json/test/DynamicOtherTest.cpp +344 -0
  566. package/external/folly/folly/json/test/DynamicParserTest.cpp +443 -0
  567. package/external/folly/folly/json/test/DynamicTest.cpp +1647 -0
  568. package/external/folly/folly/json/test/JSONSchemaTest.cpp +450 -0
  569. package/external/folly/folly/json/test/JsonBenchmark.cpp +264 -0
  570. package/external/folly/folly/json/test/JsonOtherTest.cpp +51 -0
  571. package/external/folly/folly/json/test/JsonTest.cpp +1153 -0
  572. package/external/folly/folly/json/test/JsonTestUtilTest.cpp +97 -0
  573. package/external/folly/folly/json/test/json_patch_test.cpp +361 -0
  574. package/external/folly/folly/json/test/json_pointer_test.cpp +58 -0
  575. package/external/folly/folly/json/tool/BUCK +13 -0
  576. package/external/folly/folly/json/tool/JSONSchemaTester.cpp +58 -0
  577. package/external/folly/folly/json.h +17 -0
  578. package/external/folly/folly/json_patch.h +17 -0
  579. package/external/folly/folly/json_pointer.h +17 -0
  580. package/external/folly/folly/lang/Access.h +29 -0
  581. package/external/folly/folly/lang/Align.h +240 -0
  582. package/external/folly/folly/lang/Aligned.h +92 -0
  583. package/external/folly/folly/lang/Assume.h +82 -0
  584. package/external/folly/folly/lang/BUCK +287 -0
  585. package/external/folly/folly/lang/Badge.h +108 -0
  586. package/external/folly/folly/lang/Bits.h +570 -0
  587. package/external/folly/folly/lang/BitsClass.h +312 -0
  588. package/external/folly/folly/lang/Builtin.h +74 -0
  589. package/external/folly/folly/lang/CArray.h +34 -0
  590. package/external/folly/folly/lang/CString.cpp +86 -0
  591. package/external/folly/folly/lang/CString.h +55 -0
  592. package/external/folly/folly/lang/Cast.h +51 -0
  593. package/external/folly/folly/lang/CheckedMath.h +253 -0
  594. package/external/folly/folly/lang/CustomizationPoint.h +58 -0
  595. package/external/folly/folly/lang/Exception.cpp +822 -0
  596. package/external/folly/folly/lang/Exception.h +716 -0
  597. package/external/folly/folly/lang/Extern.h +55 -0
  598. package/external/folly/folly/lang/Hint-inl.h +144 -0
  599. package/external/folly/folly/lang/Hint.h +238 -0
  600. package/external/folly/folly/lang/Keep.h +98 -0
  601. package/external/folly/folly/lang/New.h +124 -0
  602. package/external/folly/folly/lang/Ordering.h +140 -0
  603. package/external/folly/folly/lang/Pretty.h +159 -0
  604. package/external/folly/folly/lang/PropagateConst.h +413 -0
  605. package/external/folly/folly/lang/RValueReferenceWrapper.h +152 -0
  606. package/external/folly/folly/lang/SafeAssert.cpp +589 -0
  607. package/external/folly/folly/lang/StaticConst.h +33 -0
  608. package/external/folly/folly/lang/Thunk.h +100 -0
  609. package/external/folly/folly/lang/TypeInfo.h +58 -0
  610. package/external/folly/folly/lang/UncaughtExceptions.cpp +17 -0
  611. package/external/folly/folly/lang/UncaughtExceptions.h +19 -0
  612. package/external/folly/folly/lang/test/AlignTest.cpp +87 -0
  613. package/external/folly/folly/lang/test/AlignedTest.cpp +130 -0
  614. package/external/folly/folly/lang/test/BUCK +258 -0
  615. package/external/folly/folly/lang/test/BadgeTest.cpp +89 -0
  616. package/external/folly/folly/lang/test/BitsBenchmark.cpp +164 -0
  617. package/external/folly/folly/lang/test/BitsClassBenchmark.cpp +122 -0
  618. package/external/folly/folly/lang/test/BitsClassTest.cpp +379 -0
  619. package/external/folly/folly/lang/test/BitsTest.cpp +577 -0
  620. package/external/folly/folly/lang/test/CStringTest.cpp +60 -0
  621. package/external/folly/folly/lang/test/CastTest.cpp +47 -0
  622. package/external/folly/folly/lang/test/CheckedMathTest.cpp +394 -0
  623. package/external/folly/folly/lang/test/ExceptionBench.cpp +427 -0
  624. package/external/folly/folly/lang/test/ExceptionTest.cpp +413 -0
  625. package/external/folly/folly/lang/test/ExternTest.cpp +39 -0
  626. package/external/folly/folly/lang/test/HintTest.cpp +100 -0
  627. package/external/folly/folly/lang/test/NewTest.cpp +38 -0
  628. package/external/folly/folly/lang/test/OrderingTest.cpp +105 -0
  629. package/external/folly/folly/lang/test/PrettyTest.cpp +44 -0
  630. package/external/folly/folly/lang/test/PropagateConstTest.cpp +356 -0
  631. package/external/folly/folly/lang/test/RValueReferenceWrapperTest.cpp +85 -0
  632. package/external/folly/folly/lang/test/SafeAssertTest.cpp +75 -0
  633. package/external/folly/folly/lang/test/ThunkTest.cpp +105 -0
  634. package/external/folly/folly/lang/test/ToAsciiBench.cpp +466 -0
  635. package/external/folly/folly/lang/test/ToAsciiTest.cpp +266 -0
  636. package/external/folly/folly/lang/test/TypeInfoTest.cpp +56 -0
  637. package/external/folly/folly/memcpy.S +292 -0
  638. package/external/folly/folly/memcpy_select_aarch64.cpp +145 -0
  639. package/external/folly/folly/memory/Arena-inl.h +83 -0
  640. package/external/folly/folly/memory/Arena.h +325 -0
  641. package/external/folly/folly/memory/BUCK +191 -0
  642. package/external/folly/folly/memory/JemallocHugePageAllocator.cpp +449 -0
  643. package/external/folly/folly/memory/JemallocHugePageAllocator.h +105 -0
  644. package/external/folly/folly/memory/JemallocHugePageAllocatorTest.cpp +341 -0
  645. package/external/folly/folly/memory/JemallocNodumpAllocator.cpp +176 -0
  646. package/external/folly/folly/memory/JemallocNodumpAllocator.h +119 -0
  647. package/external/folly/folly/memory/JemallocNodumpAllocatorTest.cpp +61 -0
  648. package/external/folly/folly/memory/MallctlHelper.cpp +37 -0
  649. package/external/folly/folly/memory/MallctlHelper.h +167 -0
  650. package/external/folly/folly/memory/Malloc.h +551 -0
  651. package/external/folly/folly/memory/MemoryResource.h +57 -0
  652. package/external/folly/folly/memory/ReentrantAllocator.cpp +162 -0
  653. package/external/folly/folly/memory/ReentrantAllocator.h +261 -0
  654. package/external/folly/folly/memory/SanitizeAddress.cpp +75 -0
  655. package/external/folly/folly/memory/SanitizeAddress.h +117 -0
  656. package/external/folly/folly/memory/SanitizeLeak.cpp +119 -0
  657. package/external/folly/folly/memory/SanitizeLeak.h +108 -0
  658. package/external/folly/folly/memory/ThreadCachedArena.cpp +53 -0
  659. package/external/folly/folly/memory/ThreadCachedArena.h +90 -0
  660. package/external/folly/folly/memory/UninitializedMemoryHacks.h +426 -0
  661. package/external/folly/folly/memory/detail/BUCK +10 -0
  662. package/external/folly/folly/memory/detail/MallocImpl.cpp +52 -0
  663. package/external/folly/folly/memory/detail/MallocImpl.h +97 -0
  664. package/external/folly/folly/memory/not_null-inl.h +522 -0
  665. package/external/folly/folly/memory/not_null.h +449 -0
  666. package/external/folly/folly/memory/test/ArenaTest.cpp +354 -0
  667. package/external/folly/folly/memory/test/BUCK +146 -0
  668. package/external/folly/folly/memory/test/MallctlHelperTest.cpp +169 -0
  669. package/external/folly/folly/memory/test/MallocBenchmark.cpp +91 -0
  670. package/external/folly/folly/memory/test/MallocTest.cpp +78 -0
  671. package/external/folly/folly/memory/test/MemoryResourceTest.cpp +31 -0
  672. package/external/folly/folly/memory/test/ReentrantAllocatorTest.cpp +144 -0
  673. package/external/folly/folly/memory/test/SanitizeAddressTest.cpp +67 -0
  674. package/external/folly/folly/memory/test/SanitizeLeakTest.cpp +139 -0
  675. package/external/folly/folly/memory/test/ThreadCachedArenaTest.cpp +276 -0
  676. package/external/folly/folly/memory/test/UninitializedMemoryHacksODR.cpp +21 -0
  677. package/external/folly/folly/memory/test/UninitializedMemoryHacksTest.cpp +327 -0
  678. package/external/folly/folly/memory/test/not_null_test.cpp +608 -0
  679. package/external/folly/folly/memset.S +245 -0
  680. package/external/folly/folly/memset_select_aarch64.cpp +72 -0
  681. package/external/folly/folly/portability/Asm.h +50 -0
  682. package/external/folly/folly/portability/Atomic.h +31 -0
  683. package/external/folly/folly/portability/BUCK +456 -0
  684. package/external/folly/folly/portability/Builtins.cpp +31 -0
  685. package/external/folly/folly/portability/Builtins.h +161 -0
  686. package/external/folly/folly/portability/Config.h +43 -0
  687. package/external/folly/folly/portability/Constexpr.h +145 -0
  688. package/external/folly/folly/portability/Dirent.cpp +140 -0
  689. package/external/folly/folly/portability/Dirent.h +41 -0
  690. package/external/folly/folly/portability/Event.h +44 -0
  691. package/external/folly/folly/portability/Fcntl.cpp +120 -0
  692. package/external/folly/folly/portability/Fcntl.h +67 -0
  693. package/external/folly/folly/portability/Filesystem.cpp +67 -0
  694. package/external/folly/folly/portability/Filesystem.h +114 -0
  695. package/external/folly/folly/portability/FmtCompile.h +40 -0
  696. package/external/folly/folly/portability/GFlags.h +139 -0
  697. package/external/folly/folly/portability/GMock.h +35 -0
  698. package/external/folly/folly/portability/GTest.h +35 -0
  699. package/external/folly/folly/portability/IOVec.h +34 -0
  700. package/external/folly/folly/portability/Libgen.cpp +59 -0
  701. package/external/folly/folly/portability/Libgen.h +29 -0
  702. package/external/folly/folly/portability/Libunwind.h +21 -0
  703. package/external/folly/folly/portability/Malloc.cpp +31 -0
  704. package/external/folly/folly/portability/Malloc.h +53 -0
  705. package/external/folly/folly/portability/Math.h +90 -0
  706. package/external/folly/folly/portability/Memory.h +26 -0
  707. package/external/folly/folly/portability/OpenSSL.cpp +17 -0
  708. package/external/folly/folly/portability/OpenSSL.h +102 -0
  709. package/external/folly/folly/portability/PThread.cpp +697 -0
  710. package/external/folly/folly/portability/PThread.h +148 -0
  711. package/external/folly/folly/portability/README.md +21 -0
  712. package/external/folly/folly/portability/Sched.cpp +41 -0
  713. package/external/folly/folly/portability/Sched.h +45 -0
  714. package/external/folly/folly/portability/Sockets.cpp +245 -0
  715. package/external/folly/folly/portability/Sockets.h +155 -0
  716. package/external/folly/folly/portability/SourceLocation.h +49 -0
  717. package/external/folly/folly/portability/Stdio.cpp +77 -0
  718. package/external/folly/folly/portability/Stdio.h +32 -0
  719. package/external/folly/folly/portability/Stdlib.cpp +172 -0
  720. package/external/folly/folly/portability/Stdlib.h +64 -0
  721. package/external/folly/folly/portability/String.cpp +53 -0
  722. package/external/folly/folly/portability/String.h +39 -0
  723. package/external/folly/folly/portability/SysFile.cpp +46 -0
  724. package/external/folly/folly/portability/SysFile.h +27 -0
  725. package/external/folly/folly/portability/SysMembarrier.cpp +104 -0
  726. package/external/folly/folly/portability/SysMembarrier.h +26 -0
  727. package/external/folly/folly/portability/SysMman.cpp +242 -0
  728. package/external/folly/folly/portability/SysMman.h +68 -0
  729. package/external/folly/folly/portability/SysResource.cpp +108 -0
  730. package/external/folly/folly/portability/SysResource.h +71 -0
  731. package/external/folly/folly/portability/SysStat.cpp +66 -0
  732. package/external/folly/folly/portability/SysStat.h +52 -0
  733. package/external/folly/folly/portability/SysSyscall.h +73 -0
  734. package/external/folly/folly/portability/SysTime.cpp +62 -0
  735. package/external/folly/folly/portability/SysTime.h +50 -0
  736. package/external/folly/folly/portability/SysTypes.h +44 -0
  737. package/external/folly/folly/portability/SysUio.cpp +179 -0
  738. package/external/folly/folly/portability/SysUio.h +51 -0
  739. package/external/folly/folly/portability/Syslog.h +39 -0
  740. package/external/folly/folly/portability/Time.cpp +357 -0
  741. package/external/folly/folly/portability/Time.h +74 -0
  742. package/external/folly/folly/portability/Unistd.h +111 -0
  743. package/external/folly/folly/portability/Windows.h +108 -0
  744. package/external/folly/folly/portability/openat2.c +30 -0
  745. package/external/folly/folly/portability/openat2.h +39 -0
  746. package/external/folly/folly/portability/test/BUCK +59 -0
  747. package/external/folly/folly/portability/test/ConstexprTest.cpp +102 -0
  748. package/external/folly/folly/portability/test/FilesystemTest.cpp +35 -0
  749. package/external/folly/folly/portability/test/LibgenTest.cpp +35 -0
  750. package/external/folly/folly/portability/test/OpenSSLPortabilityTest.cpp +108 -0
  751. package/external/folly/folly/portability/test/PThreadTest.cpp +80 -0
  752. package/external/folly/folly/portability/test/TimeTest.cpp +90 -0
  753. package/external/folly/folly/small_vector.h +17 -0
  754. package/external/folly/folly/somerge_defs.bzl +399 -0
  755. package/external/folly/folly/sorted_vector_types.h +17 -0
  756. package/external/folly/folly/stop_watch.h +317 -0
  757. package/external/folly/folly/synchronization/AsymmetricThreadFence.cpp +91 -0
  758. package/external/folly/folly/synchronization/AsymmetricThreadFence.h +60 -0
  759. package/external/folly/folly/synchronization/AtomicNotification-inl.h +146 -0
  760. package/external/folly/folly/synchronization/AtomicNotification.cpp +34 -0
  761. package/external/folly/folly/synchronization/AtomicNotification.h +117 -0
  762. package/external/folly/folly/synchronization/AtomicRef.h +181 -0
  763. package/external/folly/folly/synchronization/AtomicStruct.h +150 -0
  764. package/external/folly/folly/synchronization/AtomicUtil-inl.h +482 -0
  765. package/external/folly/folly/synchronization/AtomicUtil.h +179 -0
  766. package/external/folly/folly/synchronization/BUCK +418 -0
  767. package/external/folly/folly/synchronization/Baton.h +419 -0
  768. package/external/folly/folly/synchronization/CallOnce.h +263 -0
  769. package/external/folly/folly/synchronization/DelayedInit.h +179 -0
  770. package/external/folly/folly/synchronization/DistributedMutex-inl.h +1744 -0
  771. package/external/folly/folly/synchronization/DistributedMutex.cpp +27 -0
  772. package/external/folly/folly/synchronization/DistributedMutex.h +342 -0
  773. package/external/folly/folly/synchronization/EventCount.h +200 -0
  774. package/external/folly/folly/synchronization/FlatCombining.h +629 -0
  775. package/external/folly/folly/synchronization/Hazptr-fwd.h +217 -0
  776. package/external/folly/folly/synchronization/Hazptr.cpp +36 -0
  777. package/external/folly/folly/synchronization/Hazptr.h +209 -0
  778. package/external/folly/folly/synchronization/HazptrDomain.cpp +68 -0
  779. package/external/folly/folly/synchronization/HazptrDomain.h +832 -0
  780. package/external/folly/folly/synchronization/HazptrHolder.h +431 -0
  781. package/external/folly/folly/synchronization/HazptrObj.h +533 -0
  782. package/external/folly/folly/synchronization/HazptrObjLinked.h +315 -0
  783. package/external/folly/folly/synchronization/HazptrRec.h +68 -0
  784. package/external/folly/folly/synchronization/HazptrThrLocal.h +180 -0
  785. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.cpp +46 -0
  786. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.h +25 -0
  787. package/external/folly/folly/synchronization/Latch.h +160 -0
  788. package/external/folly/folly/synchronization/LifoSem.h +767 -0
  789. package/external/folly/folly/synchronization/Lock.h +887 -0
  790. package/external/folly/folly/synchronization/MicroSpinLock.h +154 -0
  791. package/external/folly/folly/synchronization/NativeSemaphore.h +187 -0
  792. package/external/folly/folly/synchronization/ParkingLot.cpp +37 -0
  793. package/external/folly/folly/synchronization/ParkingLot.h +330 -0
  794. package/external/folly/folly/synchronization/PicoSpinLock.h +167 -0
  795. package/external/folly/folly/synchronization/RWSpinLock.h +549 -0
  796. package/external/folly/folly/synchronization/Rcu.cpp +26 -0
  797. package/external/folly/folly/synchronization/Rcu.h +553 -0
  798. package/external/folly/folly/synchronization/RelaxedAtomic.h +336 -0
  799. package/external/folly/folly/synchronization/SanitizeThread.cpp +141 -0
  800. package/external/folly/folly/synchronization/SanitizeThread.h +166 -0
  801. package/external/folly/folly/synchronization/SaturatingSemaphore.h +324 -0
  802. package/external/folly/folly/synchronization/SmallLocks.h +36 -0
  803. package/external/folly/folly/synchronization/ThrottledLifoSem.h +362 -0
  804. package/external/folly/folly/synchronization/WaitOptions.cpp +25 -0
  805. package/external/folly/folly/synchronization/WaitOptions.h +75 -0
  806. package/external/folly/folly/synchronization/detail/AtomicUtils.h +59 -0
  807. package/external/folly/folly/synchronization/detail/BUCK +104 -0
  808. package/external/folly/folly/synchronization/detail/Hardware.cpp +192 -0
  809. package/external/folly/folly/synchronization/detail/Hardware.h +75 -0
  810. package/external/folly/folly/synchronization/detail/HazptrUtils.h +339 -0
  811. package/external/folly/folly/synchronization/detail/InlineFunctionRef.h +229 -0
  812. package/external/folly/folly/synchronization/detail/Sleeper.cpp +27 -0
  813. package/external/folly/folly/synchronization/detail/Sleeper.h +62 -0
  814. package/external/folly/folly/synchronization/detail/Spin.h +96 -0
  815. package/external/folly/folly/synchronization/detail/ThreadCachedLists.h +174 -0
  816. package/external/folly/folly/synchronization/detail/ThreadCachedReaders.h +189 -0
  817. package/external/folly/folly/synchronization/detail/ThreadCachedTag.h +26 -0
  818. package/external/folly/folly/synchronization/detail/test/BUCK +28 -0
  819. package/external/folly/folly/synchronization/detail/test/HardwareTest.cpp +74 -0
  820. package/external/folly/folly/synchronization/detail/test/InlineFunctionRefTest.cpp +286 -0
  821. package/external/folly/folly/synchronization/example/BUCK +27 -0
  822. package/external/folly/folly/synchronization/example/HazptrLockFreeLIFO.h +88 -0
  823. package/external/folly/folly/synchronization/example/HazptrSWMRSet.h +133 -0
  824. package/external/folly/folly/synchronization/example/HazptrWideCAS.h +62 -0
  825. package/external/folly/folly/synchronization/test/AtomicNotificationTest.cpp +236 -0
  826. package/external/folly/folly/synchronization/test/AtomicRefTest.cpp +170 -0
  827. package/external/folly/folly/synchronization/test/AtomicStructTest.cpp +65 -0
  828. package/external/folly/folly/synchronization/test/AtomicUtilBench.cpp +457 -0
  829. package/external/folly/folly/synchronization/test/AtomicUtilTest.cpp +650 -0
  830. package/external/folly/folly/synchronization/test/BUCK +495 -0
  831. package/external/folly/folly/synchronization/test/Barrier.h +52 -0
  832. package/external/folly/folly/synchronization/test/BarrierTest.cpp +56 -0
  833. package/external/folly/folly/synchronization/test/BatonBenchmark.cpp +77 -0
  834. package/external/folly/folly/synchronization/test/BatonTest.cpp +164 -0
  835. package/external/folly/folly/synchronization/test/BatonTestHelpers.h +118 -0
  836. package/external/folly/folly/synchronization/test/CallOnceBenchmark.cpp +72 -0
  837. package/external/folly/folly/synchronization/test/CallOnceTest.cpp +153 -0
  838. package/external/folly/folly/synchronization/test/DelayedInitTest.cpp +281 -0
  839. package/external/folly/folly/synchronization/test/DistributedMutexTest.cpp +2074 -0
  840. package/external/folly/folly/synchronization/test/EventCountTest.cpp +124 -0
  841. package/external/folly/folly/synchronization/test/FlatCombiningBenchmark.cpp +1789 -0
  842. package/external/folly/folly/synchronization/test/FlatCombiningExamples.h +222 -0
  843. package/external/folly/folly/synchronization/test/FlatCombiningTest.cpp +121 -0
  844. package/external/folly/folly/synchronization/test/FlatCombiningTestHelpers.h +227 -0
  845. package/external/folly/folly/synchronization/test/HazptrTest.cpp +1689 -0
  846. package/external/folly/folly/synchronization/test/LatchTest.cpp +224 -0
  847. package/external/folly/folly/synchronization/test/LifoSemBench.cpp +185 -0
  848. package/external/folly/folly/synchronization/test/LifoSemTests.cpp +353 -0
  849. package/external/folly/folly/synchronization/test/LockTest.cpp +1239 -0
  850. package/external/folly/folly/synchronization/test/NativeSemaphoreTest.cpp +37 -0
  851. package/external/folly/folly/synchronization/test/ParkingLotBenchmark.cpp +239 -0
  852. package/external/folly/folly/synchronization/test/ParkingLotTest.cpp +170 -0
  853. package/external/folly/folly/synchronization/test/RWSpinLockTest.cpp +235 -0
  854. package/external/folly/folly/synchronization/test/RcuBench.cpp +66 -0
  855. package/external/folly/folly/synchronization/test/RcuTest.cpp +330 -0
  856. package/external/folly/folly/synchronization/test/RelaxedAtomicTest.cpp +389 -0
  857. package/external/folly/folly/synchronization/test/SaturatingSemaphoreTest.cpp +166 -0
  858. package/external/folly/folly/synchronization/test/Semaphore.h +242 -0
  859. package/external/folly/folly/synchronization/test/SemaphoreTest.cpp +271 -0
  860. package/external/folly/folly/synchronization/test/SmallLocksBenchmark.cpp +1296 -0
  861. package/external/folly/folly/synchronization/test/SmallLocksTest.cpp +510 -0
  862. package/external/folly/folly/synchronization/test/ThreadCachedEpochBench.h +67 -0
  863. package/external/folly/folly/synchronization/test/ThreadCachedReadersBench.cpp +42 -0
  864. package/external/folly/folly/synchronization/test/ThreadCachedReadersTest.cpp +52 -0
  865. package/external/folly/folly/synchronization/test/ThrottledLifoSemTest.cpp +243 -0
  866. package/external/folly/folly/system/AtFork.cpp +205 -0
  867. package/external/folly/folly/system/AtFork.h +116 -0
  868. package/external/folly/folly/system/AuxVector.h +198 -0
  869. package/external/folly/folly/system/BUCK +144 -0
  870. package/external/folly/folly/system/EnvUtil.cpp +93 -0
  871. package/external/folly/folly/system/EnvUtil.h +113 -0
  872. package/external/folly/folly/system/HardwareConcurrency.cpp +39 -0
  873. package/external/folly/folly/system/HardwareConcurrency.h +23 -0
  874. package/external/folly/folly/system/MemoryMapping.cpp +477 -0
  875. package/external/folly/folly/system/MemoryMapping.h +287 -0
  876. package/external/folly/folly/system/Pid.cpp +87 -0
  877. package/external/folly/folly/system/Pid.h +34 -0
  878. package/external/folly/folly/system/Shell.cpp +33 -0
  879. package/external/folly/folly/system/Shell.h +93 -0
  880. package/external/folly/folly/system/ThreadId.cpp +89 -0
  881. package/external/folly/folly/system/ThreadId.h +62 -0
  882. package/external/folly/folly/system/ThreadName.cpp +330 -0
  883. package/external/folly/folly/system/ThreadName.h +72 -0
  884. package/external/folly/folly/system/test/AtForkTest.cpp +309 -0
  885. package/external/folly/folly/system/test/AuxVectorTest.cpp +55 -0
  886. package/external/folly/folly/system/test/BUCK +120 -0
  887. package/external/folly/folly/system/test/EnvUtilSubprocess.cpp +26 -0
  888. package/external/folly/folly/system/test/EnvUtilTest.cpp +197 -0
  889. package/external/folly/folly/system/test/MemoryMappingTest.cpp +179 -0
  890. package/external/folly/folly/system/test/PidTest.cpp +46 -0
  891. package/external/folly/folly/system/test/ShellTest.cpp +66 -0
  892. package/external/folly/folly/system/test/ThreadIdTest.cpp +114 -0
  893. package/external/folly/folly/system/test/ThreadNameTest.cpp +85 -0
  894. package/external/folly/folly.vcxitems +164 -0
  895. package/external/folly/static/logo.svg +1 -0
  896. package/external/folly/sync-config.json +8 -0
  897. package/package.json +6 -6
  898. package/template/cpp-lib/proj/MyLib.sln +0 -33
  899. package/template/cs-lib/proj/MyLib.sln +0 -33
  900. package/templates/cpp-app/windows/MyApp.sln +0 -33
  901. package/templates/cpp-lib/example/metro.config.js +30 -4
  902. package/templates/cpp-lib/windows/MyLib.sln +0 -33
  903. package/Folly/Folly.vcxproj +0 -378
  904. package/Folly/Folly.vcxproj.filters +0 -558
  905. package/fmt/fmt.vcxproj +0 -153
  906. package/fmt/fmt.vcxproj.filters +0 -59
  907. package/fmt/pch.cpp +0 -4
  908. package/fmt/pch.h +0 -2
  909. /package/{fmt → external/fmt}/cgmanifest.json +0 -0
  910. /package/{Folly → external/folly}/Folly.natvis +0 -0
  911. /package/{Folly → external/folly}/cgmanifest.json +0 -0
  912. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/ConstexprMath.h +0 -0
  913. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/Conv.cpp +0 -0
  914. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/chrono/Hardware.h +0 -0
  915. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/concurrency/CacheLocality.cpp +0 -0
  916. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/dynamic-inl.h +0 -0
  917. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/json.cpp +0 -0
  918. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/SafeAssert.h +0 -0
  919. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.cpp +0 -0
  920. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.h +0 -0
  921. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/portability/Unistd.cpp +0 -0
@@ -0,0 +1,2965 @@
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
+ // Fixed-size string type, for constexpr string handling.
18
+
19
+ #pragma once
20
+
21
+ #include <cassert>
22
+ #include <cstddef>
23
+ #include <initializer_list>
24
+ #include <iosfwd>
25
+ #include <stdexcept>
26
+ #include <string>
27
+ #include <string_view>
28
+ #include <type_traits>
29
+ #include <utility>
30
+
31
+ #include <folly/ConstexprMath.h>
32
+ #include <folly/Portability.h>
33
+ #include <folly/Range.h>
34
+ #include <folly/Utility.h>
35
+ #include <folly/lang/Exception.h>
36
+ #include <folly/lang/Ordering.h>
37
+ #include <folly/portability/Constexpr.h>
38
+
39
+ namespace folly {
40
+
41
+ template <class Char, std::size_t N>
42
+ class BasicFixedString;
43
+
44
+ template <std::size_t N>
45
+ using FixedString = BasicFixedString<char, N>;
46
+
47
+ namespace detail {
48
+ namespace fixedstring {
49
+
50
+ // This is a template so that the class static npos can be defined in the
51
+ // header.
52
+ template <class = void>
53
+ struct FixedStringBase_ {
54
+ static constexpr std::size_t npos = static_cast<std::size_t>(-1);
55
+ };
56
+
57
+ using FixedStringBase = FixedStringBase_<>;
58
+
59
+ // Intentionally NOT constexpr. By making this not constexpr, we make
60
+ // checkOverflow below ill-formed in a constexpr context when the condition
61
+ // it's testing for fails. In this way, precondition violations are reported
62
+ // at compile-time instead of at runtime.
63
+ [[noreturn]] inline void assertOutOfBounds() {
64
+ assert(false && "Array index out of bounds in BasicFixedString");
65
+ throw_exception<std::out_of_range>(
66
+ "Array index out of bounds in BasicFixedString");
67
+ }
68
+
69
+ constexpr std::size_t checkOverflow(std::size_t i, std::size_t max) {
70
+ return i <= max ? i : (void(assertOutOfBounds()), max);
71
+ }
72
+
73
+ constexpr std::size_t checkOverflowOrNpos(std::size_t i, std::size_t max) {
74
+ return i == FixedStringBase::npos
75
+ ? max
76
+ : (i <= max ? i : (void(assertOutOfBounds()), max));
77
+ }
78
+
79
+ constexpr std::size_t checkOverflowIfDebug(std::size_t i, std::size_t size) {
80
+ return kIsDebug ? checkOverflow(i, size) : i;
81
+ }
82
+
83
+ // Intentionally NOT constexpr. See note above for assertOutOfBounds
84
+ [[noreturn]] inline void assertNotNullTerminated() noexcept {
85
+ assert(
86
+ false &&
87
+ "Non-null terminated string used to initialize a BasicFixedString");
88
+ std::terminate(); // Fail hard, fail fast.
89
+ }
90
+
91
+ // Parsing help for human readers: the following is a constexpr noexcept
92
+ // function that accepts a reference to an array as a parameter and returns
93
+ // a reference to the same array.
94
+ template <class Char, std::size_t N>
95
+ constexpr const Char (&checkNullTerminated(const Char (&a)[N]) noexcept)[N] {
96
+ // Strange decltype(a)(a) used to make MSVC happy.
97
+ return a[N - 1u] == Char(0)
98
+ // In Debug mode, guard against embedded nulls:
99
+ && (!kIsDebug || N - 1u == folly::constexpr_strlen(a))
100
+ ? decltype(a)(a)
101
+ : (assertNotNullTerminated(), decltype(a)(a));
102
+ }
103
+
104
+ template <class Left, class Right>
105
+ constexpr ordering compare_(
106
+ const Left& left,
107
+ std::size_t left_pos,
108
+ std::size_t left_size,
109
+ const Right& right,
110
+ std::size_t right_pos,
111
+ std::size_t right_size) noexcept {
112
+ return left_pos == left_size
113
+ ? (right_pos == right_size ? ordering::eq : ordering::lt)
114
+ : (right_pos == right_size ? ordering::gt
115
+ : (left[left_pos] < right[right_pos]
116
+ ? ordering::lt
117
+ : (left[left_pos] > right[right_pos]
118
+ ? ordering::gt
119
+ : fixedstring::compare_(
120
+ left,
121
+ left_pos + 1u,
122
+ left_size,
123
+ right,
124
+ right_pos + 1u,
125
+ right_size))));
126
+ }
127
+
128
+ template <class Left, class Right>
129
+ constexpr bool equal_(
130
+ const Left& left,
131
+ std::size_t left_size,
132
+ const Right& right,
133
+ std::size_t right_size) noexcept {
134
+ return left_size == right_size &&
135
+ ordering::eq == compare_(left, 0u, left_size, right, 0u, right_size);
136
+ }
137
+
138
+ template <class Char, class Left, class Right>
139
+ constexpr Char char_at_(
140
+ const Left& left,
141
+ std::size_t left_count,
142
+ const Right& right,
143
+ std::size_t right_count,
144
+ std::size_t i) noexcept {
145
+ return i < left_count ? left[i]
146
+ : i < (left_count + right_count) ? right[i - left_count]
147
+ : Char(0);
148
+ }
149
+
150
+ template <class Char, class Left, class Right>
151
+ constexpr Char char_at_(
152
+ const Left& left,
153
+ std::size_t left_size,
154
+ std::size_t left_pos,
155
+ std::size_t left_count,
156
+ const Right& right,
157
+ std::size_t right_pos,
158
+ std::size_t right_count,
159
+ std::size_t i) noexcept {
160
+ FOLLY_PUSH_WARNING
161
+ #if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 13
162
+ #pragma GCC diagnostic ignored "-Warray-bounds"
163
+ #endif
164
+ return i < left_pos
165
+ ? left[i]
166
+ : (i < right_count + left_pos ? right[i - left_pos + right_pos]
167
+ : (i < left_size - left_count + right_count
168
+ ? left[i - right_count + left_count]
169
+ : Char(0)));
170
+ FOLLY_POP_WARNING
171
+ }
172
+
173
+ template <class Left, class Right>
174
+ constexpr bool find_at_(
175
+ const Left& left,
176
+ const Right& right,
177
+ std::size_t pos,
178
+ std::size_t count) noexcept {
179
+ return 0u == count ||
180
+ (left[pos + count - 1u] == right[count - 1u] &&
181
+ find_at_(left, right, pos, count - 1u));
182
+ }
183
+
184
+ template <class Char, class Right>
185
+ constexpr bool find_one_of_at_(
186
+ Char ch, const Right& right, std::size_t pos) noexcept {
187
+ return 0u != pos &&
188
+ (ch == right[pos - 1u] || find_one_of_at_(ch, right, pos - 1u));
189
+ }
190
+
191
+ template <class Left, class Right>
192
+ constexpr std::size_t find_(
193
+ const Left& left,
194
+ std::size_t left_size,
195
+ const Right& right,
196
+ std::size_t pos,
197
+ std::size_t count) noexcept {
198
+ return find_at_(left, right, pos, count) ? pos
199
+ : left_size <= pos + count
200
+ ? FixedStringBase::npos
201
+ : find_(left, left_size, right, pos + 1u, count);
202
+ }
203
+
204
+ template <class Left, class Right>
205
+ constexpr std::size_t rfind_(
206
+ const Left& left,
207
+ const Right& right,
208
+ std::size_t pos,
209
+ std::size_t count) noexcept {
210
+ return find_at_(left, right, pos, count) ? pos
211
+ : 0u == pos ? FixedStringBase::npos
212
+ : rfind_(left, right, pos - 1u, count);
213
+ }
214
+
215
+ template <class Left, class Right>
216
+ constexpr std::size_t find_first_of_(
217
+ const Left& left,
218
+ std::size_t left_size,
219
+ const Right& right,
220
+ std::size_t pos,
221
+ std::size_t count) noexcept {
222
+ return find_one_of_at_(left[pos], right, count) ? pos
223
+ : left_size <= pos + 1u
224
+ ? FixedStringBase::npos
225
+ : find_first_of_(left, left_size, right, pos + 1u, count);
226
+ }
227
+
228
+ template <class Left, class Right>
229
+ constexpr std::size_t find_first_not_of_(
230
+ const Left& left,
231
+ std::size_t left_size,
232
+ const Right& right,
233
+ std::size_t pos,
234
+ std::size_t count) noexcept {
235
+ return !find_one_of_at_(left[pos], right, count) ? pos
236
+ : left_size <= pos + 1u
237
+ ? FixedStringBase::npos
238
+ : find_first_not_of_(left, left_size, right, pos + 1u, count);
239
+ }
240
+
241
+ template <class Left, class Right>
242
+ constexpr std::size_t find_last_of_(
243
+ const Left& left,
244
+ const Right& right,
245
+ std::size_t pos,
246
+ std::size_t count) noexcept {
247
+ return find_one_of_at_(left[pos], right, count) ? pos
248
+ : 0u == pos ? FixedStringBase::npos
249
+ : find_last_of_(left, right, pos - 1u, count);
250
+ }
251
+
252
+ template <class Left, class Right>
253
+ constexpr std::size_t find_last_not_of_(
254
+ const Left& left,
255
+ const Right& right,
256
+ std::size_t pos,
257
+ std::size_t count) noexcept {
258
+ return !find_one_of_at_(left[pos], right, count) ? pos
259
+ : 0u == pos ? FixedStringBase::npos
260
+ : find_last_not_of_(left, right, pos - 1u, count);
261
+ }
262
+
263
+ struct Helper {
264
+ template <class Char, class Left, class Right, std::size_t... Is>
265
+ static constexpr BasicFixedString<Char, sizeof...(Is)> concat_(
266
+ const Left& left,
267
+ std::size_t left_count,
268
+ const Right& right,
269
+ std::size_t right_count,
270
+ std::index_sequence<Is...> is) noexcept {
271
+ return {left, left_count, right, right_count, is};
272
+ }
273
+
274
+ template <class Char, class Left, class Right, std::size_t... Is>
275
+ static constexpr BasicFixedString<Char, sizeof...(Is)> replace_(
276
+ const Left& left,
277
+ std::size_t left_size,
278
+ std::size_t left_pos,
279
+ std::size_t left_count,
280
+ const Right& right,
281
+ std::size_t right_pos,
282
+ std::size_t right_count,
283
+ std::index_sequence<Is...> is) noexcept {
284
+ return {
285
+ left,
286
+ left_size,
287
+ left_pos,
288
+ left_count,
289
+ right,
290
+ right_pos,
291
+ right_count,
292
+ is};
293
+ }
294
+
295
+ template <class Char, std::size_t N>
296
+ static constexpr const Char (
297
+ &data_(const BasicFixedString<Char, N>& that) noexcept)[N + 1u] {
298
+ return that.data_;
299
+ }
300
+ };
301
+
302
+ template <class T>
303
+ constexpr void constexpr_swap(T& a, T& b) noexcept(
304
+ noexcept(a = T(std::move(a)))) {
305
+ T tmp((std::move(a)));
306
+ a = std::move(b);
307
+ b = std::move(tmp);
308
+ }
309
+
310
+ // For constexpr reverse iteration over a BasicFixedString
311
+ template <class T>
312
+ struct ReverseIterator {
313
+ private:
314
+ T* p_ = nullptr;
315
+ struct dummy_ {
316
+ T* p_ = nullptr;
317
+ };
318
+ using other = typename std::conditional<
319
+ std::is_const<T>::value,
320
+ ReverseIterator<typename std::remove_const<T>::type>,
321
+ dummy_>::type;
322
+
323
+ public:
324
+ using value_type = typename std::remove_const<T>::type;
325
+ using reference = T&;
326
+ using pointer = T*;
327
+ using difference_type = std::ptrdiff_t;
328
+ using iterator_category = std::random_access_iterator_tag;
329
+
330
+ constexpr ReverseIterator() = default;
331
+ constexpr ReverseIterator(const ReverseIterator&) = default;
332
+ constexpr ReverseIterator& operator=(const ReverseIterator&) = default;
333
+ constexpr explicit ReverseIterator(T* p) noexcept : p_(p) {}
334
+ constexpr /* implicit */ ReverseIterator(const other& that) noexcept
335
+ : p_(that.p_) {}
336
+ friend constexpr bool operator==(
337
+ ReverseIterator a, ReverseIterator b) noexcept {
338
+ return a.p_ == b.p_;
339
+ }
340
+ friend constexpr bool operator!=(
341
+ ReverseIterator a, ReverseIterator b) noexcept {
342
+ return !(a == b);
343
+ }
344
+ constexpr reference operator*() const { return *(p_ - 1); }
345
+ constexpr ReverseIterator& operator++() noexcept {
346
+ --p_;
347
+ return *this;
348
+ }
349
+ constexpr ReverseIterator operator++(int) noexcept {
350
+ auto tmp(*this);
351
+ --p_;
352
+ return tmp;
353
+ }
354
+ constexpr ReverseIterator& operator--() noexcept {
355
+ ++p_;
356
+ return *this;
357
+ }
358
+ constexpr ReverseIterator operator--(int) noexcept {
359
+ auto tmp(*this);
360
+ ++p_;
361
+ return tmp;
362
+ }
363
+ constexpr ReverseIterator& operator+=(std::ptrdiff_t i) noexcept {
364
+ p_ -= i;
365
+ return *this;
366
+ }
367
+ friend constexpr ReverseIterator operator+(
368
+ std::ptrdiff_t i, ReverseIterator that) noexcept {
369
+ return ReverseIterator{that.p_ - i};
370
+ }
371
+ friend constexpr ReverseIterator operator+(
372
+ ReverseIterator that, std::ptrdiff_t i) noexcept {
373
+ return ReverseIterator{that.p_ - i};
374
+ }
375
+ constexpr ReverseIterator& operator-=(std::ptrdiff_t i) noexcept {
376
+ p_ += i;
377
+ return *this;
378
+ }
379
+ friend constexpr ReverseIterator operator-(
380
+ ReverseIterator that, std::ptrdiff_t i) noexcept {
381
+ return ReverseIterator{that.p_ + i};
382
+ }
383
+ friend constexpr std::ptrdiff_t operator-(
384
+ ReverseIterator a, ReverseIterator b) noexcept {
385
+ return b.p_ - a.p_;
386
+ }
387
+ constexpr reference operator[](std::ptrdiff_t i) const noexcept {
388
+ return *(*this + i);
389
+ }
390
+ };
391
+
392
+ } // namespace fixedstring
393
+ } // namespace detail
394
+
395
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
396
+ * \class BasicFixedString
397
+ *
398
+ * \tparam Char The character type. Must be a scalar type.
399
+ * \tparam N The capacity and max size of string instances of this type.
400
+ *
401
+ * \brief A class for holding up to `N` characters of type `Char` that is
402
+ * amenable to `constexpr` string manipulation. It is guaranteed to not
403
+ * perform any dynamic allocation.
404
+ *
405
+ * `BasicFixedString` is a `std::string` work-alike that stores characters in an
406
+ * internal buffer. It has minor interface differences that make it easy to work
407
+ * with strings in a `constexpr` context.
408
+ *
409
+ * \par Example:
410
+ * \par
411
+ * \code
412
+ * constexpr auto hello = makeFixedString("hello"); // a FixedString<5>
413
+ * constexpr auto world = makeFixedString("world"); // a FixedString<5>
414
+ * constexpr auto hello_world = hello + ' ' + world + '!'; // a FixedString<12>
415
+ * static_assert(hello_world == "hello world!", "neato!");
416
+ * \endcode
417
+ * \par
418
+ * `FixedString<N>` is an alias for `BasicFixedString<char, N>`.
419
+ *
420
+ * \par Constexpr and In-place Mutation
421
+ * \par
422
+ * On a C++14 compiler, `BasicFixedString` supports the full `std::string`
423
+ * interface as `constexpr` member functions. On a C++11 compiler, the mutating
424
+ * members are not `constexpr`, but non-mutating alternatives, which create a
425
+ * new string, can be used instead. For example, instead of this:
426
+ * \par
427
+ * \code
428
+ * constexpr FixedString<10> replace_example_cpp14() {
429
+ * FixedString<10> test{"****"};
430
+ * test.replace(1, 2, "!!!!");
431
+ * return test; // returns "*!!!!*"
432
+ * }
433
+ * \endcode
434
+ * \par
435
+ * You might write this instead:
436
+ * \par
437
+ * \code
438
+ * constexpr FixedString<10> replace_example_cpp11() {
439
+ * // GNU compilers have an extension that make it possible to create
440
+ * // FixedString objects with a `""_fs` user-defined literal.
441
+ * using namespace folly;
442
+ * return makeFixedString("****").creplace(1, 2, "!!!!"); // "*!!!!*"
443
+ * }
444
+ * \endcode
445
+ *
446
+ * \par User-defined Literals
447
+ * Instead of using the `folly::makeFixedString` helper function, you can use
448
+ * a user-defined literal to make `FixedString` instances. The UDL feature of
449
+ * C++ has some limitations that make this less than ideal; you must tell the
450
+ * compiler roughly how many characters are in the string. The suffixes `_fs4`,
451
+ * `_fs8`, `_fs16`, `_fs32`, `_fs64`, and `_fs128` exist to create instances
452
+ * of types `FixedString<4>`, `FixedString<8>`, etc. For example:
453
+ * \par
454
+ * \code
455
+ * using namespace folly::string_literals;
456
+ * constexpr auto hello = "hello"_fs8; // A FixedString<8> containing "hello"
457
+ * \endcode
458
+ * \par
459
+ * See Error Handling below for what to expect when you try to exceed the
460
+ * capacity of a `FixedString` by storing too many characters in it.
461
+ * \par
462
+ * If your compiler supports GNU extensions, there is one additional suffix you
463
+ * can use: `_fs`. This suffix always creates `FixedString` objects of exactly
464
+ * the right size. For example:
465
+ * \par
466
+ * \code
467
+ * using namespace folly::string_literals;
468
+ * // NOTE: Only works on compilers with GNU extensions enabled. Clang and
469
+ * // gcc support this (-Wgnu-string-literal-operator-template):
470
+ * constexpr auto hello = "hello"_fs; // A FixedString<5> containing "hello"
471
+ * \endcode
472
+ *
473
+ * \par Error Handling:
474
+ * The capacity of a `BasicFixedString` is set at compile time. When the user
475
+ * asks the string to exceed its capacity, one of three things will happen,
476
+ * depending on the context:
477
+ *\par
478
+ * -# If the attempt is made while evaluating a constant expression, the
479
+ * program will fail to compile.
480
+ * -# Otherwise, if the program is being run in debug mode, it will `assert`.
481
+ * -# Otherwise, the failed operation will throw a `std::out_of_range`
482
+ * exception.
483
+ *\par
484
+ * This is also the case if an invalid offset is passed to any member function,
485
+ * or if `pop_back` or `cpop_back` is called on an empty `BasicFixedString`.
486
+ *
487
+ * Member functions documented as having preconditions will assert in Debug
488
+ * mode (`!defined(NDEBUG)`) on precondition failures. Those documented with
489
+ * \b Throws clauses will throw the specified exception on failure. Those with
490
+ * both a precondition and a \b Throws clause will assert in Debug and throw
491
+ * in Release mode.
492
+ */
493
+ template <class Char, std::size_t N>
494
+ class BasicFixedString : private detail::fixedstring::FixedStringBase {
495
+ private:
496
+ template <class, std::size_t>
497
+ friend class BasicFixedString;
498
+ friend struct detail::fixedstring::Helper;
499
+
500
+ // FUTURE: use constexpr_log2 to fold instantiations of BasicFixedString
501
+ // together. All BasicFixedString<C, N> instantiations could share the
502
+ // implementation of BasicFixedString<C, M>, where M is the next highest power
503
+ // of 2 after N.
504
+ //
505
+ // Also, because of alignment of the data_ and size_ members, N should never
506
+ // be smaller than `(alignof(std::size_t)/sizeof(C))-1` (-1 because of the
507
+ // null terminator). OR, create a specialization for BasicFixedString<C, 0u>
508
+ // that does not have a size_ member, since it is unnecessary.
509
+ Char data_[N + 1u]; // +1 for the null terminator
510
+ std::size_t size_; // Nbr of chars, not incl. null terminator. size_ <= N.
511
+
512
+ using Indices = std::make_index_sequence<N>;
513
+
514
+ template <class That, std::size_t... Is>
515
+ constexpr BasicFixedString(
516
+ const That& that,
517
+ std::size_t size,
518
+ std::index_sequence<Is...>,
519
+ std::size_t pos = 0,
520
+ std::size_t count = npos) noexcept
521
+ : data_{(Is < (size - pos) && Is < count ? that[Is + pos] : Char(0))..., Char(0)},
522
+ size_{folly::constexpr_min(size - pos, count)} {}
523
+
524
+ template <std::size_t... Is>
525
+ constexpr BasicFixedString(
526
+ std::size_t count, Char ch, std::index_sequence<Is...>) noexcept
527
+ : data_{((Is < count) ? ch : Char(0))..., Char(0)}, size_{count} {}
528
+
529
+ // Concatenation constructor
530
+ template <class Left, class Right, std::size_t... Is>
531
+ constexpr BasicFixedString(
532
+ const Left& left,
533
+ std::size_t left_size,
534
+ const Right& right,
535
+ std::size_t right_size,
536
+ std::index_sequence<Is...>) noexcept
537
+ : data_{detail::fixedstring::char_at_<Char>(left, left_size, right, right_size, Is)..., Char(0)},
538
+ size_{left_size + right_size} {}
539
+
540
+ // Replace constructor
541
+ template <class Left, class Right, std::size_t... Is>
542
+ constexpr BasicFixedString(
543
+ const Left& left,
544
+ std::size_t left_size,
545
+ std::size_t left_pos,
546
+ std::size_t left_count,
547
+ const Right& right,
548
+ std::size_t right_pos,
549
+ std::size_t right_count,
550
+ std::index_sequence<Is...>) noexcept
551
+ : data_{detail::fixedstring::char_at_<Char>(left, left_size, left_pos, left_count, right, right_pos, right_count, Is)..., Char(0)},
552
+ size_{left_size - left_count + right_count} {}
553
+
554
+ public:
555
+ using size_type = std::size_t;
556
+ using difference_type = std::ptrdiff_t;
557
+ using reference = Char&;
558
+ using const_reference = const Char&;
559
+ using pointer = Char*;
560
+ using const_pointer = const Char*;
561
+ using iterator = Char*;
562
+ using const_iterator = const Char*;
563
+ using reverse_iterator = detail::fixedstring::ReverseIterator<Char>;
564
+ using const_reverse_iterator =
565
+ detail::fixedstring::ReverseIterator<const Char>;
566
+
567
+ using detail::fixedstring::FixedStringBase::npos;
568
+
569
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
570
+ * Default construct
571
+ * \post `size() == 0`
572
+ * \post `at(0) == Char(0)`
573
+ */
574
+ constexpr BasicFixedString() : data_{}, size_{} {}
575
+
576
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
577
+ * Copy construct
578
+ * \post `size() == that.size()`
579
+ * \post `0 == strncmp(data(), that.data(), size())`
580
+ * \post `at(size()) == Char(0)`
581
+ */
582
+ constexpr BasicFixedString(const BasicFixedString& /*that*/) = default;
583
+
584
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
585
+ * Construct from a differently-sized BasicFixedString
586
+ * \pre `that.size() <= N`
587
+ * \post `size() == that.size()`
588
+ * \post `0 == strncmp(data(), that.data(), size())`
589
+ * \post `at(size()) == Char(0)`
590
+ * \throw std::out_of_range when that.size() > N. When M <= N, this
591
+ * constructor will never throw.
592
+ * \note Conversions from larger-capacity BasicFixedString objects to smaller
593
+ * ones (`M > N`) are allowed as long as the *size()* of the source string
594
+ * is small enough.
595
+ */
596
+ template <std::size_t M>
597
+ constexpr /* implicit */ BasicFixedString(
598
+ const BasicFixedString<Char, M>& that) noexcept(M <= N)
599
+ : BasicFixedString{that, 0u, that.size_} {}
600
+
601
+ // Why is this deleted? To avoid confusion with the constructor that takes
602
+ // a const Char* and a count.
603
+ template <std::size_t M>
604
+ constexpr BasicFixedString(
605
+ const BasicFixedString<Char, M>& that,
606
+ std::size_t pos) noexcept(false) = delete;
607
+
608
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
609
+ * Construct from an BasicFixedString, an offset, and a count
610
+ * \param that The source string
611
+ * \param pos The starting position in `that`
612
+ * \param count The number of characters to copy. If `npos`, `count` is taken
613
+ * to be `that.size()-pos`.
614
+ * \pre `pos <= that.size()`
615
+ * \pre `count <= that.size()-pos && count <= N`
616
+ * \post `size() == count`
617
+ * \post `0 == strncmp(data(), that.data()+pos, size())`
618
+ * \post `at(size()) == Char(0)`
619
+ * \throw std::out_of_range when pos+count > that.size(), or when
620
+ * `count > N`
621
+ */
622
+ template <std::size_t M>
623
+ constexpr BasicFixedString(
624
+ const BasicFixedString<Char, M>& that,
625
+ std::size_t pos,
626
+ std::size_t count) noexcept(false)
627
+ : BasicFixedString{
628
+ that.data_,
629
+ that.size_,
630
+ std::make_index_sequence<(M < N ? M : N)>{},
631
+ pos,
632
+ detail::fixedstring::checkOverflow(
633
+ detail::fixedstring::checkOverflowOrNpos(
634
+ count,
635
+ that.size_ -
636
+ detail::fixedstring::checkOverflow(pos, that.size_)),
637
+ N)} {}
638
+
639
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
640
+ * Construct from a string literal
641
+ * \pre `M-1 <= N`
642
+ * \pre `that[M-1] == Char(0)`
643
+ * \post `0 == strncmp(data(), that, M-1)`
644
+ * \post `size() == M-1`
645
+ * \post `at(size()) == Char(0)`
646
+ */
647
+ template <std::size_t M, class = typename std::enable_if<(M - 1u <= N)>::type>
648
+ constexpr /* implicit */ BasicFixedString(const Char (&that)[M]) noexcept
649
+ : BasicFixedString{
650
+ detail::fixedstring::checkNullTerminated(that),
651
+ M - 1u,
652
+ std::make_index_sequence<M - 1u>{}} {}
653
+
654
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
655
+ * Construct from a `const Char*` and count
656
+ * \pre `that` points to an array of at least `count` characters.
657
+ * \pre `count <= N`
658
+ * \post `size() == count`
659
+ * \post `0 == strncmp(data(), that, size())`
660
+ * \post `at(size()) == Char(0)`
661
+ * \throw std::out_of_range when count > N
662
+ */
663
+ constexpr BasicFixedString(const Char* that, std::size_t count) noexcept(
664
+ false)
665
+ : BasicFixedString{
666
+ that, detail::fixedstring::checkOverflow(count, N), Indices{}} {}
667
+
668
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
669
+ * Construct from a `std::basic_string_view<Char>`
670
+ * \param that The source basic_string_view
671
+ * \pre `that.size() <= N`
672
+ * \post `size() == that.size()`
673
+ * \post `0 == strncmp(data(), that.begin(), size())`
674
+ * \post `at(size()) == Char(0)`
675
+ * \throw std::out_of_range when that.size() > N
676
+ */
677
+ constexpr /* implicit */ BasicFixedString(
678
+ std::basic_string_view<Char> that) noexcept(false)
679
+ : BasicFixedString{that.data(), that.size()} {}
680
+
681
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
682
+ * Construct an BasicFixedString that contains `count` characters, all
683
+ * of which are `ch`.
684
+ * \pre `count <= N`
685
+ * \post `size() == count`
686
+ * \post `npos == find_first_not_of(ch)`
687
+ * \post `at(size()) == Char(0)`
688
+ * \throw std::out_of_range when count > N
689
+ */
690
+ constexpr BasicFixedString(std::size_t count, Char ch) noexcept(false)
691
+ : BasicFixedString{
692
+ detail::fixedstring::checkOverflow(count, N), ch, Indices{}} {}
693
+
694
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
695
+ * Construct an BasicFixedString from a `std::initializer_list` of
696
+ * characters.
697
+ * \pre `il.size() <= N`
698
+ * \post `size() == count`
699
+ * \post `0 == strncmp(data(), il.begin(), size())`
700
+ * \post `at(size()) == Char(0)`
701
+ * \throw std::out_of_range when il.size() > N
702
+ */
703
+ constexpr BasicFixedString(std::initializer_list<Char> il) noexcept(false)
704
+ : BasicFixedString{il.begin(), il.size()} {}
705
+
706
+ constexpr BasicFixedString& operator=(const BasicFixedString&) noexcept =
707
+ default;
708
+
709
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
710
+ * Assign from a `BasicFixedString<Char, M>`.
711
+ * \pre `that.size() <= N`
712
+ * \post `size() == that.size()`
713
+ * \post `0 == strncmp(data(), that.begin(), size())`
714
+ * \post `at(size()) == Char(0)`
715
+ * \throw std::out_of_range when that.size() > N. When M <= N, this
716
+ * assignment operator will never throw.
717
+ * \note Assignments from larger-capacity BasicFixedString objects to smaller
718
+ * ones (`M > N`) are allowed as long as the *size* of the source string is
719
+ * small enough.
720
+ * \return `*this`
721
+ */
722
+ template <std::size_t M>
723
+ constexpr BasicFixedString& operator=(
724
+ const BasicFixedString<Char, M>& that) noexcept(M <= N) {
725
+ detail::fixedstring::checkOverflow(that.size_, N);
726
+ size_ = that.copy(data_, that.size_);
727
+ data_[size_] = Char(0);
728
+ return *this;
729
+ }
730
+
731
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
732
+ * Assign from a null-terminated array of characters.
733
+ * \pre `M < N`
734
+ * \pre `that` has no embedded null characters
735
+ * \pre `that[M-1]==Char(0)`
736
+ * \post `size() == M-1`
737
+ * \post `0 == strncmp(data(), that, size())`
738
+ * \post `at(size()) == Char(0)`
739
+ * \return `*this`
740
+ */
741
+ template <std::size_t M, class = typename std::enable_if<(M - 1u <= N)>::type>
742
+ constexpr BasicFixedString& operator=(const Char (&that)[M]) noexcept {
743
+ return assign(detail::fixedstring::checkNullTerminated(that), M - 1u);
744
+ }
745
+
746
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
747
+ * Assign from an `initializer_list` of characters.
748
+ * \pre `il.size() <= N`
749
+ * \post `size() == il.size()`
750
+ * \post `0 == strncmp(data(), il.begin(), size())`
751
+ * \post `at(size()) == Char(0)`
752
+ * \throw std::out_of_range when il.size() > N
753
+ * \return `*this`
754
+ */
755
+ constexpr BasicFixedString& operator=(
756
+ std::initializer_list<Char> il) noexcept(false) {
757
+ detail::fixedstring::checkOverflow(il.size(), N);
758
+ for (std::size_t i = 0u; i < il.size(); ++i) {
759
+ data_[i] = il.begin()[i];
760
+ }
761
+ size_ = il.size();
762
+ data_[size_] = Char(0);
763
+ return *this;
764
+ }
765
+
766
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
767
+ * Conversion to folly::Range
768
+ * \return `Range<Char*>{begin(), end()}`
769
+ */
770
+ constexpr Range<Char*> toRange() noexcept { return {begin(), end()}; }
771
+
772
+ /**
773
+ * \overload
774
+ */
775
+ constexpr Range<const Char*> toRange() const noexcept {
776
+ return {begin(), end()};
777
+ }
778
+
779
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
780
+ * Conversion to std::basic_string<Char>
781
+ * \return `std::basic_string<Char>{begin(), end()}`
782
+ */
783
+ /* implicit */ operator std::basic_string<Char>() const noexcept(false) {
784
+ return std::basic_string<Char>{begin(), end()};
785
+ }
786
+
787
+ std::basic_string<Char> toStdString() const noexcept(false) {
788
+ return std::basic_string<Char>{begin(), end()};
789
+ }
790
+
791
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
792
+ * Conversion to std::basic_string_view<Char>
793
+ * \return `std::basic_string_view<Char>{begin(), end()}`
794
+ */
795
+ /* implicit */ constexpr operator std::basic_string_view<Char>() const {
796
+ return std::basic_string_view<Char>{begin(), size()};
797
+ }
798
+
799
+ // Think hard about whether this is a good idea. It's certainly better than
800
+ // an implicit conversion to `const Char*` since `delete "hi"_fs` will fail
801
+ // to compile. But it creates ambiguities when passing a FixedString to an
802
+ // API that has overloads for `const char*` and `folly::Range`, for instance.
803
+ // using ArrayType = Char[N];
804
+ // constexpr /* implicit */ operator ArrayType&() noexcept {
805
+ // return data_;
806
+ // }
807
+
808
+ // using ConstArrayType = const Char[N];
809
+ // constexpr /* implicit */ operator ConstArrayType&() const noexcept {
810
+ // return data_;
811
+ // }
812
+
813
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
814
+ * Assigns a sequence of `count` characters of value `ch`.
815
+ * \param count The count of characters.
816
+ * \param ch
817
+ * \pre `count <= N`
818
+ * \post `size() == count`
819
+ * \post `npos == find_first_not_of(ch)`
820
+ * \post `at(size()) == Char(0)`
821
+ * \throw std::out_of_range when count > N
822
+ * \return `*this`
823
+ */
824
+ constexpr BasicFixedString& assign(std::size_t count, Char ch) noexcept(
825
+ false) {
826
+ detail::fixedstring::checkOverflow(count, N);
827
+ for (std::size_t i = 0u; i < count; ++i) {
828
+ data_[i] = ch;
829
+ }
830
+ size_ = count;
831
+ data_[size_] = Char(0);
832
+ return *this;
833
+ }
834
+
835
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
836
+ * Assigns characters from an `BasicFixedString` to this object.
837
+ * \note Equivalent to `assign(that, 0, that.size())`
838
+ */
839
+ template <std::size_t M>
840
+ constexpr BasicFixedString& assign(
841
+ const BasicFixedString<Char, M>& that) noexcept(M <= N) {
842
+ return *this = that;
843
+ }
844
+
845
+ // Why is this overload deleted? So users aren't confused by the difference
846
+ // between str.assign("foo", N) and str.assign("foo"_fs, N). In the former,
847
+ // N is a count of characters. In the latter, it would be a position, which
848
+ // totally changes the meaning of the code.
849
+ template <std::size_t M>
850
+ constexpr BasicFixedString& assign(
851
+ const BasicFixedString<Char, M>& that,
852
+ std::size_t pos) noexcept(false) = delete;
853
+
854
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
855
+ * Assigns `count` characters from an `BasicFixedString` to this object,
856
+ * starting at position `pos` in the source object.
857
+ * \param that The source string.
858
+ * \param pos The starting position in the source string.
859
+ * \param count The number of characters to copy. If `npos`, `count` is taken
860
+ * to be `that.size()-pos`.
861
+ * \pre `pos <= that.size()`
862
+ * \pre `count <= that.size()-pos`
863
+ * \pre `count <= N`
864
+ * \post `size() == count`
865
+ * \post `0 == strncmp(data(), that.begin() + pos, count)`
866
+ * \post `at(size()) == Char(0)`
867
+ * \throw std::out_of_range when pos > that.size() or count > that.size()-pos
868
+ * or count > N.
869
+ * \return `*this`
870
+ */
871
+ template <std::size_t M>
872
+ constexpr BasicFixedString& assign(
873
+ const BasicFixedString<Char, M>& that,
874
+ std::size_t pos,
875
+ std::size_t count) noexcept(false) {
876
+ detail::fixedstring::checkOverflow(pos, that.size_);
877
+ return assign(
878
+ that.data_ + pos,
879
+ detail::fixedstring::checkOverflowOrNpos(count, that.size_ - pos));
880
+ }
881
+
882
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
883
+ * Assigns characters from an `BasicFixedString` to this object.
884
+ * \pre `that` contains no embedded nulls.
885
+ * \pre `that[M-1] == Char(0)`
886
+ * \note Equivalent to `assign(that, M - 1)`
887
+ */
888
+ template <std::size_t M, class = typename std::enable_if<(M - 1u <= N)>::type>
889
+ constexpr BasicFixedString& assign(const Char (&that)[M]) noexcept {
890
+ return assign(detail::fixedstring::checkNullTerminated(that), M - 1u);
891
+ }
892
+
893
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
894
+ * Assigns `count` characters from a range of characters to this object.
895
+ * \param that A pointer to a range of characters.
896
+ * \param count The number of characters to copy.
897
+ * \pre `that` points to at least `count` characters.
898
+ * \pre `count <= N`
899
+ * \post `size() == count`
900
+ * \post `0 == strncmp(data(), that, count)`
901
+ * \post `at(size()) == Char(0)`
902
+ * \throw std::out_of_range when count > N
903
+ * \return `*this`
904
+ */
905
+ constexpr BasicFixedString& assign(
906
+ const Char* that, std::size_t count) noexcept(false) {
907
+ detail::fixedstring::checkOverflow(count, N);
908
+ for (std::size_t i = 0u; i < count; ++i) {
909
+ data_[i] = that[i];
910
+ }
911
+ size_ = count;
912
+ data_[size_] = Char(0);
913
+ return *this;
914
+ }
915
+
916
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
917
+ * Swap the contents of this string with `that`.
918
+ */
919
+ constexpr void swap(BasicFixedString& that) noexcept {
920
+ // less-than-or-equal here to copy the null terminator:
921
+ for (std::size_t i = 0u; i <= folly::constexpr_max(size_, that.size_);
922
+ ++i) {
923
+ detail::fixedstring::constexpr_swap(data_[i], that.data_[i]);
924
+ }
925
+ detail::fixedstring::constexpr_swap(size_, that.size_);
926
+ }
927
+
928
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
929
+ * Return a pointer to a range of `size()+1` characters, the last of which
930
+ * is `Char(0)`.
931
+ */
932
+ constexpr Char* data() noexcept { return data_; }
933
+
934
+ /**
935
+ * \overload
936
+ */
937
+ constexpr const Char* data() const noexcept { return data_; }
938
+
939
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
940
+ * \return `data()`.
941
+ */
942
+ constexpr const Char* c_str() const noexcept { return data_; }
943
+
944
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
945
+ * \return `data()`.
946
+ */
947
+ constexpr Char* begin() noexcept { return data_; }
948
+
949
+ /**
950
+ * \overload
951
+ */
952
+ constexpr const Char* begin() const noexcept { return data_; }
953
+
954
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
955
+ * \return `data()`.
956
+ */
957
+ constexpr const Char* cbegin() const noexcept { return begin(); }
958
+
959
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
960
+ * \return `data() + size()`.
961
+ */
962
+ constexpr Char* end() noexcept { return data_ + size_; }
963
+
964
+ /**
965
+ * \overload
966
+ */
967
+ constexpr const Char* end() const noexcept { return data_ + size_; }
968
+
969
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
970
+ * \return `data() + size()`.
971
+ */
972
+ constexpr const Char* cend() const noexcept { return end(); }
973
+
974
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
975
+ * Returns a reverse iterator to the first character of the reversed string.
976
+ * It corresponds to the last + 1 character of the non-reversed string.
977
+ */
978
+ constexpr reverse_iterator rbegin() noexcept {
979
+ return reverse_iterator{data_ + size_};
980
+ }
981
+
982
+ /**
983
+ * \overload
984
+ */
985
+ constexpr const_reverse_iterator rbegin() const noexcept {
986
+ return const_reverse_iterator{data_ + size_};
987
+ }
988
+
989
+ /**
990
+ * \note Equivalent to `rbegin()` on a const-qualified reference to `*this`.
991
+ */
992
+ constexpr const_reverse_iterator crbegin() const noexcept { return rbegin(); }
993
+
994
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
995
+ * Returns a reverse iterator to the last + 1 character of the reversed
996
+ * string. It corresponds to the first character of the non-reversed string.
997
+ */
998
+ constexpr reverse_iterator rend() noexcept { return reverse_iterator{data_}; }
999
+
1000
+ /**
1001
+ * \overload
1002
+ */
1003
+ constexpr const_reverse_iterator rend() const noexcept {
1004
+ return const_reverse_iterator{data_};
1005
+ }
1006
+
1007
+ /**
1008
+ * \note Equivalent to `rend()` on a const-qualified reference to `*this`.
1009
+ */
1010
+ constexpr const_reverse_iterator crend() const noexcept { return rend(); }
1011
+
1012
+ /**
1013
+ * \return The number of `Char` elements in the string.
1014
+ */
1015
+ constexpr std::size_t size() const noexcept { return size_; }
1016
+
1017
+ /**
1018
+ * \return The number of `Char` elements in the string.
1019
+ */
1020
+ constexpr std::size_t length() const noexcept { return size_; }
1021
+
1022
+ /**
1023
+ * \return True if and only if `size() == 0`.
1024
+ */
1025
+ constexpr bool empty() const noexcept { return 0u == size_; }
1026
+
1027
+ /**
1028
+ * \return `N`.
1029
+ */
1030
+ static constexpr std::size_t capacity() noexcept { return N; }
1031
+
1032
+ /**
1033
+ * \return `N`.
1034
+ */
1035
+ static constexpr std::size_t max_size() noexcept { return N; }
1036
+
1037
+ /**
1038
+ * \note `at(size())` is allowed will return `Char(0)`.
1039
+ * \return `*(data() + i)`
1040
+ * \throw std::out_of_range when i > size()
1041
+ */
1042
+ constexpr Char& at(std::size_t i) noexcept(false) {
1043
+ return i <= size_ ? data_[i]
1044
+ : (throw_exception<std::out_of_range>(
1045
+ "Out of range in BasicFixedString::at"),
1046
+ data_[size_]);
1047
+ }
1048
+
1049
+ /**
1050
+ * \overload
1051
+ */
1052
+ constexpr const Char& at(std::size_t i) const noexcept(false) {
1053
+ return i <= size_ ? data_[i]
1054
+ : (throw_exception<std::out_of_range>(
1055
+ "Out of range in BasicFixedString::at"),
1056
+ data_[size_]);
1057
+ }
1058
+
1059
+ /**
1060
+ * \pre `i <= size()`
1061
+ * \note `(*this)[size()]` is allowed will return `Char(0)`.
1062
+ * \return `*(data() + i)`
1063
+ */
1064
+ constexpr Char& operator[](std::size_t i) noexcept {
1065
+ return data_[detail::fixedstring::checkOverflowIfDebug(i, size_)];
1066
+ }
1067
+
1068
+ /**
1069
+ * \overload
1070
+ */
1071
+ constexpr const Char& operator[](std::size_t i) const noexcept {
1072
+ return data_[detail::fixedstring::checkOverflowIfDebug(i, size_)];
1073
+ }
1074
+
1075
+ /**
1076
+ * \note Equivalent to `(*this)[0]`
1077
+ */
1078
+ constexpr Char& front() noexcept { return (*this)[0u]; }
1079
+
1080
+ /**
1081
+ * \overload
1082
+ */
1083
+ constexpr const Char& front() const noexcept { return (*this)[0u]; }
1084
+
1085
+ /**
1086
+ * \note Equivalent to `at(size()-1)`
1087
+ * \pre `!empty()`
1088
+ */
1089
+ constexpr Char& back() noexcept {
1090
+ return data_[size_ - detail::fixedstring::checkOverflowIfDebug(1u, size_)];
1091
+ }
1092
+
1093
+ /**
1094
+ * \overload
1095
+ */
1096
+ constexpr const Char& back() const noexcept {
1097
+ return data_[size_ - detail::fixedstring::checkOverflowIfDebug(1u, size_)];
1098
+ }
1099
+
1100
+ /**
1101
+ * Clears the contents of this string.
1102
+ * \post `size() == 0u`
1103
+ * \post `at(size()) == Char(0)`
1104
+ */
1105
+ constexpr void clear() noexcept {
1106
+ data_[0u] = Char(0);
1107
+ size_ = 0u;
1108
+ }
1109
+
1110
+ /**
1111
+ * \note Equivalent to `append(1u, ch)`.
1112
+ */
1113
+ constexpr void push_back(Char ch) noexcept(false) {
1114
+ detail::fixedstring::checkOverflow(1u, N - size_);
1115
+ data_[size_] = ch;
1116
+ data_[++size_] = Char(0);
1117
+ }
1118
+
1119
+ /**
1120
+ * \note Equivalent to `cappend(1u, ch)`.
1121
+ */
1122
+ constexpr BasicFixedString<Char, N + 1u> cpush_back(Char ch) const noexcept {
1123
+ return cappend(ch);
1124
+ }
1125
+
1126
+ /**
1127
+ * Removes the last character from the string.
1128
+ * \pre `!empty()`
1129
+ * \post `size()` is one fewer than before calling `pop_back()`.
1130
+ * \post `at(size()) == Char(0)`
1131
+ * \post The characters in the half-open range `[0,size()-1)` are unmodified.
1132
+ * \throw std::out_of_range if empty().
1133
+ */
1134
+ constexpr void pop_back() noexcept(false) {
1135
+ detail::fixedstring::checkOverflow(1u, size_);
1136
+ --size_;
1137
+ data_[size_] = Char(0);
1138
+ }
1139
+
1140
+ /**
1141
+ * Returns a new string with the first `size()-1` characters from this string.
1142
+ * \pre `!empty()`
1143
+ * \note Equivalent to `BasicFixedString<Char, N-1u>{*this, 0u, size()-1u}`
1144
+ * \throw std::out_of_range if empty().
1145
+ */
1146
+ constexpr BasicFixedString<Char, N - 1u> cpop_back() const noexcept(false) {
1147
+ return {*this, 0u, size_ - detail::fixedstring::checkOverflow(1u, size_)};
1148
+ }
1149
+
1150
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1151
+ * Appends `count` copies of `ch` to this string.
1152
+ * \pre `count + old_size <= N`
1153
+ * \post The first `old_size` characters of the string are unmodified.
1154
+ * \post `size() == old_size + count`
1155
+ * \throw std::out_of_range if count > N - size().
1156
+ */
1157
+ constexpr BasicFixedString& append(std::size_t count, Char ch) noexcept(
1158
+ false) {
1159
+ detail::fixedstring::checkOverflow(count, N - size_);
1160
+ for (std::size_t i = 0u; i < count; ++i) {
1161
+ data_[size_ + i] = ch;
1162
+ }
1163
+ size_ += count;
1164
+ data_[size_] = Char(0);
1165
+ return *this;
1166
+ }
1167
+
1168
+ /**
1169
+ * \note Equivalent to `append(*this, 0, that.size())`.
1170
+ */
1171
+ template <std::size_t M>
1172
+ constexpr BasicFixedString& append(
1173
+ const BasicFixedString<Char, M>& that) noexcept(false) {
1174
+ return append(that, 0u, that.size_);
1175
+ }
1176
+
1177
+ // Why is this overload deleted? So as not to get confused with
1178
+ // append("null-terminated", N), where N would be a count instead
1179
+ // of a position.
1180
+ template <std::size_t M>
1181
+ constexpr BasicFixedString& append(
1182
+ const BasicFixedString<Char, M>& that,
1183
+ std::size_t pos) noexcept(false) = delete;
1184
+
1185
+ /**
1186
+ * Appends `count` characters from another string to this one, starting at a
1187
+ * given offset, `pos`.
1188
+ * \param that The source string.
1189
+ * \param pos The starting position in the source string.
1190
+ * \param count The number of characters to append. If `npos`, `count` is
1191
+ * taken to be `that.size()-pos`.
1192
+ * \pre `pos <= that.size()`
1193
+ * \pre `count <= that.size() - pos`
1194
+ * \pre `old_size + count <= N`
1195
+ * \post The first `old_size` characters of the string are unmodified.
1196
+ * \post `size() == old_size + count`
1197
+ * \post `at(size()) == Char(0)`
1198
+ * \throw std::out_of_range if pos + count > that.size() or if
1199
+ * `old_size + count > N`.
1200
+ */
1201
+ template <std::size_t M>
1202
+ constexpr BasicFixedString& append(
1203
+ const BasicFixedString<Char, M>& that,
1204
+ std::size_t pos,
1205
+ std::size_t count) noexcept(false) {
1206
+ detail::fixedstring::checkOverflow(pos, that.size_);
1207
+ count = detail::fixedstring::checkOverflowOrNpos(count, that.size_ - pos);
1208
+ detail::fixedstring::checkOverflow(count, N - size_);
1209
+ for (std::size_t i = 0u; i < count; ++i) {
1210
+ data_[size_ + i] = that.data_[pos + i];
1211
+ }
1212
+ size_ += count;
1213
+ data_[size_] = Char(0);
1214
+ return *this;
1215
+ }
1216
+
1217
+ /**
1218
+ * \note Equivalent to `append(that, strlen(that))`.
1219
+ */
1220
+ constexpr BasicFixedString& append(const Char* that) noexcept(false) {
1221
+ return append(that, folly::constexpr_strlen(that));
1222
+ }
1223
+
1224
+ /**
1225
+ * Appends `count` characters from the specified character array.
1226
+ * \pre `that` points to a range of at least `count` characters.
1227
+ * \pre `count + old_size <= N`
1228
+ * \post The first `old_size` characters of the string are unmodified.
1229
+ * \post `size() == old_size + count`
1230
+ * \post `at(size()) == Char(0)`
1231
+ * \throw std::out_of_range if old_size + count > N.
1232
+ */
1233
+ constexpr BasicFixedString& append(
1234
+ const Char* that, std::size_t count) noexcept(false) {
1235
+ detail::fixedstring::checkOverflow(count, N - size_);
1236
+ for (std::size_t i = 0u; i < count; ++i) {
1237
+ data_[size_ + i] = that[i];
1238
+ }
1239
+ size_ += count;
1240
+ data_[size_] = Char(0);
1241
+ return *this;
1242
+ }
1243
+
1244
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1245
+ * Creates a new string by appending a character to an existing string, which
1246
+ * is left unmodified.
1247
+ * \note Equivalent to `*this + ch`
1248
+ */
1249
+ constexpr BasicFixedString<Char, N + 1u> cappend(Char ch) const noexcept {
1250
+ return *this + ch;
1251
+ }
1252
+
1253
+ /**
1254
+ * Creates a new string by appending a string to an existing string, which
1255
+ * is left unmodified.
1256
+ * \note Equivalent to `*this + ch`
1257
+ */
1258
+ template <std::size_t M>
1259
+ constexpr BasicFixedString<Char, N + M> cappend(
1260
+ const BasicFixedString<Char, M>& that) const noexcept {
1261
+ return *this + that;
1262
+ }
1263
+
1264
+ // Deleted to avoid confusion with append("char*", N), where N is a count
1265
+ // instead of a position.
1266
+ template <std::size_t M>
1267
+ constexpr BasicFixedString<Char, N + M> cappend(
1268
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
1269
+ noexcept(false) = delete;
1270
+
1271
+ /**
1272
+ * Creates a new string by appending characters from one string to another,
1273
+ * which is left unmodified.
1274
+ * \note Equivalent to `*this + that.substr(pos, count)`
1275
+ */
1276
+ template <std::size_t M>
1277
+ constexpr BasicFixedString<Char, N + M> cappend(
1278
+ const BasicFixedString<Char, M>& that,
1279
+ std::size_t pos,
1280
+ std::size_t count) const noexcept(false) {
1281
+ return creplace(size_, 0u, that, pos, count);
1282
+ }
1283
+
1284
+ /**
1285
+ * Creates a new string by appending a string literal to a string,
1286
+ * which is left unmodified.
1287
+ * \note Equivalent to `*this + that`
1288
+ */
1289
+ template <std::size_t M>
1290
+ constexpr BasicFixedString<Char, N + M - 1u> cappend(
1291
+ const Char (&that)[M]) const noexcept {
1292
+ return creplace(size_, 0u, that);
1293
+ }
1294
+
1295
+ // Deleted to avoid confusion with append("char*", N), where N is a count
1296
+ // instead of a position
1297
+ template <std::size_t M>
1298
+ constexpr BasicFixedString<Char, N + M - 1u> cappend(
1299
+ const Char (&that)[M], std::size_t pos) const noexcept(false) = delete;
1300
+
1301
+ /**
1302
+ * Creates a new string by appending characters from one string to another,
1303
+ * which is left unmodified.
1304
+ * \note Equivalent to `*this + makeFixedString(that).substr(pos, count)`
1305
+ */
1306
+ template <std::size_t M>
1307
+ constexpr BasicFixedString<Char, N + M - 1u> cappend(
1308
+ const Char (&that)[M], std::size_t pos, std::size_t count) const
1309
+ noexcept(false) {
1310
+ return creplace(size_, 0u, that, pos, count);
1311
+ }
1312
+
1313
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1314
+ * Appends characters from a null-terminated string literal to this string.
1315
+ * \note Equivalent to `append(that)`.
1316
+ */
1317
+ constexpr BasicFixedString& operator+=(const Char* that) noexcept(false) {
1318
+ return append(that);
1319
+ }
1320
+
1321
+ /**
1322
+ * Appends characters from another string to this one.
1323
+ * \note Equivalent to `append(that)`.
1324
+ */
1325
+ template <std::size_t M>
1326
+ constexpr BasicFixedString& operator+=(
1327
+ const BasicFixedString<Char, M>& that) noexcept(false) {
1328
+ return append(that, 0u, that.size_);
1329
+ }
1330
+
1331
+ /**
1332
+ * Appends a character to this string.
1333
+ * \note Equivalent to `push_back(ch)`.
1334
+ */
1335
+ constexpr BasicFixedString& operator+=(Char ch) noexcept(false) {
1336
+ push_back(ch);
1337
+ return *this;
1338
+ }
1339
+
1340
+ /**
1341
+ * Appends characters from an `initializer_list` to this string.
1342
+ * \note Equivalent to `append(il.begin(), il.size())`.
1343
+ */
1344
+ constexpr BasicFixedString& operator+=(
1345
+ std::initializer_list<Char> il) noexcept(false) {
1346
+ return append(il.begin(), il.size());
1347
+ }
1348
+
1349
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1350
+ * Erase all characters from this string.
1351
+ * \note Equivalent to `clear()`
1352
+ * \return *this;
1353
+ */
1354
+ constexpr BasicFixedString& erase() noexcept {
1355
+ clear();
1356
+ return *this;
1357
+ }
1358
+
1359
+ /**
1360
+ * Erases `count` characters from position `pos`. If `count` is `npos`,
1361
+ * erases from `pos` to the end of the string.
1362
+ * \pre `pos <= size()`
1363
+ * \pre `count <= size() - pos || count == npos`
1364
+ * \post `size() == old_size - min(count, old_size - pos)`
1365
+ * \post `at(size()) == Char(0)`
1366
+ * \return *this;
1367
+ * \throw std::out_of_range when pos > size().
1368
+ */
1369
+ constexpr BasicFixedString& erase(
1370
+ std::size_t pos, std::size_t count = npos) noexcept(false) {
1371
+ using A = const Char[1];
1372
+ constexpr A a{Char(0)};
1373
+ return replace(
1374
+ pos,
1375
+ detail::fixedstring::checkOverflowOrNpos(
1376
+ count, size_ - detail::fixedstring::checkOverflow(pos, size_)),
1377
+ a,
1378
+ 0u);
1379
+ }
1380
+
1381
+ /**
1382
+ * \note Equivalent to `erase(first - data(), 1)`
1383
+ * \return A pointer to the first character after the erased character.
1384
+ */
1385
+ constexpr Char* erase(const Char* first) noexcept(false) {
1386
+ erase(first - data_, 1u);
1387
+ return data_ + (first - data_);
1388
+ }
1389
+
1390
+ /**
1391
+ * \note Equivalent to `erase(first - data(), last - first)`
1392
+ * \return A pointer to the first character after the erased characters.
1393
+ */
1394
+ constexpr Char* erase(const Char* first, const Char* last) noexcept(false) {
1395
+ erase(first - data_, last - first);
1396
+ return data_ + (first - data_);
1397
+ }
1398
+
1399
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1400
+ * Create a new string by erasing all the characters from this string.
1401
+ * \note Equivalent to `BasicFixedString<Char, 0>{}`
1402
+ */
1403
+ constexpr BasicFixedString<Char, 0u> cerase() const noexcept { return {}; }
1404
+
1405
+ /**
1406
+ * Create a new string by erasing all the characters after position `pos` from
1407
+ * this string.
1408
+ * \note Equivalent to `creplace(pos, min(count, pos - size()), "")`
1409
+ */
1410
+ constexpr BasicFixedString cerase(
1411
+ std::size_t pos, std::size_t count = npos) const noexcept(false) {
1412
+ using A = const Char[1];
1413
+ return creplace(
1414
+ pos,
1415
+ detail::fixedstring::checkOverflowOrNpos(
1416
+ count, size_ - detail::fixedstring::checkOverflow(pos, size_)),
1417
+ A{Char(0)});
1418
+ }
1419
+
1420
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1421
+ * Compare two strings for lexicographical ordering.
1422
+ * \note Equivalent to
1423
+ * `compare(0, size(), that.data(), that.size())`
1424
+ */
1425
+ template <std::size_t M>
1426
+ constexpr int compare(const BasicFixedString<Char, M>& that) const noexcept {
1427
+ return compare(0u, size_, that, 0u, that.size_);
1428
+ }
1429
+
1430
+ /**
1431
+ * Compare two strings for lexicographical ordering.
1432
+ * \note Equivalent to
1433
+ * `compare(this_pos, this_count, that.data(), that.size())`
1434
+ */
1435
+ template <std::size_t M>
1436
+ constexpr int compare(
1437
+ std::size_t this_pos,
1438
+ std::size_t this_count,
1439
+ const BasicFixedString<Char, M>& that) const noexcept(false) {
1440
+ return compare(this_pos, this_count, that, 0u, that.size_);
1441
+ }
1442
+
1443
+ /**
1444
+ * Compare two strings for lexicographical ordering.
1445
+ * \note Equivalent to
1446
+ * `compare(this_pos, this_count, that.data() + that_pos, that_count)`
1447
+ */
1448
+ template <std::size_t M>
1449
+ constexpr int compare(
1450
+ std::size_t this_pos,
1451
+ std::size_t this_count,
1452
+ const BasicFixedString<Char, M>& that,
1453
+ std::size_t that_pos,
1454
+ std::size_t that_count) const noexcept(false) {
1455
+ return static_cast<int>(detail::fixedstring::compare_(
1456
+ data_,
1457
+ detail::fixedstring::checkOverflow(this_pos, size_),
1458
+ detail::fixedstring::checkOverflow(this_count, size_ - this_pos) +
1459
+ this_pos,
1460
+ that.data_,
1461
+ detail::fixedstring::checkOverflow(that_pos, that.size_),
1462
+ detail::fixedstring::checkOverflow(that_count, that.size_ - that_pos) +
1463
+ that_pos));
1464
+ }
1465
+
1466
+ /**
1467
+ * Compare two strings for lexicographical ordering.
1468
+ * \note Equivalent to `compare(0, size(), that, strlen(that))`
1469
+ */
1470
+ constexpr int compare(const Char* that) const noexcept {
1471
+ return compare(0u, size_, that, folly::constexpr_strlen(that));
1472
+ }
1473
+
1474
+ /**
1475
+ * \overload
1476
+ */
1477
+ constexpr int compare(Range<const Char*> that) const noexcept {
1478
+ return compare(0u, size_, that.begin(), that.size());
1479
+ }
1480
+
1481
+ /**
1482
+ * Compare two strings for lexicographical ordering.
1483
+ * \note Equivalent to
1484
+ * `compare(this_pos, this_count, that, strlen(that))`
1485
+ */
1486
+ constexpr int compare(
1487
+ std::size_t this_pos, std::size_t this_count, const Char* that) const
1488
+ noexcept(false) {
1489
+ return compare(this_pos, this_count, that, folly::constexpr_strlen(that));
1490
+ }
1491
+
1492
+ /**
1493
+ * \overload
1494
+ */
1495
+ constexpr int compare(
1496
+ std::size_t this_pos,
1497
+ std::size_t this_count,
1498
+ Range<const Char*> that) const noexcept(false) {
1499
+ return compare(this_pos, this_count, that.begin(), that.size());
1500
+ }
1501
+
1502
+ /**
1503
+ * Compare two strings for lexicographical ordering.
1504
+ *
1505
+ * Let `A` be the
1506
+ * character sequence {`(*this)[this_pos]`, ...
1507
+ * `(*this)[this_pos + this_count - 1]`}. Let `B` be the character sequence
1508
+ * {`that[0]`, ...`that[count - 1]`}. Then...
1509
+ *
1510
+ * \return
1511
+ * - `< 0` if `A` is ordered before the `B`
1512
+ * - `> 0` if `B` is ordered before `A`
1513
+ * - `0` if `A` equals `B`.
1514
+ *
1515
+ * \throw std::out_of_range if this_pos + this_count > size().
1516
+ */
1517
+ constexpr int compare(
1518
+ std::size_t this_pos,
1519
+ std::size_t this_count,
1520
+ const Char* that,
1521
+ std::size_t that_count) const noexcept(false) {
1522
+ return static_cast<int>(detail::fixedstring::compare_(
1523
+ data_,
1524
+ detail::fixedstring::checkOverflow(this_pos, size_),
1525
+ detail::fixedstring::checkOverflowOrNpos(this_count, size_ - this_pos) +
1526
+ this_pos,
1527
+ that,
1528
+ 0u,
1529
+ that_count));
1530
+ }
1531
+
1532
+ constexpr int compare(
1533
+ std::size_t this_pos,
1534
+ std::size_t this_count,
1535
+ Range<const Char*> that,
1536
+ std::size_t that_count) const noexcept(false) {
1537
+ return compare(
1538
+ this_pos,
1539
+ this_count,
1540
+ that.begin(),
1541
+ detail::fixedstring::checkOverflow(that_count, that.size()));
1542
+ }
1543
+
1544
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1545
+ * Return a substring from `pos` to the end of the string.
1546
+ * \note Equivalent to `BasicFixedString{*this, pos}`
1547
+ */
1548
+ constexpr BasicFixedString substr(std::size_t pos) const noexcept(false) {
1549
+ return {*this, pos};
1550
+ }
1551
+
1552
+ /**
1553
+ * Return a substring from `pos` to the end of the string.
1554
+ * \note Equivalent to `BasicFixedString{*this, pos, count}`
1555
+ */
1556
+ constexpr BasicFixedString substr(std::size_t pos, std::size_t count) const
1557
+ noexcept(false) {
1558
+ return {*this, pos, count};
1559
+ }
1560
+
1561
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1562
+ * Replace the characters in the range denoted by the half-open range
1563
+ * [`first`, `last`) with the string `that`.
1564
+ * \pre `first` and `last` point to characters within this string (including
1565
+ * the terminating null).
1566
+ * \note Equivalent to
1567
+ * `replace(first - data(), last - first, that.data(), that.size())`
1568
+ */
1569
+ template <std::size_t M>
1570
+ constexpr BasicFixedString& replace(
1571
+ const Char* first,
1572
+ const Char* last,
1573
+ const BasicFixedString<Char, M>& that) noexcept(false) {
1574
+ return replace(first - data_, last - first, that, 0u, that.size_);
1575
+ }
1576
+
1577
+ /**
1578
+ * Replace `this_count` characters starting from position `this_pos` with the
1579
+ * characters from string `that` starting at position `that_pos`.
1580
+ * \pre `that_pos <= that.size()`
1581
+ * \note Equivalent to
1582
+ * <tt>replace(this_pos, this_count, that.data() + that_pos,
1583
+ * that.size() - that_pos)</tt>
1584
+ */
1585
+ template <std::size_t M>
1586
+ constexpr BasicFixedString& replace(
1587
+ std::size_t this_pos,
1588
+ std::size_t this_count,
1589
+ const BasicFixedString<Char, M>& that,
1590
+ std::size_t that_pos = 0u) noexcept(false) {
1591
+ return replace(this_pos, this_count, that, that_pos, that.size_ - that_pos);
1592
+ }
1593
+
1594
+ /**
1595
+ * Replace `this_count` characters starting from position `this_pos` with
1596
+ * `that_count` characters from string `that` starting at position
1597
+ * `that_pos`.
1598
+ * \pre `that_pos <= that.size() && that_count <= that.size() - that_pos`
1599
+ * \note Equivalent to
1600
+ * `replace(this_pos, this_count, that.data() + that_pos, that_count)`
1601
+ */
1602
+ template <std::size_t M>
1603
+ constexpr BasicFixedString& replace(
1604
+ std::size_t this_pos,
1605
+ std::size_t this_count,
1606
+ const BasicFixedString<Char, M>& that,
1607
+ std::size_t that_pos,
1608
+ std::size_t that_count) noexcept(false) {
1609
+ return *this = creplace(this_pos, this_count, that, that_pos, that_count);
1610
+ }
1611
+
1612
+ /**
1613
+ * Replace `this_count` characters starting from position `this_pos` with
1614
+ * the characters from the string literal `that`.
1615
+ * \note Equivalent to
1616
+ * `replace(this_pos, this_count, that, strlen(that))`
1617
+ */
1618
+ constexpr BasicFixedString& replace(
1619
+ std::size_t this_pos,
1620
+ std::size_t this_count,
1621
+ const Char* that) noexcept(false) {
1622
+ return replace(this_pos, this_count, that, folly::constexpr_strlen(that));
1623
+ }
1624
+
1625
+ /**
1626
+ * Replace the characters denoted by the half-open range [`first`,`last`) with
1627
+ * the characters from the string literal `that`.
1628
+ * \pre `first` and `last` point to characters within this string (including
1629
+ * the terminating null).
1630
+ * \note Equivalent to
1631
+ * `replace(first - data(), last - first, that, strlen(that))`
1632
+ */
1633
+ constexpr BasicFixedString& replace(
1634
+ const Char* first, const Char* last, const Char* that) noexcept(false) {
1635
+ return replace(
1636
+ first - data_, last - first, that, folly::constexpr_strlen(that));
1637
+ }
1638
+
1639
+ /**
1640
+ * Replace `this_count` characters starting from position `this_pos` with
1641
+ * `that_count` characters from the character sequence pointed to by `that`.
1642
+ * \param this_pos The starting offset within `*this` of the first character
1643
+ * to be replaced.
1644
+ * \param this_count The number of characters to be replaced. If `npos`,
1645
+ * it is treated as if `this_count` were `size() - this_pos`.
1646
+ * \param that A pointer to the replacement string.
1647
+ * \param that_count The number of characters in the replacement string.
1648
+ * \pre `this_pos <= size() && this_count <= size() - this_pos`
1649
+ * \pre `that` points to a contiguous sequence of at least `that_count`
1650
+ * characters
1651
+ * \throw std::out_of_range on any of the following conditions:
1652
+ * - `this_pos > size()`
1653
+ * - `this_count > size() - this_pos`
1654
+ * - `size() - this_count + that_count > N`
1655
+ */
1656
+ constexpr BasicFixedString& replace(
1657
+ std::size_t this_pos,
1658
+ std::size_t this_count,
1659
+ const Char* that,
1660
+ std::size_t that_count) noexcept(false) {
1661
+ return *this = detail::fixedstring::Helper::replace_<Char>(
1662
+ data_,
1663
+ size_,
1664
+ detail::fixedstring::checkOverflow(this_pos, size_),
1665
+ detail::fixedstring::checkOverflowOrNpos(
1666
+ this_count, size_ - this_pos),
1667
+ that,
1668
+ 0u,
1669
+ that_count,
1670
+ Indices{});
1671
+ }
1672
+
1673
+ /**
1674
+ * Replace `this_count` characters starting from position `this_pos` with
1675
+ * `that_count` characters `ch`.
1676
+ * \note Equivalent to
1677
+ * `replace(this_pos, this_count, BasicFixedString{that_count, ch})`
1678
+ */
1679
+ constexpr BasicFixedString& replace(
1680
+ std::size_t this_pos,
1681
+ std::size_t this_count,
1682
+ std::size_t that_count,
1683
+ Char ch) noexcept(false) {
1684
+ return replace(this_pos, this_count, BasicFixedString{that_count, ch});
1685
+ }
1686
+
1687
+ /**
1688
+ * Replace the characters denoted by the half-open range [`first`,`last`)
1689
+ * with `that_count` characters `ch`.
1690
+ * \note Equivalent to
1691
+ * `replace(first - data(), last - first, BasicFixedString{that_count, ch})`
1692
+ */
1693
+ constexpr BasicFixedString& replace(
1694
+ const Char* first,
1695
+ const Char* last,
1696
+ std::size_t that_count,
1697
+ Char ch) noexcept(false) {
1698
+ return replace(
1699
+ first - data_, last - first, BasicFixedString{that_count, ch});
1700
+ }
1701
+
1702
+ /**
1703
+ * Replace the characters denoted by the half-open range [`first`,`last`) with
1704
+ * the characters from the string literal `that`.
1705
+ * \pre `first` and `last` point to characters within this string (including
1706
+ * the terminating null).
1707
+ * \note Equivalent to
1708
+ * `replace(this_pos, this_count, il.begin(), il.size())`
1709
+ */
1710
+ constexpr BasicFixedString& replace(
1711
+ const Char* first,
1712
+ const Char* last,
1713
+ std::initializer_list<Char> il) noexcept(false) {
1714
+ return replace(first - data_, last - first, il.begin(), il.size());
1715
+ }
1716
+
1717
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1718
+ * Construct a new string by replacing `this_count` characters starting from
1719
+ * position `this_pos` within this string with the characters from string
1720
+ * `that` starting at position `that_pos`.
1721
+ * \pre `that_pos <= that.size()`
1722
+ * \note Equivalent to
1723
+ * <tt>creplace(this_pos, this_count, that, that_pos,
1724
+ * that.size() - that_pos)</tt>
1725
+ */
1726
+ template <std::size_t M>
1727
+ constexpr BasicFixedString<Char, N + M> creplace(
1728
+ std::size_t this_pos,
1729
+ std::size_t this_count,
1730
+ const BasicFixedString<Char, M>& that,
1731
+ std::size_t that_pos = 0u) const noexcept(false) {
1732
+ return creplace(
1733
+ this_pos,
1734
+ this_count,
1735
+ that,
1736
+ that_pos,
1737
+ that.size_ - detail::fixedstring::checkOverflow(that_pos, that.size_));
1738
+ }
1739
+
1740
+ /**
1741
+ * Construct a new string by replacing `this_count` characters starting from
1742
+ * position `this_pos` within this string with `that_count` characters from
1743
+ * string `that` starting at position `that_pos`.
1744
+ * \param this_pos The starting offset within `*this` of the first character
1745
+ * to be replaced.
1746
+ * \param this_count The number of characters to be replaced. If `npos`,
1747
+ * it is treated as if `this_count` were `size() - this_pos`.
1748
+ * \param that A string that contains the replacement string.
1749
+ * \param that_pos The offset to the first character in the replacement
1750
+ * string.
1751
+ * \param that_count The number of characters in the replacement string.
1752
+ * \pre `this_pos <= size() && this_count <= size() - this_pos`
1753
+ * \pre `that_pos <= that.size() && that_count <= that.size() - that_pos`
1754
+ * \post The size of the returned string is `size() - this_count + that_count`
1755
+ * \note Equivalent to <tt>BasicFixedString<Char, N + M>{substr(0, this_pos) +
1756
+ * that.substr(that_pos, that_count) + substr(this_pos + this_count)}</tt>
1757
+ * \throw std::out_of_range on any of the following conditions:
1758
+ * - `this_pos > size()`
1759
+ * - `this_count > size() - this_pos`
1760
+ * - `that_pos > that.size()`
1761
+ * - `that_count > that.size() - that_pos`
1762
+ */
1763
+ template <std::size_t M>
1764
+ constexpr BasicFixedString<Char, N + M> creplace(
1765
+ std::size_t this_pos,
1766
+ std::size_t this_count,
1767
+ const BasicFixedString<Char, M>& that,
1768
+ std::size_t that_pos,
1769
+ std::size_t that_count) const noexcept(false) {
1770
+ return detail::fixedstring::Helper::replace_<Char>(
1771
+ data_,
1772
+ size_,
1773
+ detail::fixedstring::checkOverflow(this_pos, size_),
1774
+ detail::fixedstring::checkOverflowOrNpos(this_count, size_ - this_pos),
1775
+ that.data_,
1776
+ detail::fixedstring::checkOverflow(that_pos, that.size_),
1777
+ detail::fixedstring::checkOverflowOrNpos(
1778
+ that_count, that.size_ - that_pos),
1779
+ std::make_index_sequence<N + M>{});
1780
+ }
1781
+
1782
+ /**
1783
+ * Construct a new string by replacing the characters denoted by the half-open
1784
+ * range [`first`,`last`) within this string with the characters from string
1785
+ * `that` starting at position `that_pos`.
1786
+ * \pre `that_pos <= that.size()`
1787
+ * \note Equivalent to
1788
+ * <tt>creplace(first - data(), last - first, that, that_pos,
1789
+ * that.size() - that_pos)</tt>
1790
+ */
1791
+ template <std::size_t M>
1792
+ constexpr BasicFixedString<Char, N + M> creplace(
1793
+ const Char* first,
1794
+ const Char* last,
1795
+ const BasicFixedString<Char, M>& that,
1796
+ std::size_t that_pos = 0u) const noexcept(false) {
1797
+ return creplace(
1798
+ first - data_,
1799
+ last - first,
1800
+ that,
1801
+ that_pos,
1802
+ that.size_ - detail::fixedstring::checkOverflow(that_pos, that.size_));
1803
+ }
1804
+
1805
+ /**
1806
+ * Construct a new string by replacing the characters denoted by the half-open
1807
+ * range [`first`,`last`) within this string with the `that_count`
1808
+ * characters from string `that` starting at position `that_pos`.
1809
+ * \note Equivalent to
1810
+ * <tt>creplace(first - data(), last - first, that, that_pos,
1811
+ * that_count)</tt>
1812
+ */
1813
+ template <std::size_t M>
1814
+ constexpr BasicFixedString<Char, N + M> creplace(
1815
+ const Char* first,
1816
+ const Char* last,
1817
+ const BasicFixedString<Char, M>& that,
1818
+ std::size_t that_pos,
1819
+ std::size_t that_count) const noexcept(false) {
1820
+ return creplace(first - data_, last - first, that, that_pos, that_count);
1821
+ }
1822
+
1823
+ /**
1824
+ * Construct a new string by replacing `this_count` characters starting from
1825
+ * position `this_pos` within this string with `M-1` characters from
1826
+ * character array `that`.
1827
+ * \pre `strlen(that) == M-1`
1828
+ * \note Equivalent to
1829
+ * <tt>creplace(this_pos, this_count, that, 0, M - 1)</tt>
1830
+ */
1831
+ template <std::size_t M>
1832
+ constexpr BasicFixedString<Char, N + M - 1u> creplace(
1833
+ std::size_t this_pos, std::size_t this_count, const Char (&that)[M]) const
1834
+ noexcept(false) {
1835
+ return creplace(this_pos, this_count, that, 0u, M - 1u);
1836
+ }
1837
+
1838
+ /**
1839
+ * Replace `this_count` characters starting from position `this_pos` with
1840
+ * `that_count` characters from the character array `that` starting at
1841
+ * position `that_pos`.
1842
+ * \param this_pos The starting offset within `*this` of the first character
1843
+ * to be replaced.
1844
+ * \param this_count The number of characters to be replaced. If `npos`,
1845
+ * it is treated as if `this_count` were `size() - this_pos`.
1846
+ * \param that An array of characters containing the replacement string.
1847
+ * \param that_pos The starting offset of the replacement string.
1848
+ * \param that_count The number of characters in the replacement string. If
1849
+ * `npos`, it is treated as if `that_count` were `M - 1 - that_pos`
1850
+ * \pre `this_pos <= size() && this_count <= size() - this_pos`
1851
+ * \pre `that_pos <= M - 1 && that_count <= M - 1 - that_pos`
1852
+ * \post The size of the returned string is `size() - this_count + that_count`
1853
+ * \note Equivalent to <tt>BasicFixedString<Char, N + M - 1>{
1854
+ * substr(0, this_pos) +
1855
+ * makeFixedString(that).substr(that_pos, that_count) +
1856
+ * substr(this_pos + this_count)}</tt>
1857
+ * \throw std::out_of_range on any of the following conditions:
1858
+ * - `this_pos > size()`
1859
+ * - `this_count > size() - this_pos`
1860
+ * - `that_pos >= M`
1861
+ * - `that_count >= M - that_pos`
1862
+ */
1863
+ template <std::size_t M>
1864
+ constexpr BasicFixedString<Char, N + M - 1u> creplace(
1865
+ std::size_t this_pos,
1866
+ std::size_t this_count,
1867
+ const Char (&that)[M],
1868
+ std::size_t that_pos,
1869
+ std::size_t that_count) const noexcept(false) {
1870
+ return detail::fixedstring::Helper::replace_<Char>(
1871
+ data_,
1872
+ size_,
1873
+ detail::fixedstring::checkOverflow(this_pos, size_),
1874
+ detail::fixedstring::checkOverflowOrNpos(this_count, size_ - this_pos),
1875
+ detail::fixedstring::checkNullTerminated(that),
1876
+ detail::fixedstring::checkOverflow(that_pos, M - 1u),
1877
+ detail::fixedstring::checkOverflowOrNpos(that_count, M - 1u - that_pos),
1878
+ std::make_index_sequence<N + M - 1u>{});
1879
+ }
1880
+
1881
+ /**
1882
+ * Construct a new string by replacing the characters denoted by the half-open
1883
+ * range [`first`,`last`) within this string with the first `M-1`
1884
+ * characters from the character array `that`.
1885
+ * \pre `strlen(that) == M-1`
1886
+ * \note Equivalent to
1887
+ * <tt>creplace(first - data(), last - first, that, 0, M-1)</tt>
1888
+ */
1889
+ template <std::size_t M>
1890
+ constexpr BasicFixedString<Char, N + M - 1u> creplace(
1891
+ const Char* first, const Char* last, const Char (&that)[M]) const
1892
+ noexcept(false) {
1893
+ return creplace(first - data_, last - first, that, 0u, M - 1u);
1894
+ }
1895
+
1896
+ /**
1897
+ * Construct a new string by replacing the characters denoted by the half-open
1898
+ * range [`first`,`last`) within this string with the `that_count`
1899
+ * characters from the character array `that` starting at position
1900
+ * `that_pos`.
1901
+ * \pre `strlen(that) == M-1`
1902
+ * \note Equivalent to
1903
+ * `creplace(first - data(), last - first, that, that_pos, that_count)`
1904
+ */
1905
+ template <std::size_t M>
1906
+ constexpr BasicFixedString<Char, N + M - 1u> creplace(
1907
+ const Char* first,
1908
+ const Char* last,
1909
+ const Char (&that)[M],
1910
+ std::size_t that_pos,
1911
+ std::size_t that_count) const noexcept(false) {
1912
+ return creplace(first - data_, last - first, that, that_pos, that_count);
1913
+ }
1914
+
1915
+ /**
1916
+ * Copies `min(count, size())` characters starting from offset `0`
1917
+ * from this string into the buffer pointed to by `dest`.
1918
+ * \return The number of characters copied.
1919
+ */
1920
+ constexpr std::size_t copy(Char* dest, std::size_t count) const noexcept {
1921
+ return copy(dest, count, 0u);
1922
+ }
1923
+
1924
+ /**
1925
+ * Copies `min(count, size() - pos)` characters starting from offset `pos`
1926
+ * from this string into the buffer pointed to by `dest`.
1927
+ * \pre `pos <= size()`
1928
+ * \return The number of characters copied.
1929
+ * \throw std::out_of_range if `pos > size()`
1930
+ */
1931
+ constexpr std::size_t copy(
1932
+ Char* dest, std::size_t count, std::size_t pos) const noexcept(false) {
1933
+ detail::fixedstring::checkOverflow(pos, size_);
1934
+ for (std::size_t i = 0u; i < count; ++i) {
1935
+ if (i + pos == size_) {
1936
+ return size_;
1937
+ }
1938
+ dest[i] = data_[i + pos];
1939
+ }
1940
+ return count;
1941
+ }
1942
+
1943
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1944
+ * Resizes the current string.
1945
+ * \note Equivalent to `resize(count, Char(0))`
1946
+ */
1947
+ constexpr void resize(std::size_t count) noexcept(false) {
1948
+ resize(count, Char(0));
1949
+ }
1950
+
1951
+ /**
1952
+ * Resizes the current string by setting the size to `count` and setting
1953
+ * `data()[count]` to `Char(0)`. If `count > old_size`, the characters
1954
+ * in the range [`old_size`,`count`) are set to `ch`.
1955
+ */
1956
+ constexpr void resize(std::size_t count, Char ch) noexcept(false) {
1957
+ detail::fixedstring::checkOverflow(count, N);
1958
+ if (count == size_) {
1959
+ } else if (count < size_) {
1960
+ size_ = count;
1961
+ data_[size_] = Char(0);
1962
+ } else {
1963
+ for (; size_ < count; ++size_) {
1964
+ data_[size_] = ch;
1965
+ }
1966
+ data_[size_] = Char(0);
1967
+ }
1968
+ }
1969
+
1970
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
1971
+ * Finds the first occurrence of the character sequence `that` in this string.
1972
+ * \note Equivalent to `find(that.data(), 0, that.size())`
1973
+ */
1974
+ template <std::size_t M>
1975
+ constexpr std::size_t find(
1976
+ const BasicFixedString<Char, M>& that) const noexcept {
1977
+ return find(that, 0u);
1978
+ }
1979
+
1980
+ /**
1981
+ * Finds the first occurrence of the character sequence `that` in this string,
1982
+ * starting at offset `pos`.
1983
+ * \pre `pos <= size()`
1984
+ * \note Equivalent to `find(that.data(), pos, that.size())`
1985
+ */
1986
+ template <std::size_t M>
1987
+ constexpr std::size_t find(
1988
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
1989
+ noexcept(false) {
1990
+ return that.size_ <= size_ - detail::fixedstring::checkOverflow(pos, size_)
1991
+ ? detail::fixedstring::find_(data_, size_, that.data_, pos, that.size_)
1992
+ : npos;
1993
+ }
1994
+
1995
+ /**
1996
+ * Finds the first occurrence of the character sequence `that` in this string.
1997
+ * \note Equivalent to `find(that.data(), 0, strlen(that))`
1998
+ */
1999
+ constexpr std::size_t find(const Char* that) const noexcept {
2000
+ return find(that, 0u, folly::constexpr_strlen(that));
2001
+ }
2002
+
2003
+ /**
2004
+ * Finds the first occurrence of the character sequence `that` in this string,
2005
+ * starting at offset `pos`.
2006
+ * \pre `pos <= size()`
2007
+ * \note Equivalent to `find(that.data(), pos, strlen(that))`
2008
+ */
2009
+ constexpr std::size_t find(const Char* that, std::size_t pos) const
2010
+ noexcept(false) {
2011
+ return find(that, pos, folly::constexpr_strlen(that));
2012
+ }
2013
+
2014
+ /**
2015
+ * Finds the first occurrence of the first `count` characters in the buffer
2016
+ * pointed to by `that` in this string, starting at offset `pos`.
2017
+ * \pre `pos <= size()`
2018
+ * \pre `that` points to a buffer containing at least `count` contiguous
2019
+ * characters.
2020
+ * \return The lowest offset `i` such that `i >= pos` and
2021
+ * `0 == strncmp(data() + i, that, count)`; or `npos` if there is no such
2022
+ * offset `i`.
2023
+ * \throw std::out_of_range when `pos > size()`
2024
+ */
2025
+ constexpr std::size_t find(
2026
+ const Char* that, std::size_t pos, std::size_t count) const
2027
+ noexcept(false) {
2028
+ return count <= size_ - detail::fixedstring::checkOverflow(pos, size_)
2029
+ ? detail::fixedstring::find_(data_, size_, that, pos, count)
2030
+ : npos;
2031
+ }
2032
+
2033
+ /**
2034
+ * Finds the first occurrence of the character `ch` in this string.
2035
+ * \note Equivalent to `find(&ch, 0, 1)`
2036
+ */
2037
+ constexpr std::size_t find(Char ch) const noexcept { return find(ch, 0u); }
2038
+
2039
+ /**
2040
+ * Finds the first occurrence of the character character `c` in this string,
2041
+ * starting at offset `pos`.
2042
+ * \pre `pos <= size()`
2043
+ * \note Equivalent to `find(&ch, pos, 1)`
2044
+ */
2045
+ constexpr std::size_t find(Char ch, std::size_t pos) const noexcept(false) {
2046
+ using A = const Char[1u];
2047
+ return 0u == size_ - detail::fixedstring::checkOverflow(pos, size_)
2048
+ ? npos
2049
+ : detail::fixedstring::find_(data_, size_, A{ch}, pos, 1u);
2050
+ }
2051
+
2052
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2053
+ * Finds the last occurrence of characters in the string
2054
+ * `that` in this string.
2055
+ * \note Equivalent to `rfind(that.data(), size(), that.size())`
2056
+ */
2057
+ template <std::size_t M>
2058
+ constexpr std::size_t rfind(
2059
+ const BasicFixedString<Char, M>& that) const noexcept {
2060
+ return rfind(that, size_);
2061
+ }
2062
+
2063
+ /**
2064
+ * Finds the last occurrence of characters in the string
2065
+ * `that` in this string, starting at offset `pos`.
2066
+ * \note Equivalent to `rfind(that.data(), pos, that.size())`
2067
+ */
2068
+ template <std::size_t M>
2069
+ constexpr std::size_t rfind(
2070
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
2071
+ noexcept(false) {
2072
+ return that.size_ <= size_
2073
+ ? detail::fixedstring::rfind_(
2074
+ data_,
2075
+ that.data_,
2076
+ folly::constexpr_min(
2077
+ detail::fixedstring::checkOverflow(pos, size_),
2078
+ size_ - that.size_),
2079
+ that.size_)
2080
+ : npos;
2081
+ }
2082
+
2083
+ /**
2084
+ * Finds the last occurrence of characters in the buffer
2085
+ * pointed to by `that` in this string.
2086
+ * \note Equivalent to `rfind(that, size(), strlen(that))`
2087
+ */
2088
+ constexpr std::size_t rfind(const Char* that) const noexcept {
2089
+ return rfind(that, size_, folly::constexpr_strlen(that));
2090
+ }
2091
+
2092
+ /**
2093
+ * Finds the last occurrence of characters in the buffer
2094
+ * pointed to by `that` in this string, starting at offset `pos`.
2095
+ * \note Equivalent to `rfind(that, pos, strlen(that))`
2096
+ */
2097
+ constexpr std::size_t rfind(const Char* that, std::size_t pos) const
2098
+ noexcept(false) {
2099
+ return rfind(that, pos, folly::constexpr_strlen(that));
2100
+ }
2101
+
2102
+ /**
2103
+ * Finds the last occurrence of the first `count` characters in the buffer
2104
+ * pointed to by `that` in this string, starting at offset `pos`.
2105
+ * \pre `pos <= size()`
2106
+ * \pre `that` points to a buffer containing at least `count` contiguous
2107
+ * characters.
2108
+ * \return The largest offset `i` such that `i <= pos` and
2109
+ * `i + count <= size()` and `0 == strncmp(data() + i, that, count)`; or
2110
+ * `npos` if there is no such offset `i`.
2111
+ * \throw std::out_of_range when `pos > size()`
2112
+ */
2113
+ constexpr std::size_t rfind(
2114
+ const Char* that, std::size_t pos, std::size_t count) const
2115
+ noexcept(false) {
2116
+ return count <= size_
2117
+ ? detail::fixedstring::rfind_(
2118
+ data_,
2119
+ that,
2120
+ folly::constexpr_min(
2121
+ detail::fixedstring::checkOverflow(pos, size_),
2122
+ size_ - count),
2123
+ count)
2124
+ : npos;
2125
+ }
2126
+
2127
+ /**
2128
+ * Finds the last occurrence of the character character `ch` in this string.
2129
+ * \note Equivalent to `rfind(&ch, size(), 1)`
2130
+ */
2131
+ constexpr std::size_t rfind(Char ch) const noexcept {
2132
+ return rfind(ch, size_);
2133
+ }
2134
+
2135
+ /**
2136
+ * Finds the last occurrence of the character character `ch` in this string,
2137
+ * starting at offset `pos`.
2138
+ * \pre `pos <= size()`
2139
+ * \note Equivalent to `rfind(&ch, pos, 1)`
2140
+ */
2141
+ constexpr std::size_t rfind(Char ch, std::size_t pos) const noexcept(false) {
2142
+ using A = const Char[1u];
2143
+ return 0u == size_
2144
+ ? npos
2145
+ : detail::fixedstring::rfind_(
2146
+ data_,
2147
+ A{ch},
2148
+ folly::constexpr_min(
2149
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2150
+ 1u);
2151
+ }
2152
+
2153
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2154
+ * Finds the first occurrence of any character in `that` in this string.
2155
+ * \note Equivalent to `find_first_of(that.data(), 0, that.size())`
2156
+ */
2157
+ template <std::size_t M>
2158
+ constexpr std::size_t find_first_of(
2159
+ const BasicFixedString<Char, M>& that) const noexcept {
2160
+ return find_first_of(that, 0u);
2161
+ }
2162
+
2163
+ /**
2164
+ * Finds the first occurrence of any character in `that` in this string,
2165
+ * starting at offset `pos`
2166
+ * \note Equivalent to `find_first_of(that.data(), pos, that.size())`
2167
+ */
2168
+ template <std::size_t M>
2169
+ constexpr std::size_t find_first_of(
2170
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
2171
+ noexcept(false) {
2172
+ return size_ == detail::fixedstring::checkOverflow(pos, size_)
2173
+ ? npos
2174
+ : detail::fixedstring::find_first_of_(
2175
+ data_, size_, that.data_, pos, that.size_);
2176
+ }
2177
+
2178
+ /**
2179
+ * Finds the first occurrence of any character in the null-terminated
2180
+ * character sequence pointed to by `that` in this string.
2181
+ * \note Equivalent to `find_first_of(that, 0, strlen(that))`
2182
+ */
2183
+ constexpr std::size_t find_first_of(const Char* that) const noexcept {
2184
+ return find_first_of(that, 0u, folly::constexpr_strlen(that));
2185
+ }
2186
+
2187
+ /**
2188
+ * Finds the first occurrence of any character in the null-terminated
2189
+ * character sequence pointed to by `that` in this string,
2190
+ * starting at offset `pos`
2191
+ * \note Equivalent to `find_first_of(that, pos, strlen(that))`
2192
+ */
2193
+ constexpr std::size_t find_first_of(const Char* that, std::size_t pos) const
2194
+ noexcept(false) {
2195
+ return find_first_of(that, pos, folly::constexpr_strlen(that));
2196
+ }
2197
+
2198
+ /**
2199
+ * Finds the first occurrence of any character in the first `count` characters
2200
+ * in the buffer pointed to by `that` in this string, starting at offset
2201
+ * `pos`.
2202
+ * \pre `pos <= size()`
2203
+ * \pre `that` points to a buffer containing at least `count` contiguous
2204
+ * characters.
2205
+ * \return The smallest offset `i` such that `i >= pos` and
2206
+ * `std::find(that, that+count, at(i)) != that+count`; or
2207
+ * `npos` if there is no such offset `i`.
2208
+ * \throw std::out_of_range when `pos > size()`
2209
+ */
2210
+ constexpr std::size_t find_first_of(
2211
+ const Char* that, std::size_t pos, std::size_t count) const
2212
+ noexcept(false) {
2213
+ return size_ == detail::fixedstring::checkOverflow(pos, size_)
2214
+ ? npos
2215
+ : detail::fixedstring::find_first_of_(data_, size_, that, pos, count);
2216
+ }
2217
+
2218
+ /**
2219
+ * Finds the first occurrence of `ch` in this string.
2220
+ * \note Equivalent to `find_first_of(&ch, 0, 1)`
2221
+ */
2222
+ constexpr std::size_t find_first_of(Char ch) const noexcept {
2223
+ return find_first_of(ch, 0u);
2224
+ }
2225
+
2226
+ /**
2227
+ * Finds the first occurrence of `ch` in this string,
2228
+ * starting at offset `pos`.
2229
+ * \note Equivalent to `find_first_of(&ch, pos, 1)`
2230
+ */
2231
+ constexpr std::size_t find_first_of(Char ch, std::size_t pos) const
2232
+ noexcept(false) {
2233
+ using A = const Char[1u];
2234
+ return size_ == detail::fixedstring::checkOverflow(pos, size_)
2235
+ ? npos
2236
+ : detail::fixedstring::find_first_of_(data_, size_, A{ch}, pos, 1u);
2237
+ }
2238
+
2239
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2240
+ * Finds the first occurrence of any character not in `that` in this string.
2241
+ * \note Equivalent to `find_first_not_of(that.data(), 0, that.size())`
2242
+ */
2243
+ template <std::size_t M>
2244
+ constexpr std::size_t find_first_not_of(
2245
+ const BasicFixedString<Char, M>& that) const noexcept {
2246
+ return find_first_not_of(that, 0u);
2247
+ }
2248
+
2249
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2250
+ * Finds the first occurrence of any character not in `that` in this string.
2251
+ * \note Equivalent to `find_first_not_of(that.data(), 0, that.size())`
2252
+ */
2253
+ template <std::size_t M>
2254
+ constexpr std::size_t find_first_not_of(
2255
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
2256
+ noexcept(false) {
2257
+ return size_ == detail::fixedstring::checkOverflow(pos, size_)
2258
+ ? npos
2259
+ : detail::fixedstring::find_first_not_of_(
2260
+ data_, size_, that.data_, pos, that.size_);
2261
+ }
2262
+
2263
+ /**
2264
+ * Finds the first occurrence of any character not in the null-terminated
2265
+ * character sequence pointed to by `that` in this string.
2266
+ * \note Equivalent to `find_first_not_of(that, 0, strlen(that))`
2267
+ */
2268
+ constexpr std::size_t find_first_not_of(const Char* that) const noexcept {
2269
+ return find_first_not_of(that, 0u, folly::constexpr_strlen(that));
2270
+ }
2271
+
2272
+ /**
2273
+ * Finds the first occurrence of any character not in the null-terminated
2274
+ * character sequence pointed to by `that` in this string,
2275
+ * starting at offset `pos`
2276
+ * \note Equivalent to `find_first_not_of(that, pos, strlen(that))`
2277
+ */
2278
+ constexpr std::size_t find_first_not_of(
2279
+ const Char* that, std::size_t pos) const noexcept(false) {
2280
+ return find_first_not_of(that, pos, folly::constexpr_strlen(that));
2281
+ }
2282
+
2283
+ /**
2284
+ * Finds the first occurrence of any character not in the first `count`
2285
+ * characters in the buffer pointed to by `that` in this string, starting at
2286
+ * offset `pos`.
2287
+ * \pre `pos <= size()`
2288
+ * \pre `that` points to a buffer containing at least `count` contiguous
2289
+ * characters.
2290
+ * \return The smallest offset `i` such that `i >= pos` and
2291
+ * `std::find(that, that+count, at(i)) == that+count`; or
2292
+ * `npos` if there is no such offset `i`.
2293
+ * \throw std::out_of_range when `pos > size()`
2294
+ */
2295
+ constexpr std::size_t find_first_not_of(
2296
+ const Char* that, std::size_t pos, std::size_t count) const
2297
+ noexcept(false) {
2298
+ return size_ == detail::fixedstring::checkOverflow(pos, size_)
2299
+ ? npos
2300
+ : detail::fixedstring::find_first_not_of_(
2301
+ data_, size_, that, pos, count);
2302
+ }
2303
+
2304
+ /**
2305
+ * Finds the first occurrence of any character other than `ch` in this string.
2306
+ * \note Equivalent to `find_first_not_of(&ch, 0, 1)`
2307
+ */
2308
+ constexpr std::size_t find_first_not_of(Char ch) const noexcept {
2309
+ return find_first_not_of(ch, 0u);
2310
+ }
2311
+
2312
+ /**
2313
+ * Finds the first occurrence of any character other than `ch` in this string,
2314
+ * starting at offset `pos`.
2315
+ * \note Equivalent to `find_first_not_of(&ch, pos, 1)`
2316
+ */
2317
+ constexpr std::size_t find_first_not_of(Char ch, std::size_t pos) const
2318
+ noexcept(false) {
2319
+ using A = const Char[1u];
2320
+ return 1u <= size_ - detail::fixedstring::checkOverflow(pos, size_)
2321
+ ? detail::fixedstring::find_first_not_of_(data_, size_, A{ch}, pos, 1u)
2322
+ : npos;
2323
+ }
2324
+
2325
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2326
+ * Finds the last occurrence of any character in `that` in this string.
2327
+ * \note Equivalent to `find_last_of(that.data(), size(), that.size())`
2328
+ */
2329
+ template <std::size_t M>
2330
+ constexpr std::size_t find_last_of(
2331
+ const BasicFixedString<Char, M>& that) const noexcept {
2332
+ return find_last_of(that, size_);
2333
+ }
2334
+
2335
+ /**
2336
+ * Finds the last occurrence of any character in `that` in this string,
2337
+ * starting at offset `pos`
2338
+ * \note Equivalent to `find_last_of(that.data(), pos, that.size())`
2339
+ */
2340
+ template <std::size_t M>
2341
+ constexpr std::size_t find_last_of(
2342
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
2343
+ noexcept(false) {
2344
+ return 0u == size_
2345
+ ? npos
2346
+ : detail::fixedstring::find_last_of_(
2347
+ data_,
2348
+ that.data_,
2349
+ folly::constexpr_min(
2350
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2351
+ that.size_);
2352
+ }
2353
+
2354
+ /**
2355
+ * Finds the last occurrence of any character in the null-terminated
2356
+ * character sequence pointed to by `that` in this string.
2357
+ * \note Equivalent to `find_last_of(that, size(), strlen(that))`
2358
+ */
2359
+ constexpr std::size_t find_last_of(const Char* that) const noexcept {
2360
+ return find_last_of(that, size_, folly::constexpr_strlen(that));
2361
+ }
2362
+
2363
+ /**
2364
+ * Finds the last occurrence of any character in the null-terminated
2365
+ * character sequence pointed to by `that` in this string,
2366
+ * starting at offset `pos`
2367
+ * \note Equivalent to `find_last_of(that, pos, strlen(that))`
2368
+ */
2369
+ constexpr std::size_t find_last_of(const Char* that, std::size_t pos) const
2370
+ noexcept(false) {
2371
+ return find_last_of(that, pos, folly::constexpr_strlen(that));
2372
+ }
2373
+
2374
+ /**
2375
+ * Finds the last occurrence of any character in the first `count` characters
2376
+ * in the buffer pointed to by `that` in this string, starting at offset
2377
+ * `pos`.
2378
+ * \pre `pos <= size()`
2379
+ * \pre `that` points to a buffer containing at least `count` contiguous
2380
+ * characters.
2381
+ * \return The largest offset `i` such that `i <= pos` and
2382
+ * `i < size()` and `std::find(that, that+count, at(i)) != that+count`; or
2383
+ * `npos` if there is no such offset `i`.
2384
+ * \throw std::out_of_range when `pos > size()`
2385
+ */
2386
+ constexpr std::size_t find_last_of(
2387
+ const Char* that, std::size_t pos, std::size_t count) const
2388
+ noexcept(false) {
2389
+ return 0u == size_
2390
+ ? npos
2391
+ : detail::fixedstring::find_last_of_(
2392
+ data_,
2393
+ that,
2394
+ folly::constexpr_min(
2395
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2396
+ count);
2397
+ }
2398
+
2399
+ /**
2400
+ * Finds the last occurrence of `ch` in this string.
2401
+ * \note Equivalent to `find_last_of(&ch, size(), 1)`
2402
+ */
2403
+ constexpr std::size_t find_last_of(Char ch) const noexcept {
2404
+ return find_last_of(ch, size_);
2405
+ }
2406
+
2407
+ /**
2408
+ * Finds the last occurrence of `ch` in this string,
2409
+ * starting at offset `pos`.
2410
+ * \note Equivalent to `find_last_of(&ch, pos, 1)`
2411
+ */
2412
+ constexpr std::size_t find_last_of(Char ch, std::size_t pos) const
2413
+ noexcept(false) {
2414
+ using A = const Char[1u];
2415
+ return 0u == size_
2416
+ ? npos
2417
+ : detail::fixedstring::find_last_of_(
2418
+ data_,
2419
+ A{ch},
2420
+ folly::constexpr_min(
2421
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2422
+ 1u);
2423
+ }
2424
+
2425
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2426
+ * Finds the last occurrence of any character not in `that` in this string.
2427
+ * \note Equivalent to `find_last_not_of(that.data(), size(), that.size())`
2428
+ */
2429
+ template <std::size_t M>
2430
+ constexpr std::size_t find_last_not_of(
2431
+ const BasicFixedString<Char, M>& that) const noexcept {
2432
+ return find_last_not_of(that, size_);
2433
+ }
2434
+
2435
+ /**
2436
+ * Finds the last occurrence of any character not in `that` in this string,
2437
+ * starting at offset `pos`
2438
+ * \note Equivalent to `find_last_not_of(that.data(), pos, that.size())`
2439
+ */
2440
+ template <std::size_t M>
2441
+ constexpr std::size_t find_last_not_of(
2442
+ const BasicFixedString<Char, M>& that, std::size_t pos) const
2443
+ noexcept(false) {
2444
+ return 0u == size_
2445
+ ? npos
2446
+ : detail::fixedstring::find_last_not_of_(
2447
+ data_,
2448
+ that.data_,
2449
+ folly::constexpr_min(
2450
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2451
+ that.size_);
2452
+ }
2453
+
2454
+ /**
2455
+ * Finds the last occurrence of any character not in the null-terminated
2456
+ * character sequence pointed to by `that` in this string.
2457
+ * \note Equivalent to `find_last_not_of(that, size(), strlen(that))`
2458
+ */
2459
+ constexpr std::size_t find_last_not_of(const Char* that) const noexcept {
2460
+ return find_last_not_of(that, size_, folly::constexpr_strlen(that));
2461
+ }
2462
+
2463
+ /**
2464
+ * Finds the last occurrence of any character not in the null-terminated
2465
+ * character sequence pointed to by `that` in this string,
2466
+ * starting at offset `pos`
2467
+ * \note Equivalent to `find_last_not_of(that, pos, strlen(that))`
2468
+ */
2469
+ constexpr std::size_t find_last_not_of(
2470
+ const Char* that, std::size_t pos) const noexcept(false) {
2471
+ return find_last_not_of(that, pos, folly::constexpr_strlen(that));
2472
+ }
2473
+
2474
+ /**
2475
+ * Finds the last occurrence of any character not in the first `count`
2476
+ * characters in the buffer pointed to by `that` in this string, starting at
2477
+ * offset `pos`.
2478
+ * \pre `pos <= size()`
2479
+ * \pre `that` points to a buffer containing at least `count` contiguous
2480
+ * characters.
2481
+ * \return The largest offset `i` such that `i <= pos` and
2482
+ * `i < size()` and `std::find(that, that+count, at(i)) == that+count`; or
2483
+ * `npos` if there is no such offset `i`.
2484
+ * \throw std::out_of_range when `pos > size()`
2485
+ */
2486
+ constexpr std::size_t find_last_not_of(
2487
+ const Char* that, std::size_t pos, std::size_t count) const
2488
+ noexcept(false) {
2489
+ return 0u == size_
2490
+ ? npos
2491
+ : detail::fixedstring::find_last_not_of_(
2492
+ data_,
2493
+ that,
2494
+ folly::constexpr_min(
2495
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2496
+ count);
2497
+ }
2498
+
2499
+ /**
2500
+ * Finds the last occurrence of any character other than `ch` in this string.
2501
+ * \note Equivalent to `find_last_not_of(&ch, size(), 1)`
2502
+ */
2503
+ constexpr std::size_t find_last_not_of(Char ch) const noexcept {
2504
+ return find_last_not_of(ch, size_);
2505
+ }
2506
+
2507
+ /**
2508
+ * Finds the last occurrence of any character other than `ch` in this string,
2509
+ * starting at offset `pos`.
2510
+ * \note Equivalent to `find_last_not_of(&ch, pos, 1)`
2511
+ */
2512
+ constexpr std::size_t find_last_not_of(Char ch, std::size_t pos) const
2513
+ noexcept(false) {
2514
+ using A = const Char[1u];
2515
+ return 0u == size_
2516
+ ? npos
2517
+ : detail::fixedstring::find_last_not_of_(
2518
+ data_,
2519
+ A{ch},
2520
+ folly::constexpr_min(
2521
+ detail::fixedstring::checkOverflow(pos, size_), size_ - 1u),
2522
+ 1u);
2523
+ }
2524
+
2525
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2526
+ * Asymmetric relational operators
2527
+ */
2528
+ friend constexpr bool operator==(
2529
+ const Char* a, const BasicFixedString& b) noexcept {
2530
+ return detail::fixedstring::equal_(
2531
+ a, folly::constexpr_strlen(a), b.data_, b.size_);
2532
+ }
2533
+
2534
+ /**
2535
+ * \overload
2536
+ */
2537
+ friend constexpr bool operator==(
2538
+ const BasicFixedString& a, const Char* b) noexcept {
2539
+ return b == a;
2540
+ }
2541
+
2542
+ /**
2543
+ * \overload
2544
+ */
2545
+ friend constexpr bool operator==(
2546
+ Range<const Char*> a, const BasicFixedString& b) noexcept {
2547
+ return detail::fixedstring::equal_(a.begin(), a.size(), b.data_, b.size_);
2548
+ }
2549
+
2550
+ /**
2551
+ * \overload
2552
+ */
2553
+ friend constexpr bool operator==(
2554
+ const BasicFixedString& a, Range<const Char*> b) noexcept {
2555
+ return b == a;
2556
+ }
2557
+
2558
+ friend constexpr bool operator!=(
2559
+ const Char* a, const BasicFixedString& b) noexcept {
2560
+ return !(a == b);
2561
+ }
2562
+
2563
+ /**
2564
+ * \overload
2565
+ */
2566
+ friend constexpr bool operator!=(
2567
+ const BasicFixedString& a, const Char* b) noexcept {
2568
+ return !(b == a);
2569
+ }
2570
+
2571
+ /**
2572
+ * \overload
2573
+ */
2574
+ friend constexpr bool operator!=(
2575
+ Range<const Char*> a, const BasicFixedString& b) noexcept {
2576
+ return !(a == b);
2577
+ }
2578
+
2579
+ /**
2580
+ * \overload
2581
+ */
2582
+ friend constexpr bool operator!=(
2583
+ const BasicFixedString& a, Range<const Char*> b) noexcept {
2584
+ return !(a == b);
2585
+ }
2586
+
2587
+ friend constexpr bool operator<(
2588
+ const Char* a, const BasicFixedString& b) noexcept {
2589
+ return ordering::lt ==
2590
+ detail::fixedstring::compare_(
2591
+ a, 0u, folly::constexpr_strlen(a), b.data_, 0u, b.size_);
2592
+ }
2593
+
2594
+ /**
2595
+ * \overload
2596
+ */
2597
+ friend constexpr bool operator<(
2598
+ const BasicFixedString& a, const Char* b) noexcept {
2599
+ return ordering::lt ==
2600
+ detail::fixedstring::compare_(
2601
+ a.data_, 0u, a.size_, b, 0u, folly::constexpr_strlen(b));
2602
+ }
2603
+
2604
+ /**
2605
+ * \overload
2606
+ */
2607
+ friend constexpr bool operator<(
2608
+ Range<const Char*> a, const BasicFixedString& b) noexcept {
2609
+ return ordering::lt ==
2610
+ detail::fixedstring::compare_(
2611
+ a.begin(), 0u, a.size(), b.data_, 0u, b.size_);
2612
+ }
2613
+
2614
+ /**
2615
+ * \overload
2616
+ */
2617
+ friend constexpr bool operator<(
2618
+ const BasicFixedString& a, Range<const Char*> b) noexcept {
2619
+ return ordering::lt ==
2620
+ detail::fixedstring::compare_(
2621
+ a.data_, 0u, a.size_, b.begin(), 0u, b.size());
2622
+ }
2623
+
2624
+ friend constexpr bool operator>(
2625
+ const Char* a, const BasicFixedString& b) noexcept {
2626
+ return b < a;
2627
+ }
2628
+
2629
+ /**
2630
+ * \overload
2631
+ */
2632
+ friend constexpr bool operator>(
2633
+ const BasicFixedString& a, const Char* b) noexcept {
2634
+ return b < a;
2635
+ }
2636
+
2637
+ /**
2638
+ * \overload
2639
+ */
2640
+ friend constexpr bool operator>(
2641
+ Range<const Char*> a, const BasicFixedString& b) noexcept {
2642
+ return b < a;
2643
+ }
2644
+
2645
+ /**
2646
+ * \overload
2647
+ */
2648
+ friend constexpr bool operator>(
2649
+ const BasicFixedString& a, Range<const Char*> b) noexcept {
2650
+ return b < a;
2651
+ }
2652
+
2653
+ friend constexpr bool operator<=(
2654
+ const Char* a, const BasicFixedString& b) noexcept {
2655
+ return !(b < a);
2656
+ }
2657
+
2658
+ /**
2659
+ * \overload
2660
+ */
2661
+ friend constexpr bool operator<=(
2662
+ const BasicFixedString& a, const Char* b) noexcept {
2663
+ return !(b < a);
2664
+ }
2665
+
2666
+ /**
2667
+ * \overload
2668
+ */
2669
+ friend constexpr bool operator<=(
2670
+ Range<const Char*> const& a, const BasicFixedString& b) noexcept {
2671
+ return !(b < a);
2672
+ }
2673
+
2674
+ /**
2675
+ * \overload
2676
+ */
2677
+ friend constexpr bool operator<=(
2678
+ const BasicFixedString& a, Range<const Char*> b) noexcept {
2679
+ return !(b < a);
2680
+ }
2681
+
2682
+ friend constexpr bool operator>=(
2683
+ const Char* a, const BasicFixedString& b) noexcept {
2684
+ return !(a < b);
2685
+ }
2686
+
2687
+ /**
2688
+ * \overload
2689
+ */
2690
+ friend constexpr bool operator>=(
2691
+ const BasicFixedString& a, const Char* b) noexcept {
2692
+ return !(a < b);
2693
+ }
2694
+
2695
+ /**
2696
+ * \overload
2697
+ */
2698
+ friend constexpr bool operator>=(
2699
+ Range<const Char*> a, const BasicFixedString& b) noexcept {
2700
+ return !(a < b);
2701
+ }
2702
+
2703
+ /**
2704
+ * \overload
2705
+ */
2706
+ friend constexpr bool operator>=(
2707
+ const BasicFixedString& a, Range<const Char*> const& b) noexcept {
2708
+ return !(a < b);
2709
+ }
2710
+
2711
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2712
+ * Asymmetric concatenation
2713
+ */
2714
+ template <std::size_t M>
2715
+ friend constexpr BasicFixedString<Char, N + M - 1u> operator+(
2716
+ const Char (&a)[M], const BasicFixedString& b) noexcept {
2717
+ return detail::fixedstring::Helper::concat_<Char>(
2718
+ detail::fixedstring::checkNullTerminated(a),
2719
+ M - 1u,
2720
+ b.data_,
2721
+ b.size_,
2722
+ std::make_index_sequence<N + M - 1u>{});
2723
+ }
2724
+
2725
+ /**
2726
+ * \overload
2727
+ */
2728
+ template <std::size_t M>
2729
+ friend constexpr BasicFixedString<Char, N + M - 1u> operator+(
2730
+ const BasicFixedString& a, const Char (&b)[M]) noexcept {
2731
+ return detail::fixedstring::Helper::concat_<Char>(
2732
+ a.data_,
2733
+ a.size_,
2734
+ detail::fixedstring::checkNullTerminated(b),
2735
+ M - 1u,
2736
+ std::make_index_sequence<N + M - 1u>{});
2737
+ }
2738
+
2739
+ /**
2740
+ * \overload
2741
+ */
2742
+ friend constexpr BasicFixedString<Char, N + 1u> operator+(
2743
+ Char a, const BasicFixedString& b) noexcept {
2744
+ using A = const Char[2u];
2745
+ return detail::fixedstring::Helper::concat_<Char>(
2746
+ A{a, Char(0)},
2747
+ 1u,
2748
+ b.data_,
2749
+ b.size_,
2750
+ std::make_index_sequence<N + 1u>{});
2751
+ }
2752
+
2753
+ /**
2754
+ * \overload
2755
+ */
2756
+ friend constexpr BasicFixedString<Char, N + 1u> operator+(
2757
+ const BasicFixedString& a, Char b) noexcept {
2758
+ using A = const Char[2u];
2759
+ return detail::fixedstring::Helper::concat_<Char>(
2760
+ a.data_,
2761
+ a.size_,
2762
+ A{b, Char(0)},
2763
+ 1u,
2764
+ std::make_index_sequence<N + 1u>{});
2765
+ }
2766
+ };
2767
+
2768
+ template <class C, std::size_t N>
2769
+ inline std::basic_ostream<C>& operator<<(
2770
+ std::basic_ostream<C>& os, const BasicFixedString<C, N>& string) {
2771
+ using StreamSize = decltype(os.width());
2772
+ os.write(string.begin(), static_cast<StreamSize>(string.size()));
2773
+ return os;
2774
+ }
2775
+
2776
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2777
+ * Symmetric relational operators
2778
+ */
2779
+ template <class Char, std::size_t A, std::size_t B>
2780
+ constexpr bool operator==(
2781
+ const BasicFixedString<Char, A>& a,
2782
+ const BasicFixedString<Char, B>& b) noexcept {
2783
+ return detail::fixedstring::equal_(
2784
+ detail::fixedstring::Helper::data_(a),
2785
+ a.size(),
2786
+ detail::fixedstring::Helper::data_(b),
2787
+ b.size());
2788
+ }
2789
+
2790
+ template <class Char, std::size_t A, std::size_t B>
2791
+ constexpr bool operator!=(
2792
+ const BasicFixedString<Char, A>& a, const BasicFixedString<Char, B>& b) {
2793
+ return !(a == b);
2794
+ }
2795
+
2796
+ template <class Char, std::size_t A, std::size_t B>
2797
+ constexpr bool operator<(
2798
+ const BasicFixedString<Char, A>& a,
2799
+ const BasicFixedString<Char, B>& b) noexcept {
2800
+ return ordering::lt ==
2801
+ detail::fixedstring::compare_(
2802
+ detail::fixedstring::Helper::data_(a),
2803
+ 0u,
2804
+ a.size(),
2805
+ detail::fixedstring::Helper::data_(b),
2806
+ 0u,
2807
+ b.size());
2808
+ }
2809
+
2810
+ template <class Char, std::size_t A, std::size_t B>
2811
+ constexpr bool operator>(
2812
+ const BasicFixedString<Char, A>& a,
2813
+ const BasicFixedString<Char, B>& b) noexcept {
2814
+ return b < a;
2815
+ }
2816
+
2817
+ template <class Char, std::size_t A, std::size_t B>
2818
+ constexpr bool operator<=(
2819
+ const BasicFixedString<Char, A>& a,
2820
+ const BasicFixedString<Char, B>& b) noexcept {
2821
+ return !(b < a);
2822
+ }
2823
+
2824
+ template <class Char, std::size_t A, std::size_t B>
2825
+ constexpr bool operator>=(
2826
+ const BasicFixedString<Char, A>& a,
2827
+ const BasicFixedString<Char, B>& b) noexcept {
2828
+ return !(a < b);
2829
+ }
2830
+
2831
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2832
+ * Symmetric concatenation
2833
+ */
2834
+ template <class Char, std::size_t N, std::size_t M>
2835
+ constexpr BasicFixedString<Char, N + M> operator+(
2836
+ const BasicFixedString<Char, N>& a,
2837
+ const BasicFixedString<Char, M>& b) noexcept {
2838
+ return detail::fixedstring::Helper::concat_<Char>(
2839
+ detail::fixedstring::Helper::data_(a),
2840
+ a.size(),
2841
+ detail::fixedstring::Helper::data_(b),
2842
+ b.size(),
2843
+ std::make_index_sequence<N + M>{});
2844
+ }
2845
+
2846
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2847
+ * Construct a `BasicFixedString` object from a null-terminated array of
2848
+ * characters. The capacity and size of the string will be equal to one less
2849
+ * than the size of the array.
2850
+ * \pre `a` contains no embedded null characters.
2851
+ * \pre `a[N-1] == Char(0)`
2852
+ * \post For a returned string `s`, `s[i]==a[i]` for every `i` in [`0`,`N-1`].
2853
+ */
2854
+ template <class Char, std::size_t N>
2855
+ constexpr BasicFixedString<Char, N - 1u> makeFixedString(
2856
+ const Char (&a)[N]) noexcept {
2857
+ return {a};
2858
+ }
2859
+
2860
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
2861
+ * Swap function
2862
+ */
2863
+ template <class Char, std::size_t N>
2864
+ constexpr void swap(
2865
+ BasicFixedString<Char, N>& a, BasicFixedString<Char, N>& b) noexcept {
2866
+ a.swap(b);
2867
+ }
2868
+
2869
+ inline namespace literals {
2870
+ inline namespace string_literals {
2871
+ inline namespace {
2872
+ // "const std::size_t&" is so that folly::npos has the same address in every
2873
+ // translation unit. This is to avoid potential violations of the ODR.
2874
+ constexpr const std::size_t& npos = detail::fixedstring::FixedStringBase::npos;
2875
+ } // namespace
2876
+
2877
+ #if defined(__GNUC__) && !defined(__ICC)
2878
+ #pragma GCC diagnostic push
2879
+ #pragma GCC diagnostic ignored "-Wpragmas"
2880
+ #pragma GCC diagnostic ignored "-Wgnu-string-literal-operator-template"
2881
+
2882
+ /** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** *
2883
+ * User-defined literals for creating FixedString objects from string literals
2884
+ * on the compilers that support it.
2885
+ *
2886
+ * \par Example:
2887
+ * \par
2888
+ * \code
2889
+ * using namespace folly::string_literals;
2890
+ * constexpr auto hello = "hello world!"_fs;
2891
+ * \endcode
2892
+ *
2893
+ * \note This requires a GNU compiler extension
2894
+ * (-Wgnu-string-literal-operator-template) supported by clang and gcc,
2895
+ * proposed for standardization in
2896
+ * <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0424r0.pdf>.
2897
+ * \par
2898
+ * For portable code, prefer the suffixes `_fs4`, `_fs8`, `_fs16`, `_fs32`,
2899
+ * `_fs64`, and `_fs128` for creating instances of types `FixedString<4>`,
2900
+ * `FixedString<8>`, `FixedString<16>`, etc.
2901
+ */
2902
+ template <class Char, Char... Cs>
2903
+ constexpr BasicFixedString<Char, sizeof...(Cs)> operator""_fs() noexcept {
2904
+ const Char a[] = {Cs..., Char(0)};
2905
+ return {+a, sizeof...(Cs)};
2906
+ }
2907
+
2908
+ #pragma GCC diagnostic pop
2909
+ #endif
2910
+
2911
+ #ifndef NO_FIXED_STR_UDL
2912
+ #define FOLLY_DEFINE_FIXED_STRING_UDL(N) \
2913
+ constexpr FixedString<N> operator""_fs##N( \
2914
+ const char* that, std::size_t count) noexcept(false) { \
2915
+ return {that, count}; \
2916
+ } \
2917
+ /**/
2918
+
2919
+ // Define UDLs _fs4, _fs8, _fs16, etc for FixedString<[4, 8, 16, ...]>
2920
+ FOLLY_DEFINE_FIXED_STRING_UDL(4)
2921
+ FOLLY_DEFINE_FIXED_STRING_UDL(8)
2922
+ FOLLY_DEFINE_FIXED_STRING_UDL(16)
2923
+ FOLLY_DEFINE_FIXED_STRING_UDL(32)
2924
+ FOLLY_DEFINE_FIXED_STRING_UDL(64)
2925
+ FOLLY_DEFINE_FIXED_STRING_UDL(128)
2926
+
2927
+ #undef FOLLY_DEFINE_FIXED_STRING_UDL
2928
+ #endif
2929
+ } // namespace string_literals
2930
+ } // namespace literals
2931
+
2932
+ // TODO:
2933
+ // // numeric conversions:
2934
+ // template <std::size_t N>
2935
+ // constexpr int stoi(const FixedString<N>& str, int base = 10);
2936
+ // template <std::size_t N>
2937
+ // constexpr unsigned stou(const FixedString<N>& str, int base = 10);
2938
+ // template <std::size_t N>
2939
+ // constexpr long stol(const FixedString<N>& str, int base = 10);
2940
+ // template <std::size_t N>
2941
+ // constexpr unsigned long stoul(const FixedString<N>& str, int base = 10;
2942
+ // template <std::size_t N>
2943
+ // constexpr long long stoll(const FixedString<N>& str, int base = 10);
2944
+ // template <std::size_t N>
2945
+ // constexpr unsigned long long stoull(const FixedString<N>& str,
2946
+ // int base = 10);
2947
+ // template <std::size_t N>
2948
+ // constexpr float stof(const FixedString<N>& str);
2949
+ // template <std::size_t N>
2950
+ // constexpr double stod(const FixedString<N>& str);
2951
+ // template <std::size_t N>
2952
+ // constexpr long double stold(const FixedString<N>& str);
2953
+ // template <int val>
2954
+ // constexpr FixedString</*...*/> to_fixed_string_i() noexcept;
2955
+ // template <unsigned val>
2956
+ // constexpr FixedString</*...*/> to_fixed_string_u() noexcept;
2957
+ // template <long val>
2958
+ // constexpr FixedString</*...*/> to_fixed_string_l() noexcept;
2959
+ // template <unsigned long val>
2960
+ // constexpr FixedString</*...*/> to_fixed_string_ul() noexcept;
2961
+ // template <long long val>
2962
+ // constexpr FixedString</*...*/> to_fixed_string_ll() noexcept
2963
+ // template <unsigned long long val>
2964
+ // constexpr FixedString</*...*/> to_fixed_string_ull() noexcept;
2965
+ } // namespace folly