react-native-windows 0.81.32 → 0.81.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (891) hide show
  1. package/Directory.Build.props +2 -17
  2. package/Folly/ThreadNameStub.cpp +4 -6
  3. package/Microsoft.ReactNative/Fabric/Composition/BorderPrimitive.cpp +1 -1
  4. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +27 -4
  5. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +8 -4
  6. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +7 -3
  7. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +2 -8
  8. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj.filters +0 -3
  9. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +2 -2
  10. package/PropertySheets/Bundle.props +3 -3
  11. package/PropertySheets/CIBuildOptimizations.props +2 -2
  12. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  13. package/PropertySheets/JSEngine.props +1 -1
  14. package/PropertySheets/NuGet.LockFile.props +2 -1
  15. package/PropertySheets/React.Cpp.props +4 -4
  16. package/ReactCommon/ReactCommon.vcxproj +0 -10
  17. package/ReactCommon/packages.lock.win32.json +0 -10
  18. package/Scripts/NuGetRestoreForceEvaluateAllSolutions.ps1 +61 -6
  19. package/Scripts/Tfs/Layout-Desktop-Headers.ps1 +4 -37
  20. package/Scripts/Warm-RnwFeedCache.ps1 +413 -0
  21. package/Scripts/creaternwapp.cmd +5 -1
  22. package/Scripts/creaternwlib.cmd +8 -2
  23. package/Shared/Shared.vcxitems +2 -0
  24. package/{Folly → external}/.clang-format +0 -1
  25. package/external/External.vcxitems +10 -0
  26. package/external/fast-float/.syncignore +11 -0
  27. package/external/fast-float/LICENSE-APACHE +190 -0
  28. package/external/fast-float/LICENSE-BOOST +23 -0
  29. package/external/fast-float/LICENSE-MIT +27 -0
  30. package/external/fast-float/cgmanifest.json +15 -0
  31. package/external/fast-float/fast-float.vcxitems +14 -0
  32. package/external/fast-float/include/fast_float/ascii_number.h +588 -0
  33. package/external/fast-float/include/fast_float/bigint.h +638 -0
  34. package/external/fast-float/include/fast_float/constexpr_feature_detect.h +46 -0
  35. package/external/fast-float/include/fast_float/decimal_to_binary.h +212 -0
  36. package/external/fast-float/include/fast_float/digit_comparison.h +457 -0
  37. package/external/fast-float/include/fast_float/fast_float.h +59 -0
  38. package/external/fast-float/include/fast_float/fast_table.h +708 -0
  39. package/external/fast-float/include/fast_float/float_common.h +1240 -0
  40. package/external/fast-float/include/fast_float/parse_number.h +399 -0
  41. package/external/fast-float/sync-config.json +8 -0
  42. package/external/fmt/.syncignore +12 -0
  43. package/external/fmt/CONTRIBUTING.md +20 -0
  44. package/external/fmt/LICENSE +27 -0
  45. package/{fmt → external/fmt}/cgmanifest.json +1 -1
  46. package/external/fmt/fmt.vcxitems +28 -0
  47. package/external/fmt/include/fmt/args.h +228 -0
  48. package/{fmt/TEMP_UntilFmtUpdate/core.h → external/fmt/include/fmt/base.h} +1188 -1036
  49. package/external/fmt/include/fmt/chrono.h +2432 -0
  50. package/external/fmt/include/fmt/color.h +612 -0
  51. package/external/fmt/include/fmt/compile.h +529 -0
  52. package/external/fmt/include/fmt/core.h +5 -0
  53. package/external/fmt/include/fmt/format-inl.h +1928 -0
  54. package/external/fmt/include/fmt/format.h +4427 -0
  55. package/external/fmt/include/fmt/os.h +439 -0
  56. package/external/fmt/include/fmt/ostream.h +211 -0
  57. package/external/fmt/include/fmt/printf.h +656 -0
  58. package/external/fmt/include/fmt/ranges.h +882 -0
  59. package/external/fmt/include/fmt/std.h +699 -0
  60. package/external/fmt/include/fmt/xchar.h +322 -0
  61. package/external/fmt/src/fmt.cc +135 -0
  62. package/external/fmt/src/format.cc +43 -0
  63. package/external/fmt/src/os.cc +403 -0
  64. package/external/fmt/sync-config.json +8 -0
  65. package/external/folly/.syncignore +61 -0
  66. package/external/folly/LICENSE +200 -0
  67. package/{fmt → external/folly/folly}/.clang-format +0 -1
  68. package/external/folly/folly/AtomicHashArray-inl.h +546 -0
  69. package/external/folly/folly/AtomicHashArray.h +431 -0
  70. package/external/folly/folly/AtomicHashMap-inl.h +653 -0
  71. package/external/folly/folly/AtomicHashMap.h +484 -0
  72. package/external/folly/folly/AtomicIntrusiveLinkedList.h +206 -0
  73. package/external/folly/folly/AtomicLinkedList.h +110 -0
  74. package/external/folly/folly/AtomicUnorderedMap.h +522 -0
  75. package/external/folly/folly/BUCK +1631 -0
  76. package/external/folly/folly/BUILD_MODE.bzl +72 -0
  77. package/external/folly/folly/Benchmark.cpp +986 -0
  78. package/external/folly/folly/Benchmark.h +680 -0
  79. package/external/folly/folly/BenchmarkUtil.h +47 -0
  80. package/external/folly/folly/Bits.h +17 -0
  81. package/external/folly/folly/CMakeLists.txt +110 -0
  82. package/external/folly/folly/CPortability.h +338 -0
  83. package/external/folly/folly/CancellationToken-inl.h +449 -0
  84. package/external/folly/folly/CancellationToken.cpp +250 -0
  85. package/external/folly/folly/CancellationToken.h +365 -0
  86. package/external/folly/folly/Chrono.h +132 -0
  87. package/external/folly/folly/ClockGettimeWrappers.cpp +93 -0
  88. package/external/folly/folly/ClockGettimeWrappers.h +29 -0
  89. package/external/folly/folly/ConcurrentBitSet.h +157 -0
  90. package/external/folly/folly/ConcurrentLazy.h +74 -0
  91. package/external/folly/folly/ConcurrentSkipList-inl.h +341 -0
  92. package/external/folly/folly/ConcurrentSkipList.h +824 -0
  93. package/external/folly/folly/ConstructorCallbackList.h +158 -0
  94. package/external/folly/folly/Conv.h +2026 -0
  95. package/external/folly/folly/CppAttributes.h +170 -0
  96. package/external/folly/folly/CpuId.h +297 -0
  97. package/external/folly/folly/DefaultKeepAliveExecutor.h +172 -0
  98. package/external/folly/folly/Demangle.cpp +255 -0
  99. package/external/folly/folly/Demangle.h +73 -0
  100. package/external/folly/folly/DiscriminatedPtr.h +236 -0
  101. package/external/folly/folly/DynamicConverter.h +17 -0
  102. package/external/folly/folly/Exception.h +150 -0
  103. package/external/folly/folly/ExceptionString.cpp +51 -0
  104. package/external/folly/folly/ExceptionString.h +33 -0
  105. package/external/folly/folly/ExceptionWrapper-inl.h +264 -0
  106. package/external/folly/folly/ExceptionWrapper.cpp +37 -0
  107. package/external/folly/folly/ExceptionWrapper.h +377 -0
  108. package/external/folly/folly/Executor.cpp +111 -0
  109. package/external/folly/folly/Executor.h +351 -0
  110. package/external/folly/folly/Expected.h +1725 -0
  111. package/external/folly/folly/FBString.h +2888 -0
  112. package/external/folly/folly/FBVector.h +17 -0
  113. package/external/folly/folly/File.cpp +180 -0
  114. package/external/folly/folly/File.h +177 -0
  115. package/external/folly/folly/FileUtil.cpp +378 -0
  116. package/external/folly/folly/FileUtil.h +332 -0
  117. package/external/folly/folly/Fingerprint.cpp +135 -0
  118. package/external/folly/folly/Fingerprint.h +289 -0
  119. package/external/folly/folly/FixedString.h +2965 -0
  120. package/external/folly/folly/FollyMemcpy.cpp +30 -0
  121. package/external/folly/folly/FollyMemcpy.h +23 -0
  122. package/external/folly/folly/FollyMemset.cpp +29 -0
  123. package/external/folly/folly/FollyMemset.h +25 -0
  124. package/external/folly/folly/Format-inl.h +1152 -0
  125. package/external/folly/folly/Format.cpp +429 -0
  126. package/external/folly/folly/Format.h +463 -0
  127. package/external/folly/folly/FormatArg.h +285 -0
  128. package/external/folly/folly/FormatTraits.h +65 -0
  129. package/external/folly/folly/Function.h +1159 -0
  130. package/external/folly/folly/GLog.h +85 -0
  131. package/external/folly/folly/GroupVarint.cpp +153 -0
  132. package/external/folly/folly/GroupVarint.h +630 -0
  133. package/external/folly/folly/Hash.h +20 -0
  134. package/external/folly/folly/IPAddress.cpp +490 -0
  135. package/external/folly/folly/IPAddress.h +667 -0
  136. package/external/folly/folly/IPAddressException.h +82 -0
  137. package/external/folly/folly/IPAddressV4.cpp +305 -0
  138. package/external/folly/folly/IPAddressV4.h +495 -0
  139. package/external/folly/folly/IPAddressV6.cpp +541 -0
  140. package/external/folly/folly/IPAddressV6.h +627 -0
  141. package/external/folly/folly/Indestructible.h +164 -0
  142. package/external/folly/folly/IndexedMemPool.h +550 -0
  143. package/external/folly/folly/IntrusiveList.h +17 -0
  144. package/external/folly/folly/Lazy.h +142 -0
  145. package/external/folly/folly/Likely.h +76 -0
  146. package/external/folly/folly/MPMCPipeline.h +280 -0
  147. package/external/folly/folly/MPMCQueue.h +1556 -0
  148. package/external/folly/folly/MacAddress.cpp +188 -0
  149. package/external/folly/folly/MacAddress.h +260 -0
  150. package/external/folly/folly/MapUtil.h +17 -0
  151. package/external/folly/folly/Math.h +258 -0
  152. package/external/folly/folly/MaybeManagedPtr.h +120 -0
  153. package/external/folly/folly/Memory.h +900 -0
  154. package/external/folly/folly/MicroLock.cpp +76 -0
  155. package/external/folly/folly/MicroLock.h +354 -0
  156. package/external/folly/folly/MicroSpinLock.h +17 -0
  157. package/external/folly/folly/MoveWrapper.h +76 -0
  158. package/external/folly/folly/ObserverContainer.h +1026 -0
  159. package/external/folly/folly/Optional.h +743 -0
  160. package/external/folly/folly/Overload.h +325 -0
  161. package/external/folly/folly/PackedSyncPtr.h +147 -0
  162. package/external/folly/folly/Padded.h +464 -0
  163. package/external/folly/folly/Poly-inl.h +230 -0
  164. package/external/folly/folly/Poly.h +1095 -0
  165. package/external/folly/folly/PolyException.h +43 -0
  166. package/external/folly/folly/Portability.h +644 -0
  167. package/external/folly/folly/Preprocessor.h +236 -0
  168. package/external/folly/folly/ProducerConsumerQueue.h +182 -0
  169. package/external/folly/folly/RWSpinLock.h +17 -0
  170. package/external/folly/folly/Random-inl.h +86 -0
  171. package/external/folly/folly/Random.cpp +184 -0
  172. package/external/folly/folly/Random.h +434 -0
  173. package/external/folly/folly/Range.h +1772 -0
  174. package/external/folly/folly/Replaceable.h +636 -0
  175. package/external/folly/folly/ScopeGuard.cpp +29 -0
  176. package/external/folly/folly/ScopeGuard.h +420 -0
  177. package/external/folly/folly/SharedMutex.cpp +81 -0
  178. package/external/folly/folly/SharedMutex.h +1751 -0
  179. package/external/folly/folly/Singleton-inl.h +332 -0
  180. package/external/folly/folly/Singleton.cpp +512 -0
  181. package/external/folly/folly/Singleton.h +891 -0
  182. package/external/folly/folly/SingletonThreadLocal.cpp +53 -0
  183. package/external/folly/folly/SingletonThreadLocal.h +263 -0
  184. package/external/folly/folly/SocketAddress.cpp +786 -0
  185. package/external/folly/folly/SocketAddress.h +768 -0
  186. package/external/folly/folly/SpinLock.h +55 -0
  187. package/external/folly/folly/String-inl.h +668 -0
  188. package/external/folly/folly/String.cpp +777 -0
  189. package/external/folly/folly/String.h +767 -0
  190. package/external/folly/folly/Subprocess.cpp +1142 -0
  191. package/external/folly/folly/Subprocess.h +1055 -0
  192. package/external/folly/folly/Synchronized.h +1833 -0
  193. package/external/folly/folly/SynchronizedPtr.h +106 -0
  194. package/external/folly/folly/ThreadCachedInt.h +175 -0
  195. package/external/folly/folly/ThreadLocal.h +478 -0
  196. package/external/folly/folly/TimeoutQueue.cpp +78 -0
  197. package/external/folly/folly/TimeoutQueue.h +123 -0
  198. package/external/folly/folly/TokenBucket.h +673 -0
  199. package/external/folly/folly/Traits.h +1442 -0
  200. package/external/folly/folly/Try-inl.h +372 -0
  201. package/external/folly/folly/Try.cpp +23 -0
  202. package/external/folly/folly/Try.h +728 -0
  203. package/external/folly/folly/UTF8String.h +56 -0
  204. package/external/folly/folly/Unicode.cpp +201 -0
  205. package/external/folly/folly/Unicode.h +94 -0
  206. package/external/folly/folly/Unit.h +65 -0
  207. package/external/folly/folly/Uri-inl.h +101 -0
  208. package/external/folly/folly/Uri.cpp +190 -0
  209. package/external/folly/folly/Uri.h +142 -0
  210. package/external/folly/folly/Utility.h +932 -0
  211. package/external/folly/folly/VERSION +1 -0
  212. package/external/folly/folly/Varint.h +230 -0
  213. package/external/folly/folly/VirtualExecutor.h +17 -0
  214. package/external/folly/folly/algorithm/simd/BUCK +47 -0
  215. package/external/folly/folly/algorithm/simd/Contains.cpp +42 -0
  216. package/external/folly/folly/algorithm/simd/Contains.h +116 -0
  217. package/external/folly/folly/algorithm/simd/FindFixed.h +301 -0
  218. package/external/folly/folly/algorithm/simd/Ignore.h +52 -0
  219. package/external/folly/folly/algorithm/simd/Movemask.h +207 -0
  220. package/external/folly/folly/algorithm/simd/detail/BUCK +70 -0
  221. package/external/folly/folly/algorithm/simd/detail/ContainsImpl.h +91 -0
  222. package/external/folly/folly/algorithm/simd/detail/SimdAnyOf.h +83 -0
  223. package/external/folly/folly/algorithm/simd/detail/SimdForEach.h +209 -0
  224. package/external/folly/folly/algorithm/simd/detail/SimdPlatform.h +445 -0
  225. package/external/folly/folly/algorithm/simd/detail/Traits.h +125 -0
  226. package/external/folly/folly/algorithm/simd/detail/UnrollUtils.h +126 -0
  227. package/external/folly/folly/base64.h +264 -0
  228. package/external/folly/folly/chrono/BUCK +29 -0
  229. package/external/folly/folly/chrono/Clock.h +65 -0
  230. package/external/folly/folly/chrono/Conv.h +712 -0
  231. package/external/folly/folly/chrono/test/BUCK +26 -0
  232. package/external/folly/folly/chrono/test/ClockTest.cpp +68 -0
  233. package/external/folly/folly/chrono/test/ConvTest.cpp +652 -0
  234. package/external/folly/folly/concurrency/AtomicSharedPtr.h +387 -0
  235. package/external/folly/folly/concurrency/BUCK +170 -0
  236. package/external/folly/folly/concurrency/CacheLocality.h +460 -0
  237. package/external/folly/folly/concurrency/ConcurrentHashMap.h +822 -0
  238. package/external/folly/folly/concurrency/CoreCachedSharedPtr.h +232 -0
  239. package/external/folly/folly/concurrency/DeadlockDetector.cpp +27 -0
  240. package/external/folly/folly/concurrency/DeadlockDetector.h +44 -0
  241. package/external/folly/folly/concurrency/DynamicBoundedQueue.h +751 -0
  242. package/external/folly/folly/concurrency/PriorityUnboundedQueueSet.h +207 -0
  243. package/external/folly/folly/concurrency/ProcessLocalUniqueId.cpp +46 -0
  244. package/external/folly/folly/concurrency/ProcessLocalUniqueId.h +38 -0
  245. package/external/folly/folly/concurrency/SingletonRelaxedCounter.h +325 -0
  246. package/external/folly/folly/concurrency/ThreadCachedSynchronized.h +227 -0
  247. package/external/folly/folly/concurrency/UnboundedQueue.h +891 -0
  248. package/external/folly/folly/concurrency/container/BUCK +77 -0
  249. package/external/folly/folly/concurrency/container/FlatCombiningPriorityQueue.h +426 -0
  250. package/external/folly/folly/concurrency/container/LockFreeRingBuffer.h +306 -0
  251. package/external/folly/folly/concurrency/container/RelaxedConcurrentPriorityQueue.h +1212 -0
  252. package/external/folly/folly/concurrency/container/SingleWriterFixedHashMap.h +322 -0
  253. package/external/folly/folly/concurrency/container/atomic_grow_array.h +564 -0
  254. package/external/folly/folly/concurrency/container/test/BUCK +75 -0
  255. package/external/folly/folly/concurrency/container/test/FlatCombiningPriorityQueueTest.cpp +570 -0
  256. package/external/folly/folly/concurrency/container/test/LockFreeRingBufferTest.cpp +276 -0
  257. package/external/folly/folly/concurrency/container/test/RelaxedConcurrentPriorityQueueTest.cpp +1570 -0
  258. package/external/folly/folly/concurrency/container/test/SingleWriterFixedHashMapTest.cpp +401 -0
  259. package/external/folly/folly/concurrency/container/test/atomic_grow_array_test.cpp +187 -0
  260. package/external/folly/folly/concurrency/detail/AtomicSharedPtr-detail.h +212 -0
  261. package/external/folly/folly/concurrency/detail/ConcurrentHashMap-detail.h +1911 -0
  262. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.cpp +43 -0
  263. package/external/folly/folly/concurrency/memory/AtomicReadMostlyMainPtr.h +190 -0
  264. package/external/folly/folly/concurrency/memory/BUCK +53 -0
  265. package/external/folly/folly/concurrency/memory/PrimaryPtr.h +338 -0
  266. package/external/folly/folly/concurrency/memory/ReadMostlySharedPtr.h +511 -0
  267. package/external/folly/folly/concurrency/memory/TLRefCount.h +228 -0
  268. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrBenchmark.cpp +56 -0
  269. package/external/folly/folly/concurrency/memory/test/AtomicReadMostlyMainPtrTest.cpp +454 -0
  270. package/external/folly/folly/concurrency/memory/test/BUCK +95 -0
  271. package/external/folly/folly/concurrency/memory/test/PrimaryPtrTest.cpp +303 -0
  272. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrBenchmark.cpp +138 -0
  273. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrStressTest.cpp +75 -0
  274. package/external/folly/folly/concurrency/memory/test/ReadMostlySharedPtrTest.cpp +378 -0
  275. package/external/folly/folly/concurrency/memory/test/RefCountBenchmark.cpp +90 -0
  276. package/external/folly/folly/concurrency/memory/test/RefCountTest.cpp +168 -0
  277. package/external/folly/folly/concurrency/test/AtomicSharedPtrCounted.h +156 -0
  278. package/external/folly/folly/concurrency/test/AtomicSharedPtrPerformance.cpp +255 -0
  279. package/external/folly/folly/concurrency/test/AtomicSharedPtrTest.cpp +257 -0
  280. package/external/folly/folly/concurrency/test/BUCK +229 -0
  281. package/external/folly/folly/concurrency/test/CacheLocalityBenchmark.cpp +392 -0
  282. package/external/folly/folly/concurrency/test/CacheLocalityTest.cpp +1229 -0
  283. package/external/folly/folly/concurrency/test/ConcurrentHashMapBench.cpp +260 -0
  284. package/external/folly/folly/concurrency/test/ConcurrentHashMapTest.cpp +1242 -0
  285. package/external/folly/folly/concurrency/test/CoreCachedSharedPtrTest.cpp +408 -0
  286. package/external/folly/folly/concurrency/test/DynamicBoundedQueueTest.cpp +984 -0
  287. package/external/folly/folly/concurrency/test/PriorityUnboundedQueueSetTest.cpp +73 -0
  288. package/external/folly/folly/concurrency/test/ProcessLocalUniqueIdTest.cpp +66 -0
  289. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterBench.cpp +101 -0
  290. package/external/folly/folly/concurrency/test/SingletonRelaxedCounterTest.cpp +185 -0
  291. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedBench.cpp +76 -0
  292. package/external/folly/folly/concurrency/test/ThreadCachedSynchronizedTest.cpp +93 -0
  293. package/external/folly/folly/concurrency/test/UnboundedQueueTest.cpp +1302 -0
  294. package/external/folly/folly/container/Access.h +57 -0
  295. package/external/folly/folly/container/Array.h +87 -0
  296. package/external/folly/folly/container/BUCK +353 -0
  297. package/external/folly/folly/container/BitIterator.h +203 -0
  298. package/external/folly/folly/container/Enumerate.h +162 -0
  299. package/external/folly/folly/container/EvictingCacheMap.h +730 -0
  300. package/external/folly/folly/container/F14.md +300 -0
  301. package/external/folly/folly/container/F14Map-fwd.h +113 -0
  302. package/external/folly/folly/container/F14Map.h +2108 -0
  303. package/external/folly/folly/container/F14Set-fwd.h +95 -0
  304. package/external/folly/folly/container/F14Set.h +1603 -0
  305. package/external/folly/folly/container/FBVector.h +1711 -0
  306. package/external/folly/folly/container/Foreach-inl.h +316 -0
  307. package/external/folly/folly/container/Foreach.h +209 -0
  308. package/external/folly/folly/container/HeterogeneousAccess-fwd.h +33 -0
  309. package/external/folly/folly/container/HeterogeneousAccess.h +171 -0
  310. package/external/folly/folly/container/IntrusiveHeap.h +268 -0
  311. package/external/folly/folly/container/IntrusiveList.h +131 -0
  312. package/external/folly/folly/container/Iterator.h +843 -0
  313. package/external/folly/folly/container/MapUtil.h +376 -0
  314. package/external/folly/folly/container/Merge.h +90 -0
  315. package/external/folly/folly/container/RegexMatchCache.cpp +521 -0
  316. package/external/folly/folly/container/RegexMatchCache.h +699 -0
  317. package/external/folly/folly/container/Reserve.h +109 -0
  318. package/external/folly/folly/container/SparseByteSet.h +123 -0
  319. package/external/folly/folly/container/View.h +81 -0
  320. package/external/folly/folly/container/WeightedEvictingCacheMap.h +651 -0
  321. package/external/folly/folly/container/detail/BUCK +115 -0
  322. package/external/folly/folly/container/detail/BitIteratorDetail.h +87 -0
  323. package/external/folly/folly/container/detail/F14Defaults.h +34 -0
  324. package/external/folly/folly/container/detail/F14IntrinsicsAvailability.h +67 -0
  325. package/external/folly/folly/container/detail/F14MapFallback.h +717 -0
  326. package/external/folly/folly/container/detail/F14Mask.h +235 -0
  327. package/external/folly/folly/container/detail/F14Policy.h +1523 -0
  328. package/external/folly/folly/container/detail/F14SetFallback.h +528 -0
  329. package/external/folly/folly/container/detail/F14Table.cpp +71 -0
  330. package/external/folly/folly/container/detail/F14Table.h +2680 -0
  331. package/external/folly/folly/container/detail/Util.h +303 -0
  332. package/external/folly/folly/container/detail/tape_detail.h +135 -0
  333. package/external/folly/folly/container/detail/test/BUCK +14 -0
  334. package/external/folly/folly/container/detail/test/F14DetailTest.cpp +47 -0
  335. package/external/folly/folly/container/heap_vector_types.h +1683 -0
  336. package/external/folly/folly/container/range_traits.h +81 -0
  337. package/external/folly/folly/container/small_vector.h +1476 -0
  338. package/external/folly/folly/container/sorted_vector_types.h +1652 -0
  339. package/external/folly/folly/container/span.h +408 -0
  340. package/external/folly/folly/container/tape.h +608 -0
  341. package/external/folly/folly/container/test/.clang-tidy +12 -0
  342. package/external/folly/folly/container/test/AccessTest.cpp +138 -0
  343. package/external/folly/folly/container/test/ArrayTest.cpp +84 -0
  344. package/external/folly/folly/container/test/BUCK +568 -0
  345. package/external/folly/folly/container/test/BitIteratorBench.cpp +112 -0
  346. package/external/folly/folly/container/test/BitIteratorTest.cpp +109 -0
  347. package/external/folly/folly/container/test/EnumerateTest.cpp +294 -0
  348. package/external/folly/folly/container/test/EvictingCacheMapBench.cpp +80 -0
  349. package/external/folly/folly/container/test/EvictingCacheMapTest.cpp +842 -0
  350. package/external/folly/folly/container/test/F14AsanSupportTest.cpp +143 -0
  351. package/external/folly/folly/container/test/F14FwdTest.cpp +37 -0
  352. package/external/folly/folly/container/test/F14InterprocessTest.cpp +404 -0
  353. package/external/folly/folly/container/test/F14MapTest.cpp +2543 -0
  354. package/external/folly/folly/container/test/F14PolicyTest.cpp +49 -0
  355. package/external/folly/folly/container/test/F14SetTest.cpp +1738 -0
  356. package/external/folly/folly/container/test/F14SmallOverheads.cpp +215 -0
  357. package/external/folly/folly/container/test/F14TestUtil.h +117 -0
  358. package/external/folly/folly/container/test/FBVectorBenchmark.cpp +380 -0
  359. package/external/folly/folly/container/test/FBVectorBenchmarks.cpp.h +100 -0
  360. package/external/folly/folly/container/test/FBVectorTest.cpp +326 -0
  361. package/external/folly/folly/container/test/FBVectorTests.cpp.h +304 -0
  362. package/external/folly/folly/container/test/ForeachBenchmark.cpp +388 -0
  363. package/external/folly/folly/container/test/ForeachTest.cpp +338 -0
  364. package/external/folly/folly/container/test/HashMapsBench.cpp +458 -0
  365. package/external/folly/folly/container/test/HeterogeneousAccessTest.cpp +242 -0
  366. package/external/folly/folly/container/test/IntrusiveHeapTest.cpp +262 -0
  367. package/external/folly/folly/container/test/IteratorTest.cpp +989 -0
  368. package/external/folly/folly/container/test/MapUtilTest.cpp +365 -0
  369. package/external/folly/folly/container/test/MergeTest.cpp +66 -0
  370. package/external/folly/folly/container/test/RegexMatchCacheTest.cpp +634 -0
  371. package/external/folly/folly/container/test/ReserveTest.cpp +173 -0
  372. package/external/folly/folly/container/test/SparseByteSetBenchmark.cpp +153 -0
  373. package/external/folly/folly/container/test/SparseByteSetTest.cpp +117 -0
  374. package/external/folly/folly/container/test/TrackingTypes.h +584 -0
  375. package/external/folly/folly/container/test/UtilTest.cpp +609 -0
  376. package/external/folly/folly/container/test/WeightedEvictingCacheMapTest.cpp +800 -0
  377. package/external/folly/folly/container/test/heap_vector_types_test.cpp +1774 -0
  378. package/external/folly/folly/container/test/range_traits_test.cpp +59 -0
  379. package/external/folly/folly/container/test/small_vector_test.cpp +1571 -0
  380. package/external/folly/folly/container/test/sorted_vector_test.cpp +1589 -0
  381. package/external/folly/folly/container/test/span_test.cpp +520 -0
  382. package/external/folly/folly/container/test/tape_bench.cpp +200 -0
  383. package/external/folly/folly/container/test/tape_test.cpp +590 -0
  384. package/external/folly/folly/defs.bzl +238 -0
  385. package/external/folly/folly/detail/AsyncTrace.cpp +36 -0
  386. package/external/folly/folly/detail/AsyncTrace.h +44 -0
  387. package/external/folly/folly/detail/AtomicHashUtils.h +42 -0
  388. package/external/folly/folly/detail/AtomicUnorderedMapUtils.h +80 -0
  389. package/external/folly/folly/detail/BUCK +406 -0
  390. package/external/folly/folly/detail/DiscriminatedPtrDetail.h +172 -0
  391. package/external/folly/folly/detail/FileUtilDetail.cpp +63 -0
  392. package/external/folly/folly/detail/FileUtilDetail.h +85 -0
  393. package/external/folly/folly/detail/FileUtilVectorDetail.h +81 -0
  394. package/external/folly/folly/detail/FingerprintPolynomial.h +132 -0
  395. package/external/folly/folly/detail/Futex-inl.h +123 -0
  396. package/external/folly/folly/detail/Futex.cpp +273 -0
  397. package/external/folly/folly/detail/Futex.h +109 -0
  398. package/external/folly/folly/detail/GroupVarintDetail.h +101 -0
  399. package/external/folly/folly/detail/IPAddress.cpp +37 -0
  400. package/external/folly/folly/detail/IPAddress.h +57 -0
  401. package/external/folly/folly/detail/IPAddressSource.h +278 -0
  402. package/external/folly/folly/detail/Iterators.h +156 -0
  403. package/external/folly/folly/detail/MPMCPipelineDetail.h +122 -0
  404. package/external/folly/folly/detail/MemoryIdler.cpp +233 -0
  405. package/external/folly/folly/detail/MemoryIdler.h +216 -0
  406. package/external/folly/folly/detail/PerfScoped.cpp +112 -0
  407. package/external/folly/folly/detail/PerfScoped.h +70 -0
  408. package/external/folly/folly/detail/PolyDetail.h +921 -0
  409. package/external/folly/folly/detail/RangeCommon.cpp +55 -0
  410. package/external/folly/folly/detail/RangeCommon.h +93 -0
  411. package/external/folly/folly/detail/RangeSse42.cpp +198 -0
  412. package/external/folly/folly/detail/RangeSse42.h +30 -0
  413. package/external/folly/folly/detail/SimpleSimdStringUtils.cpp +31 -0
  414. package/external/folly/folly/detail/SimpleSimdStringUtils.h +27 -0
  415. package/external/folly/folly/detail/SimpleSimdStringUtilsImpl.h +63 -0
  416. package/external/folly/folly/detail/Singleton.h +34 -0
  417. package/external/folly/folly/detail/SlowFingerprint.h +90 -0
  418. package/external/folly/folly/detail/SocketFastOpen.cpp +175 -0
  419. package/external/folly/folly/detail/SocketFastOpen.h +89 -0
  420. package/external/folly/folly/detail/SplitStringSimd.cpp +84 -0
  421. package/external/folly/folly/detail/SplitStringSimd.h +151 -0
  422. package/external/folly/folly/detail/SplitStringSimdImpl.h +149 -0
  423. package/external/folly/folly/detail/Sse.cpp +35 -0
  424. package/external/folly/folly/detail/Sse.h +45 -0
  425. package/external/folly/folly/detail/StaticSingletonManager.cpp +119 -0
  426. package/external/folly/folly/detail/StaticSingletonManager.h +298 -0
  427. package/external/folly/folly/detail/ThreadLocalDetail.cpp +492 -0
  428. package/external/folly/folly/detail/ThreadLocalDetail.h +800 -0
  429. package/external/folly/folly/detail/TrapOnAvx512.cpp +41 -0
  430. package/external/folly/folly/detail/TrapOnAvx512.h +21 -0
  431. package/external/folly/folly/detail/TurnSequencer.h +295 -0
  432. package/external/folly/folly/detail/TypeList.h +551 -0
  433. package/external/folly/folly/detail/UniqueInstance.cpp +136 -0
  434. package/external/folly/folly/detail/UniqueInstance.h +68 -0
  435. package/external/folly/folly/detail/base64_detail/BUCK +102 -0
  436. package/external/folly/folly/detail/base64_detail/Base64Api.cpp +40 -0
  437. package/external/folly/folly/detail/base64_detail/Base64Api.h +101 -0
  438. package/external/folly/folly/detail/base64_detail/Base64Common.h +80 -0
  439. package/external/folly/folly/detail/base64_detail/Base64Constants.h +79 -0
  440. package/external/folly/folly/detail/base64_detail/Base64HiddenConstants.h +129 -0
  441. package/external/folly/folly/detail/base64_detail/Base64SWAR.cpp +161 -0
  442. package/external/folly/folly/detail/base64_detail/Base64SWAR.h +32 -0
  443. package/external/folly/folly/detail/base64_detail/Base64Scalar.h +262 -0
  444. package/external/folly/folly/detail/base64_detail/Base64Simd.h +102 -0
  445. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.cpp +42 -0
  446. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2.h +33 -0
  447. package/external/folly/folly/detail/base64_detail/Base64_SSE4_2_Platform.h +167 -0
  448. package/external/folly/folly/detail/base64_detail/README.md +392 -0
  449. package/external/folly/folly/detail/base64_detail/tests/BUCK +36 -0
  450. package/external/folly/folly/detail/base64_detail/tests/Base64AgainstScalarTest.cpp +141 -0
  451. package/external/folly/folly/detail/base64_detail/tests/Base64PlatformTest.cpp +273 -0
  452. package/external/folly/folly/detail/base64_detail/tests/Base64SpecialCasesTest.cpp +555 -0
  453. package/external/folly/folly/detail/test/AsyncTraceTest.cpp +43 -0
  454. package/external/folly/folly/detail/test/BUCK +118 -0
  455. package/external/folly/folly/detail/test/FileUtilDetailTest.cpp +56 -0
  456. package/external/folly/folly/detail/test/PerfScopedTest.cpp +107 -0
  457. package/external/folly/folly/detail/test/SimpleSimdStringUtilsTest.cpp +92 -0
  458. package/external/folly/folly/detail/test/SplitStringSimdTest.cpp +242 -0
  459. package/external/folly/folly/detail/test/StaticSingletonManagerTest.cpp +121 -0
  460. package/external/folly/folly/detail/test/ThreadLocalBenchmark.cpp +116 -0
  461. package/external/folly/folly/detail/test/ThreadLocalDetailTest.cpp +194 -0
  462. package/external/folly/folly/detail/test/TrapOnAvx512TestNegative.cpp +29 -0
  463. package/external/folly/folly/detail/test/UniqueInstanceTest.cpp +60 -0
  464. package/external/folly/folly/detail/thread_local_globals.cpp +69 -0
  465. package/external/folly/folly/detail/thread_local_globals.h +36 -0
  466. package/external/folly/folly/dynamic-inl.h +17 -0
  467. package/external/folly/folly/dynamic.h +17 -0
  468. package/external/folly/folly/folly_extended_library.bzl +28 -0
  469. package/external/folly/folly/functional/ApplyTuple.h +204 -0
  470. package/external/folly/folly/functional/BUCK +57 -0
  471. package/external/folly/folly/functional/Invoke.h +880 -0
  472. package/external/folly/folly/functional/Partial.h +130 -0
  473. package/external/folly/folly/functional/protocol.h +203 -0
  474. package/external/folly/folly/functional/test/ApplyTupleTest.cpp +549 -0
  475. package/external/folly/folly/functional/test/BUCK +57 -0
  476. package/external/folly/folly/functional/test/InvokeTest.cpp +483 -0
  477. package/external/folly/folly/functional/test/PartialTest.cpp +141 -0
  478. package/external/folly/folly/functional/test/protocol_test.cpp +177 -0
  479. package/external/folly/folly/functional/test/traits_test.cpp +551 -0
  480. package/external/folly/folly/functional/traits.h +675 -0
  481. package/external/folly/folly/hash/BUCK +86 -0
  482. package/external/folly/folly/hash/Checksum.cpp +275 -0
  483. package/external/folly/folly/hash/Checksum.h +94 -0
  484. package/external/folly/folly/hash/FarmHash.h +46 -0
  485. package/external/folly/folly/hash/Hash.h +1045 -0
  486. package/external/folly/folly/hash/MurmurHash.h +86 -0
  487. package/external/folly/folly/hash/SpookyHashV1.cpp +391 -0
  488. package/external/folly/folly/hash/SpookyHashV1.h +307 -0
  489. package/external/folly/folly/hash/SpookyHashV2.cpp +392 -0
  490. package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/hash/SpookyHashV2.h +6 -1
  491. package/external/folly/folly/hash/detail/BUCK +26 -0
  492. package/external/folly/folly/hash/detail/ChecksumDetail.cpp +296 -0
  493. package/external/folly/folly/hash/detail/ChecksumDetail.h +137 -0
  494. package/external/folly/folly/hash/detail/Crc32CombineDetail.cpp +191 -0
  495. package/external/folly/folly/hash/detail/Crc32cDetail.cpp +303 -0
  496. package/external/folly/folly/hash/test/BUCK +132 -0
  497. package/external/folly/folly/hash/test/ChecksumBenchmark.cpp +91 -0
  498. package/external/folly/folly/hash/test/ChecksumTest.cpp +587 -0
  499. package/external/folly/folly/hash/test/FarmHashTest.cpp +41 -0
  500. package/external/folly/folly/hash/test/HashBenchmark.cpp +238 -0
  501. package/external/folly/folly/hash/test/HashTest.cpp +997 -0
  502. package/external/folly/folly/hash/test/MurmurHashTest.cpp +76 -0
  503. package/external/folly/folly/hash/test/SpookyHashV1Test.cpp +559 -0
  504. package/external/folly/folly/hash/test/SpookyHashV2Test.cpp +549 -0
  505. package/external/folly/folly/hash/test/traits_test.cpp +69 -0
  506. package/external/folly/folly/hash/traits.h +115 -0
  507. package/external/folly/folly/json/BUCK +155 -0
  508. package/external/folly/folly/json/DynamicConverter.h +464 -0
  509. package/external/folly/folly/json/DynamicParser-inl.h +316 -0
  510. package/external/folly/folly/json/DynamicParser.cpp +198 -0
  511. package/external/folly/folly/json/DynamicParser.h +394 -0
  512. package/external/folly/folly/json/JSONSchema.cpp +1030 -0
  513. package/external/folly/folly/json/JSONSchema.h +73 -0
  514. package/external/folly/folly/json/JsonMockUtil.h +73 -0
  515. package/external/folly/folly/json/JsonTestUtil.cpp +167 -0
  516. package/external/folly/folly/json/JsonTestUtil.h +88 -0
  517. package/external/folly/folly/json/bser/BUCK +24 -0
  518. package/external/folly/folly/json/bser/Bser.h +107 -0
  519. package/external/folly/folly/json/bser/Dump.cpp +253 -0
  520. package/external/folly/folly/json/bser/Load.cpp +246 -0
  521. package/external/folly/folly/json/bser/test/BUCK +14 -0
  522. package/external/folly/folly/json/bser/test/BserTest.cpp +149 -0
  523. package/external/folly/folly/json/dynamic.cpp +552 -0
  524. package/external/folly/folly/json/dynamic.h +1346 -0
  525. package/external/folly/folly/json/json.h +238 -0
  526. package/external/folly/folly/json/json_patch.cpp +325 -0
  527. package/external/folly/folly/json/json_patch.h +126 -0
  528. package/external/folly/folly/json/json_pointer.cpp +114 -0
  529. package/external/folly/folly/json/json_pointer.h +87 -0
  530. package/external/folly/folly/json/test/BUCK +147 -0
  531. package/external/folly/folly/json/test/DynamicBenchmark.cpp +146 -0
  532. package/external/folly/folly/json/test/DynamicConverterTest.cpp +518 -0
  533. package/external/folly/folly/json/test/DynamicOtherTest.cpp +344 -0
  534. package/external/folly/folly/json/test/DynamicParserTest.cpp +443 -0
  535. package/external/folly/folly/json/test/DynamicTest.cpp +1647 -0
  536. package/external/folly/folly/json/test/JSONSchemaTest.cpp +450 -0
  537. package/external/folly/folly/json/test/JsonBenchmark.cpp +264 -0
  538. package/external/folly/folly/json/test/JsonOtherTest.cpp +51 -0
  539. package/external/folly/folly/json/test/JsonTest.cpp +1153 -0
  540. package/external/folly/folly/json/test/JsonTestUtilTest.cpp +97 -0
  541. package/external/folly/folly/json/test/json_patch_test.cpp +361 -0
  542. package/external/folly/folly/json/test/json_pointer_test.cpp +58 -0
  543. package/external/folly/folly/json/tool/BUCK +13 -0
  544. package/external/folly/folly/json/tool/JSONSchemaTester.cpp +58 -0
  545. package/external/folly/folly/json.h +17 -0
  546. package/external/folly/folly/json_patch.h +17 -0
  547. package/external/folly/folly/json_pointer.h +17 -0
  548. package/external/folly/folly/lang/Access.h +29 -0
  549. package/external/folly/folly/lang/Align.h +240 -0
  550. package/external/folly/folly/lang/Aligned.h +92 -0
  551. package/external/folly/folly/lang/Assume.h +82 -0
  552. package/external/folly/folly/lang/BUCK +287 -0
  553. package/external/folly/folly/lang/Badge.h +108 -0
  554. package/external/folly/folly/lang/Bits.h +570 -0
  555. package/external/folly/folly/lang/BitsClass.h +312 -0
  556. package/external/folly/folly/lang/Builtin.h +74 -0
  557. package/external/folly/folly/lang/CArray.h +34 -0
  558. package/external/folly/folly/lang/CString.cpp +86 -0
  559. package/external/folly/folly/lang/CString.h +55 -0
  560. package/external/folly/folly/lang/Cast.h +51 -0
  561. package/external/folly/folly/lang/CheckedMath.h +253 -0
  562. package/external/folly/folly/lang/CustomizationPoint.h +58 -0
  563. package/external/folly/folly/lang/Exception.cpp +822 -0
  564. package/external/folly/folly/lang/Exception.h +716 -0
  565. package/external/folly/folly/lang/Extern.h +55 -0
  566. package/external/folly/folly/lang/Hint-inl.h +144 -0
  567. package/external/folly/folly/lang/Hint.h +238 -0
  568. package/external/folly/folly/lang/Keep.h +98 -0
  569. package/external/folly/folly/lang/New.h +124 -0
  570. package/external/folly/folly/lang/Ordering.h +140 -0
  571. package/external/folly/folly/lang/Pretty.h +159 -0
  572. package/external/folly/folly/lang/PropagateConst.h +413 -0
  573. package/external/folly/folly/lang/RValueReferenceWrapper.h +152 -0
  574. package/external/folly/folly/lang/SafeAssert.cpp +589 -0
  575. package/external/folly/folly/lang/StaticConst.h +33 -0
  576. package/external/folly/folly/lang/Thunk.h +100 -0
  577. package/external/folly/folly/lang/TypeInfo.h +58 -0
  578. package/external/folly/folly/lang/UncaughtExceptions.cpp +17 -0
  579. package/external/folly/folly/lang/UncaughtExceptions.h +19 -0
  580. package/external/folly/folly/lang/test/AlignTest.cpp +87 -0
  581. package/external/folly/folly/lang/test/AlignedTest.cpp +130 -0
  582. package/external/folly/folly/lang/test/BUCK +258 -0
  583. package/external/folly/folly/lang/test/BadgeTest.cpp +89 -0
  584. package/external/folly/folly/lang/test/BitsBenchmark.cpp +164 -0
  585. package/external/folly/folly/lang/test/BitsClassBenchmark.cpp +122 -0
  586. package/external/folly/folly/lang/test/BitsClassTest.cpp +379 -0
  587. package/external/folly/folly/lang/test/BitsTest.cpp +577 -0
  588. package/external/folly/folly/lang/test/CStringTest.cpp +60 -0
  589. package/external/folly/folly/lang/test/CastTest.cpp +47 -0
  590. package/external/folly/folly/lang/test/CheckedMathTest.cpp +394 -0
  591. package/external/folly/folly/lang/test/ExceptionBench.cpp +427 -0
  592. package/external/folly/folly/lang/test/ExceptionTest.cpp +413 -0
  593. package/external/folly/folly/lang/test/ExternTest.cpp +39 -0
  594. package/external/folly/folly/lang/test/HintTest.cpp +100 -0
  595. package/external/folly/folly/lang/test/NewTest.cpp +38 -0
  596. package/external/folly/folly/lang/test/OrderingTest.cpp +105 -0
  597. package/external/folly/folly/lang/test/PrettyTest.cpp +44 -0
  598. package/external/folly/folly/lang/test/PropagateConstTest.cpp +356 -0
  599. package/external/folly/folly/lang/test/RValueReferenceWrapperTest.cpp +85 -0
  600. package/external/folly/folly/lang/test/SafeAssertTest.cpp +75 -0
  601. package/external/folly/folly/lang/test/ThunkTest.cpp +105 -0
  602. package/external/folly/folly/lang/test/ToAsciiBench.cpp +466 -0
  603. package/external/folly/folly/lang/test/ToAsciiTest.cpp +266 -0
  604. package/external/folly/folly/lang/test/TypeInfoTest.cpp +56 -0
  605. package/external/folly/folly/memcpy.S +292 -0
  606. package/external/folly/folly/memcpy_select_aarch64.cpp +145 -0
  607. package/external/folly/folly/memory/Arena-inl.h +83 -0
  608. package/external/folly/folly/memory/Arena.h +325 -0
  609. package/external/folly/folly/memory/BUCK +191 -0
  610. package/external/folly/folly/memory/JemallocHugePageAllocator.cpp +449 -0
  611. package/external/folly/folly/memory/JemallocHugePageAllocator.h +105 -0
  612. package/external/folly/folly/memory/JemallocHugePageAllocatorTest.cpp +341 -0
  613. package/external/folly/folly/memory/JemallocNodumpAllocator.cpp +176 -0
  614. package/external/folly/folly/memory/JemallocNodumpAllocator.h +119 -0
  615. package/external/folly/folly/memory/JemallocNodumpAllocatorTest.cpp +61 -0
  616. package/external/folly/folly/memory/MallctlHelper.cpp +37 -0
  617. package/external/folly/folly/memory/MallctlHelper.h +167 -0
  618. package/external/folly/folly/memory/Malloc.h +551 -0
  619. package/external/folly/folly/memory/MemoryResource.h +57 -0
  620. package/external/folly/folly/memory/ReentrantAllocator.cpp +162 -0
  621. package/external/folly/folly/memory/ReentrantAllocator.h +261 -0
  622. package/external/folly/folly/memory/SanitizeAddress.cpp +75 -0
  623. package/external/folly/folly/memory/SanitizeAddress.h +117 -0
  624. package/external/folly/folly/memory/SanitizeLeak.cpp +119 -0
  625. package/external/folly/folly/memory/SanitizeLeak.h +108 -0
  626. package/external/folly/folly/memory/ThreadCachedArena.cpp +53 -0
  627. package/external/folly/folly/memory/ThreadCachedArena.h +90 -0
  628. package/external/folly/folly/memory/UninitializedMemoryHacks.h +426 -0
  629. package/external/folly/folly/memory/detail/BUCK +10 -0
  630. package/external/folly/folly/memory/detail/MallocImpl.cpp +52 -0
  631. package/external/folly/folly/memory/detail/MallocImpl.h +97 -0
  632. package/external/folly/folly/memory/not_null-inl.h +522 -0
  633. package/external/folly/folly/memory/not_null.h +449 -0
  634. package/external/folly/folly/memory/test/ArenaTest.cpp +354 -0
  635. package/external/folly/folly/memory/test/BUCK +146 -0
  636. package/external/folly/folly/memory/test/MallctlHelperTest.cpp +169 -0
  637. package/external/folly/folly/memory/test/MallocBenchmark.cpp +91 -0
  638. package/external/folly/folly/memory/test/MallocTest.cpp +78 -0
  639. package/external/folly/folly/memory/test/MemoryResourceTest.cpp +31 -0
  640. package/external/folly/folly/memory/test/ReentrantAllocatorTest.cpp +144 -0
  641. package/external/folly/folly/memory/test/SanitizeAddressTest.cpp +67 -0
  642. package/external/folly/folly/memory/test/SanitizeLeakTest.cpp +139 -0
  643. package/external/folly/folly/memory/test/ThreadCachedArenaTest.cpp +276 -0
  644. package/external/folly/folly/memory/test/UninitializedMemoryHacksODR.cpp +21 -0
  645. package/external/folly/folly/memory/test/UninitializedMemoryHacksTest.cpp +327 -0
  646. package/external/folly/folly/memory/test/not_null_test.cpp +608 -0
  647. package/external/folly/folly/memset.S +245 -0
  648. package/external/folly/folly/memset_select_aarch64.cpp +72 -0
  649. package/external/folly/folly/portability/Asm.h +50 -0
  650. package/external/folly/folly/portability/Atomic.h +31 -0
  651. package/external/folly/folly/portability/BUCK +456 -0
  652. package/external/folly/folly/portability/Builtins.cpp +31 -0
  653. package/external/folly/folly/portability/Builtins.h +161 -0
  654. package/external/folly/folly/portability/Config.h +43 -0
  655. package/external/folly/folly/portability/Constexpr.h +145 -0
  656. package/external/folly/folly/portability/Dirent.cpp +140 -0
  657. package/external/folly/folly/portability/Dirent.h +41 -0
  658. package/external/folly/folly/portability/Event.h +44 -0
  659. package/external/folly/folly/portability/Fcntl.cpp +120 -0
  660. package/external/folly/folly/portability/Fcntl.h +67 -0
  661. package/external/folly/folly/portability/Filesystem.cpp +67 -0
  662. package/external/folly/folly/portability/Filesystem.h +114 -0
  663. package/external/folly/folly/portability/FmtCompile.h +40 -0
  664. package/external/folly/folly/portability/GFlags.h +139 -0
  665. package/external/folly/folly/portability/GMock.h +35 -0
  666. package/external/folly/folly/portability/GTest.h +35 -0
  667. package/external/folly/folly/portability/IOVec.h +34 -0
  668. package/external/folly/folly/portability/Libgen.cpp +59 -0
  669. package/external/folly/folly/portability/Libgen.h +29 -0
  670. package/external/folly/folly/portability/Libunwind.h +21 -0
  671. package/external/folly/folly/portability/Malloc.cpp +31 -0
  672. package/external/folly/folly/portability/Malloc.h +53 -0
  673. package/external/folly/folly/portability/Math.h +90 -0
  674. package/external/folly/folly/portability/Memory.h +26 -0
  675. package/external/folly/folly/portability/OpenSSL.cpp +17 -0
  676. package/external/folly/folly/portability/OpenSSL.h +102 -0
  677. package/external/folly/folly/portability/PThread.cpp +697 -0
  678. package/external/folly/folly/portability/PThread.h +148 -0
  679. package/external/folly/folly/portability/README.md +21 -0
  680. package/external/folly/folly/portability/Sched.cpp +41 -0
  681. package/external/folly/folly/portability/Sched.h +45 -0
  682. package/external/folly/folly/portability/Sockets.cpp +245 -0
  683. package/external/folly/folly/portability/Sockets.h +155 -0
  684. package/external/folly/folly/portability/SourceLocation.h +49 -0
  685. package/external/folly/folly/portability/Stdio.cpp +77 -0
  686. package/external/folly/folly/portability/Stdio.h +32 -0
  687. package/external/folly/folly/portability/Stdlib.cpp +172 -0
  688. package/external/folly/folly/portability/Stdlib.h +64 -0
  689. package/external/folly/folly/portability/String.cpp +53 -0
  690. package/external/folly/folly/portability/String.h +39 -0
  691. package/external/folly/folly/portability/SysFile.cpp +46 -0
  692. package/external/folly/folly/portability/SysFile.h +27 -0
  693. package/external/folly/folly/portability/SysMembarrier.cpp +104 -0
  694. package/external/folly/folly/portability/SysMembarrier.h +26 -0
  695. package/external/folly/folly/portability/SysMman.cpp +242 -0
  696. package/external/folly/folly/portability/SysMman.h +68 -0
  697. package/external/folly/folly/portability/SysResource.cpp +108 -0
  698. package/external/folly/folly/portability/SysResource.h +71 -0
  699. package/external/folly/folly/portability/SysStat.cpp +66 -0
  700. package/external/folly/folly/portability/SysStat.h +52 -0
  701. package/external/folly/folly/portability/SysSyscall.h +73 -0
  702. package/external/folly/folly/portability/SysTime.cpp +62 -0
  703. package/external/folly/folly/portability/SysTime.h +50 -0
  704. package/external/folly/folly/portability/SysTypes.h +44 -0
  705. package/external/folly/folly/portability/SysUio.cpp +179 -0
  706. package/external/folly/folly/portability/SysUio.h +51 -0
  707. package/external/folly/folly/portability/Syslog.h +39 -0
  708. package/external/folly/folly/portability/Time.cpp +357 -0
  709. package/external/folly/folly/portability/Time.h +74 -0
  710. package/external/folly/folly/portability/Unistd.h +111 -0
  711. package/external/folly/folly/portability/Windows.h +108 -0
  712. package/external/folly/folly/portability/openat2.c +30 -0
  713. package/external/folly/folly/portability/openat2.h +39 -0
  714. package/external/folly/folly/portability/test/BUCK +59 -0
  715. package/external/folly/folly/portability/test/ConstexprTest.cpp +102 -0
  716. package/external/folly/folly/portability/test/FilesystemTest.cpp +35 -0
  717. package/external/folly/folly/portability/test/LibgenTest.cpp +35 -0
  718. package/external/folly/folly/portability/test/OpenSSLPortabilityTest.cpp +108 -0
  719. package/external/folly/folly/portability/test/PThreadTest.cpp +80 -0
  720. package/external/folly/folly/portability/test/TimeTest.cpp +90 -0
  721. package/external/folly/folly/small_vector.h +17 -0
  722. package/external/folly/folly/somerge_defs.bzl +399 -0
  723. package/external/folly/folly/sorted_vector_types.h +17 -0
  724. package/external/folly/folly/stop_watch.h +317 -0
  725. package/external/folly/folly/synchronization/AsymmetricThreadFence.cpp +91 -0
  726. package/external/folly/folly/synchronization/AsymmetricThreadFence.h +60 -0
  727. package/external/folly/folly/synchronization/AtomicNotification-inl.h +146 -0
  728. package/external/folly/folly/synchronization/AtomicNotification.cpp +34 -0
  729. package/external/folly/folly/synchronization/AtomicNotification.h +117 -0
  730. package/external/folly/folly/synchronization/AtomicRef.h +181 -0
  731. package/external/folly/folly/synchronization/AtomicStruct.h +150 -0
  732. package/external/folly/folly/synchronization/AtomicUtil-inl.h +482 -0
  733. package/external/folly/folly/synchronization/AtomicUtil.h +179 -0
  734. package/external/folly/folly/synchronization/BUCK +418 -0
  735. package/external/folly/folly/synchronization/Baton.h +419 -0
  736. package/external/folly/folly/synchronization/CallOnce.h +263 -0
  737. package/external/folly/folly/synchronization/DelayedInit.h +179 -0
  738. package/external/folly/folly/synchronization/DistributedMutex-inl.h +1744 -0
  739. package/external/folly/folly/synchronization/DistributedMutex.cpp +27 -0
  740. package/external/folly/folly/synchronization/DistributedMutex.h +342 -0
  741. package/external/folly/folly/synchronization/EventCount.h +200 -0
  742. package/external/folly/folly/synchronization/FlatCombining.h +629 -0
  743. package/external/folly/folly/synchronization/Hazptr-fwd.h +217 -0
  744. package/external/folly/folly/synchronization/Hazptr.cpp +36 -0
  745. package/external/folly/folly/synchronization/Hazptr.h +209 -0
  746. package/external/folly/folly/synchronization/HazptrDomain.cpp +68 -0
  747. package/external/folly/folly/synchronization/HazptrDomain.h +832 -0
  748. package/external/folly/folly/synchronization/HazptrHolder.h +431 -0
  749. package/external/folly/folly/synchronization/HazptrObj.h +533 -0
  750. package/external/folly/folly/synchronization/HazptrObjLinked.h +315 -0
  751. package/external/folly/folly/synchronization/HazptrRec.h +68 -0
  752. package/external/folly/folly/synchronization/HazptrThrLocal.h +180 -0
  753. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.cpp +46 -0
  754. package/external/folly/folly/synchronization/HazptrThreadPoolExecutor.h +25 -0
  755. package/external/folly/folly/synchronization/Latch.h +160 -0
  756. package/external/folly/folly/synchronization/LifoSem.h +767 -0
  757. package/external/folly/folly/synchronization/Lock.h +887 -0
  758. package/external/folly/folly/synchronization/MicroSpinLock.h +154 -0
  759. package/external/folly/folly/synchronization/NativeSemaphore.h +187 -0
  760. package/external/folly/folly/synchronization/ParkingLot.cpp +37 -0
  761. package/external/folly/folly/synchronization/ParkingLot.h +330 -0
  762. package/external/folly/folly/synchronization/PicoSpinLock.h +167 -0
  763. package/external/folly/folly/synchronization/RWSpinLock.h +549 -0
  764. package/external/folly/folly/synchronization/Rcu.cpp +26 -0
  765. package/external/folly/folly/synchronization/Rcu.h +553 -0
  766. package/external/folly/folly/synchronization/RelaxedAtomic.h +336 -0
  767. package/external/folly/folly/synchronization/SanitizeThread.cpp +141 -0
  768. package/external/folly/folly/synchronization/SanitizeThread.h +166 -0
  769. package/external/folly/folly/synchronization/SaturatingSemaphore.h +324 -0
  770. package/external/folly/folly/synchronization/SmallLocks.h +36 -0
  771. package/external/folly/folly/synchronization/ThrottledLifoSem.h +362 -0
  772. package/external/folly/folly/synchronization/WaitOptions.cpp +25 -0
  773. package/external/folly/folly/synchronization/WaitOptions.h +75 -0
  774. package/external/folly/folly/synchronization/detail/AtomicUtils.h +59 -0
  775. package/external/folly/folly/synchronization/detail/BUCK +104 -0
  776. package/external/folly/folly/synchronization/detail/Hardware.cpp +192 -0
  777. package/external/folly/folly/synchronization/detail/Hardware.h +75 -0
  778. package/external/folly/folly/synchronization/detail/HazptrUtils.h +339 -0
  779. package/external/folly/folly/synchronization/detail/InlineFunctionRef.h +229 -0
  780. package/external/folly/folly/synchronization/detail/Sleeper.cpp +27 -0
  781. package/external/folly/folly/synchronization/detail/Sleeper.h +62 -0
  782. package/external/folly/folly/synchronization/detail/Spin.h +96 -0
  783. package/external/folly/folly/synchronization/detail/ThreadCachedLists.h +174 -0
  784. package/external/folly/folly/synchronization/detail/ThreadCachedReaders.h +189 -0
  785. package/external/folly/folly/synchronization/detail/ThreadCachedTag.h +26 -0
  786. package/external/folly/folly/synchronization/detail/test/BUCK +28 -0
  787. package/external/folly/folly/synchronization/detail/test/HardwareTest.cpp +74 -0
  788. package/external/folly/folly/synchronization/detail/test/InlineFunctionRefTest.cpp +286 -0
  789. package/external/folly/folly/synchronization/example/BUCK +27 -0
  790. package/external/folly/folly/synchronization/example/HazptrLockFreeLIFO.h +88 -0
  791. package/external/folly/folly/synchronization/example/HazptrSWMRSet.h +133 -0
  792. package/external/folly/folly/synchronization/example/HazptrWideCAS.h +62 -0
  793. package/external/folly/folly/synchronization/test/AtomicNotificationTest.cpp +236 -0
  794. package/external/folly/folly/synchronization/test/AtomicRefTest.cpp +170 -0
  795. package/external/folly/folly/synchronization/test/AtomicStructTest.cpp +65 -0
  796. package/external/folly/folly/synchronization/test/AtomicUtilBench.cpp +457 -0
  797. package/external/folly/folly/synchronization/test/AtomicUtilTest.cpp +650 -0
  798. package/external/folly/folly/synchronization/test/BUCK +495 -0
  799. package/external/folly/folly/synchronization/test/Barrier.h +52 -0
  800. package/external/folly/folly/synchronization/test/BarrierTest.cpp +56 -0
  801. package/external/folly/folly/synchronization/test/BatonBenchmark.cpp +77 -0
  802. package/external/folly/folly/synchronization/test/BatonTest.cpp +164 -0
  803. package/external/folly/folly/synchronization/test/BatonTestHelpers.h +118 -0
  804. package/external/folly/folly/synchronization/test/CallOnceBenchmark.cpp +72 -0
  805. package/external/folly/folly/synchronization/test/CallOnceTest.cpp +153 -0
  806. package/external/folly/folly/synchronization/test/DelayedInitTest.cpp +281 -0
  807. package/external/folly/folly/synchronization/test/DistributedMutexTest.cpp +2074 -0
  808. package/external/folly/folly/synchronization/test/EventCountTest.cpp +124 -0
  809. package/external/folly/folly/synchronization/test/FlatCombiningBenchmark.cpp +1789 -0
  810. package/external/folly/folly/synchronization/test/FlatCombiningExamples.h +222 -0
  811. package/external/folly/folly/synchronization/test/FlatCombiningTest.cpp +121 -0
  812. package/external/folly/folly/synchronization/test/FlatCombiningTestHelpers.h +227 -0
  813. package/external/folly/folly/synchronization/test/HazptrTest.cpp +1689 -0
  814. package/external/folly/folly/synchronization/test/LatchTest.cpp +224 -0
  815. package/external/folly/folly/synchronization/test/LifoSemBench.cpp +185 -0
  816. package/external/folly/folly/synchronization/test/LifoSemTests.cpp +353 -0
  817. package/external/folly/folly/synchronization/test/LockTest.cpp +1239 -0
  818. package/external/folly/folly/synchronization/test/NativeSemaphoreTest.cpp +37 -0
  819. package/external/folly/folly/synchronization/test/ParkingLotBenchmark.cpp +239 -0
  820. package/external/folly/folly/synchronization/test/ParkingLotTest.cpp +170 -0
  821. package/external/folly/folly/synchronization/test/RWSpinLockTest.cpp +235 -0
  822. package/external/folly/folly/synchronization/test/RcuBench.cpp +66 -0
  823. package/external/folly/folly/synchronization/test/RcuTest.cpp +330 -0
  824. package/external/folly/folly/synchronization/test/RelaxedAtomicTest.cpp +389 -0
  825. package/external/folly/folly/synchronization/test/SaturatingSemaphoreTest.cpp +166 -0
  826. package/external/folly/folly/synchronization/test/Semaphore.h +242 -0
  827. package/external/folly/folly/synchronization/test/SemaphoreTest.cpp +271 -0
  828. package/external/folly/folly/synchronization/test/SmallLocksBenchmark.cpp +1296 -0
  829. package/external/folly/folly/synchronization/test/SmallLocksTest.cpp +510 -0
  830. package/external/folly/folly/synchronization/test/ThreadCachedEpochBench.h +67 -0
  831. package/external/folly/folly/synchronization/test/ThreadCachedReadersBench.cpp +42 -0
  832. package/external/folly/folly/synchronization/test/ThreadCachedReadersTest.cpp +52 -0
  833. package/external/folly/folly/synchronization/test/ThrottledLifoSemTest.cpp +243 -0
  834. package/external/folly/folly/system/AtFork.cpp +205 -0
  835. package/external/folly/folly/system/AtFork.h +116 -0
  836. package/external/folly/folly/system/AuxVector.h +198 -0
  837. package/external/folly/folly/system/BUCK +144 -0
  838. package/external/folly/folly/system/EnvUtil.cpp +93 -0
  839. package/external/folly/folly/system/EnvUtil.h +113 -0
  840. package/external/folly/folly/system/HardwareConcurrency.cpp +39 -0
  841. package/external/folly/folly/system/HardwareConcurrency.h +23 -0
  842. package/external/folly/folly/system/MemoryMapping.cpp +477 -0
  843. package/external/folly/folly/system/MemoryMapping.h +287 -0
  844. package/external/folly/folly/system/Pid.cpp +87 -0
  845. package/external/folly/folly/system/Pid.h +34 -0
  846. package/external/folly/folly/system/Shell.cpp +33 -0
  847. package/external/folly/folly/system/Shell.h +93 -0
  848. package/external/folly/folly/system/ThreadId.cpp +89 -0
  849. package/external/folly/folly/system/ThreadId.h +62 -0
  850. package/external/folly/folly/system/ThreadName.cpp +330 -0
  851. package/external/folly/folly/system/ThreadName.h +72 -0
  852. package/external/folly/folly/system/test/AtForkTest.cpp +309 -0
  853. package/external/folly/folly/system/test/AuxVectorTest.cpp +55 -0
  854. package/external/folly/folly/system/test/BUCK +120 -0
  855. package/external/folly/folly/system/test/EnvUtilSubprocess.cpp +26 -0
  856. package/external/folly/folly/system/test/EnvUtilTest.cpp +197 -0
  857. package/external/folly/folly/system/test/MemoryMappingTest.cpp +179 -0
  858. package/external/folly/folly/system/test/PidTest.cpp +46 -0
  859. package/external/folly/folly/system/test/ShellTest.cpp +66 -0
  860. package/external/folly/folly/system/test/ThreadIdTest.cpp +114 -0
  861. package/external/folly/folly/system/test/ThreadNameTest.cpp +85 -0
  862. package/external/folly/folly.vcxitems +164 -0
  863. package/external/folly/sync-config.json +8 -0
  864. package/package.json +6 -6
  865. package/template/cpp-app/proj/MyApp.sln +0 -33
  866. package/template/cpp-lib/proj/MyLib.sln +0 -33
  867. package/template/cs-app/proj/MyApp.sln +0 -33
  868. package/template/cs-lib/proj/MyLib.sln +0 -33
  869. package/templates/cpp-app/windows/MyApp.sln +0 -33
  870. package/templates/cpp-lib/windows/MyLib.sln +0 -33
  871. package/Folly/Folly.vcxproj +0 -383
  872. package/Folly/Folly.vcxproj.filters +0 -558
  873. package/Folly/Folly.win32.vcxproj +0 -11
  874. package/Folly/packages.lock.win32.json +0 -20
  875. package/fmt/fmt.vcxproj +0 -163
  876. package/fmt/fmt.vcxproj.filters +0 -59
  877. package/fmt/fmt.win32.vcxproj +0 -10
  878. package/fmt/pch.cpp +0 -4
  879. package/fmt/pch.h +0 -2
  880. /package/{Folly → external/folly}/Folly.natvis +0 -0
  881. /package/{Folly → external/folly}/cgmanifest.json +0 -0
  882. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/ConstexprMath.h +0 -0
  883. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/Conv.cpp +0 -0
  884. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/chrono/Hardware.h +0 -0
  885. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/concurrency/CacheLocality.cpp +0 -0
  886. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/dynamic-inl.h +0 -0
  887. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/json/json.cpp +0 -0
  888. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/SafeAssert.h +0 -0
  889. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.cpp +0 -0
  890. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/lang/ToAscii.h +0 -0
  891. /package/{Folly/TEMP_UntilFollyUpdate → external/folly/folly}/portability/Unistd.cpp +0 -0
