licenses.list.txt 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276
  1. ====================Apache-2.0====================
  2. Apache License
  3. Version 2.0, January 2004
  4. http://www.apache.org/licenses/
  5. TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
  6. 1. Definitions.
  7. "License" shall mean the terms and conditions for use, reproduction,
  8. and distribution as defined by Sections 1 through 9 of this document.
  9. "Licensor" shall mean the copyright owner or entity authorized by
  10. the copyright owner that is granting the License.
  11. "Legal Entity" shall mean the union of the acting entity and all
  12. other entities that control, are controlled by, or are under common
  13. control with that entity. For the purposes of this definition,
  14. "control" means (i) the power, direct or indirect, to cause the
  15. direction or management of such entity, whether by contract or
  16. otherwise, or (ii) ownership of fifty percent (50%) or more of the
  17. outstanding shares, or (iii) beneficial ownership of such entity.
  18. "You" (or "Your") shall mean an individual or Legal Entity
  19. exercising permissions granted by this License.
  20. "Source" form shall mean the preferred form for making modifications,
  21. including but not limited to software source code, documentation
  22. source, and configuration files.
  23. "Object" form shall mean any form resulting from mechanical
  24. transformation or translation of a Source form, including but
  25. not limited to compiled object code, generated documentation,
  26. and conversions to other media types.
  27. "Work" shall mean the work of authorship, whether in Source or
  28. Object form, made available under the License, as indicated by a
  29. copyright notice that is included in or attached to the work
  30. (an example is provided in the Appendix below).
  31. "Derivative Works" shall mean any work, whether in Source or Object
  32. form, that is based on (or derived from) the Work and for which the
  33. editorial revisions, annotations, elaborations, or other modifications
  34. represent, as a whole, an original work of authorship. For the purposes
  35. of this License, Derivative Works shall not include works that remain
  36. separable from, or merely link (or bind by name) to the interfaces of,
  37. the Work and Derivative Works thereof.
  38. "Contribution" shall mean any work of authorship, including
  39. the original version of the Work and any modifications or additions
  40. to that Work or Derivative Works thereof, that is intentionally
  41. submitted to Licensor for inclusion in the Work by the copyright owner
  42. or by an individual or Legal Entity authorized to submit on behalf of
  43. the copyright owner. For the purposes of this definition, "submitted"
  44. means any form of electronic, verbal, or written communication sent
  45. to the Licensor or its representatives, including but not limited to
  46. communication on electronic mailing lists, source code control systems,
  47. and issue tracking systems that are managed by, or on behalf of, the
  48. Licensor for the purpose of discussing and improving the Work, but
  49. excluding communication that is conspicuously marked or otherwise
  50. designated in writing by the copyright owner as "Not a Contribution."
  51. "Contributor" shall mean Licensor and any individual or Legal Entity
  52. on behalf of whom a Contribution has been received by Licensor and
  53. subsequently incorporated within the Work.
  54. 2. Grant of Copyright License. Subject to the terms and conditions of
  55. this License, each Contributor hereby grants to You a perpetual,
  56. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  57. copyright license to reproduce, prepare Derivative Works of,
  58. publicly display, publicly perform, sublicense, and distribute the
  59. Work and such Derivative Works in Source or Object form.
  60. 3. Grant of Patent License. Subject to the terms and conditions of
  61. this License, each Contributor hereby grants to You a perpetual,
  62. worldwide, non-exclusive, no-charge, royalty-free, irrevocable
  63. (except as stated in this section) patent license to make, have made,
  64. use, offer to sell, sell, import, and otherwise transfer the Work,
  65. where such license applies only to those patent claims licensable
  66. by such Contributor that are necessarily infringed by their
  67. Contribution(s) alone or by combination of their Contribution(s)
  68. with the Work to which such Contribution(s) was submitted. If You
  69. institute patent litigation against any entity (including a
  70. cross-claim or counterclaim in a lawsuit) alleging that the Work
  71. or a Contribution incorporated within the Work constitutes direct
  72. or contributory patent infringement, then any patent licenses
  73. granted to You under this License for that Work shall terminate
  74. as of the date such litigation is filed.
  75. 4. Redistribution. You may reproduce and distribute copies of the
  76. Work or Derivative Works thereof in any medium, with or without
  77. modifications, and in Source or Object form, provided that You
  78. meet the following conditions:
  79. (a) You must give any other recipients of the Work or
  80. Derivative Works a copy of this License; and
  81. (b) You must cause any modified files to carry prominent notices
  82. stating that You changed the files; and
  83. (c) You must retain, in the Source form of any Derivative Works
  84. that You distribute, all copyright, patent, trademark, and
  85. attribution notices from the Source form of the Work,
  86. excluding those notices that do not pertain to any part of
  87. the Derivative Works; and
  88. (d) If the Work includes a "NOTICE" text file as part of its
  89. distribution, then any Derivative Works that You distribute must
  90. include a readable copy of the attribution notices contained
  91. within such NOTICE file, excluding those notices that do not
  92. pertain to any part of the Derivative Works, in at least one
  93. of the following places: within a NOTICE text file distributed
  94. as part of the Derivative Works; within the Source form or
  95. documentation, if provided along with the Derivative Works; or,
  96. within a display generated by the Derivative Works, if and
  97. wherever such third-party notices normally appear. The contents
  98. of the NOTICE file are for informational purposes only and
  99. do not modify the License. You may add Your own attribution
  100. notices within Derivative Works that You distribute, alongside
  101. or as an addendum to the NOTICE text from the Work, provided
  102. that such additional attribution notices cannot be construed
  103. as modifying the License.
  104. You may add Your own copyright statement to Your modifications and
  105. may provide additional or different license terms and conditions
  106. for use, reproduction, or distribution of Your modifications, or
  107. for any such Derivative Works as a whole, provided Your use,
  108. reproduction, and distribution of the Work otherwise complies with
  109. the conditions stated in this License.
  110. 5. Submission of Contributions. Unless You explicitly state otherwise,
  111. any Contribution intentionally submitted for inclusion in the Work
  112. by You to the Licensor shall be under the terms and conditions of
  113. this License, without any additional terms or conditions.
  114. Notwithstanding the above, nothing herein shall supersede or modify
  115. the terms of any separate license agreement you may have executed
  116. with Licensor regarding such Contributions.
  117. 6. Trademarks. This License does not grant permission to use the trade
  118. names, trademarks, service marks, or product names of the Licensor,
  119. except as required for reasonable and customary use in describing the
  120. origin of the Work and reproducing the content of the NOTICE file.
  121. 7. Disclaimer of Warranty. Unless required by applicable law or
  122. agreed to in writing, Licensor provides the Work (and each
  123. Contributor provides its Contributions) on an "AS IS" BASIS,
  124. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  125. implied, including, without limitation, any warranties or conditions
  126. of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
  127. PARTICULAR PURPOSE. You are solely responsible for determining the
  128. appropriateness of using or redistributing the Work and assume any
  129. risks associated with Your exercise of permissions under this License.
  130. 8. Limitation of Liability. In no event and under no legal theory,
  131. whether in tort (including negligence), contract, or otherwise,
  132. unless required by applicable law (such as deliberate and grossly
  133. negligent acts) or agreed to in writing, shall any Contributor be
  134. liable to You for damages, including any direct, indirect, special,
  135. incidental, or consequential damages of any character arising as a
  136. result of this License or out of the use or inability to use the
  137. Work (including but not limited to damages for loss of goodwill,
  138. work stoppage, computer failure or malfunction, or any and all
  139. other commercial damages or losses), even if such Contributor
  140. has been advised of the possibility of such damages.
  141. 9. Accepting Warranty or Additional Liability. While redistributing
  142. the Work or Derivative Works thereof, You may choose to offer,
  143. and charge a fee for, acceptance of support, warranty, indemnity,
  144. or other liability obligations and/or rights consistent with this
  145. License. However, in accepting such obligations, You may act only
  146. on Your own behalf and on Your sole responsibility, not on behalf
  147. of any other Contributor, and only if You agree to indemnify,
  148. defend, and hold each Contributor harmless for any liability
  149. incurred by, or claims asserted against, such Contributor by reason
  150. of your accepting any such warranty or additional liability.
  151. END OF TERMS AND CONDITIONS
  152. APPENDIX: How to apply the Apache License to your work.
  153. To apply the Apache License to your work, attach the following
  154. boilerplate notice, with the fields enclosed by brackets "[]"
  155. replaced with your own identifying information. (Don't include
  156. the brackets!) The text should be enclosed in the appropriate
  157. comment syntax for the file format. We also recommend that a
  158. file or class name and description of purpose be included on the
  159. same "printed page" as the copyright notice for easier
  160. identification within third-party archives.
  161. Copyright [yyyy] [name of copyright owner]
  162. Licensed under the Apache License, Version 2.0 (the "License");
  163. you may not use this file except in compliance with the License.
  164. You may obtain a copy of the License at
  165. http://www.apache.org/licenses/LICENSE-2.0
  166. Unless required by applicable law or agreed to in writing, software
  167. distributed under the License is distributed on an "AS IS" BASIS,
  168. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  169. See the License for the specific language governing permissions and
  170. limitations under the License.
  171. ====================Apache-2.0 WITH LLVM-exception====================
  172. * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  173. * See https://llvm.org/LICENSE.txt for license information.
  174. ====================Apache-2.0 WITH LLVM-exception====================
  175. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  176. ====================Apache-2.0 WITH LLVM-exception====================
  177. ---- LLVM Exceptions to the Apache 2.0 License ----
  178. As an exception, if, as a result of your compiling your source code, portions
  179. of this Software are embedded into an Object form of such source code, you
  180. may redistribute such embedded portions in such Object form without complying
  181. with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
  182. In addition, if you combine or link compiled forms of this Software with
  183. software that is licensed under the GPLv2 ("Combined Software") and if a
  184. court of competent jurisdiction determines that the patent provision (Section
  185. 3), the indemnity provision (Section 9) or other Section of the License
  186. conflicts with the conditions of the GPLv2, you may retroactively and
  187. prospectively choose to deem waived or otherwise exclude such Section(s) of
  188. the License, but only in their entirety and only with respect to the Combined
  189. Software.
  190. ====================Apache-2.0 WITH LLVM-exception====================
  191. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  192. // See https://llvm.org/LICENSE.txt for license information.
  193. ====================Apache-2.0 WITH LLVM-exception====================
  194. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  195. ====================Apache-2.0 WITH LLVM-exception====================
  196. The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
  197. ====================BSD-2-Clause====================
  198. * Redistribution and use in source and binary forms, with or without
  199. * modification, are permitted provided that the following conditions
  200. * are met:
  201. * 1. Redistributions of source code must retain the above copyright
  202. * notice, this list of conditions and the following disclaimer.
  203. * 2. Redistributions in binary form must reproduce the above copyright
  204. * notice, this list of conditions and the following disclaimer in the
  205. * documentation and/or other materials provided with the distribution.
  206. *
  207. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  208. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  209. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  210. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  211. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  212. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  213. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  214. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  215. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  216. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  217. * SUCH DAMAGE.
  218. ====================BSD-2-Clause AND MIT====================
  219. 2-clause BSD license instead of the MIT/UUIC license that the rest of libc++ is
  220. ====================BSL-1.0====================
  221. // Boost Software License - Version 1.0 - August 17th, 2003
  222. // Permission is hereby granted, free of charge, to any person or organization
  223. // obtaining a copy of the software and accompanying documentation covered by
  224. // this license (the "Software") to use, reproduce, display, distribute,
  225. // execute, and transmit the Software, and to prepare derivative works of the
  226. // Software, and to permit third-parties to whom the Software is furnished to
  227. // do so, all subject to the following:
  228. // The copyright notices in the Software and this entire statement, including
  229. // the above license grant, this restriction and the following disclaimer,
  230. // must be included in all copies of the Software, in whole or in part, and
  231. // all derivative works of the Software, unless such copies or derivative
  232. // works are solely in the form of machine-executable object code generated by
  233. // a source language processor.
  234. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  235. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  236. // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
  237. // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
  238. // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
  239. // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  240. // DEALINGS IN THE SOFTWARE.
  241. ====================COPYRIGHT====================
  242. * FreeBSD libc. These are covered by the following copyright:
  243. *
  244. * Copyright (c) 2002-2004 Tim J. Robbins.
  245. ====================COPYRIGHT====================
  246. // Copyright (c) Microsoft Corporation.
  247. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  248. ====================COPYRIGHT====================
  249. // Copyright 2018 Ulf Adams
  250. // Copyright (c) Microsoft Corporation. All rights reserved.
  251. ====================COPYRIGHT====================
  252. Copyright (c) 2009-2014 by the contributors listed in CREDITS.TXT
  253. ====================COPYRIGHT====================
  254. Copyright (c) 2009-2019 by the contributors listed in CREDITS.TXT
  255. ====================File: .git/description====================
  256. Unnamed repository; edit this file 'description' to name the repository.
  257. ====================File: .git/info/exclude====================
  258. # git ls-files --others --exclude-from=.git/info/exclude
  259. # Lines that start with '#' are comments.
  260. # For a project mostly in C, the following would be a good set of
  261. # exclude patterns (uncomment them if you want to use them):
  262. # *.[oa]
  263. # *~
  264. ====================File: CREDITS.TXT====================
  265. This file is a partial list of people who have contributed to the LLVM/libc++
  266. project. If you have contributed a patch or made some other contribution to
  267. LLVM/libc++, please submit a patch to this file to add yourself, and it will be
  268. done!
  269. The list is sorted by surname and formatted to allow easy grepping and
  270. beautification by scripts. The fields are: name (N), email (E), web-address
  271. (W), PGP key ID and fingerprint (P), description (D), and snail-mail address
  272. (S).
  273. N: Saleem Abdulrasool
  274. E: compnerd@compnerd.org
  275. D: Minor patches and Linux fixes.
  276. N: Ulf Adams
  277. D: Invented the Ryu and Ryu Printf algorithms used in floating-point to_chars, and wrote the initial code.
  278. N: Muiez Ahmed
  279. E: muiez@ibm.com
  280. D: z/OS port.
  281. N: Dan Albert
  282. E: danalbert@google.com
  283. D: Android support and test runner improvements.
  284. N: Dimitry Andric
  285. E: dimitry@andric.com
  286. D: Visibility fixes, minor FreeBSD portability patches.
  287. N: Holger Arnold
  288. E: holgerar@gmail.com
  289. D: Minor fix.
  290. N: Jorg Brown
  291. D: Ported floating-point to_chars from MSVC to libc++.
  292. N: David Chisnall
  293. E: theraven at theravensnest dot org
  294. D: FreeBSD and Solaris ports, libcxxrt support, some atomics work.
  295. N: Marshall Clow
  296. E: mclow.lists@gmail.com
  297. E: marshall@idio.com
  298. D: C++14 support, patches and bug fixes.
  299. N: Jonathan B Coe
  300. E: jbcoe@me.com
  301. D: Implementation of propagate_const.
  302. N: Matthew Dempsky
  303. E: matthew@dempsky.org
  304. D: Minor patches and bug fixes.
  305. N: Christopher Di Bella
  306. E: cjdb@google.com
  307. E: cjdb.ns@gmail.com
  308. D: Library concepts.
  309. N: Glen Joseph Fernandes
  310. E: glenjofe@gmail.com
  311. D: Implementation of to_address.
  312. N: Eric Fiselier
  313. E: eric@efcs.ca
  314. D: LFTS support, patches and bug fixes.
  315. N: Bill Fisher
  316. E: william.w.fisher@gmail.com
  317. D: Regex bug fixes.
  318. N: Google Inc.
  319. D: Copyright owner and contributor of the CityHash algorithm
  320. N: Howard Hinnant
  321. E: hhinnant@apple.com
  322. D: Architect and primary author of libc++
  323. N: Sergej Jaskiewicz
  324. E: jaskiewiczs@icloud.com
  325. D: Minor improvements in the testing infrastructure
  326. N: Hyeon-bin Jeong
  327. E: tuhertz@gmail.com
  328. D: Minor patches and bug fixes.
  329. N: Argyrios Kyrtzidis
  330. E: kyrtzidis@apple.com
  331. D: Bug fixes.
  332. N: Stephan T. Lavavej
  333. E: stl@microsoft.com
  334. E: stl@nuwen.net
  335. D: Implemented floating-point to_chars.
  336. N: Microsoft Corporation
  337. D: Contributed floating-point to_chars.
  338. N: Bruce Mitchener, Jr.
  339. E: bruce.mitchener@gmail.com
  340. D: Emscripten-related changes.
  341. N: Michel Morin
  342. E: mimomorin@gmail.com
  343. D: Minor patches to is_convertible.
  344. N: Andrew Morrow
  345. E: andrew.c.morrow@gmail.com
  346. D: Minor patches and Linux fixes.
  347. N: Michael Park
  348. E: mcypark@gmail.com
  349. D: Implementation of <variant>.
  350. N: Arvid Picciani
  351. E: aep at exys dot org
  352. D: Minor patches and musl port.
  353. N: Bjorn Reese
  354. E: breese@users.sourceforge.net
  355. D: Initial regex prototype
  356. N: Nico Rieck
  357. E: nico.rieck@gmail.com
  358. D: Windows fixes
  359. N: Jon Roelofs
  360. E: jroelofS@jroelofs.com
  361. D: Remote testing, Newlib port, baremetal/single-threaded support.
  362. N: Kent Ross
  363. E: k@mad.cash
  364. D: Patches for operator<=> support
  365. N: Jonathan Sauer
  366. D: Minor patches, mostly related to constexpr
  367. N: Craig Silverstein
  368. E: csilvers@google.com
  369. D: Implemented Cityhash as the string hash function on 64-bit machines
  370. N: Richard Smith
  371. D: Minor patches.
  372. N: Joerg Sonnenberger
  373. E: joerg@NetBSD.org
  374. D: NetBSD port.
  375. N: Stephan Tolksdorf
  376. E: st@quanttec.com
  377. D: Minor <atomic> fix
  378. N: Ruben Van Boxem
  379. E: vanboxem dot ruben at gmail dot com
  380. D: Initial Windows patches.
  381. N: Michael van der Westhuizen
  382. E: r1mikey at gmail dot com
  383. N: Larisse Voufo
  384. D: Minor patches.
  385. N: Klaas de Vries
  386. E: klaas at klaasgaaf dot nl
  387. D: Minor bug fix.
  388. N: Mark de Wever
  389. E: koraq at xs4all dot nl
  390. D: Format library support.
  391. D: Finalized the porting of MSVC's to_chars to libc++.
  392. N: Zhang Xiongpang
  393. E: zhangxiongpang@gmail.com
  394. D: Minor patches and bug fixes.
  395. N: Xing Xue
  396. E: xingxue@ca.ibm.com
  397. D: AIX port
  398. N: Jeffrey Yasskin
  399. E: jyasskin@gmail.com
  400. E: jyasskin@google.com
  401. D: Linux fixes.
  402. N: Zhihao Yuan
  403. E: lichray@gmail.com
  404. D: Standard compatibility fixes.
  405. ====================File: include/any====================
  406. // -*- C++ -*-
  407. //===----------------------------------------------------------------------===//
  408. //
  409. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  410. // See https://llvm.org/LICENSE.txt for license information.
  411. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  412. //
  413. //===----------------------------------------------------------------------===//
  414. #ifndef _LIBCPP_ANY
  415. #define _LIBCPP_ANY
  416. /*
  417. any synopsis
  418. namespace std {
  419. class bad_any_cast : public bad_cast
  420. {
  421. public:
  422. virtual const char* what() const noexcept;
  423. };
  424. class any
  425. {
  426. public:
  427. // 6.3.1 any construct/destruct
  428. any() noexcept;
  429. any(const any& other);
  430. any(any&& other) noexcept;
  431. template <class ValueType>
  432. any(ValueType&& value);
  433. ~any();
  434. // 6.3.2 any assignments
  435. any& operator=(const any& rhs);
  436. any& operator=(any&& rhs) noexcept;
  437. template <class ValueType>
  438. any& operator=(ValueType&& rhs);
  439. // 6.3.3 any modifiers
  440. template <class ValueType, class... Args>
  441. decay_t<ValueType>& emplace(Args&&... args);
  442. template <class ValueType, class U, class... Args>
  443. decay_t<ValueType>& emplace(initializer_list<U>, Args&&...);
  444. void reset() noexcept;
  445. void swap(any& rhs) noexcept;
  446. // 6.3.4 any observers
  447. bool has_value() const noexcept;
  448. const type_info& type() const noexcept;
  449. };
  450. // 6.4 Non-member functions
  451. void swap(any& x, any& y) noexcept;
  452. template <class T, class ...Args>
  453. any make_any(Args&& ...args);
  454. template <class T, class U, class ...Args>
  455. any make_any(initializer_list<U>, Args&& ...args);
  456. template<class ValueType>
  457. ValueType any_cast(const any& operand);
  458. template<class ValueType>
  459. ValueType any_cast(any& operand);
  460. template<class ValueType>
  461. ValueType any_cast(any&& operand);
  462. template<class ValueType>
  463. const ValueType* any_cast(const any* operand) noexcept;
  464. template<class ValueType>
  465. ValueType* any_cast(any* operand) noexcept;
  466. } // namespace std
  467. */
  468. #include <__availability>
  469. #include <__config>
  470. #include <__utility/forward.h>
  471. #include <cstdlib>
  472. #include <memory>
  473. #include <type_traits>
  474. #include <typeinfo>
  475. #include <version>
  476. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  477. # pragma GCC system_header
  478. #endif
  479. namespace std {
  480. class _LIBCPP_EXCEPTION_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
  481. {
  482. public:
  483. virtual const char* what() const _NOEXCEPT;
  484. };
  485. } // namespace std
  486. _LIBCPP_BEGIN_NAMESPACE_STD
  487. #if _LIBCPP_STD_VER > 14
  488. _LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
  489. _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
  490. void __throw_bad_any_cast()
  491. {
  492. #ifndef _LIBCPP_NO_EXCEPTIONS
  493. throw bad_any_cast();
  494. #else
  495. _VSTD::abort();
  496. #endif
  497. }
  498. // Forward declarations
  499. class _LIBCPP_TEMPLATE_VIS any;
  500. template <class _ValueType>
  501. _LIBCPP_INLINE_VISIBILITY
  502. add_pointer_t<add_const_t<_ValueType>>
  503. any_cast(any const *) _NOEXCEPT;
  504. template <class _ValueType>
  505. _LIBCPP_INLINE_VISIBILITY
  506. add_pointer_t<_ValueType> any_cast(any *) _NOEXCEPT;
  507. namespace __any_imp
  508. {
  509. using _Buffer = aligned_storage_t<3*sizeof(void*), alignment_of<void*>::value>;
  510. template <class _Tp>
  511. using _IsSmallObject = integral_constant<bool
  512. , sizeof(_Tp) <= sizeof(_Buffer)
  513. && alignment_of<_Buffer>::value
  514. % alignment_of<_Tp>::value == 0
  515. && is_nothrow_move_constructible<_Tp>::value
  516. >;
  517. enum class _Action {
  518. _Destroy,
  519. _Copy,
  520. _Move,
  521. _Get,
  522. _TypeInfo
  523. };
  524. template <class _Tp> struct _SmallHandler;
  525. template <class _Tp> struct _LargeHandler;
  526. template <class _Tp>
  527. struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo { static constexpr int __id = 0; };
  528. template <class _Tp> constexpr int __unique_typeinfo<_Tp>::__id;
  529. template <class _Tp>
  530. inline _LIBCPP_INLINE_VISIBILITY
  531. constexpr const void* __get_fallback_typeid() {
  532. return &__unique_typeinfo<remove_cv_t<remove_reference_t<_Tp>>>::__id;
  533. }
  534. template <class _Tp>
  535. inline _LIBCPP_INLINE_VISIBILITY
  536. bool __compare_typeid(type_info const* __id, const void* __fallback_id)
  537. {
  538. #if !defined(_LIBCPP_NO_RTTI)
  539. if (__id && *__id == typeid(_Tp))
  540. return true;
  541. #endif
  542. if (!__id && __fallback_id == __any_imp::__get_fallback_typeid<_Tp>())
  543. return true;
  544. return false;
  545. }
  546. template <class _Tp>
  547. using _Handler = conditional_t<
  548. _IsSmallObject<_Tp>::value, _SmallHandler<_Tp>, _LargeHandler<_Tp>>;
  549. } // namespace __any_imp
  550. class _LIBCPP_TEMPLATE_VIS any
  551. {
  552. public:
  553. // construct/destruct
  554. _LIBCPP_INLINE_VISIBILITY
  555. constexpr any() _NOEXCEPT : __h(nullptr) {}
  556. _LIBCPP_INLINE_VISIBILITY
  557. any(any const & __other) : __h(nullptr)
  558. {
  559. if (__other.__h) __other.__call(_Action::_Copy, this);
  560. }
  561. _LIBCPP_INLINE_VISIBILITY
  562. any(any && __other) _NOEXCEPT : __h(nullptr)
  563. {
  564. if (__other.__h) __other.__call(_Action::_Move, this);
  565. }
  566. template <
  567. class _ValueType
  568. , class _Tp = decay_t<_ValueType>
  569. , class = enable_if_t<
  570. !is_same<_Tp, any>::value &&
  571. !__is_inplace_type<_ValueType>::value &&
  572. is_copy_constructible<_Tp>::value>
  573. >
  574. _LIBCPP_INLINE_VISIBILITY
  575. any(_ValueType && __value);
  576. template <class _ValueType, class ..._Args,
  577. class _Tp = decay_t<_ValueType>,
  578. class = enable_if_t<
  579. is_constructible<_Tp, _Args...>::value &&
  580. is_copy_constructible<_Tp>::value
  581. >
  582. >
  583. _LIBCPP_INLINE_VISIBILITY
  584. explicit any(in_place_type_t<_ValueType>, _Args&&... __args);
  585. template <class _ValueType, class _Up, class ..._Args,
  586. class _Tp = decay_t<_ValueType>,
  587. class = enable_if_t<
  588. is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
  589. is_copy_constructible<_Tp>::value>
  590. >
  591. _LIBCPP_INLINE_VISIBILITY
  592. explicit any(in_place_type_t<_ValueType>, initializer_list<_Up>, _Args&&... __args);
  593. _LIBCPP_INLINE_VISIBILITY
  594. ~any() { this->reset(); }
  595. // assignments
  596. _LIBCPP_INLINE_VISIBILITY
  597. any & operator=(any const & __rhs) {
  598. any(__rhs).swap(*this);
  599. return *this;
  600. }
  601. _LIBCPP_INLINE_VISIBILITY
  602. any & operator=(any && __rhs) _NOEXCEPT {
  603. any(_VSTD::move(__rhs)).swap(*this);
  604. return *this;
  605. }
  606. template <
  607. class _ValueType
  608. , class _Tp = decay_t<_ValueType>
  609. , class = enable_if_t<
  610. !is_same<_Tp, any>::value
  611. && is_copy_constructible<_Tp>::value>
  612. >
  613. _LIBCPP_INLINE_VISIBILITY
  614. any & operator=(_ValueType && __rhs);
  615. template <class _ValueType, class ..._Args,
  616. class _Tp = decay_t<_ValueType>,
  617. class = enable_if_t<
  618. is_constructible<_Tp, _Args...>::value &&
  619. is_copy_constructible<_Tp>::value>
  620. >
  621. _LIBCPP_INLINE_VISIBILITY
  622. _Tp& emplace(_Args&&... args);
  623. template <class _ValueType, class _Up, class ..._Args,
  624. class _Tp = decay_t<_ValueType>,
  625. class = enable_if_t<
  626. is_constructible<_Tp, initializer_list<_Up>&, _Args...>::value &&
  627. is_copy_constructible<_Tp>::value>
  628. >
  629. _LIBCPP_INLINE_VISIBILITY
  630. _Tp& emplace(initializer_list<_Up>, _Args&&...);
  631. // 6.3.3 any modifiers
  632. _LIBCPP_INLINE_VISIBILITY
  633. void reset() _NOEXCEPT { if (__h) this->__call(_Action::_Destroy); }
  634. _LIBCPP_INLINE_VISIBILITY
  635. void swap(any & __rhs) _NOEXCEPT;
  636. // 6.3.4 any observers
  637. _LIBCPP_INLINE_VISIBILITY
  638. bool has_value() const _NOEXCEPT { return __h != nullptr; }
  639. #if !defined(_LIBCPP_NO_RTTI)
  640. _LIBCPP_INLINE_VISIBILITY
  641. const type_info & type() const _NOEXCEPT {
  642. if (__h) {
  643. return *static_cast<type_info const *>(this->__call(_Action::_TypeInfo));
  644. } else {
  645. return typeid(void);
  646. }
  647. }
  648. #endif
  649. private:
  650. typedef __any_imp::_Action _Action;
  651. using _HandleFuncPtr = void* (*)(_Action, any const *, any *, const type_info *,
  652. const void* __fallback_info);
  653. union _Storage {
  654. constexpr _Storage() : __ptr(nullptr) {}
  655. void * __ptr;
  656. __any_imp::_Buffer __buf;
  657. };
  658. _LIBCPP_INLINE_VISIBILITY
  659. void * __call(_Action __a, any * __other = nullptr,
  660. type_info const * __info = nullptr,
  661. const void* __fallback_info = nullptr) const
  662. {
  663. return __h(__a, this, __other, __info, __fallback_info);
  664. }
  665. _LIBCPP_INLINE_VISIBILITY
  666. void * __call(_Action __a, any * __other = nullptr,
  667. type_info const * __info = nullptr,
  668. const void* __fallback_info = nullptr)
  669. {
  670. return __h(__a, this, __other, __info, __fallback_info);
  671. }
  672. template <class>
  673. friend struct __any_imp::_SmallHandler;
  674. template <class>
  675. friend struct __any_imp::_LargeHandler;
  676. template <class _ValueType>
  677. friend add_pointer_t<add_const_t<_ValueType>>
  678. any_cast(any const *) _NOEXCEPT;
  679. template <class _ValueType>
  680. friend add_pointer_t<_ValueType>
  681. any_cast(any *) _NOEXCEPT;
  682. _HandleFuncPtr __h = nullptr;
  683. _Storage __s;
  684. };
  685. namespace __any_imp
  686. {
  687. template <class _Tp>
  688. struct _LIBCPP_TEMPLATE_VIS _SmallHandler
  689. {
  690. _LIBCPP_INLINE_VISIBILITY
  691. static void* __handle(_Action __act, any const * __this, any * __other,
  692. type_info const * __info, const void* __fallback_info)
  693. {
  694. switch (__act)
  695. {
  696. case _Action::_Destroy:
  697. __destroy(const_cast<any &>(*__this));
  698. return nullptr;
  699. case _Action::_Copy:
  700. __copy(*__this, *__other);
  701. return nullptr;
  702. case _Action::_Move:
  703. __move(const_cast<any &>(*__this), *__other);
  704. return nullptr;
  705. case _Action::_Get:
  706. return __get(const_cast<any &>(*__this), __info, __fallback_info);
  707. case _Action::_TypeInfo:
  708. return __type_info();
  709. }
  710. }
  711. template <class ..._Args>
  712. _LIBCPP_INLINE_VISIBILITY
  713. static _Tp& __create(any & __dest, _Args&&... __args) {
  714. typedef allocator<_Tp> _Alloc;
  715. typedef allocator_traits<_Alloc> _ATraits;
  716. _Alloc __a;
  717. _Tp * __ret = static_cast<_Tp*>(static_cast<void*>(&__dest.__s.__buf));
  718. _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
  719. __dest.__h = &_SmallHandler::__handle;
  720. return *__ret;
  721. }
  722. private:
  723. _LIBCPP_INLINE_VISIBILITY
  724. static void __destroy(any & __this) {
  725. typedef allocator<_Tp> _Alloc;
  726. typedef allocator_traits<_Alloc> _ATraits;
  727. _Alloc __a;
  728. _Tp * __p = static_cast<_Tp *>(static_cast<void*>(&__this.__s.__buf));
  729. _ATraits::destroy(__a, __p);
  730. __this.__h = nullptr;
  731. }
  732. _LIBCPP_INLINE_VISIBILITY
  733. static void __copy(any const & __this, any & __dest) {
  734. _SmallHandler::__create(__dest, *static_cast<_Tp const *>(
  735. static_cast<void const *>(&__this.__s.__buf)));
  736. }
  737. _LIBCPP_INLINE_VISIBILITY
  738. static void __move(any & __this, any & __dest) {
  739. _SmallHandler::__create(__dest, _VSTD::move(
  740. *static_cast<_Tp*>(static_cast<void*>(&__this.__s.__buf))));
  741. __destroy(__this);
  742. }
  743. _LIBCPP_INLINE_VISIBILITY
  744. static void* __get(any & __this,
  745. type_info const * __info,
  746. const void* __fallback_id)
  747. {
  748. if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_id))
  749. return static_cast<void*>(&__this.__s.__buf);
  750. return nullptr;
  751. }
  752. _LIBCPP_INLINE_VISIBILITY
  753. static void* __type_info()
  754. {
  755. #if !defined(_LIBCPP_NO_RTTI)
  756. return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
  757. #else
  758. return nullptr;
  759. #endif
  760. }
  761. };
  762. template <class _Tp>
  763. struct _LIBCPP_TEMPLATE_VIS _LargeHandler
  764. {
  765. _LIBCPP_INLINE_VISIBILITY
  766. static void* __handle(_Action __act, any const * __this,
  767. any * __other, type_info const * __info,
  768. void const* __fallback_info)
  769. {
  770. switch (__act)
  771. {
  772. case _Action::_Destroy:
  773. __destroy(const_cast<any &>(*__this));
  774. return nullptr;
  775. case _Action::_Copy:
  776. __copy(*__this, *__other);
  777. return nullptr;
  778. case _Action::_Move:
  779. __move(const_cast<any &>(*__this), *__other);
  780. return nullptr;
  781. case _Action::_Get:
  782. return __get(const_cast<any &>(*__this), __info, __fallback_info);
  783. case _Action::_TypeInfo:
  784. return __type_info();
  785. }
  786. }
  787. template <class ..._Args>
  788. _LIBCPP_INLINE_VISIBILITY
  789. static _Tp& __create(any & __dest, _Args&&... __args) {
  790. typedef allocator<_Tp> _Alloc;
  791. typedef allocator_traits<_Alloc> _ATraits;
  792. typedef __allocator_destructor<_Alloc> _Dp;
  793. _Alloc __a;
  794. unique_ptr<_Tp, _Dp> __hold(_ATraits::allocate(__a, 1), _Dp(__a, 1));
  795. _Tp * __ret = __hold.get();
  796. _ATraits::construct(__a, __ret, _VSTD::forward<_Args>(__args)...);
  797. __dest.__s.__ptr = __hold.release();
  798. __dest.__h = &_LargeHandler::__handle;
  799. return *__ret;
  800. }
  801. private:
  802. _LIBCPP_INLINE_VISIBILITY
  803. static void __destroy(any & __this){
  804. typedef allocator<_Tp> _Alloc;
  805. typedef allocator_traits<_Alloc> _ATraits;
  806. _Alloc __a;
  807. _Tp * __p = static_cast<_Tp *>(__this.__s.__ptr);
  808. _ATraits::destroy(__a, __p);
  809. _ATraits::deallocate(__a, __p, 1);
  810. __this.__h = nullptr;
  811. }
  812. _LIBCPP_INLINE_VISIBILITY
  813. static void __copy(any const & __this, any & __dest) {
  814. _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr));
  815. }
  816. _LIBCPP_INLINE_VISIBILITY
  817. static void __move(any & __this, any & __dest) {
  818. __dest.__s.__ptr = __this.__s.__ptr;
  819. __dest.__h = &_LargeHandler::__handle;
  820. __this.__h = nullptr;
  821. }
  822. _LIBCPP_INLINE_VISIBILITY
  823. static void* __get(any & __this, type_info const * __info,
  824. void const* __fallback_info)
  825. {
  826. if (__any_imp::__compare_typeid<_Tp>(__info, __fallback_info))
  827. return static_cast<void*>(__this.__s.__ptr);
  828. return nullptr;
  829. }
  830. _LIBCPP_INLINE_VISIBILITY
  831. static void* __type_info()
  832. {
  833. #if !defined(_LIBCPP_NO_RTTI)
  834. return const_cast<void*>(static_cast<void const *>(&typeid(_Tp)));
  835. #else
  836. return nullptr;
  837. #endif
  838. }
  839. };
  840. } // namespace __any_imp
  841. template <class _ValueType, class _Tp, class>
  842. any::any(_ValueType && __v) : __h(nullptr)
  843. {
  844. __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_ValueType>(__v));
  845. }
  846. template <class _ValueType, class ..._Args, class _Tp, class>
  847. any::any(in_place_type_t<_ValueType>, _Args&&... __args) {
  848. __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
  849. }
  850. template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
  851. any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) {
  852. __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
  853. }
  854. template <class _ValueType, class, class>
  855. inline _LIBCPP_INLINE_VISIBILITY
  856. any & any::operator=(_ValueType && __v)
  857. {
  858. any(_VSTD::forward<_ValueType>(__v)).swap(*this);
  859. return *this;
  860. }
  861. template <class _ValueType, class ..._Args, class _Tp, class>
  862. inline _LIBCPP_INLINE_VISIBILITY
  863. _Tp& any::emplace(_Args&&... __args) {
  864. reset();
  865. return __any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
  866. }
  867. template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
  868. inline _LIBCPP_INLINE_VISIBILITY
  869. _Tp& any::emplace(initializer_list<_Up> __il, _Args&&... __args) {
  870. reset();
  871. return __any_imp::_Handler<_Tp>::__create(*this, __il, _VSTD::forward<_Args>(__args)...);
  872. }
  873. inline _LIBCPP_INLINE_VISIBILITY
  874. void any::swap(any & __rhs) _NOEXCEPT
  875. {
  876. if (this == &__rhs)
  877. return;
  878. if (__h && __rhs.__h) {
  879. any __tmp;
  880. __rhs.__call(_Action::_Move, &__tmp);
  881. this->__call(_Action::_Move, &__rhs);
  882. __tmp.__call(_Action::_Move, this);
  883. }
  884. else if (__h) {
  885. this->__call(_Action::_Move, &__rhs);
  886. }
  887. else if (__rhs.__h) {
  888. __rhs.__call(_Action::_Move, this);
  889. }
  890. }
  891. // 6.4 Non-member functions
  892. inline _LIBCPP_INLINE_VISIBILITY
  893. void swap(any & __lhs, any & __rhs) _NOEXCEPT
  894. {
  895. __lhs.swap(__rhs);
  896. }
  897. template <class _Tp, class ..._Args>
  898. inline _LIBCPP_INLINE_VISIBILITY
  899. any make_any(_Args&&... __args) {
  900. return any(in_place_type<_Tp>, _VSTD::forward<_Args>(__args)...);
  901. }
  902. template <class _Tp, class _Up, class ..._Args>
  903. inline _LIBCPP_INLINE_VISIBILITY
  904. any make_any(initializer_list<_Up> __il, _Args&&... __args) {
  905. return any(in_place_type<_Tp>, __il, _VSTD::forward<_Args>(__args)...);
  906. }
  907. template <class _ValueType>
  908. inline _LIBCPP_INLINE_VISIBILITY
  909. _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
  910. _ValueType any_cast(any const & __v)
  911. {
  912. using _RawValueType = __uncvref_t<_ValueType>;
  913. static_assert(is_constructible<_ValueType, _RawValueType const &>::value,
  914. "ValueType is required to be a const lvalue reference "
  915. "or a CopyConstructible type");
  916. auto __tmp = _VSTD::any_cast<add_const_t<_RawValueType>>(&__v);
  917. if (__tmp == nullptr)
  918. __throw_bad_any_cast();
  919. return static_cast<_ValueType>(*__tmp);
  920. }
  921. template <class _ValueType>
  922. inline _LIBCPP_INLINE_VISIBILITY
  923. _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
  924. _ValueType any_cast(any & __v)
  925. {
  926. using _RawValueType = __uncvref_t<_ValueType>;
  927. static_assert(is_constructible<_ValueType, _RawValueType &>::value,
  928. "ValueType is required to be an lvalue reference "
  929. "or a CopyConstructible type");
  930. auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
  931. if (__tmp == nullptr)
  932. __throw_bad_any_cast();
  933. return static_cast<_ValueType>(*__tmp);
  934. }
  935. template <class _ValueType>
  936. inline _LIBCPP_INLINE_VISIBILITY
  937. _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
  938. _ValueType any_cast(any && __v)
  939. {
  940. using _RawValueType = __uncvref_t<_ValueType>;
  941. static_assert(is_constructible<_ValueType, _RawValueType>::value,
  942. "ValueType is required to be an rvalue reference "
  943. "or a CopyConstructible type");
  944. auto __tmp = _VSTD::any_cast<_RawValueType>(&__v);
  945. if (__tmp == nullptr)
  946. __throw_bad_any_cast();
  947. return static_cast<_ValueType>(_VSTD::move(*__tmp));
  948. }
  949. template <class _ValueType>
  950. inline _LIBCPP_INLINE_VISIBILITY
  951. add_pointer_t<add_const_t<_ValueType>>
  952. any_cast(any const * __any) _NOEXCEPT
  953. {
  954. static_assert(!is_reference<_ValueType>::value,
  955. "_ValueType may not be a reference.");
  956. return _VSTD::any_cast<_ValueType>(const_cast<any *>(__any));
  957. }
  958. template <class _RetType>
  959. inline _LIBCPP_INLINE_VISIBILITY
  960. _RetType __pointer_or_func_cast(void* __p, /*IsFunction*/false_type) noexcept {
  961. return static_cast<_RetType>(__p);
  962. }
  963. template <class _RetType>
  964. inline _LIBCPP_INLINE_VISIBILITY
  965. _RetType __pointer_or_func_cast(void*, /*IsFunction*/true_type) noexcept {
  966. return nullptr;
  967. }
  968. template <class _ValueType>
  969. add_pointer_t<_ValueType>
  970. any_cast(any * __any) _NOEXCEPT
  971. {
  972. using __any_imp::_Action;
  973. static_assert(!is_reference<_ValueType>::value,
  974. "_ValueType may not be a reference.");
  975. typedef typename add_pointer<_ValueType>::type _ReturnType;
  976. if (__any && __any->__h) {
  977. void *__p = __any->__call(_Action::_Get, nullptr,
  978. #if !defined(_LIBCPP_NO_RTTI)
  979. &typeid(_ValueType),
  980. #else
  981. nullptr,
  982. #endif
  983. __any_imp::__get_fallback_typeid<_ValueType>());
  984. return _VSTD::__pointer_or_func_cast<_ReturnType>(
  985. __p, is_function<_ValueType>{});
  986. }
  987. return nullptr;
  988. }
  989. #endif // _LIBCPP_STD_VER > 14
  990. _LIBCPP_END_NAMESPACE_STD
  991. #endif // _LIBCPP_ANY
  992. ====================MIT====================
  993. Permission is hereby granted, free of charge, to any person obtaining a copy
  994. of this software and associated documentation files (the "Software"), to deal
  995. in the Software without restriction, including without limitation the rights
  996. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  997. copies of the Software, and to permit persons to whom the Software is
  998. furnished to do so, subject to the following conditions:
  999. The above copyright notice and this permission notice shall be included in
  1000. all copies or substantial portions of the Software.
  1001. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1002. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  1003. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1004. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1005. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1006. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  1007. THE SOFTWARE.
  1008. ====================NCSA====================
  1009. Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
  1010. ====================NCSA====================
  1011. Permission is hereby granted, free of charge, to any person obtaining a copy of
  1012. this software and associated documentation files (the "Software"), to deal with
  1013. the Software without restriction, including without limitation the rights to
  1014. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
  1015. of the Software, and to permit persons to whom the Software is furnished to do
  1016. so, subject to the following conditions:
  1017. * Redistributions of source code must retain the above copyright notice,
  1018. this list of conditions and the following disclaimers.
  1019. * Redistributions in binary form must reproduce the above copyright notice,
  1020. this list of conditions and the following disclaimers in the
  1021. documentation and/or other materials provided with the distribution.
  1022. * Neither the names of the LLVM Team, University of Illinois at
  1023. Urbana-Champaign, nor the names of its contributors may be used to
  1024. endorse or promote products derived from this Software without specific
  1025. prior written permission.
  1026. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  1027. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  1028. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  1029. CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  1030. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  1031. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE
  1032. SOFTWARE.
  1033. ====================NCSA====================
  1034. University of Illinois/NCSA
  1035. Open Source License
  1036. ====================NCSA AND MIT====================
  1037. The libc++ library is dual licensed under both the University of Illinois
  1038. "BSD-Like" license and the MIT license. As a user of this code you may choose
  1039. to use it under either license. As a contributor, you agree to allow your code
  1040. to be used under both.
  1041. Full text of the relevant licenses is included below.