@@ -0,0 +1,2432 @@
1
+ // Formatting library for C++ - chrono support
2
+ //
3
+ // Copyright (c) 2012 - present, Victor Zverovich
4
+ // All rights reserved.
5
+ //
6
+ // For the license information refer to format.h.
7
+
8
+ #ifndef FMT_CHRONO_H_
9
+ #define FMT_CHRONO_H_
10
+
11
+ #ifndef FMT_MODULE
12
+ # include <algorithm>
13
+ # include <chrono>
14
+ # include <cmath> // std::isfinite
15
+ # include <cstring> // std::memcpy
16
+ # include <ctime>
17
+ # include <iterator>
18
+ # include <locale>
19
+ # include <ostream>
20
+ # include <type_traits>
21
+ #endif
22
+
23
+ #include "format.h"
24
+
25
+ FMT_BEGIN_NAMESPACE
26
+
27
+ // Check if std::chrono::local_t is available.
28
+ #ifndef FMT_USE_LOCAL_TIME
29
+ # ifdef __cpp_lib_chrono
30
+ # define FMT_USE_LOCAL_TIME (__cpp_lib_chrono >= 201907L)
31
+ # else
32
+ # define FMT_USE_LOCAL_TIME 0
33
+ # endif
34
+ #endif
35
+
36
+ // Check if std::chrono::utc_timestamp is available.
37
+ #ifndef FMT_USE_UTC_TIME
38
+ # ifdef __cpp_lib_chrono
39
+ # define FMT_USE_UTC_TIME (__cpp_lib_chrono >= 201907L)
40
+ # else
41
+ # define FMT_USE_UTC_TIME 0
42
+ # endif
43
+ #endif
44
+
45
+ // Enable tzset.
46
+ #ifndef FMT_USE_TZSET
47
+ // UWP doesn't provide _tzset.
48
+ # if FMT_HAS_INCLUDE("winapifamily.h")
49
+ # include <winapifamily.h>
50
+ # endif
51
+ # if defined(_WIN32) && (!defined(WINAPI_FAMILY) || \
52
+ (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
53
+ # define FMT_USE_TZSET 1
54
+ # else
55
+ # define FMT_USE_TZSET 0
56
+ # endif
57
+ #endif
58
+
59
+ // Enable safe chrono durations, unless explicitly disabled.
60
+ #ifndef FMT_SAFE_DURATION_CAST
61
+ # define FMT_SAFE_DURATION_CAST 1
62
+ #endif
63
+ #if FMT_SAFE_DURATION_CAST
64
+
65
+ // For conversion between std::chrono::durations without undefined
66
+ // behaviour or erroneous results.
67
+ // This is a stripped down version of duration_cast, for inclusion in fmt.
68
+ // See https://github.com/pauldreik/safe_duration_cast
69
+ //
70
+ // Copyright Paul Dreik 2019
71
+ namespace safe_duration_cast {
72
+
73
+ template <typename To, typename From,
74
+ FMT_ENABLE_IF(!std::is_same<From, To>::value &&
75
+ std::numeric_limits<From>::is_signed ==
76
+ std::numeric_limits<To>::is_signed)>
77
+ FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
78
+ -> To {
79
+ ec = 0;
80
+ using F = std::numeric_limits<From>;
81
+ using T = std::numeric_limits<To>;
82
+ static_assert(F::is_integer, "From must be integral");
83
+ static_assert(T::is_integer, "To must be integral");
84
+
85
+ // A and B are both signed, or both unsigned.
86
+ if (detail::const_check(F::digits <= T::digits)) {
87
+ // From fits in To without any problem.
88
+ } else {
89
+ // From does not always fit in To, resort to a dynamic check.
90
+ if (from < (T::min)() || from > (T::max)()) {
91
+ // outside range.
92
+ ec = 1;
93
+ return {};
94
+ }
95
+ }
96
+ return static_cast<To>(from);
97
+ }
98
+
99
+ /// Converts From to To, without loss. If the dynamic value of from
100
+ /// can't be converted to To without loss, ec is set.
101
+ template <typename To, typename From,
102
+ FMT_ENABLE_IF(!std::is_same<From, To>::value &&
103
+ std::numeric_limits<From>::is_signed !=
104
+ std::numeric_limits<To>::is_signed)>
105
+ FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
106
+ -> To {
107
+ ec = 0;
108
+ using F = std::numeric_limits<From>;
109
+ using T = std::numeric_limits<To>;
110
+ static_assert(F::is_integer, "From must be integral");
111
+ static_assert(T::is_integer, "To must be integral");
112
+
113
+ if (detail::const_check(F::is_signed && !T::is_signed)) {
114
+ // From may be negative, not allowed!
115
+ if (fmt::detail::is_negative(from)) {
116
+ ec = 1;
117
+ return {};
118
+ }
119
+ // From is positive. Can it always fit in To?
120
+ if (detail::const_check(F::digits > T::digits) &&
121
+ from > static_cast<From>(detail::max_value<To>())) {
122
+ ec = 1;
123
+ return {};
124
+ }
125
+ }
126
+
127
+ if (detail::const_check(!F::is_signed && T::is_signed &&
128
+ F::digits >= T::digits) &&
129
+ from > static_cast<From>(detail::max_value<To>())) {
130
+ ec = 1;
131
+ return {};
132
+ }
133
+ return static_cast<To>(from); // Lossless conversion.
134
+ }
135
+
136
+ template <typename To, typename From,
137
+ FMT_ENABLE_IF(std::is_same<From, To>::value)>
138
+ FMT_CONSTEXPR auto lossless_integral_conversion(const From from, int& ec)
139
+ -> To {
140
+ ec = 0;
141
+ return from;
142
+ } // function
143
+
144
+ // clang-format off
145
+ /**
146
+ * converts From to To if possible, otherwise ec is set.
147
+ *
148
+ * input | output
149
+ * ---------------------------------|---------------
150
+ * NaN | NaN
151
+ * Inf | Inf
152
+ * normal, fits in output | converted (possibly lossy)
153
+ * normal, does not fit in output | ec is set
154
+ * subnormal | best effort
155
+ * -Inf | -Inf
156
+ */
157
+ // clang-format on
158
+ template <typename To, typename From,
159
+ FMT_ENABLE_IF(!std::is_same<From, To>::value)>
160
+ FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {
161
+ ec = 0;
162
+ using T = std::numeric_limits<To>;
163
+ static_assert(std::is_floating_point<From>::value, "From must be floating");
164
+ static_assert(std::is_floating_point<To>::value, "To must be floating");
165
+
166
+ // catch the only happy case
167
+ if (std::isfinite(from)) {
168
+ if (from >= T::lowest() && from <= (T::max)()) {
169
+ return static_cast<To>(from);
170
+ }
171
+ // not within range.
172
+ ec = 1;
173
+ return {};
174
+ }
175
+
176
+ // nan and inf will be preserved
177
+ return static_cast<To>(from);
178
+ } // function
179
+
180
+ template <typename To, typename From,
181
+ FMT_ENABLE_IF(std::is_same<From, To>::value)>
182
+ FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {
183
+ ec = 0;
184
+ static_assert(std::is_floating_point<From>::value, "From must be floating");
185
+ return from;
186
+ }
187
+
188
+ /// Safe duration cast between integral durations
189
+ template <typename To, typename FromRep, typename FromPeriod,
190
+ FMT_ENABLE_IF(std::is_integral<FromRep>::value),
191
+ FMT_ENABLE_IF(std::is_integral<typename To::rep>::value)>
192
+ auto safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
193
+ int& ec) -> To {
194
+ using From = std::chrono::duration<FromRep, FromPeriod>;
195
+ ec = 0;
196
+ // the basic idea is that we need to convert from count() in the from type
197
+ // to count() in the To type, by multiplying it with this:
198
+ struct Factor
199
+ : std::ratio_divide<typename From::period, typename To::period> {};
200
+
201
+ static_assert(Factor::num > 0, "num must be positive");
202
+ static_assert(Factor::den > 0, "den must be positive");
203
+
204
+ // the conversion is like this: multiply from.count() with Factor::num
205
+ // /Factor::den and convert it to To::rep, all this without
206
+ // overflow/underflow. let's start by finding a suitable type that can hold
207
+ // both To, From and Factor::num
208
+ using IntermediateRep =
209
+ typename std::common_type<typename From::rep, typename To::rep,
210
+ decltype(Factor::num)>::type;
211
+
212
+ // safe conversion to IntermediateRep
213
+ IntermediateRep count =
214
+ lossless_integral_conversion<IntermediateRep>(from.count(), ec);
215
+ if (ec) return {};
216
+ // multiply with Factor::num without overflow or underflow
217
+ if (detail::const_check(Factor::num != 1)) {
218
+ const auto max1 = detail::max_value<IntermediateRep>() / Factor::num;
219
+ if (count > max1) {
220
+ ec = 1;
221
+ return {};
222
+ }
223
+ const auto min1 =
224
+ (std::numeric_limits<IntermediateRep>::min)() / Factor::num;
225
+ if (detail::const_check(!std::is_unsigned<IntermediateRep>::value) &&
226
+ count < min1) {
227
+ ec = 1;
228
+ return {};
229
+ }
230
+ count *= Factor::num;
231
+ }
232
+
233
+ if (detail::const_check(Factor::den != 1)) count /= Factor::den;
234
+ auto tocount = lossless_integral_conversion<typename To::rep>(count, ec);
235
+ return ec ? To() : To(tocount);
236
+ }
237
+
238
+ /// Safe duration_cast between floating point durations
239
+ template <typename To, typename FromRep, typename FromPeriod,
240
+ FMT_ENABLE_IF(std::is_floating_point<FromRep>::value),
241
+ FMT_ENABLE_IF(std::is_floating_point<typename To::rep>::value)>
242
+ auto safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
243
+ int& ec) -> To {
244
+ using From = std::chrono::duration<FromRep, FromPeriod>;
245
+ ec = 0;
246
+ if (std::isnan(from.count())) {
247
+ // nan in, gives nan out. easy.
248
+ return To{std::numeric_limits<typename To::rep>::quiet_NaN()};
249
+ }
250
+ // maybe we should also check if from is denormal, and decide what to do about
251
+ // it.
252
+
253
+ // +-inf should be preserved.
254
+ if (std::isinf(from.count())) {
255
+ return To{from.count()};
256
+ }
257
+
258
+ // the basic idea is that we need to convert from count() in the from type
259
+ // to count() in the To type, by multiplying it with this:
260
+ struct Factor
261
+ : std::ratio_divide<typename From::period, typename To::period> {};
262
+
263
+ static_assert(Factor::num > 0, "num must be positive");
264
+ static_assert(Factor::den > 0, "den must be positive");
265
+
266
+ // the conversion is like this: multiply from.count() with Factor::num
267
+ // /Factor::den and convert it to To::rep, all this without
268
+ // overflow/underflow. let's start by finding a suitable type that can hold
269
+ // both To, From and Factor::num
270
+ using IntermediateRep =
271
+ typename std::common_type<typename From::rep, typename To::rep,
272
+ decltype(Factor::num)>::type;
273
+
274
+ // force conversion of From::rep -> IntermediateRep to be safe,
275
+ // even if it will never happen be narrowing in this context.
276
+ IntermediateRep count =
277
+ safe_float_conversion<IntermediateRep>(from.count(), ec);
278
+ if (ec) {
279
+ return {};
280
+ }
281
+
282
+ // multiply with Factor::num without overflow or underflow
283
+ if (detail::const_check(Factor::num != 1)) {
284
+ constexpr auto max1 = detail::max_value<IntermediateRep>() /
285
+ static_cast<IntermediateRep>(Factor::num);
286
+ if (count > max1) {
287
+ ec = 1;
288
+ return {};
289
+ }
290
+ constexpr auto min1 = std::numeric_limits<IntermediateRep>::lowest() /
291
+ static_cast<IntermediateRep>(Factor::num);
292
+ if (count < min1) {
293
+ ec = 1;
294
+ return {};
295
+ }
296
+ count *= static_cast<IntermediateRep>(Factor::num);
297
+ }
298
+
299
+ // this can't go wrong, right? den>0 is checked earlier.
300
+ if (detail::const_check(Factor::den != 1)) {
301
+ using common_t = typename std::common_type<IntermediateRep, intmax_t>::type;
302
+ count /= static_cast<common_t>(Factor::den);
303
+ }
304
+
305
+ // convert to the to type, safely
306
+ using ToRep = typename To::rep;
307
+
308
+ const ToRep tocount = safe_float_conversion<ToRep>(count, ec);
309
+ if (ec) {
310
+ return {};
311
+ }
312
+ return To{tocount};
313
+ }
314
+ } // namespace safe_duration_cast
315
+ #endif
316
+
317
+ // Prevents expansion of a preceding token as a function-style macro.
318
+ // Usage: f FMT_NOMACRO()
319
+ #define FMT_NOMACRO
320
+
321
+ namespace detail {
322
+ template <typename T = void> struct null {};
323
+ inline auto localtime_r FMT_NOMACRO(...) -> null<> { return null<>(); }
324
+ inline auto localtime_s(...) -> null<> { return null<>(); }
325
+ inline auto gmtime_r(...) -> null<> { return null<>(); }
326
+ inline auto gmtime_s(...) -> null<> { return null<>(); }
327
+
328
+ // It is defined here and not in ostream.h because the latter has expensive
329
+ // includes.
330
+ template <typename Streambuf> class formatbuf : public Streambuf {
331
+ private:
332
+ using char_type = typename Streambuf::char_type;
333
+ using streamsize = decltype(std::declval<Streambuf>().sputn(nullptr, 0));
334
+ using int_type = typename Streambuf::int_type;
335
+ using traits_type = typename Streambuf::traits_type;
336
+
337
+ buffer<char_type>& buffer_;
338
+
339
+ public:
340
+ explicit formatbuf(buffer<char_type>& buf) : buffer_(buf) {}
341
+
342
+ protected:
343
+ // The put area is always empty. This makes the implementation simpler and has
344
+ // the advantage that the streambuf and the buffer are always in sync and
345
+ // sputc never writes into uninitialized memory. A disadvantage is that each
346
+ // call to sputc always results in a (virtual) call to overflow. There is no
347
+ // disadvantage here for sputn since this always results in a call to xsputn.
348
+
349
+ auto overflow(int_type ch) -> int_type override {
350
+ if (!traits_type::eq_int_type(ch, traits_type::eof()))
351
+ buffer_.push_back(static_cast<char_type>(ch));
352
+ return ch;
353
+ }
354
+
355
+ auto xsputn(const char_type* s, streamsize count) -> streamsize override {
356
+ buffer_.append(s, s + count);
357
+ return count;
358
+ }
359
+ };
360
+
361
+ inline auto get_classic_locale() -> const std::locale& {
362
+ static const auto& locale = std::locale::classic();
363
+ return locale;
364
+ }
365
+
366
+ template <typename CodeUnit> struct codecvt_result {
367
+ static constexpr const size_t max_size = 32;
368
+ CodeUnit buf[max_size];
369
+ CodeUnit* end;
370
+ };
371
+
372
+ template <typename CodeUnit>
373
+ void write_codecvt(codecvt_result<CodeUnit>& out, string_view in_buf,
374
+ const std::locale& loc) {
375
+ #if FMT_CLANG_VERSION
376
+ # pragma clang diagnostic push
377
+ # pragma clang diagnostic ignored "-Wdeprecated"
378
+ auto& f = std::use_facet<std::codecvt<CodeUnit, char, std::mbstate_t>>(loc);
379
+ # pragma clang diagnostic pop
380
+ #else
381
+ auto& f = std::use_facet<std::codecvt<CodeUnit, char, std::mbstate_t>>(loc);
382
+ #endif
383
+ auto mb = std::mbstate_t();
384
+ const char* from_next = nullptr;
385
+ auto result = f.in(mb, in_buf.begin(), in_buf.end(), from_next,
386
+ std::begin(out.buf), std::end(out.buf), out.end);
387
+ if (result != std::codecvt_base::ok)
388
+ FMT_THROW(format_error("failed to format time"));
389
+ }
390
+
391
+ template <typename OutputIt>
392
+ auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
393
+ -> OutputIt {
394
+ if (detail::use_utf8() && loc != get_classic_locale()) {
395
+ // char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
396
+ // gcc-4.
397
+ #if FMT_MSC_VERSION != 0 || \
398
+ (defined(__GLIBCXX__) && \
399
+ (!defined(_GLIBCXX_USE_DUAL_ABI) || _GLIBCXX_USE_DUAL_ABI == 0))
400
+ // The _GLIBCXX_USE_DUAL_ABI macro is always defined in libstdc++ from gcc-5
401
+ // and newer.
402
+ using code_unit = wchar_t;
403
+ #else
404
+ using code_unit = char32_t;
405
+ #endif
406
+
407
+ using unit_t = codecvt_result<code_unit>;
408
+ unit_t unit;
409
+ write_codecvt(unit, in, loc);
410
+ // In UTF-8 is used one to four one-byte code units.
411
+ auto u =
412
+ to_utf8<code_unit, basic_memory_buffer<char, unit_t::max_size * 4>>();
413
+ if (!u.convert({unit.buf, to_unsigned(unit.end - unit.buf)}))
414
+ FMT_THROW(format_error("failed to format time"));
415
+ return copy<char>(u.c_str(), u.c_str() + u.size(), out);
416
+ }
417
+ return copy<char>(in.data(), in.data() + in.size(), out);
418
+ }
419
+
420
+ template <typename Char, typename OutputIt,
421
+ FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
422
+ auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
423
+ -> OutputIt {
424
+ codecvt_result<Char> unit;
425
+ write_codecvt(unit, sv, loc);
426
+ return copy<Char>(unit.buf, unit.end, out);
427
+ }
428
+
429
+ template <typename Char, typename OutputIt,
430
+ FMT_ENABLE_IF(std::is_same<Char, char>::value)>
431
+ auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
432
+ -> OutputIt {
433
+ return write_encoded_tm_str(out, sv, loc);
434
+ }
435
+
436
+ template <typename Char>
437
+ inline void do_write(buffer<Char>& buf, const std::tm& time,
438
+ const std::locale& loc, char format, char modifier) {
439
+ auto&& format_buf = formatbuf<std::basic_streambuf<Char>>(buf);
440
+ auto&& os = std::basic_ostream<Char>(&format_buf);
441
+ os.imbue(loc);
442
+ const auto& facet = std::use_facet<std::time_put<Char>>(loc);
443
+ auto end = facet.put(os, os, Char(' '), &time, format, modifier);
444
+ if (end.failed()) FMT_THROW(format_error("failed to format time"));
445
+ }
446
+
447
+ template <typename Char, typename OutputIt,
448
+ FMT_ENABLE_IF(!std::is_same<Char, char>::value)>
449
+ auto write(OutputIt out, const std::tm& time, const std::locale& loc,
450
+ char format, char modifier = 0) -> OutputIt {
451
+ auto&& buf = get_buffer<Char>(out);
452
+ do_write<Char>(buf, time, loc, format, modifier);
453
+ return get_iterator(buf, out);
454
+ }
455
+
456
+ template <typename Char, typename OutputIt,
457
+ FMT_ENABLE_IF(std::is_same<Char, char>::value)>
458
+ auto write(OutputIt out, const std::tm& time, const std::locale& loc,
459
+ char format, char modifier = 0) -> OutputIt {
460
+ auto&& buf = basic_memory_buffer<Char>();
461
+ do_write<char>(buf, time, loc, format, modifier);
462
+ return write_encoded_tm_str(out, string_view(buf.data(), buf.size()), loc);
463
+ }
464
+
465
+ template <typename Rep1, typename Rep2>
466
+ struct is_same_arithmetic_type
467
+ : public std::integral_constant<bool,
468
+ (std::is_integral<Rep1>::value &&
469
+ std::is_integral<Rep2>::value) ||
470
+ (std::is_floating_point<Rep1>::value &&
471
+ std::is_floating_point<Rep2>::value)> {
472
+ };
473
+
474
+ template <
475
+ typename To, typename FromRep, typename FromPeriod,
476
+ FMT_ENABLE_IF(is_same_arithmetic_type<FromRep, typename To::rep>::value)>
477
+ auto fmt_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
478
+ #if FMT_SAFE_DURATION_CAST
479
+ // Throwing version of safe_duration_cast is only available for
480
+ // integer to integer or float to float casts.
481
+ int ec;
482
+ To to = safe_duration_cast::safe_duration_cast<To>(from, ec);
483
+ if (ec) FMT_THROW(format_error("cannot format duration"));
484
+ return to;
485
+ #else
486
+ // Standard duration cast, may overflow.
487
+ return std::chrono::duration_cast<To>(from);
488
+ #endif
489
+ }
490
+
491
+ template <
492
+ typename To, typename FromRep, typename FromPeriod,
493
+ FMT_ENABLE_IF(!is_same_arithmetic_type<FromRep, typename To::rep>::value)>
494
+ auto fmt_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
495
+ // Mixed integer <-> float cast is not supported by safe_duration_cast.
496
+ return std::chrono::duration_cast<To>(from);
497
+ }
498
+
499
+ template <typename Duration>
500
+ auto to_time_t(
501
+ std::chrono::time_point<std::chrono::system_clock, Duration> time_point)
502
+ -> std::time_t {
503
+ // Cannot use std::chrono::system_clock::to_time_t since this would first
504
+ // require a cast to std::chrono::system_clock::time_point, which could
505
+ // overflow.
506
+ return fmt_duration_cast<std::chrono::duration<std::time_t>>(
507
+ time_point.time_since_epoch())
508
+ .count();
509
+ }
510
+ } // namespace detail
511
+
512
+ FMT_BEGIN_EXPORT
513
+
514
+ /**
515
+ * Converts given time since epoch as `std::time_t` value into calendar time,
516
+ * expressed in local time. Unlike `std::localtime`, this function is
517
+ * thread-safe on most platforms.
518
+ */
519
+ inline auto localtime(std::time_t time) -> std::tm {
520
+ struct dispatcher {
521
+ std::time_t time_;
522
+ std::tm tm_;
523
+
524
+ dispatcher(std::time_t t) : time_(t) {}
525
+
526
+ auto run() -> bool {
527
+ using namespace fmt::detail;
528
+ return handle(localtime_r(&time_, &tm_));
529
+ }
530
+
531
+ auto handle(std::tm* tm) -> bool { return tm != nullptr; }
532
+
533
+ auto handle(detail::null<>) -> bool {
534
+ using namespace fmt::detail;
535
+ return fallback(localtime_s(&tm_, &time_));
536
+ }
537
+
538
+ auto fallback(int res) -> bool { return res == 0; }
539
+
540
+ #if !FMT_MSC_VERSION
541
+ auto fallback(detail::null<>) -> bool {
542
+ using namespace fmt::detail;
543
+ std::tm* tm = std::localtime(&time_);
544
+ if (tm) tm_ = *tm;
545
+ return tm != nullptr;
546
+ }
547
+ #endif
548
+ };
549
+ dispatcher lt(time);
550
+ // Too big time values may be unsupported.
551
+ if (!lt.run()) FMT_THROW(format_error("time_t value out of range"));
552
+ return lt.tm_;
553
+ }
554
+
555
+ #if FMT_USE_LOCAL_TIME
556
+ template <typename Duration>
557
+ inline auto localtime(std::chrono::local_time<Duration> time) -> std::tm {
558
+ return localtime(
559
+ detail::to_time_t(std::chrono::current_zone()->to_sys(time)));
560
+ }
561
+ #endif
562
+
563
+ /**
564
+ * Converts given time since epoch as `std::time_t` value into calendar time,
565
+ * expressed in Coordinated Universal Time (UTC). Unlike `std::gmtime`, this
566
+ * function is thread-safe on most platforms.
567
+ */
568
+ inline auto gmtime(std::time_t time) -> std::tm {
569
+ struct dispatcher {
570
+ std::time_t time_;
571
+ std::tm tm_;
572
+
573
+ dispatcher(std::time_t t) : time_(t) {}
574
+
575
+ auto run() -> bool {
576
+ using namespace fmt::detail;
577
+ return handle(gmtime_r(&time_, &tm_));
578
+ }
579
+
580
+ auto handle(std::tm* tm) -> bool { return tm != nullptr; }
581
+
582
+ auto handle(detail::null<>) -> bool {
583
+ using namespace fmt::detail;
584
+ return fallback(gmtime_s(&tm_, &time_));
585
+ }
586
+
587
+ auto fallback(int res) -> bool { return res == 0; }
588
+
589
+ #if !FMT_MSC_VERSION
590
+ auto fallback(detail::null<>) -> bool {
591
+ std::tm* tm = std::gmtime(&time_);
592
+ if (tm) tm_ = *tm;
593
+ return tm != nullptr;
594
+ }
595
+ #endif
596
+ };
597
+ auto gt = dispatcher(time);
598
+ // Too big time values may be unsupported.
599
+ if (!gt.run()) FMT_THROW(format_error("time_t value out of range"));
600
+ return gt.tm_;
601
+ }
602
+
603
+ template <typename Duration>
604
+ inline auto gmtime(
605
+ std::chrono::time_point<std::chrono::system_clock, Duration> time_point)
606
+ -> std::tm {
607
+ return gmtime(detail::to_time_t(time_point));
608
+ }
609
+
610
+ namespace detail {
611
+
612
+ // Writes two-digit numbers a, b and c separated by sep to buf.
613
+ // The method by Pavel Novikov based on
614
+ // https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/.
615
+ inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
616
+ unsigned c, char sep) {
617
+ unsigned long long digits =
618
+ a | (b << 24) | (static_cast<unsigned long long>(c) << 48);
619
+ // Convert each value to BCD.
620
+ // We have x = a * 10 + b and we want to convert it to BCD y = a * 16 + b.
621
+ // The difference is
622
+ // y - x = a * 6
623
+ // a can be found from x:
624
+ // a = floor(x / 10)
625
+ // then
626
+ // y = x + a * 6 = x + floor(x / 10) * 6
627
+ // floor(x / 10) is (x * 205) >> 11 (needs 16 bits).
628
+ digits += (((digits * 205) >> 11) & 0x000f00000f00000f) * 6;
629
+ // Put low nibbles to high bytes and high nibbles to low bytes.
630
+ digits = ((digits & 0x00f00000f00000f0) >> 4) |
631
+ ((digits & 0x000f00000f00000f) << 8);
632
+ auto usep = static_cast<unsigned long long>(sep);
633
+ // Add ASCII '0' to each digit byte and insert separators.
634
+ digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
635
+
636
+ constexpr const size_t len = 8;
637
+ if (const_check(is_big_endian())) {
638
+ char tmp[len];
639
+ std::memcpy(tmp, &digits, len);
640
+ std::reverse_copy(tmp, tmp + len, buf);
641
+ } else {
642
+ std::memcpy(buf, &digits, len);
643
+ }
644
+ }
645
+
646
+ template <typename Period>
647
+ FMT_CONSTEXPR inline auto get_units() -> const char* {
648
+ if (std::is_same<Period, std::atto>::value) return "as";
649
+ if (std::is_same<Period, std::femto>::value) return "fs";
650
+ if (std::is_same<Period, std::pico>::value) return "ps";
651
+ if (std::is_same<Period, std::nano>::value) return "ns";
652
+ if (std::is_same<Period, std::micro>::value) return "µs";
653
+ if (std::is_same<Period, std::milli>::value) return "ms";
654
+ if (std::is_same<Period, std::centi>::value) return "cs";
655
+ if (std::is_same<Period, std::deci>::value) return "ds";
656
+ if (std::is_same<Period, std::ratio<1>>::value) return "s";
657
+ if (std::is_same<Period, std::deca>::value) return "das";
658
+ if (std::is_same<Period, std::hecto>::value) return "hs";
659
+ if (std::is_same<Period, std::kilo>::value) return "ks";
660
+ if (std::is_same<Period, std::mega>::value) return "Ms";
661
+ if (std::is_same<Period, std::giga>::value) return "Gs";
662
+ if (std::is_same<Period, std::tera>::value) return "Ts";
663
+ if (std::is_same<Period, std::peta>::value) return "Ps";
664
+ if (std::is_same<Period, std::exa>::value) return "Es";
665
+ if (std::is_same<Period, std::ratio<60>>::value) return "min";
666
+ if (std::is_same<Period, std::ratio<3600>>::value) return "h";
667
+ if (std::is_same<Period, std::ratio<86400>>::value) return "d";
668
+ return nullptr;
669
+ }
670
+
671
+ enum class numeric_system {
672
+ standard,
673
+ // Alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale.
674
+ alternative
675
+ };
676
+
677
+ // Glibc extensions for formatting numeric values.
678
+ enum class pad_type {
679
+ // Pad a numeric result string with zeros (the default).
680
+ zero,
681
+ // Do not pad a numeric result string.
682
+ none,
683
+ // Pad a numeric result string with spaces.
684
+ space,
685
+ };
686
+
687
+ template <typename OutputIt>
688
+ auto write_padding(OutputIt out, pad_type pad, int width) -> OutputIt {
689
+ if (pad == pad_type::none) return out;
690
+ return detail::fill_n(out, width, pad == pad_type::space ? ' ' : '0');
691
+ }
692
+
693
+ template <typename OutputIt>
694
+ auto write_padding(OutputIt out, pad_type pad) -> OutputIt {
695
+ if (pad != pad_type::none) *out++ = pad == pad_type::space ? ' ' : '0';
696
+ return out;
697
+ }
698
+
699
+ // Parses a put_time-like format string and invokes handler actions.
700
+ template <typename Char, typename Handler>
701
+ FMT_CONSTEXPR auto parse_chrono_format(const Char* begin, const Char* end,
702
+ Handler&& handler) -> const Char* {
703
+ if (begin == end || *begin == '}') return begin;
704
+ if (*begin != '%') FMT_THROW(format_error("invalid format"));
705
+ auto ptr = begin;
706
+ while (ptr != end) {
707
+ pad_type pad = pad_type::zero;
708
+ auto c = *ptr;
709
+ if (c == '}') break;
710
+ if (c != '%') {
711
+ ++ptr;
712
+ continue;
713
+ }
714
+ if (begin != ptr) handler.on_text(begin, ptr);
715
+ ++ptr; // consume '%'
716
+ if (ptr == end) FMT_THROW(format_error("invalid format"));
717
+ c = *ptr;
718
+ switch (c) {
719
+ case '_':
720
+ pad = pad_type::space;
721
+ ++ptr;
722
+ break;
723
+ case '-':
724
+ pad = pad_type::none;
725
+ ++ptr;
726
+ break;
727
+ }
728
+ if (ptr == end) FMT_THROW(format_error("invalid format"));
729
+ c = *ptr++;
730
+ switch (c) {
731
+ case '%':
732
+ handler.on_text(ptr - 1, ptr);
733
+ break;
734
+ case 'n': {
735
+ const Char newline[] = {'\n'};
736
+ handler.on_text(newline, newline + 1);
737
+ break;
738
+ }
739
+ case 't': {
740
+ const Char tab[] = {'\t'};
741
+ handler.on_text(tab, tab + 1);
742
+ break;
743
+ }
744
+ // Year:
745
+ case 'Y':
746
+ handler.on_year(numeric_system::standard);
747
+ break;
748
+ case 'y':
749
+ handler.on_short_year(numeric_system::standard);
750
+ break;
751
+ case 'C':
752
+ handler.on_century(numeric_system::standard);
753
+ break;
754
+ case 'G':
755
+ handler.on_iso_week_based_year();
756
+ break;
757
+ case 'g':
758
+ handler.on_iso_week_based_short_year();
759
+ break;
760
+ // Day of the week:
761
+ case 'a':
762
+ handler.on_abbr_weekday();
763
+ break;
764
+ case 'A':
765
+ handler.on_full_weekday();
766
+ break;
767
+ case 'w':
768
+ handler.on_dec0_weekday(numeric_system::standard);
769
+ break;
770
+ case 'u':
771
+ handler.on_dec1_weekday(numeric_system::standard);
772
+ break;
773
+ // Month:
774
+ case 'b':
775
+ case 'h':
776
+ handler.on_abbr_month();
777
+ break;
778
+ case 'B':
779
+ handler.on_full_month();
780
+ break;
781
+ case 'm':
782
+ handler.on_dec_month(numeric_system::standard);
783
+ break;
784
+ // Day of the year/month:
785
+ case 'U':
786
+ handler.on_dec0_week_of_year(numeric_system::standard, pad);
787
+ break;
788
+ case 'W':
789
+ handler.on_dec1_week_of_year(numeric_system::standard, pad);
790
+ break;
791
+ case 'V':
792
+ handler.on_iso_week_of_year(numeric_system::standard, pad);
793
+ break;
794
+ case 'j':
795
+ handler.on_day_of_year();
796
+ break;
797
+ case 'd':
798
+ handler.on_day_of_month(numeric_system::standard, pad);
799
+ break;
800
+ case 'e':
801
+ handler.on_day_of_month(numeric_system::standard, pad_type::space);
802
+ break;
803
+ // Hour, minute, second:
804
+ case 'H':
805
+ handler.on_24_hour(numeric_system::standard, pad);
806
+ break;
807
+ case 'I':
808
+ handler.on_12_hour(numeric_system::standard, pad);
809
+ break;
810
+ case 'M':
811
+ handler.on_minute(numeric_system::standard, pad);
812
+ break;
813
+ case 'S':
814
+ handler.on_second(numeric_system::standard, pad);
815
+ break;
816
+ // Other:
817
+ case 'c':
818
+ handler.on_datetime(numeric_system::standard);
819
+ break;
820
+ case 'x':
821
+ handler.on_loc_date(numeric_system::standard);
822
+ break;
823
+ case 'X':
824
+ handler.on_loc_time(numeric_system::standard);
825
+ break;
826
+ case 'D':
827
+ handler.on_us_date();
828
+ break;
829
+ case 'F':
830
+ handler.on_iso_date();
831
+ break;
832
+ case 'r':
833
+ handler.on_12_hour_time();
834
+ break;
835
+ case 'R':
836
+ handler.on_24_hour_time();
837
+ break;
838
+ case 'T':
839
+ handler.on_iso_time();
840
+ break;
841
+ case 'p':
842
+ handler.on_am_pm();
843
+ break;
844
+ case 'Q':
845
+ handler.on_duration_value();
846
+ break;
847
+ case 'q':
848
+ handler.on_duration_unit();
849
+ break;
850
+ case 'z':
851
+ handler.on_utc_offset(numeric_system::standard);
852
+ break;
853
+ case 'Z':
854
+ handler.on_tz_name();
855
+ break;
856
+ // Alternative representation:
857
+ case 'E': {
858
+ if (ptr == end) FMT_THROW(format_error("invalid format"));
859
+ c = *ptr++;
860
+ switch (c) {
861
+ case 'Y':
862
+ handler.on_year(numeric_system::alternative);
863
+ break;
864
+ case 'y':
865
+ handler.on_offset_year();
866
+ break;
867
+ case 'C':
868
+ handler.on_century(numeric_system::alternative);
869
+ break;
870
+ case 'c':
871
+ handler.on_datetime(numeric_system::alternative);
872
+ break;
873
+ case 'x':
874
+ handler.on_loc_date(numeric_system::alternative);
875
+ break;
876
+ case 'X':
877
+ handler.on_loc_time(numeric_system::alternative);
878
+ break;
879
+ case 'z':
880
+ handler.on_utc_offset(numeric_system::alternative);
881
+ break;
882
+ default:
883
+ FMT_THROW(format_error("invalid format"));
884
+ }
885
+ break;
886
+ }
887
+ case 'O':
888
+ if (ptr == end) FMT_THROW(format_error("invalid format"));
889
+ c = *ptr++;
890
+ switch (c) {
891
+ case 'y':
892
+ handler.on_short_year(numeric_system::alternative);
893
+ break;
894
+ case 'm':
895
+ handler.on_dec_month(numeric_system::alternative);
896
+ break;
897
+ case 'U':
898
+ handler.on_dec0_week_of_year(numeric_system::alternative, pad);
899
+ break;
900
+ case 'W':
901
+ handler.on_dec1_week_of_year(numeric_system::alternative, pad);
902
+ break;
903
+ case 'V':
904
+ handler.on_iso_week_of_year(numeric_system::alternative, pad);
905
+ break;
906
+ case 'd':
907
+ handler.on_day_of_month(numeric_system::alternative, pad);
908
+ break;
909
+ case 'e':
910
+ handler.on_day_of_month(numeric_system::alternative, pad_type::space);
911
+ break;
912
+ case 'w':
913
+ handler.on_dec0_weekday(numeric_system::alternative);
914
+ break;
915
+ case 'u':
916
+ handler.on_dec1_weekday(numeric_system::alternative);
917
+ break;
918
+ case 'H':
919
+ handler.on_24_hour(numeric_system::alternative, pad);
920
+ break;
921
+ case 'I':
922
+ handler.on_12_hour(numeric_system::alternative, pad);
923
+ break;
924
+ case 'M':
925
+ handler.on_minute(numeric_system::alternative, pad);
926
+ break;
927
+ case 'S':
928
+ handler.on_second(numeric_system::alternative, pad);
929
+ break;
930
+ case 'z':
931
+ handler.on_utc_offset(numeric_system::alternative);
932
+ break;
933
+ default:
934
+ FMT_THROW(format_error("invalid format"));
935
+ }
936
+ break;
937
+ default:
938
+ FMT_THROW(format_error("invalid format"));
939
+ }
940
+ begin = ptr;
941
+ }
942
+ if (begin != ptr) handler.on_text(begin, ptr);
943
+ return ptr;
944
+ }
945
+
946
+ template <typename Derived> struct null_chrono_spec_handler {
947
+ FMT_CONSTEXPR void unsupported() {
948
+ static_cast<Derived*>(this)->unsupported();
949
+ }
950
+ FMT_CONSTEXPR void on_year(numeric_system) { unsupported(); }
951
+ FMT_CONSTEXPR void on_short_year(numeric_system) { unsupported(); }
952
+ FMT_CONSTEXPR void on_offset_year() { unsupported(); }
953
+ FMT_CONSTEXPR void on_century(numeric_system) { unsupported(); }
954
+ FMT_CONSTEXPR void on_iso_week_based_year() { unsupported(); }
955
+ FMT_CONSTEXPR void on_iso_week_based_short_year() { unsupported(); }
956
+ FMT_CONSTEXPR void on_abbr_weekday() { unsupported(); }
957
+ FMT_CONSTEXPR void on_full_weekday() { unsupported(); }
958
+ FMT_CONSTEXPR void on_dec0_weekday(numeric_system) { unsupported(); }
959
+ FMT_CONSTEXPR void on_dec1_weekday(numeric_system) { unsupported(); }
960
+ FMT_CONSTEXPR void on_abbr_month() { unsupported(); }
961
+ FMT_CONSTEXPR void on_full_month() { unsupported(); }
962
+ FMT_CONSTEXPR void on_dec_month(numeric_system) { unsupported(); }
963
+ FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system, pad_type) {
964
+ unsupported();
965
+ }
966
+ FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system, pad_type) {
967
+ unsupported();
968
+ }
969
+ FMT_CONSTEXPR void on_iso_week_of_year(numeric_system, pad_type) {
970
+ unsupported();
971
+ }
972
+ FMT_CONSTEXPR void on_day_of_year() { unsupported(); }
973
+ FMT_CONSTEXPR void on_day_of_month(numeric_system, pad_type) {
974
+ unsupported();
975
+ }
976
+ FMT_CONSTEXPR void on_24_hour(numeric_system) { unsupported(); }
977
+ FMT_CONSTEXPR void on_12_hour(numeric_system) { unsupported(); }
978
+ FMT_CONSTEXPR void on_minute(numeric_system) { unsupported(); }
979
+ FMT_CONSTEXPR void on_second(numeric_system) { unsupported(); }
980
+ FMT_CONSTEXPR void on_datetime(numeric_system) { unsupported(); }
981
+ FMT_CONSTEXPR void on_loc_date(numeric_system) { unsupported(); }
982
+ FMT_CONSTEXPR void on_loc_time(numeric_system) { unsupported(); }
983
+ FMT_CONSTEXPR void on_us_date() { unsupported(); }
984
+ FMT_CONSTEXPR void on_iso_date() { unsupported(); }
985
+ FMT_CONSTEXPR void on_12_hour_time() { unsupported(); }
986
+ FMT_CONSTEXPR void on_24_hour_time() { unsupported(); }
987
+ FMT_CONSTEXPR void on_iso_time() { unsupported(); }
988
+ FMT_CONSTEXPR void on_am_pm() { unsupported(); }
989
+ FMT_CONSTEXPR void on_duration_value() { unsupported(); }
990
+ FMT_CONSTEXPR void on_duration_unit() { unsupported(); }
991
+ FMT_CONSTEXPR void on_utc_offset(numeric_system) { unsupported(); }
992
+ FMT_CONSTEXPR void on_tz_name() { unsupported(); }
993
+ };
994
+
995
+ struct tm_format_checker : null_chrono_spec_handler<tm_format_checker> {
996
+ FMT_NORETURN void unsupported() { FMT_THROW(format_error("no format")); }
997
+
998
+ template <typename Char>
999
+ FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
1000
+ FMT_CONSTEXPR void on_year(numeric_system) {}
1001
+ FMT_CONSTEXPR void on_short_year(numeric_system) {}
1002
+ FMT_CONSTEXPR void on_offset_year() {}
1003
+ FMT_CONSTEXPR void on_century(numeric_system) {}
1004
+ FMT_CONSTEXPR void on_iso_week_based_year() {}
1005
+ FMT_CONSTEXPR void on_iso_week_based_short_year() {}
1006
+ FMT_CONSTEXPR void on_abbr_weekday() {}
1007
+ FMT_CONSTEXPR void on_full_weekday() {}
1008
+ FMT_CONSTEXPR void on_dec0_weekday(numeric_system) {}
1009
+ FMT_CONSTEXPR void on_dec1_weekday(numeric_system) {}
1010
+ FMT_CONSTEXPR void on_abbr_month() {}
1011
+ FMT_CONSTEXPR void on_full_month() {}
1012
+ FMT_CONSTEXPR void on_dec_month(numeric_system) {}
1013
+ FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system, pad_type) {}
1014
+ FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system, pad_type) {}
1015
+ FMT_CONSTEXPR void on_iso_week_of_year(numeric_system, pad_type) {}
1016
+ FMT_CONSTEXPR void on_day_of_year() {}
1017
+ FMT_CONSTEXPR void on_day_of_month(numeric_system, pad_type) {}
1018
+ FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {}
1019
+ FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {}
1020
+ FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {}
1021
+ FMT_CONSTEXPR void on_second(numeric_system, pad_type) {}
1022
+ FMT_CONSTEXPR void on_datetime(numeric_system) {}
1023
+ FMT_CONSTEXPR void on_loc_date(numeric_system) {}
1024
+ FMT_CONSTEXPR void on_loc_time(numeric_system) {}
1025
+ FMT_CONSTEXPR void on_us_date() {}
1026
+ FMT_CONSTEXPR void on_iso_date() {}
1027
+ FMT_CONSTEXPR void on_12_hour_time() {}
1028
+ FMT_CONSTEXPR void on_24_hour_time() {}
1029
+ FMT_CONSTEXPR void on_iso_time() {}
1030
+ FMT_CONSTEXPR void on_am_pm() {}
1031
+ FMT_CONSTEXPR void on_utc_offset(numeric_system) {}
1032
+ FMT_CONSTEXPR void on_tz_name() {}
1033
+ };
1034
+
1035
+ inline auto tm_wday_full_name(int wday) -> const char* {
1036
+ static constexpr const char* full_name_list[] = {
1037
+ "Sunday", "Monday", "Tuesday", "Wednesday",
1038
+ "Thursday", "Friday", "Saturday"};
1039
+ return wday >= 0 && wday <= 6 ? full_name_list[wday] : "?";
1040
+ }
1041
+ inline auto tm_wday_short_name(int wday) -> const char* {
1042
+ static constexpr const char* short_name_list[] = {"Sun", "Mon", "Tue", "Wed",
1043
+ "Thu", "Fri", "Sat"};
1044
+ return wday >= 0 && wday <= 6 ? short_name_list[wday] : "???";
1045
+ }
1046
+
1047
+ inline auto tm_mon_full_name(int mon) -> const char* {
1048
+ static constexpr const char* full_name_list[] = {
1049
+ "January", "February", "March", "April", "May", "June",
1050
+ "July", "August", "September", "October", "November", "December"};
1051
+ return mon >= 0 && mon <= 11 ? full_name_list[mon] : "?";
1052
+ }
1053
+ inline auto tm_mon_short_name(int mon) -> const char* {
1054
+ static constexpr const char* short_name_list[] = {
1055
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
1056
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
1057
+ };
1058
+ return mon >= 0 && mon <= 11 ? short_name_list[mon] : "???";
1059
+ }
1060
+
1061
+ template <typename T, typename = void>
1062
+ struct has_member_data_tm_gmtoff : std::false_type {};
1063
+ template <typename T>
1064
+ struct has_member_data_tm_gmtoff<T, void_t<decltype(T::tm_gmtoff)>>
1065
+ : std::true_type {};
1066
+
1067
+ template <typename T, typename = void>
1068
+ struct has_member_data_tm_zone : std::false_type {};
1069
+ template <typename T>
1070
+ struct has_member_data_tm_zone<T, void_t<decltype(T::tm_zone)>>
1071
+ : std::true_type {};
1072
+
1073
+ #if FMT_USE_TZSET
1074
+ inline void tzset_once() {
1075
+ static bool init = []() -> bool {
1076
+ _tzset();
1077
+ return true;
1078
+ }();
1079
+ ignore_unused(init);
1080
+ }
1081
+ #endif
1082
+
1083
+ // Converts value to Int and checks that it's in the range [0, upper).
1084
+ template <typename T, typename Int, FMT_ENABLE_IF(std::is_integral<T>::value)>
1085
+ inline auto to_nonnegative_int(T value, Int upper) -> Int {
1086
+ if (!std::is_unsigned<Int>::value &&
1087
+ (value < 0 || to_unsigned(value) > to_unsigned(upper))) {
1088
+ FMT_THROW(fmt::format_error("chrono value is out of range"));
1089
+ }
1090
+ return static_cast<Int>(value);
1091
+ }
1092
+ template <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>
1093
+ inline auto to_nonnegative_int(T value, Int upper) -> Int {
1094
+ auto int_value = static_cast<Int>(value);
1095
+ if (int_value < 0 || value > static_cast<T>(upper))
1096
+ FMT_THROW(format_error("invalid value"));
1097
+ return int_value;
1098
+ }
1099
+
1100
+ constexpr auto pow10(std::uint32_t n) -> long long {
1101
+ return n == 0 ? 1 : 10 * pow10(n - 1);
1102
+ }
1103
+
1104
+ // Counts the number of fractional digits in the range [0, 18] according to the
1105
+ // C++20 spec. If more than 18 fractional digits are required then returns 6 for
1106
+ // microseconds precision.
1107
+ template <long long Num, long long Den, int N = 0,
1108
+ bool Enabled = (N < 19) && (Num <= max_value<long long>() / 10)>
1109
+ struct count_fractional_digits {
1110
+ static constexpr int value =
1111
+ Num % Den == 0 ? N : count_fractional_digits<Num * 10, Den, N + 1>::value;
1112
+ };
1113
+
1114
+ // Base case that doesn't instantiate any more templates
1115
+ // in order to avoid overflow.
1116
+ template <long long Num, long long Den, int N>
1117
+ struct count_fractional_digits<Num, Den, N, false> {
1118
+ static constexpr int value = (Num % Den == 0) ? N : 6;
1119
+ };
1120
+
1121
+ // Format subseconds which are given as an integer type with an appropriate
1122
+ // number of digits.
1123
+ template <typename Char, typename OutputIt, typename Duration>
1124
+ void write_fractional_seconds(OutputIt& out, Duration d, int precision = -1) {
1125
+ constexpr auto num_fractional_digits =
1126
+ count_fractional_digits<Duration::period::num,
1127
+ Duration::period::den>::value;
1128
+
1129
+ using subsecond_precision = std::chrono::duration<
1130
+ typename std::common_type<typename Duration::rep,
1131
+ std::chrono::seconds::rep>::type,
1132
+ std::ratio<1, detail::pow10(num_fractional_digits)>>;
1133
+
1134
+ const auto fractional = d - fmt_duration_cast<std::chrono::seconds>(d);
1135
+ const auto subseconds =
1136
+ std::chrono::treat_as_floating_point<
1137
+ typename subsecond_precision::rep>::value
1138
+ ? fractional.count()
1139
+ : fmt_duration_cast<subsecond_precision>(fractional).count();
1140
+ auto n = static_cast<uint32_or_64_or_128_t<long long>>(subseconds);
1141
+ const int num_digits = detail::count_digits(n);
1142
+
1143
+ int leading_zeroes = (std::max)(0, num_fractional_digits - num_digits);
1144
+ if (precision < 0) {
1145
+ FMT_ASSERT(!std::is_floating_point<typename Duration::rep>::value, "");
1146
+ if (std::ratio_less<typename subsecond_precision::period,
1147
+ std::chrono::seconds::period>::value) {
1148
+ *out++ = '.';
1149
+ out = detail::fill_n(out, leading_zeroes, '0');
1150
+ out = format_decimal<Char>(out, n, num_digits).end;
1151
+ }
1152
+ } else if (precision > 0) {
1153
+ *out++ = '.';
1154
+ leading_zeroes = (std::min)(leading_zeroes, precision);
1155
+ int remaining = precision - leading_zeroes;
1156
+ out = detail::fill_n(out, leading_zeroes, '0');
1157
+ if (remaining < num_digits) {
1158
+ int num_truncated_digits = num_digits - remaining;
1159
+ n /= to_unsigned(detail::pow10(to_unsigned(num_truncated_digits)));
1160
+ if (n) {
1161
+ out = format_decimal<Char>(out, n, remaining).end;
1162
+ }
1163
+ return;
1164
+ }
1165
+ if (n) {
1166
+ out = format_decimal<Char>(out, n, num_digits).end;
1167
+ remaining -= num_digits;
1168
+ }
1169
+ out = detail::fill_n(out, remaining, '0');
1170
+ }
1171
+ }
1172
+
1173
+ // Format subseconds which are given as a floating point type with an
1174
+ // appropriate number of digits. We cannot pass the Duration here, as we
1175
+ // explicitly need to pass the Rep value in the chrono_formatter.
1176
+ template <typename Duration>
1177
+ void write_floating_seconds(memory_buffer& buf, Duration duration,
1178
+ int num_fractional_digits = -1) {
1179
+ using rep = typename Duration::rep;
1180
+ FMT_ASSERT(std::is_floating_point<rep>::value, "");
1181
+
1182
+ auto val = duration.count();
1183
+
1184
+ if (num_fractional_digits < 0) {
1185
+ // For `std::round` with fallback to `round`:
1186
+ // On some toolchains `std::round` is not available (e.g. GCC 6).
1187
+ using namespace std;
1188
+ num_fractional_digits =
1189
+ count_fractional_digits<Duration::period::num,
1190
+ Duration::period::den>::value;
1191
+ if (num_fractional_digits < 6 && static_cast<rep>(round(val)) != val)
1192
+ num_fractional_digits = 6;
1193
+ }
1194
+
1195
+ fmt::format_to(std::back_inserter(buf), FMT_STRING("{:.{}f}"),
1196
+ std::fmod(val * static_cast<rep>(Duration::period::num) /
1197
+ static_cast<rep>(Duration::period::den),
1198
+ static_cast<rep>(60)),
1199
+ num_fractional_digits);
1200
+ }
1201
+
1202
+ template <typename OutputIt, typename Char,
1203
+ typename Duration = std::chrono::seconds>
1204
+ class tm_writer {
1205
+ private:
1206
+ static constexpr int days_per_week = 7;
1207
+
1208
+ const std::locale& loc_;
1209
+ const bool is_classic_;
1210
+ OutputIt out_;
1211
+ const Duration* subsecs_;
1212
+ const std::tm& tm_;
1213
+
1214
+ auto tm_sec() const noexcept -> int {
1215
+ FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61, "");
1216
+ return tm_.tm_sec;
1217
+ }
1218
+ auto tm_min() const noexcept -> int {
1219
+ FMT_ASSERT(tm_.tm_min >= 0 && tm_.tm_min <= 59, "");
1220
+ return tm_.tm_min;
1221
+ }
1222
+ auto tm_hour() const noexcept -> int {
1223
+ FMT_ASSERT(tm_.tm_hour >= 0 && tm_.tm_hour <= 23, "");
1224
+ return tm_.tm_hour;
1225
+ }
1226
+ auto tm_mday() const noexcept -> int {
1227
+ FMT_ASSERT(tm_.tm_mday >= 1 && tm_.tm_mday <= 31, "");
1228
+ return tm_.tm_mday;
1229
+ }
1230
+ auto tm_mon() const noexcept -> int {
1231
+ FMT_ASSERT(tm_.tm_mon >= 0 && tm_.tm_mon <= 11, "");
1232
+ return tm_.tm_mon;
1233
+ }
1234
+ auto tm_year() const noexcept -> long long { return 1900ll + tm_.tm_year; }
1235
+ auto tm_wday() const noexcept -> int {
1236
+ FMT_ASSERT(tm_.tm_wday >= 0 && tm_.tm_wday <= 6, "");
1237
+ return tm_.tm_wday;
1238
+ }
1239
+ auto tm_yday() const noexcept -> int {
1240
+ FMT_ASSERT(tm_.tm_yday >= 0 && tm_.tm_yday <= 365, "");
1241
+ return tm_.tm_yday;
1242
+ }
1243
+
1244
+ auto tm_hour12() const noexcept -> int {
1245
+ const auto h = tm_hour();
1246
+ const auto z = h < 12 ? h : h - 12;
1247
+ return z == 0 ? 12 : z;
1248
+ }
1249
+
1250
+ // POSIX and the C Standard are unclear or inconsistent about what %C and %y
1251
+ // do if the year is negative or exceeds 9999. Use the convention that %C
1252
+ // concatenated with %y yields the same output as %Y, and that %Y contains at
1253
+ // least 4 characters, with more only if necessary.
1254
+ auto split_year_lower(long long year) const noexcept -> int {
1255
+ auto l = year % 100;
1256
+ if (l < 0) l = -l; // l in [0, 99]
1257
+ return static_cast<int>(l);
1258
+ }
1259
+
1260
+ // Algorithm: https://en.wikipedia.org/wiki/ISO_week_date.
1261
+ auto iso_year_weeks(long long curr_year) const noexcept -> int {
1262
+ const auto prev_year = curr_year - 1;
1263
+ const auto curr_p =
1264
+ (curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %
1265
+ days_per_week;
1266
+ const auto prev_p =
1267
+ (prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %
1268
+ days_per_week;
1269
+ return 52 + ((curr_p == 4 || prev_p == 3) ? 1 : 0);
1270
+ }
1271
+ auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int {
1272
+ return (tm_yday + 11 - (tm_wday == 0 ? days_per_week : tm_wday)) /
1273
+ days_per_week;
1274
+ }
1275
+ auto tm_iso_week_year() const noexcept -> long long {
1276
+ const auto year = tm_year();
1277
+ const auto w = iso_week_num(tm_yday(), tm_wday());
1278
+ if (w < 1) return year - 1;
1279
+ if (w > iso_year_weeks(year)) return year + 1;
1280
+ return year;
1281
+ }
1282
+ auto tm_iso_week_of_year() const noexcept -> int {
1283
+ const auto year = tm_year();
1284
+ const auto w = iso_week_num(tm_yday(), tm_wday());
1285
+ if (w < 1) return iso_year_weeks(year - 1);
1286
+ if (w > iso_year_weeks(year)) return 1;
1287
+ return w;
1288
+ }
1289
+
1290
+ void write1(int value) {
1291
+ *out_++ = static_cast<char>('0' + to_unsigned(value) % 10);
1292
+ }
1293
+ void write2(int value) {
1294
+ const char* d = digits2(to_unsigned(value) % 100);
1295
+ *out_++ = *d++;
1296
+ *out_++ = *d;
1297
+ }
1298
+ void write2(int value, pad_type pad) {
1299
+ unsigned int v = to_unsigned(value) % 100;
1300
+ if (v >= 10) {
1301
+ const char* d = digits2(v);
1302
+ *out_++ = *d++;
1303
+ *out_++ = *d;
1304
+ } else {
1305
+ out_ = detail::write_padding(out_, pad);
1306
+ *out_++ = static_cast<char>('0' + v);
1307
+ }
1308
+ }
1309
+
1310
+ void write_year_extended(long long year) {
1311
+ // At least 4 characters.
1312
+ int width = 4;
1313
+ if (year < 0) {
1314
+ *out_++ = '-';
1315
+ year = 0 - year;
1316
+ --width;
1317
+ }
1318
+ uint32_or_64_or_128_t<long long> n = to_unsigned(year);
1319
+ const int num_digits = count_digits(n);
1320
+ if (width > num_digits)
1321
+ out_ = detail::fill_n(out_, width - num_digits, '0');
1322
+ out_ = format_decimal<Char>(out_, n, num_digits).end;
1323
+ }
1324
+ void write_year(long long year) {
1325
+ if (year >= 0 && year < 10000) {
1326
+ write2(static_cast<int>(year / 100));
1327
+ write2(static_cast<int>(year % 100));
1328
+ } else {
1329
+ write_year_extended(year);
1330
+ }
1331
+ }
1332
+
1333
+ void write_utc_offset(long offset, numeric_system ns) {
1334
+ if (offset < 0) {
1335
+ *out_++ = '-';
1336
+ offset = -offset;
1337
+ } else {
1338
+ *out_++ = '+';
1339
+ }
1340
+ offset /= 60;
1341
+ write2(static_cast<int>(offset / 60));
1342
+ if (ns != numeric_system::standard) *out_++ = ':';
1343
+ write2(static_cast<int>(offset % 60));
1344
+ }
1345
+ template <typename T, FMT_ENABLE_IF(has_member_data_tm_gmtoff<T>::value)>
1346
+ void format_utc_offset_impl(const T& tm, numeric_system ns) {
1347
+ write_utc_offset(tm.tm_gmtoff, ns);
1348
+ }
1349
+ template <typename T, FMT_ENABLE_IF(!has_member_data_tm_gmtoff<T>::value)>
1350
+ void format_utc_offset_impl(const T& tm, numeric_system ns) {
1351
+ #if defined(_WIN32) && defined(_UCRT)
1352
+ # if FMT_USE_TZSET
1353
+ tzset_once();
1354
+ # endif
1355
+ long offset = 0;
1356
+ _get_timezone(&offset);
1357
+ if (tm.tm_isdst) {
1358
+ long dstbias = 0;
1359
+ _get_dstbias(&dstbias);
1360
+ offset += dstbias;
1361
+ }
1362
+ write_utc_offset(-offset, ns);
1363
+ #else
1364
+ if (ns == numeric_system::standard) return format_localized('z');
1365
+
1366
+ // Extract timezone offset from timezone conversion functions.
1367
+ std::tm gtm = tm;
1368
+ std::time_t gt = std::mktime(&gtm);
1369
+ std::tm ltm = gmtime(gt);
1370
+ std::time_t lt = std::mktime(&ltm);
1371
+ long offset = gt - lt;
1372
+ write_utc_offset(offset, ns);
1373
+ #endif
1374
+ }
1375
+
1376
+ template <typename T, FMT_ENABLE_IF(has_member_data_tm_zone<T>::value)>
1377
+ void format_tz_name_impl(const T& tm) {
1378
+ if (is_classic_)
1379
+ out_ = write_tm_str<Char>(out_, tm.tm_zone, loc_);
1380
+ else
1381
+ format_localized('Z');
1382
+ }
1383
+ template <typename T, FMT_ENABLE_IF(!has_member_data_tm_zone<T>::value)>
1384
+ void format_tz_name_impl(const T&) {
1385
+ format_localized('Z');
1386
+ }
1387
+
1388
+ void format_localized(char format, char modifier = 0) {
1389
+ out_ = write<Char>(out_, tm_, loc_, format, modifier);
1390
+ }
1391
+
1392
+ public:
1393
+ tm_writer(const std::locale& loc, OutputIt out, const std::tm& tm,
1394
+ const Duration* subsecs = nullptr)
1395
+ : loc_(loc),
1396
+ is_classic_(loc_ == get_classic_locale()),
1397
+ out_(out),
1398
+ subsecs_(subsecs),
1399
+ tm_(tm) {}
1400
+
1401
+ auto out() const -> OutputIt { return out_; }
1402
+
1403
+ FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
1404
+ out_ = copy<Char>(begin, end, out_);
1405
+ }
1406
+
1407
+ void on_abbr_weekday() {
1408
+ if (is_classic_)
1409
+ out_ = write(out_, tm_wday_short_name(tm_wday()));
1410
+ else
1411
+ format_localized('a');
1412
+ }
1413
+ void on_full_weekday() {
1414
+ if (is_classic_)
1415
+ out_ = write(out_, tm_wday_full_name(tm_wday()));
1416
+ else
1417
+ format_localized('A');
1418
+ }
1419
+ void on_dec0_weekday(numeric_system ns) {
1420
+ if (is_classic_ || ns == numeric_system::standard) return write1(tm_wday());
1421
+ format_localized('w', 'O');
1422
+ }
1423
+ void on_dec1_weekday(numeric_system ns) {
1424
+ if (is_classic_ || ns == numeric_system::standard) {
1425
+ auto wday = tm_wday();
1426
+ write1(wday == 0 ? days_per_week : wday);
1427
+ } else {
1428
+ format_localized('u', 'O');
1429
+ }
1430
+ }
1431
+
1432
+ void on_abbr_month() {
1433
+ if (is_classic_)
1434
+ out_ = write(out_, tm_mon_short_name(tm_mon()));
1435
+ else
1436
+ format_localized('b');
1437
+ }
1438
+ void on_full_month() {
1439
+ if (is_classic_)
1440
+ out_ = write(out_, tm_mon_full_name(tm_mon()));
1441
+ else
1442
+ format_localized('B');
1443
+ }
1444
+
1445
+ void on_datetime(numeric_system ns) {
1446
+ if (is_classic_) {
1447
+ on_abbr_weekday();
1448
+ *out_++ = ' ';
1449
+ on_abbr_month();
1450
+ *out_++ = ' ';
1451
+ on_day_of_month(numeric_system::standard, pad_type::space);
1452
+ *out_++ = ' ';
1453
+ on_iso_time();
1454
+ *out_++ = ' ';
1455
+ on_year(numeric_system::standard);
1456
+ } else {
1457
+ format_localized('c', ns == numeric_system::standard ? '\0' : 'E');
1458
+ }
1459
+ }
1460
+ void on_loc_date(numeric_system ns) {
1461
+ if (is_classic_)
1462
+ on_us_date();
1463
+ else
1464
+ format_localized('x', ns == numeric_system::standard ? '\0' : 'E');
1465
+ }
1466
+ void on_loc_time(numeric_system ns) {
1467
+ if (is_classic_)
1468
+ on_iso_time();
1469
+ else
1470
+ format_localized('X', ns == numeric_system::standard ? '\0' : 'E');
1471
+ }
1472
+ void on_us_date() {
1473
+ char buf[8];
1474
+ write_digit2_separated(buf, to_unsigned(tm_mon() + 1),
1475
+ to_unsigned(tm_mday()),
1476
+ to_unsigned(split_year_lower(tm_year())), '/');
1477
+ out_ = copy<Char>(std::begin(buf), std::end(buf), out_);
1478
+ }
1479
+ void on_iso_date() {
1480
+ auto year = tm_year();
1481
+ char buf[10];
1482
+ size_t offset = 0;
1483
+ if (year >= 0 && year < 10000) {
1484
+ copy2(buf, digits2(static_cast<size_t>(year / 100)));
1485
+ } else {
1486
+ offset = 4;
1487
+ write_year_extended(year);
1488
+ year = 0;
1489
+ }
1490
+ write_digit2_separated(buf + 2, static_cast<unsigned>(year % 100),
1491
+ to_unsigned(tm_mon() + 1), to_unsigned(tm_mday()),
1492
+ '-');
1493
+ out_ = copy<Char>(std::begin(buf) + offset, std::end(buf), out_);
1494
+ }
1495
+
1496
+ void on_utc_offset(numeric_system ns) { format_utc_offset_impl(tm_, ns); }
1497
+ void on_tz_name() { format_tz_name_impl(tm_); }
1498
+
1499
+ void on_year(numeric_system ns) {
1500
+ if (is_classic_ || ns == numeric_system::standard)
1501
+ return write_year(tm_year());
1502
+ format_localized('Y', 'E');
1503
+ }
1504
+ void on_short_year(numeric_system ns) {
1505
+ if (is_classic_ || ns == numeric_system::standard)
1506
+ return write2(split_year_lower(tm_year()));
1507
+ format_localized('y', 'O');
1508
+ }
1509
+ void on_offset_year() {
1510
+ if (is_classic_) return write2(split_year_lower(tm_year()));
1511
+ format_localized('y', 'E');
1512
+ }
1513
+
1514
+ void on_century(numeric_system ns) {
1515
+ if (is_classic_ || ns == numeric_system::standard) {
1516
+ auto year = tm_year();
1517
+ auto upper = year / 100;
1518
+ if (year >= -99 && year < 0) {
1519
+ // Zero upper on negative year.
1520
+ *out_++ = '-';
1521
+ *out_++ = '0';
1522
+ } else if (upper >= 0 && upper < 100) {
1523
+ write2(static_cast<int>(upper));
1524
+ } else {
1525
+ out_ = write<Char>(out_, upper);
1526
+ }
1527
+ } else {
1528
+ format_localized('C', 'E');
1529
+ }
1530
+ }
1531
+
1532
+ void on_dec_month(numeric_system ns) {
1533
+ if (is_classic_ || ns == numeric_system::standard)
1534
+ return write2(tm_mon() + 1);
1535
+ format_localized('m', 'O');
1536
+ }
1537
+
1538
+ void on_dec0_week_of_year(numeric_system ns, pad_type pad) {
1539
+ if (is_classic_ || ns == numeric_system::standard)
1540
+ return write2((tm_yday() + days_per_week - tm_wday()) / days_per_week,
1541
+ pad);
1542
+ format_localized('U', 'O');
1543
+ }
1544
+ void on_dec1_week_of_year(numeric_system ns, pad_type pad) {
1545
+ if (is_classic_ || ns == numeric_system::standard) {
1546
+ auto wday = tm_wday();
1547
+ write2((tm_yday() + days_per_week -
1548
+ (wday == 0 ? (days_per_week - 1) : (wday - 1))) /
1549
+ days_per_week,
1550
+ pad);
1551
+ } else {
1552
+ format_localized('W', 'O');
1553
+ }
1554
+ }
1555
+ void on_iso_week_of_year(numeric_system ns, pad_type pad) {
1556
+ if (is_classic_ || ns == numeric_system::standard)
1557
+ return write2(tm_iso_week_of_year(), pad);
1558
+ format_localized('V', 'O');
1559
+ }
1560
+
1561
+ void on_iso_week_based_year() { write_year(tm_iso_week_year()); }
1562
+ void on_iso_week_based_short_year() {
1563
+ write2(split_year_lower(tm_iso_week_year()));
1564
+ }
1565
+
1566
+ void on_day_of_year() {
1567
+ auto yday = tm_yday() + 1;
1568
+ write1(yday / 100);
1569
+ write2(yday % 100);
1570
+ }
1571
+ void on_day_of_month(numeric_system ns, pad_type pad) {
1572
+ if (is_classic_ || ns == numeric_system::standard)
1573
+ return write2(tm_mday(), pad);
1574
+ format_localized('d', 'O');
1575
+ }
1576
+
1577
+ void on_24_hour(numeric_system ns, pad_type pad) {
1578
+ if (is_classic_ || ns == numeric_system::standard)
1579
+ return write2(tm_hour(), pad);
1580
+ format_localized('H', 'O');
1581
+ }
1582
+ void on_12_hour(numeric_system ns, pad_type pad) {
1583
+ if (is_classic_ || ns == numeric_system::standard)
1584
+ return write2(tm_hour12(), pad);
1585
+ format_localized('I', 'O');
1586
+ }
1587
+ void on_minute(numeric_system ns, pad_type pad) {
1588
+ if (is_classic_ || ns == numeric_system::standard)
1589
+ return write2(tm_min(), pad);
1590
+ format_localized('M', 'O');
1591
+ }
1592
+
1593
+ void on_second(numeric_system ns, pad_type pad) {
1594
+ if (is_classic_ || ns == numeric_system::standard) {
1595
+ write2(tm_sec(), pad);
1596
+ if (subsecs_) {
1597
+ if (std::is_floating_point<typename Duration::rep>::value) {
1598
+ auto buf = memory_buffer();
1599
+ write_floating_seconds(buf, *subsecs_);
1600
+ if (buf.size() > 1) {
1601
+ // Remove the leading "0", write something like ".123".
1602
+ out_ = std::copy(buf.begin() + 1, buf.end(), out_);
1603
+ }
1604
+ } else {
1605
+ write_fractional_seconds<Char>(out_, *subsecs_);
1606
+ }
1607
+ }
1608
+ } else {
1609
+ // Currently no formatting of subseconds when a locale is set.
1610
+ format_localized('S', 'O');
1611
+ }
1612
+ }
1613
+
1614
+ void on_12_hour_time() {
1615
+ if (is_classic_) {
1616
+ char buf[8];
1617
+ write_digit2_separated(buf, to_unsigned(tm_hour12()),
1618
+ to_unsigned(tm_min()), to_unsigned(tm_sec()), ':');
1619
+ out_ = copy<Char>(std::begin(buf), std::end(buf), out_);
1620
+ *out_++ = ' ';
1621
+ on_am_pm();
1622
+ } else {
1623
+ format_localized('r');
1624
+ }
1625
+ }
1626
+ void on_24_hour_time() {
1627
+ write2(tm_hour());
1628
+ *out_++ = ':';
1629
+ write2(tm_min());
1630
+ }
1631
+ void on_iso_time() {
1632
+ on_24_hour_time();
1633
+ *out_++ = ':';
1634
+ on_second(numeric_system::standard, pad_type::zero);
1635
+ }
1636
+
1637
+ void on_am_pm() {
1638
+ if (is_classic_) {
1639
+ *out_++ = tm_hour() < 12 ? 'A' : 'P';
1640
+ *out_++ = 'M';
1641
+ } else {
1642
+ format_localized('p');
1643
+ }
1644
+ }
1645
+
1646
+ // These apply to chrono durations but not tm.
1647
+ void on_duration_value() {}
1648
+ void on_duration_unit() {}
1649
+ };
1650
+
1651
+ struct chrono_format_checker : null_chrono_spec_handler<chrono_format_checker> {
1652
+ bool has_precision_integral = false;
1653
+
1654
+ FMT_NORETURN void unsupported() { FMT_THROW(format_error("no date")); }
1655
+
1656
+ template <typename Char>
1657
+ FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
1658
+ FMT_CONSTEXPR void on_day_of_year() {}
1659
+ FMT_CONSTEXPR void on_24_hour(numeric_system, pad_type) {}
1660
+ FMT_CONSTEXPR void on_12_hour(numeric_system, pad_type) {}
1661
+ FMT_CONSTEXPR void on_minute(numeric_system, pad_type) {}
1662
+ FMT_CONSTEXPR void on_second(numeric_system, pad_type) {}
1663
+ FMT_CONSTEXPR void on_12_hour_time() {}
1664
+ FMT_CONSTEXPR void on_24_hour_time() {}
1665
+ FMT_CONSTEXPR void on_iso_time() {}
1666
+ FMT_CONSTEXPR void on_am_pm() {}
1667
+ FMT_CONSTEXPR void on_duration_value() const {
1668
+ if (has_precision_integral) {
1669
+ FMT_THROW(format_error("precision not allowed for this argument type"));
1670
+ }
1671
+ }
1672
+ FMT_CONSTEXPR void on_duration_unit() {}
1673
+ };
1674
+
1675
+ template <typename T,
1676
+ FMT_ENABLE_IF(std::is_integral<T>::value&& has_isfinite<T>::value)>
1677
+ inline auto isfinite(T) -> bool {
1678
+ return true;
1679
+ }
1680
+
1681
+ template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
1682
+ inline auto mod(T x, int y) -> T {
1683
+ return x % static_cast<T>(y);
1684
+ }
1685
+ template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
1686
+ inline auto mod(T x, int y) -> T {
1687
+ return std::fmod(x, static_cast<T>(y));
1688
+ }
1689
+
1690
+ // If T is an integral type, maps T to its unsigned counterpart, otherwise
1691
+ // leaves it unchanged (unlike std::make_unsigned).
1692
+ template <typename T, bool INTEGRAL = std::is_integral<T>::value>
1693
+ struct make_unsigned_or_unchanged {
1694
+ using type = T;
1695
+ };
1696
+
1697
+ template <typename T> struct make_unsigned_or_unchanged<T, true> {
1698
+ using type = typename std::make_unsigned<T>::type;
1699
+ };
1700
+
1701
+ template <typename Rep, typename Period,
1702
+ FMT_ENABLE_IF(std::is_integral<Rep>::value)>
1703
+ inline auto get_milliseconds(std::chrono::duration<Rep, Period> d)
1704
+ -> std::chrono::duration<Rep, std::milli> {
1705
+ // this may overflow and/or the result may not fit in the
1706
+ // target type.
1707
+ #if FMT_SAFE_DURATION_CAST
1708
+ using CommonSecondsType =
1709
+ typename std::common_type<decltype(d), std::chrono::seconds>::type;
1710
+ const auto d_as_common = fmt_duration_cast<CommonSecondsType>(d);
1711
+ const auto d_as_whole_seconds =
1712
+ fmt_duration_cast<std::chrono::seconds>(d_as_common);
1713
+ // this conversion should be nonproblematic
1714
+ const auto diff = d_as_common - d_as_whole_seconds;
1715
+ const auto ms =
1716
+ fmt_duration_cast<std::chrono::duration<Rep, std::milli>>(diff);
1717
+ return ms;
1718
+ #else
1719
+ auto s = fmt_duration_cast<std::chrono::seconds>(d);
1720
+ return fmt_duration_cast<std::chrono::milliseconds>(d - s);
1721
+ #endif
1722
+ }
1723
+
1724
+ template <typename Char, typename Rep, typename OutputIt,
1725
+ FMT_ENABLE_IF(std::is_integral<Rep>::value)>
1726
+ auto format_duration_value(OutputIt out, Rep val, int) -> OutputIt {
1727
+ return write<Char>(out, val);
1728
+ }
1729
+
1730
+ template <typename Char, typename Rep, typename OutputIt,
1731
+ FMT_ENABLE_IF(std::is_floating_point<Rep>::value)>
1732
+ auto format_duration_value(OutputIt out, Rep val, int precision) -> OutputIt {
1733
+ auto specs = format_specs();
1734
+ specs.precision = precision;
1735
+ specs.type =
1736
+ precision >= 0 ? presentation_type::fixed : presentation_type::general;
1737
+ return write<Char>(out, val, specs);
1738
+ }
1739
+
1740
+ template <typename Char, typename OutputIt>
1741
+ auto copy_unit(string_view unit, OutputIt out, Char) -> OutputIt {
1742
+ return std::copy(unit.begin(), unit.end(), out);
1743
+ }
1744
+
1745
+ template <typename OutputIt>
1746
+ auto copy_unit(string_view unit, OutputIt out, wchar_t) -> OutputIt {
1747
+ // This works when wchar_t is UTF-32 because units only contain characters
1748
+ // that have the same representation in UTF-16 and UTF-32.
1749
+ utf8_to_utf16 u(unit);
1750
+ return std::copy(u.c_str(), u.c_str() + u.size(), out);
1751
+ }
1752
+
1753
+ template <typename Char, typename Period, typename OutputIt>
1754
+ auto format_duration_unit(OutputIt out) -> OutputIt {
1755
+ if (const char* unit = get_units<Period>())
1756
+ return copy_unit(string_view(unit), out, Char());
1757
+ *out++ = '[';
1758
+ out = write<Char>(out, Period::num);
1759
+ if (const_check(Period::den != 1)) {
1760
+ *out++ = '/';
1761
+ out = write<Char>(out, Period::den);
1762
+ }
1763
+ *out++ = ']';
1764
+ *out++ = 's';
1765
+ return out;
1766
+ }
1767
+
1768
+ class get_locale {
1769
+ private:
1770
+ union {
1771
+ std::locale locale_;
1772
+ };
1773
+ bool has_locale_ = false;
1774
+
1775
+ public:
1776
+ get_locale(bool localized, locale_ref loc) : has_locale_(localized) {
1777
+ #ifndef FMT_STATIC_THOUSANDS_SEPARATOR
1778
+ if (localized)
1779
+ ::new (&locale_) std::locale(loc.template get<std::locale>());
1780
+ #endif
1781
+ }
1782
+ ~get_locale() {
1783
+ if (has_locale_) locale_.~locale();
1784
+ }
1785
+ operator const std::locale&() const {
1786
+ return has_locale_ ? locale_ : get_classic_locale();
1787
+ }
1788
+ };
1789
+
1790
+ template <typename FormatContext, typename OutputIt, typename Rep,
1791
+ typename Period>
1792
+ struct chrono_formatter {
1793
+ FormatContext& context;
1794
+ OutputIt out;
1795
+ int precision;
1796
+ bool localized = false;
1797
+ // rep is unsigned to avoid overflow.
1798
+ using rep =
1799
+ conditional_t<std::is_integral<Rep>::value && sizeof(Rep) < sizeof(int),
1800
+ unsigned, typename make_unsigned_or_unchanged<Rep>::type>;
1801
+ rep val;
1802
+ using seconds = std::chrono::duration<rep>;
1803
+ seconds s;
1804
+ using milliseconds = std::chrono::duration<rep, std::milli>;
1805
+ bool negative;
1806
+
1807
+ using char_type = typename FormatContext::char_type;
1808
+ using tm_writer_type = tm_writer<OutputIt, char_type>;
1809
+
1810
+ chrono_formatter(FormatContext& ctx, OutputIt o,
1811
+ std::chrono::duration<Rep, Period> d)
1812
+ : context(ctx),
1813
+ out(o),
1814
+ val(static_cast<rep>(d.count())),
1815
+ negative(false) {
1816
+ if (d.count() < 0) {
1817
+ val = 0 - val;
1818
+ negative = true;
1819
+ }
1820
+
1821
+ // this may overflow and/or the result may not fit in the
1822
+ // target type.
1823
+ // might need checked conversion (rep!=Rep)
1824
+ s = fmt_duration_cast<seconds>(std::chrono::duration<rep, Period>(val));
1825
+ }
1826
+
1827
+ // returns true if nan or inf, writes to out.
1828
+ auto handle_nan_inf() -> bool {
1829
+ if (isfinite(val)) {
1830
+ return false;
1831
+ }
1832
+ if (isnan(val)) {
1833
+ write_nan();
1834
+ return true;
1835
+ }
1836
+ // must be +-inf
1837
+ if (val > 0) {
1838
+ write_pinf();
1839
+ } else {
1840
+ write_ninf();
1841
+ }
1842
+ return true;
1843
+ }
1844
+
1845
+ auto days() const -> Rep { return static_cast<Rep>(s.count() / 86400); }
1846
+ auto hour() const -> Rep {
1847
+ return static_cast<Rep>(mod((s.count() / 3600), 24));
1848
+ }
1849
+
1850
+ auto hour12() const -> Rep {
1851
+ Rep hour = static_cast<Rep>(mod((s.count() / 3600), 12));
1852
+ return hour <= 0 ? 12 : hour;
1853
+ }
1854
+
1855
+ auto minute() const -> Rep {
1856
+ return static_cast<Rep>(mod((s.count() / 60), 60));
1857
+ }
1858
+ auto second() const -> Rep { return static_cast<Rep>(mod(s.count(), 60)); }
1859
+
1860
+ auto time() const -> std::tm {
1861
+ auto time = std::tm();
1862
+ time.tm_hour = to_nonnegative_int(hour(), 24);
1863
+ time.tm_min = to_nonnegative_int(minute(), 60);
1864
+ time.tm_sec = to_nonnegative_int(second(), 60);
1865
+ return time;
1866
+ }
1867
+
1868
+ void write_sign() {
1869
+ if (negative) {
1870
+ *out++ = '-';
1871
+ negative = false;
1872
+ }
1873
+ }
1874
+
1875
+ void write(Rep value, int width, pad_type pad = pad_type::zero) {
1876
+ write_sign();
1877
+ if (isnan(value)) return write_nan();
1878
+ uint32_or_64_or_128_t<int> n =
1879
+ to_unsigned(to_nonnegative_int(value, max_value<int>()));
1880
+ int num_digits = detail::count_digits(n);
1881
+ if (width > num_digits) {
1882
+ out = detail::write_padding(out, pad, width - num_digits);
1883
+ }
1884
+ out = format_decimal<char_type>(out, n, num_digits).end;
1885
+ }
1886
+
1887
+ void write_nan() { std::copy_n("nan", 3, out); }
1888
+ void write_pinf() { std::copy_n("inf", 3, out); }
1889
+ void write_ninf() { std::copy_n("-inf", 4, out); }
1890
+
1891
+ template <typename Callback, typename... Args>
1892
+ void format_tm(const tm& time, Callback cb, Args... args) {
1893
+ if (isnan(val)) return write_nan();
1894
+ get_locale loc(localized, context.locale());
1895
+ auto w = tm_writer_type(loc, out, time);
1896
+ (w.*cb)(args...);
1897
+ out = w.out();
1898
+ }
1899
+
1900
+ void on_text(const char_type* begin, const char_type* end) {
1901
+ std::copy(begin, end, out);
1902
+ }
1903
+
1904
+ // These are not implemented because durations don't have date information.
1905
+ void on_abbr_weekday() {}
1906
+ void on_full_weekday() {}
1907
+ void on_dec0_weekday(numeric_system) {}
1908
+ void on_dec1_weekday(numeric_system) {}
1909
+ void on_abbr_month() {}
1910
+ void on_full_month() {}
1911
+ void on_datetime(numeric_system) {}
1912
+ void on_loc_date(numeric_system) {}
1913
+ void on_loc_time(numeric_system) {}
1914
+ void on_us_date() {}
1915
+ void on_iso_date() {}
1916
+ void on_utc_offset(numeric_system) {}
1917
+ void on_tz_name() {}
1918
+ void on_year(numeric_system) {}
1919
+ void on_short_year(numeric_system) {}
1920
+ void on_offset_year() {}
1921
+ void on_century(numeric_system) {}
1922
+ void on_iso_week_based_year() {}
1923
+ void on_iso_week_based_short_year() {}
1924
+ void on_dec_month(numeric_system) {}
1925
+ void on_dec0_week_of_year(numeric_system, pad_type) {}
1926
+ void on_dec1_week_of_year(numeric_system, pad_type) {}
1927
+ void on_iso_week_of_year(numeric_system, pad_type) {}
1928
+ void on_day_of_month(numeric_system, pad_type) {}
1929
+
1930
+ void on_day_of_year() {
1931
+ if (handle_nan_inf()) return;
1932
+ write(days(), 0);
1933
+ }
1934
+
1935
+ void on_24_hour(numeric_system ns, pad_type pad) {
1936
+ if (handle_nan_inf()) return;
1937
+
1938
+ if (ns == numeric_system::standard) return write(hour(), 2, pad);
1939
+ auto time = tm();
1940
+ time.tm_hour = to_nonnegative_int(hour(), 24);
1941
+ format_tm(time, &tm_writer_type::on_24_hour, ns, pad);
1942
+ }
1943
+
1944
+ void on_12_hour(numeric_system ns, pad_type pad) {
1945
+ if (handle_nan_inf()) return;
1946
+
1947
+ if (ns == numeric_system::standard) return write(hour12(), 2, pad);
1948
+ auto time = tm();
1949
+ time.tm_hour = to_nonnegative_int(hour12(), 12);
1950
+ format_tm(time, &tm_writer_type::on_12_hour, ns, pad);
1951
+ }
1952
+
1953
+ void on_minute(numeric_system ns, pad_type pad) {
1954
+ if (handle_nan_inf()) return;
1955
+
1956
+ if (ns == numeric_system::standard) return write(minute(), 2, pad);
1957
+ auto time = tm();
1958
+ time.tm_min = to_nonnegative_int(minute(), 60);
1959
+ format_tm(time, &tm_writer_type::on_minute, ns, pad);
1960
+ }
1961
+
1962
+ void on_second(numeric_system ns, pad_type pad) {
1963
+ if (handle_nan_inf()) return;
1964
+
1965
+ if (ns == numeric_system::standard) {
1966
+ if (std::is_floating_point<rep>::value) {
1967
+ auto buf = memory_buffer();
1968
+ write_floating_seconds(buf, std::chrono::duration<rep, Period>(val),
1969
+ precision);
1970
+ if (negative) *out++ = '-';
1971
+ if (buf.size() < 2 || buf[1] == '.') {
1972
+ out = detail::write_padding(out, pad);
1973
+ }
1974
+ out = std::copy(buf.begin(), buf.end(), out);
1975
+ } else {
1976
+ write(second(), 2, pad);
1977
+ write_fractional_seconds<char_type>(
1978
+ out, std::chrono::duration<rep, Period>(val), precision);
1979
+ }
1980
+ return;
1981
+ }
1982
+ auto time = tm();
1983
+ time.tm_sec = to_nonnegative_int(second(), 60);
1984
+ format_tm(time, &tm_writer_type::on_second, ns, pad);
1985
+ }
1986
+
1987
+ void on_12_hour_time() {
1988
+ if (handle_nan_inf()) return;
1989
+ format_tm(time(), &tm_writer_type::on_12_hour_time);
1990
+ }
1991
+
1992
+ void on_24_hour_time() {
1993
+ if (handle_nan_inf()) {
1994
+ *out++ = ':';
1995
+ handle_nan_inf();
1996
+ return;
1997
+ }
1998
+
1999
+ write(hour(), 2);
2000
+ *out++ = ':';
2001
+ write(minute(), 2);
2002
+ }
2003
+
2004
+ void on_iso_time() {
2005
+ on_24_hour_time();
2006
+ *out++ = ':';
2007
+ if (handle_nan_inf()) return;
2008
+ on_second(numeric_system::standard, pad_type::zero);
2009
+ }
2010
+
2011
+ void on_am_pm() {
2012
+ if (handle_nan_inf()) return;
2013
+ format_tm(time(), &tm_writer_type::on_am_pm);
2014
+ }
2015
+
2016
+ void on_duration_value() {
2017
+ if (handle_nan_inf()) return;
2018
+ write_sign();
2019
+ out = format_duration_value<char_type>(out, val, precision);
2020
+ }
2021
+
2022
+ void on_duration_unit() {
2023
+ out = format_duration_unit<char_type, Period>(out);
2024
+ }
2025
+ };
2026
+
2027
+ } // namespace detail
2028
+
2029
+ #if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907
2030
+ using weekday = std::chrono::weekday;
2031
+ using day = std::chrono::day;
2032
+ using month = std::chrono::month;
2033
+ using year = std::chrono::year;
2034
+ using year_month_day = std::chrono::year_month_day;
2035
+ #else
2036
+ // A fallback version of weekday.
2037
+ class weekday {
2038
+ private:
2039
+ unsigned char value_;
2040
+
2041
+ public:
2042
+ weekday() = default;
2043
+ constexpr explicit weekday(unsigned wd) noexcept
2044
+ : value_(static_cast<unsigned char>(wd != 7 ? wd : 0)) {}
2045
+ constexpr auto c_encoding() const noexcept -> unsigned { return value_; }
2046
+ };
2047
+
2048
+ class day {
2049
+ private:
2050
+ unsigned char value_;
2051
+
2052
+ public:
2053
+ day() = default;
2054
+ constexpr explicit day(unsigned d) noexcept
2055
+ : value_(static_cast<unsigned char>(d)) {}
2056
+ constexpr explicit operator unsigned() const noexcept { return value_; }
2057
+ };
2058
+
2059
+ class month {
2060
+ private:
2061
+ unsigned char value_;
2062
+
2063
+ public:
2064
+ month() = default;
2065
+ constexpr explicit month(unsigned m) noexcept
2066
+ : value_(static_cast<unsigned char>(m)) {}
2067
+ constexpr explicit operator unsigned() const noexcept { return value_; }
2068
+ };
2069
+
2070
+ class year {
2071
+ private:
2072
+ int value_;
2073
+
2074
+ public:
2075
+ year() = default;
2076
+ constexpr explicit year(int y) noexcept : value_(y) {}
2077
+ constexpr explicit operator int() const noexcept { return value_; }
2078
+ };
2079
+
2080
+ class year_month_day {
2081
+ private:
2082
+ fmt::year year_;
2083
+ fmt::month month_;
2084
+ fmt::day day_;
2085
+
2086
+ public:
2087
+ year_month_day() = default;
2088
+ constexpr year_month_day(const year& y, const month& m, const day& d) noexcept
2089
+ : year_(y), month_(m), day_(d) {}
2090
+ constexpr auto year() const noexcept -> fmt::year { return year_; }
2091
+ constexpr auto month() const noexcept -> fmt::month { return month_; }
2092
+ constexpr auto day() const noexcept -> fmt::day { return day_; }
2093
+ };
2094
+ #endif
2095
+
2096
+ template <typename Char>
2097
+ struct formatter<weekday, Char> : private formatter<std::tm, Char> {
2098
+ private:
2099
+ bool localized_ = false;
2100
+ bool use_tm_formatter_ = false;
2101
+
2102
+ public:
2103
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2104
+ -> decltype(ctx.begin()) {
2105
+ auto it = ctx.begin(), end = ctx.end();
2106
+ if (it != end && *it == 'L') {
2107
+ ++it;
2108
+ localized_ = true;
2109
+ return it;
2110
+ }
2111
+ use_tm_formatter_ = it != end && *it != '}';
2112
+ return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
2113
+ }
2114
+
2115
+ template <typename FormatContext>
2116
+ auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) {
2117
+ auto time = std::tm();
2118
+ time.tm_wday = static_cast<int>(wd.c_encoding());
2119
+ if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
2120
+ detail::get_locale loc(localized_, ctx.locale());
2121
+ auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
2122
+ w.on_abbr_weekday();
2123
+ return w.out();
2124
+ }
2125
+ };
2126
+
2127
+ template <typename Char>
2128
+ struct formatter<day, Char> : private formatter<std::tm, Char> {
2129
+ private:
2130
+ bool use_tm_formatter_ = false;
2131
+
2132
+ public:
2133
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2134
+ -> decltype(ctx.begin()) {
2135
+ auto it = ctx.begin(), end = ctx.end();
2136
+ use_tm_formatter_ = it != end && *it != '}';
2137
+ return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
2138
+ }
2139
+
2140
+ template <typename FormatContext>
2141
+ auto format(day d, FormatContext& ctx) const -> decltype(ctx.out()) {
2142
+ auto time = std::tm();
2143
+ time.tm_mday = static_cast<int>(static_cast<unsigned>(d));
2144
+ if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
2145
+ detail::get_locale loc(false, ctx.locale());
2146
+ auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
2147
+ w.on_day_of_month(detail::numeric_system::standard, detail::pad_type::zero);
2148
+ return w.out();
2149
+ }
2150
+ };
2151
+
2152
+ template <typename Char>
2153
+ struct formatter<month, Char> : private formatter<std::tm, Char> {
2154
+ private:
2155
+ bool localized_ = false;
2156
+ bool use_tm_formatter_ = false;
2157
+
2158
+ public:
2159
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2160
+ -> decltype(ctx.begin()) {
2161
+ auto it = ctx.begin(), end = ctx.end();
2162
+ if (it != end && *it == 'L') {
2163
+ ++it;
2164
+ localized_ = true;
2165
+ return it;
2166
+ }
2167
+ use_tm_formatter_ = it != end && *it != '}';
2168
+ return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
2169
+ }
2170
+
2171
+ template <typename FormatContext>
2172
+ auto format(month m, FormatContext& ctx) const -> decltype(ctx.out()) {
2173
+ auto time = std::tm();
2174
+ time.tm_mon = static_cast<int>(static_cast<unsigned>(m)) - 1;
2175
+ if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
2176
+ detail::get_locale loc(localized_, ctx.locale());
2177
+ auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
2178
+ w.on_abbr_month();
2179
+ return w.out();
2180
+ }
2181
+ };
2182
+
2183
+ template <typename Char>
2184
+ struct formatter<year, Char> : private formatter<std::tm, Char> {
2185
+ private:
2186
+ bool use_tm_formatter_ = false;
2187
+
2188
+ public:
2189
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2190
+ -> decltype(ctx.begin()) {
2191
+ auto it = ctx.begin(), end = ctx.end();
2192
+ use_tm_formatter_ = it != end && *it != '}';
2193
+ return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
2194
+ }
2195
+
2196
+ template <typename FormatContext>
2197
+ auto format(year y, FormatContext& ctx) const -> decltype(ctx.out()) {
2198
+ auto time = std::tm();
2199
+ time.tm_year = static_cast<int>(y) - 1900;
2200
+ if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
2201
+ detail::get_locale loc(false, ctx.locale());
2202
+ auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
2203
+ w.on_year(detail::numeric_system::standard);
2204
+ return w.out();
2205
+ }
2206
+ };
2207
+
2208
+ template <typename Char>
2209
+ struct formatter<year_month_day, Char> : private formatter<std::tm, Char> {
2210
+ private:
2211
+ bool use_tm_formatter_ = false;
2212
+
2213
+ public:
2214
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2215
+ -> decltype(ctx.begin()) {
2216
+ auto it = ctx.begin(), end = ctx.end();
2217
+ use_tm_formatter_ = it != end && *it != '}';
2218
+ return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
2219
+ }
2220
+
2221
+ template <typename FormatContext>
2222
+ auto format(year_month_day val, FormatContext& ctx) const
2223
+ -> decltype(ctx.out()) {
2224
+ auto time = std::tm();
2225
+ time.tm_year = static_cast<int>(val.year()) - 1900;
2226
+ time.tm_mon = static_cast<int>(static_cast<unsigned>(val.month())) - 1;
2227
+ time.tm_mday = static_cast<int>(static_cast<unsigned>(val.day()));
2228
+ if (use_tm_formatter_) return formatter<std::tm, Char>::format(time, ctx);
2229
+ detail::get_locale loc(true, ctx.locale());
2230
+ auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
2231
+ w.on_iso_date();
2232
+ return w.out();
2233
+ }
2234
+ };
2235
+
2236
+ template <typename Rep, typename Period, typename Char>
2237
+ struct formatter<std::chrono::duration<Rep, Period>, Char> {
2238
+ private:
2239
+ format_specs specs_;
2240
+ detail::arg_ref<Char> width_ref_;
2241
+ detail::arg_ref<Char> precision_ref_;
2242
+ bool localized_ = false;
2243
+ basic_string_view<Char> format_str_;
2244
+
2245
+ public:
2246
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2247
+ -> decltype(ctx.begin()) {
2248
+ auto it = ctx.begin(), end = ctx.end();
2249
+ if (it == end || *it == '}') return it;
2250
+
2251
+ it = detail::parse_align(it, end, specs_);
2252
+ if (it == end) return it;
2253
+
2254
+ it = detail::parse_dynamic_spec(it, end, specs_.width, width_ref_, ctx);
2255
+ if (it == end) return it;
2256
+
2257
+ auto checker = detail::chrono_format_checker();
2258
+ if (*it == '.') {
2259
+ checker.has_precision_integral = !std::is_floating_point<Rep>::value;
2260
+ it = detail::parse_precision(it, end, specs_.precision, precision_ref_,
2261
+ ctx);
2262
+ }
2263
+ if (it != end && *it == 'L') {
2264
+ localized_ = true;
2265
+ ++it;
2266
+ }
2267
+ end = detail::parse_chrono_format(it, end, checker);
2268
+ format_str_ = {it, detail::to_unsigned(end - it)};
2269
+ return end;
2270
+ }
2271
+
2272
+ template <typename FormatContext>
2273
+ auto format(std::chrono::duration<Rep, Period> d, FormatContext& ctx) const
2274
+ -> decltype(ctx.out()) {
2275
+ auto specs = specs_;
2276
+ auto precision = specs.precision;
2277
+ specs.precision = -1;
2278
+ auto begin = format_str_.begin(), end = format_str_.end();
2279
+ // As a possible future optimization, we could avoid extra copying if width
2280
+ // is not specified.
2281
+ auto buf = basic_memory_buffer<Char>();
2282
+ auto out = std::back_inserter(buf);
2283
+ detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
2284
+ ctx);
2285
+ detail::handle_dynamic_spec<detail::precision_checker>(precision,
2286
+ precision_ref_, ctx);
2287
+ if (begin == end || *begin == '}') {
2288
+ out = detail::format_duration_value<Char>(out, d.count(), precision);
2289
+ detail::format_duration_unit<Char, Period>(out);
2290
+ } else {
2291
+ using chrono_formatter =
2292
+ detail::chrono_formatter<FormatContext, decltype(out), Rep, Period>;
2293
+ auto f = chrono_formatter(ctx, out, d);
2294
+ f.precision = precision;
2295
+ f.localized = localized_;
2296
+ detail::parse_chrono_format(begin, end, f);
2297
+ }
2298
+ return detail::write(
2299
+ ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
2300
+ }
2301
+ };
2302
+
2303
+ template <typename Char, typename Duration>
2304
+ struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
2305
+ Char> : formatter<std::tm, Char> {
2306
+ FMT_CONSTEXPR formatter() {
2307
+ this->format_str_ = detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>{};
2308
+ }
2309
+
2310
+ template <typename FormatContext>
2311
+ auto format(std::chrono::time_point<std::chrono::system_clock, Duration> val,
2312
+ FormatContext& ctx) const -> decltype(ctx.out()) {
2313
+ std::tm tm = gmtime(val);
2314
+ using period = typename Duration::period;
2315
+ if (detail::const_check(
2316
+ period::num == 1 && period::den == 1 &&
2317
+ !std::is_floating_point<typename Duration::rep>::value)) {
2318
+ return formatter<std::tm, Char>::format(tm, ctx);
2319
+ }
2320
+ Duration epoch = val.time_since_epoch();
2321
+ Duration subsecs = detail::fmt_duration_cast<Duration>(
2322
+ epoch - detail::fmt_duration_cast<std::chrono::seconds>(epoch));
2323
+ if (subsecs.count() < 0) {
2324
+ auto second =
2325
+ detail::fmt_duration_cast<Duration>(std::chrono::seconds(1));
2326
+ if (tm.tm_sec != 0)
2327
+ --tm.tm_sec;
2328
+ else
2329
+ tm = gmtime(val - second);
2330
+ subsecs += detail::fmt_duration_cast<Duration>(std::chrono::seconds(1));
2331
+ }
2332
+ return formatter<std::tm, Char>::do_format(tm, ctx, &subsecs);
2333
+ }
2334
+ };
2335
+
2336
+ #if FMT_USE_LOCAL_TIME
2337
+ template <typename Char, typename Duration>
2338
+ struct formatter<std::chrono::local_time<Duration>, Char>
2339
+ : formatter<std::tm, Char> {
2340
+ FMT_CONSTEXPR formatter() {
2341
+ this->format_str_ = detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>{};
2342
+ }
2343
+
2344
+ template <typename FormatContext>
2345
+ auto format(std::chrono::local_time<Duration> val, FormatContext& ctx) const
2346
+ -> decltype(ctx.out()) {
2347
+ using period = typename Duration::period;
2348
+ if (period::num != 1 || period::den != 1 ||
2349
+ std::is_floating_point<typename Duration::rep>::value) {
2350
+ const auto epoch = val.time_since_epoch();
2351
+ const auto subsecs = detail::fmt_duration_cast<Duration>(
2352
+ epoch - detail::fmt_duration_cast<std::chrono::seconds>(epoch));
2353
+
2354
+ return formatter<std::tm, Char>::do_format(localtime(val), ctx, &subsecs);
2355
+ }
2356
+
2357
+ return formatter<std::tm, Char>::format(localtime(val), ctx);
2358
+ }
2359
+ };
2360
+ #endif
2361
+
2362
+ #if FMT_USE_UTC_TIME
2363
+ template <typename Char, typename Duration>
2364
+ struct formatter<std::chrono::time_point<std::chrono::utc_clock, Duration>,
2365
+ Char>
2366
+ : formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
2367
+ Char> {
2368
+ template <typename FormatContext>
2369
+ auto format(std::chrono::time_point<std::chrono::utc_clock, Duration> val,
2370
+ FormatContext& ctx) const -> decltype(ctx.out()) {
2371
+ return formatter<
2372
+ std::chrono::time_point<std::chrono::system_clock, Duration>,
2373
+ Char>::format(std::chrono::utc_clock::to_sys(val), ctx);
2374
+ }
2375
+ };
2376
+ #endif
2377
+
2378
+ template <typename Char> struct formatter<std::tm, Char> {
2379
+ private:
2380
+ format_specs specs_;
2381
+ detail::arg_ref<Char> width_ref_;
2382
+
2383
+ protected:
2384
+ basic_string_view<Char> format_str_;
2385
+
2386
+ template <typename FormatContext, typename Duration>
2387
+ auto do_format(const std::tm& tm, FormatContext& ctx,
2388
+ const Duration* subsecs) const -> decltype(ctx.out()) {
2389
+ auto specs = specs_;
2390
+ auto buf = basic_memory_buffer<Char>();
2391
+ auto out = std::back_inserter(buf);
2392
+ detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
2393
+ ctx);
2394
+
2395
+ auto loc_ref = ctx.locale();
2396
+ detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);
2397
+ auto w =
2398
+ detail::tm_writer<decltype(out), Char, Duration>(loc, out, tm, subsecs);
2399
+ detail::parse_chrono_format(format_str_.begin(), format_str_.end(), w);
2400
+ return detail::write(
2401
+ ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
2402
+ }
2403
+
2404
+ public:
2405
+ FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
2406
+ -> decltype(ctx.begin()) {
2407
+ auto it = ctx.begin(), end = ctx.end();
2408
+ if (it == end || *it == '}') return it;
2409
+
2410
+ it = detail::parse_align(it, end, specs_);
2411
+ if (it == end) return it;
2412
+
2413
+ it = detail::parse_dynamic_spec(it, end, specs_.width, width_ref_, ctx);
2414
+ if (it == end) return it;
2415
+
2416
+ end = detail::parse_chrono_format(it, end, detail::tm_format_checker());
2417
+ // Replace the default format_str only if the new spec is not empty.
2418
+ if (end != it) format_str_ = {it, detail::to_unsigned(end - it)};
2419
+ return end;
2420
+ }
2421
+
2422
+ template <typename FormatContext>
2423
+ auto format(const std::tm& tm, FormatContext& ctx) const
2424
+ -> decltype(ctx.out()) {
2425
+ return do_format<FormatContext, std::chrono::seconds>(tm, ctx, nullptr);
2426
+ }
2427
+ };
2428
+
2429
+ FMT_END_EXPORT
2430
+ FMT_END_NAMESPACE
2431
+
2432
+ #endif // FMT_CHRONO_H_