aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:16 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-20 20:51:16 +0000
commit1147845301c03308e3419b89c28c77bb6917fe04 (patch)
tree225f45e462607f9595a5e5f418a9533ab50e83bb
parentb7332b04df5d50c92640c74cfeb138ecb7e3f7ae (diff)
downloadsrc-1147845301c03308e3419b89c28c77bb6917fe04.tar.gz
src-1147845301c03308e3419b89c28c77bb6917fe04.zip
Vendor import of stripped libc++ trunk r366426 (just before the release_90 branchvendor/libc++/libc++-trunk-r366426
Notes
Notes: svn path=/vendor/libc++/dist/; revision=351284 svn path=/vendor/libc++/libc++-trunk-r366426/; revision=351285; tag=vendor/libc++/libc++-trunk-r366426
-rw-r--r--LICENSE.TXT237
-rw-r--r--include/__bit_reference35
-rw-r--r--include/__bsd_locale_defaults.h7
-rw-r--r--include/__bsd_locale_fallbacks.h7
-rw-r--r--include/__config287
-rw-r--r--include/__debug55
-rw-r--r--include/__errc7
-rw-r--r--include/__functional_037
-rw-r--r--include/__functional_base17
-rw-r--r--include/__functional_base_037
-rw-r--r--include/__hash_table30
-rw-r--r--include/__libcpp_version2
-rw-r--r--include/__locale80
-rw-r--r--include/__mutex_base49
-rw-r--r--include/__node_handle12
-rw-r--r--include/__nullptr7
-rw-r--r--include/__sso_allocator7
-rw-r--r--include/__std_stream7
-rw-r--r--include/__string7
-rw-r--r--include/__threading_support19
-rw-r--r--include/__tree218
-rw-r--r--include/__tuple68
-rw-r--r--include/__undef_macros7
-rw-r--r--include/algorithm459
-rw-r--r--include/any9
-rw-r--r--include/array36
-rw-r--r--include/atomic1068
-rw-r--r--include/bit371
-rw-r--r--include/bitset11
-rw-r--r--include/cassert7
-rw-r--r--include/ccomplex7
-rw-r--r--include/cctype7
-rw-r--r--include/cerrno7
-rw-r--r--include/cfenv7
-rw-r--r--include/cfloat7
-rw-r--r--include/charconv43
-rw-r--r--include/chrono109
-rw-r--r--include/cinttypes7
-rw-r--r--include/ciso6467
-rw-r--r--include/climits7
-rw-r--r--include/clocale7
-rw-r--r--include/cmath35
-rw-r--r--include/codecvt7
-rw-r--r--include/compare7
-rw-r--r--include/complex11
-rw-r--r--include/complex.h7
-rw-r--r--include/condition_variable7
-rw-r--r--include/csetjmp7
-rw-r--r--include/csignal7
-rw-r--r--include/cstdarg7
-rw-r--r--include/cstdbool7
-rw-r--r--include/cstddef7
-rw-r--r--include/cstdint7
-rw-r--r--include/cstdio7
-rw-r--r--include/cstdlib7
-rw-r--r--include/cstring7
-rw-r--r--include/ctgmath7
-rw-r--r--include/ctime7
-rw-r--r--include/ctype.h7
-rw-r--r--include/cwchar7
-rw-r--r--include/cwctype7
-rw-r--r--include/deque31
-rw-r--r--include/errno.h7
-rw-r--r--include/exception21
-rw-r--r--include/experimental/__config15
-rw-r--r--include/experimental/__memory7
-rw-r--r--include/experimental/algorithm7
-rw-r--r--include/experimental/any21
-rw-r--r--include/experimental/chrono21
-rw-r--r--include/experimental/coroutine13
-rw-r--r--include/experimental/deque7
-rw-r--r--include/experimental/filesystem7
-rw-r--r--include/experimental/forward_list7
-rw-r--r--include/experimental/functional16
-rw-r--r--include/experimental/iterator7
-rw-r--r--include/experimental/list7
-rw-r--r--include/experimental/map7
-rw-r--r--include/experimental/memory_resource7
-rw-r--r--include/experimental/numeric21
-rw-r--r--include/experimental/optional21
-rw-r--r--include/experimental/propagate_const7
-rw-r--r--include/experimental/ratio21
-rw-r--r--include/experimental/regex7
-rw-r--r--include/experimental/set7
-rw-r--r--include/experimental/simd7
-rw-r--r--include/experimental/string7
-rw-r--r--include/experimental/string_view21
-rw-r--r--include/experimental/system_error21
-rw-r--r--include/experimental/tuple21
-rw-r--r--include/experimental/type_traits17
-rw-r--r--include/experimental/unordered_map7
-rw-r--r--include/experimental/unordered_set7
-rw-r--r--include/experimental/utility7
-rw-r--r--include/experimental/vector7
-rw-r--r--include/ext/__hash34
-rw-r--r--include/ext/hash_map78
-rw-r--r--include/ext/hash_set34
-rw-r--r--include/fenv.h116
-rw-r--r--include/filesystem32
-rw-r--r--include/float.h7
-rw-r--r--include/forward_list77
-rw-r--r--include/fstream23
-rw-r--r--include/functional140
-rw-r--r--include/future21
-rw-r--r--include/initializer_list9
-rw-r--r--include/inttypes.h12
-rw-r--r--include/iomanip17
-rw-r--r--include/ios56
-rw-r--r--include/iosfwd7
-rw-r--r--include/iostream7
-rw-r--r--include/istream895
-rw-r--r--include/iterator247
-rw-r--r--include/limits9
-rw-r--r--include/limits.h7
-rw-r--r--include/list158
-rw-r--r--include/locale21
-rw-r--r--include/locale.h7
-rw-r--r--include/map104
-rw-r--r--include/math.h143
-rw-r--r--include/memory403
-rw-r--r--include/module.modulemap5
-rw-r--r--include/mutex26
-rw-r--r--include/new42
-rw-r--r--include/numeric84
-rw-r--r--include/optional114
-rw-r--r--include/ostream12
-rw-r--r--include/queue27
-rw-r--r--include/random23
-rw-r--r--include/ratio7
-rw-r--r--include/regex135
-rw-r--r--include/scoped_allocator7
-rw-r--r--include/set98
-rw-r--r--include/setjmp.h7
-rw-r--r--include/shared_mutex7
-rw-r--r--include/span251
-rw-r--r--include/sstream9
-rw-r--r--include/stack17
-rw-r--r--include/stdbool.h7
-rw-r--r--include/stddef.h7
-rw-r--r--include/stdexcept36
-rw-r--r--include/stdint.h12
-rw-r--r--include/stdio.h7
-rw-r--r--include/stdlib.h41
-rw-r--r--include/streambuf7
-rw-r--r--include/string77
-rw-r--r--include/string.h7
-rw-r--r--include/string_view41
-rw-r--r--include/strstream7
-rw-r--r--include/system_error7
-rw-r--r--include/tgmath.h7
-rw-r--r--include/thread12
-rw-r--r--include/tuple155
-rw-r--r--include/type_traits1587
-rw-r--r--include/typeindex7
-rw-r--r--include/typeinfo266
-rw-r--r--include/unordered_map201
-rw-r--r--include/unordered_set165
-rw-r--r--include/utility57
-rw-r--r--include/valarray32
-rw-r--r--include/variant78
-rw-r--r--include/vector42
-rw-r--r--include/version17
-rw-r--r--include/wchar.h7
-rw-r--r--include/wctype.h7
-rw-r--r--src/CMakeLists.txt495
-rw-r--r--src/algorithm.cpp12
-rw-r--r--src/any.cpp7
-rw-r--r--src/bind.cpp7
-rw-r--r--src/charconv.cpp167
-rw-r--r--src/chrono.cpp31
-rw-r--r--src/condition_variable.cpp18
-rw-r--r--src/condition_variable_destructor.cpp46
-rw-r--r--src/debug.cpp94
-rw-r--r--src/exception.cpp10
-rw-r--r--src/experimental/memory_resource.cpp34
-rw-r--r--src/filesystem/directory_iterator.cpp10
-rw-r--r--src/filesystem/filesystem_common.h7
-rw-r--r--src/filesystem/int128_builtins.cpp7
-rw-r--r--src/filesystem/operations.cpp42
-rw-r--r--src/functional.cpp7
-rw-r--r--src/future.cpp7
-rw-r--r--src/hash.cpp19
-rw-r--r--src/include/apple_availability.h7
-rw-r--r--src/include/atomic_support.h7
-rw-r--r--src/include/config_elast.h9
-rw-r--r--src/include/refstring.h7
-rw-r--r--src/ios.cpp28
-rw-r--r--src/iostream.cpp28
-rw-r--r--src/locale.cpp27
-rw-r--r--src/memory.cpp10
-rw-r--r--src/mutex.cpp34
-rw-r--r--src/mutex_destructor.cpp51
-rw-r--r--src/new.cpp31
-rw-r--r--src/optional.cpp7
-rw-r--r--src/random.cpp7
-rw-r--r--src/regex.cpp7
-rw-r--r--src/shared_mutex.cpp10
-rw-r--r--src/stdexcept.cpp99
-rw-r--r--src/string.cpp147
-rw-r--r--src/strstream.cpp7
-rw-r--r--src/support/runtime/exception_fallback.ipp7
-rw-r--r--src/support/runtime/exception_glibcxx.ipp7
-rw-r--r--src/support/runtime/exception_libcxxabi.ipp7
-rw-r--r--src/support/runtime/exception_libcxxrt.ipp7
-rw-r--r--src/support/runtime/exception_msvc.ipp11
-rw-r--r--src/support/runtime/exception_pointer_cxxabi.ipp7
-rw-r--r--src/support/runtime/exception_pointer_glibcxx.ipp7
-rw-r--r--src/support/runtime/exception_pointer_msvc.ipp7
-rw-r--r--src/support/runtime/exception_pointer_unimplemented.ipp7
-rw-r--r--src/support/runtime/new_handler_fallback.ipp7
-rw-r--r--src/support/runtime/stdexcept_default.ipp64
-rw-r--r--src/support/runtime/stdexcept_vcruntime.ipp16
-rw-r--r--src/system_error.cpp7
-rw-r--r--src/thread.cpp15
-rw-r--r--src/typeinfo.cpp17
-rw-r--r--src/utility.cpp7
-rw-r--r--src/valarray.cpp11
-rw-r--r--src/variant.cpp7
-rw-r--r--src/vector.cpp7
219 files changed, 6814 insertions, 5326 deletions
diff --git a/LICENSE.TXT b/LICENSE.TXT
index 190d9394d517..e159d283443f 100644
--- a/LICENSE.TXT
+++ b/LICENSE.TXT
@@ -1,5 +1,240 @@
==============================================================================
-libc++ License
+The LLVM Project is under the Apache License v2.0 with LLVM Exceptions:
+==============================================================================
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+---- LLVM Exceptions to the Apache 2.0 License ----
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into an Object form of such source code, you
+may redistribute such embedded portions in such Object form without complying
+with the conditions of Sections 4(a), 4(b) and 4(d) of the License.
+
+In addition, if you combine or link compiled forms of this Software with
+software that is licensed under the GPLv2 ("Combined Software") and if a
+court of competent jurisdiction determines that the patent provision (Section
+3), the indemnity provision (Section 9) or other Section of the License
+conflicts with the conditions of the GPLv2, you may retroactively and
+prospectively choose to deem waived or otherwise exclude such Section(s) of
+the License, but only in their entirety and only with respect to the Combined
+Software.
+
+==============================================================================
+Software from third parties included in the LLVM Project:
+==============================================================================
+The LLVM Project contains third party software which is under different license
+terms. All such code will be identified clearly using at least one of two
+mechanisms:
+1) It will be in a separate directory tree with its own `LICENSE.txt` or
+ `LICENSE` file at the top containing the specific license and restrictions
+ which apply to that software, or
+2) It will contain specific license and restriction terms at the top of every
+ file.
+
+==============================================================================
+Legacy LLVM License (https://llvm.org/docs/DeveloperPolicy.html#legacy):
==============================================================================
The libc++ library is dual licensed under both the University of Illinois
diff --git a/include/__bit_reference b/include/__bit_reference
index c208af2b4d76..cce74fb50236 100644
--- a/include/__bit_reference
+++ b/include/__bit_reference
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -69,7 +68,7 @@ public:
_LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT {*__seg_ ^= __mask_;}
_LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, false> operator&() const _NOEXCEPT
- {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__ctz(__mask_)));}
+ {return __bit_iterator<_Cp, false>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
__bit_reference(__storage_pointer __s, __storage_type __m) _NOEXCEPT
@@ -141,7 +140,7 @@ public:
{return static_cast<bool>(*__seg_ & __mask_);}
_LIBCPP_INLINE_VISIBILITY __bit_iterator<_Cp, true> operator&() const _NOEXCEPT
- {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__ctz(__mask_)));}
+ {return __bit_iterator<_Cp, true>(__seg_, static_cast<unsigned>(__libcpp_ctz(__mask_)));}
private:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
@@ -168,7 +167,7 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
__storage_type __b = *__first.__seg_ & __m;
if (__b)
- return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
if (__n == __dn)
return __first + __n;
__n -= __dn;
@@ -177,14 +176,14 @@ __find_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
// do middle whole words
for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
if (*__first.__seg_)
- return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(*__first.__seg_)));
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(*__first.__seg_)));
// do last partial word
if (__n > 0)
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
__storage_type __b = *__first.__seg_ & __m;
if (__b)
- return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
}
return _It(__first.__seg_, static_cast<unsigned>(__n));
}
@@ -204,7 +203,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
__storage_type __b = ~*__first.__seg_ & __m;
if (__b)
- return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
if (__n == __dn)
return __first + __n;
__n -= __dn;
@@ -215,7 +214,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
{
__storage_type __b = ~*__first.__seg_;
if (__b)
- return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
}
// do last partial word
if (__n > 0)
@@ -223,7 +222,7 @@ __find_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
__storage_type __b = ~*__first.__seg_ & __m;
if (__b)
- return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__ctz(__b)));
+ return _It(__first.__seg_, static_cast<unsigned>(_VSTD::__libcpp_ctz(__b)));
}
return _It(__first.__seg_, static_cast<unsigned>(__n));
}
@@ -255,18 +254,18 @@ __count_bool_true(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_type
__storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
__storage_type __dn = _VSTD::min(__clz_f, __n);
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
- __r = _VSTD::__popcount(*__first.__seg_ & __m);
+ __r = _VSTD::__libcpp_popcount(*__first.__seg_ & __m);
__n -= __dn;
++__first.__seg_;
}
// do middle whole words
for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
- __r += _VSTD::__popcount(*__first.__seg_);
+ __r += _VSTD::__libcpp_popcount(*__first.__seg_);
// do last partial word
if (__n > 0)
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
- __r += _VSTD::__popcount(*__first.__seg_ & __m);
+ __r += _VSTD::__libcpp_popcount(*__first.__seg_ & __m);
}
return __r;
}
@@ -286,18 +285,18 @@ __count_bool_false(__bit_iterator<_Cp, _IsConst> __first, typename _Cp::size_typ
__storage_type __clz_f = static_cast<__storage_type>(__bits_per_word - __first.__ctz_);
__storage_type __dn = _VSTD::min(__clz_f, __n);
__storage_type __m = (~__storage_type(0) << __first.__ctz_) & (~__storage_type(0) >> (__clz_f - __dn));
- __r = _VSTD::__popcount(~*__first.__seg_ & __m);
+ __r = _VSTD::__libcpp_popcount(~*__first.__seg_ & __m);
__n -= __dn;
++__first.__seg_;
}
// do middle whole words
for (; __n >= __bits_per_word; ++__first.__seg_, __n -= __bits_per_word)
- __r += _VSTD::__popcount(~*__first.__seg_);
+ __r += _VSTD::__libcpp_popcount(~*__first.__seg_);
// do last partial word
if (__n > 0)
{
__storage_type __m = ~__storage_type(0) >> (__bits_per_word - __n);
- __r += _VSTD::__popcount(~*__first.__seg_ & __m);
+ __r += _VSTD::__libcpp_popcount(~*__first.__seg_ & __m);
}
return __r;
}
diff --git a/include/__bsd_locale_defaults.h b/include/__bsd_locale_defaults.h
index cbc407d10305..2ace2a21cb01 100644
--- a/include/__bsd_locale_defaults.h
+++ b/include/__bsd_locale_defaults.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------- __bsd_locale_defaults.h -----------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// The BSDs have lots of *_l functions. We don't want to define those symbols
diff --git a/include/__bsd_locale_fallbacks.h b/include/__bsd_locale_fallbacks.h
index 3097b01410d3..a807fe039554 100644
--- a/include/__bsd_locale_fallbacks.h
+++ b/include/__bsd_locale_fallbacks.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------- __bsd_locale_fallbacks.h ----------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// The BSDs have lots of *_l functions. This file provides reimplementations
diff --git a/include/__config b/include/__config
index f0bc3483facd..1ecced9f4792 100644
--- a/include/__config
+++ b/include/__config
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- __config ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -33,12 +32,16 @@
# define _GNUC_VER_NEW 0
#endif
-#define _LIBCPP_VERSION 8000
+#define _LIBCPP_VERSION 9000
#ifndef _LIBCPP_ABI_VERSION
# define _LIBCPP_ABI_VERSION 1
#endif
+#ifndef __STDC_HOSTED__
+# define _LIBCPP_FREESTANDING
+#endif
+
#ifndef _LIBCPP_STD_VER
# if __cplusplus <= 201103L
# define _LIBCPP_STD_VER 11
@@ -93,10 +96,12 @@
// Enable optimized version of __do_get_(un)signed which avoids redundant copies.
# define _LIBCPP_ABI_OPTIMIZED_LOCALE_NUM_GET
// Use the smallest possible integer type to represent the index of the variant.
-// Previously libc++ used "unsigned int" exclusivly.
+// Previously libc++ used "unsigned int" exclusively.
# define _LIBCPP_ABI_VARIANT_INDEX_TYPE_OPTIMIZATION
// Unstable attempt to provide a more optimized std::function
# define _LIBCPP_ABI_OPTIMIZED_FUNCTION
+// All the regex constants must be distinct and nonzero.
+# define _LIBCPP_ABI_REGEX_CONSTANTS_NONZERO
#elif _LIBCPP_ABI_VERSION == 1
# if !defined(_LIBCPP_OBJECT_FORMAT_COFF)
// Enable compiling copies of now inline methods into the dylib to support
@@ -182,6 +187,10 @@
#define _LIBCPP_CLANG_VER 0
#endif
+#if defined(_LIBCPP_COMPILER_GCC) && __cplusplus < 201103L
+#error "libc++ does not support using GCC with C++03. Please enable C++11"
+#endif
+
// FIXME: ABI detection should be done via compiler builtin macros. This
// is just a placeholder until Clang implements such macros. For now assume
// that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
@@ -201,6 +210,10 @@
# endif
#endif
+#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
+# define _LIBCPP_ABI_VCRUNTIME
+#endif
+
// Need to detect which libc we're using if we're on Linux.
#if defined(__linux__)
# include <features.h>
@@ -257,7 +270,7 @@
# define _LIBCPP_WIN32API
# define _LIBCPP_LITTLE_ENDIAN
# define _LIBCPP_SHORT_WCHAR 1
-// Both MinGW and native MSVC provide a "MSVC"-like enviroment
+// Both MinGW and native MSVC provide a "MSVC"-like environment
# define _LIBCPP_MSVCRT_LIKE
// If mingw not explicitly detected, assume using MS C runtime only if
// a MS compatibility version is specified.
@@ -298,7 +311,7 @@
// random data even when using sandboxing mechanisms such as chroots,
// Capsicum, etc.
# define _LIBCPP_USING_ARC4_RANDOM
-#elif defined(__Fuchsia__)
+#elif defined(__Fuchsia__) || defined(__wasi__)
# define _LIBCPP_USING_GETENTROPY
#elif defined(__native_client__)
// NaCl's sandbox (which PNaCl also runs in) doesn't allow filesystem access,
@@ -332,7 +345,7 @@
# if defined(__FreeBSD__)
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_C11_FEATURES
-# elif defined(__Fuchsia__)
+# elif defined(__Fuchsia__) || defined(__wasi__)
# define _LIBCPP_HAS_QUICK_EXIT
# define _LIBCPP_HAS_TIMESPEC_GET
# define _LIBCPP_HAS_C11_FEATURES
@@ -400,10 +413,6 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_STRONG_ENUMS
#endif
-#if !(__has_feature(cxx_decltype))
-#define _LIBCPP_HAS_NO_DECLTYPE
-#endif
-
#if __has_feature(cxx_attributes)
# define _LIBCPP_NORETURN [[noreturn]]
#else
@@ -434,18 +443,6 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_VARIADICS
#endif
-#if !(__has_feature(cxx_generalized_initializers))
-#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-#endif
-
-#if __has_feature(is_base_of)
-#define _LIBCPP_HAS_IS_BASE_OF
-#endif
-
-#if __has_feature(is_final)
-#define _LIBCPP_HAS_IS_FINAL
-#endif
-
// Objective-C++ features (opt-in)
#if __has_feature(objc_arc)
#define _LIBCPP_HAS_OBJC_ARC
@@ -455,10 +452,6 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_OBJC_ARC_WEAK
#endif
-#if !(__has_feature(cxx_constexpr))
-#define _LIBCPP_HAS_NO_CONSTEXPR
-#endif
-
#if !(__has_feature(cxx_relaxed_constexpr))
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#endif
@@ -471,14 +464,6 @@ typedef __char32_t char32_t;
#define _LIBCPP_HAS_NO_NOEXCEPT
#endif
-#if __has_feature(underlying_type)
-#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
-#endif
-
-#if __has_feature(is_literal)
-#define _LIBCPP_IS_LITERAL(T) __is_literal(T)
-#endif
-
#if !defined(_LIBCPP_HAS_NO_ASAN) && !__has_feature(address_sanitizer)
#define _LIBCPP_HAS_NO_ASAN
#endif
@@ -510,69 +495,20 @@ typedef __char32_t char32_t;
#define _LIBCPP_NORETURN __attribute__((noreturn))
-#if _GNUC_VER >= 407
-#define _LIBCPP_UNDERLYING_TYPE(T) __underlying_type(T)
-#define _LIBCPP_IS_LITERAL(T) __is_literal_type(T)
-#define _LIBCPP_HAS_IS_FINAL
-#endif
-
-#if defined(__GNUC__) && _GNUC_VER >= 403
-#define _LIBCPP_HAS_IS_BASE_OF
-#endif
-
#if !__EXCEPTIONS && !defined(_LIBCPP_NO_EXCEPTIONS)
#define _LIBCPP_NO_EXCEPTIONS
#endif
-// constexpr was added to GCC in 4.6.
-#if _GNUC_VER < 406
-# define _LIBCPP_HAS_NO_CONSTEXPR
-// Can only use constexpr in c++11 mode.
-#elif !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L
-# define _LIBCPP_HAS_NO_CONSTEXPR
-#endif
-
// Determine if GCC supports relaxed constexpr
#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#endif
-// GCC 5 will support variable templates
+// GCC 5 supports variable templates
#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#endif
-#ifndef __GXX_EXPERIMENTAL_CXX0X__
-
-#define _LIBCPP_HAS_NO_DECLTYPE
-#define _LIBCPP_HAS_NO_NULLPTR
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#define _LIBCPP_HAS_NO_VARIADICS
-#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#define _LIBCPP_HAS_NO_STRONG_ENUMS
-#define _LIBCPP_HAS_NO_NOEXCEPT
-
-#else // __GXX_EXPERIMENTAL_CXX0X__
-
-#if _GNUC_VER < 403
-#define _LIBCPP_HAS_NO_RVALUE_REFERENCES
-#endif
-
-
-#if _GNUC_VER < 404
-#define _LIBCPP_HAS_NO_DECLTYPE
-#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#define _LIBCPP_HAS_NO_VARIADICS
-#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-#endif // _GNUC_VER < 404
-
-#if _GNUC_VER < 406
-#define _LIBCPP_HAS_NO_NOEXCEPT
-#define _LIBCPP_HAS_NO_NULLPTR
-#endif
-
-#endif // __GXX_EXPERIMENTAL_CXX0X__
-
#if !defined(_LIBCPP_HAS_NO_ASAN) && !defined(__SANITIZE_ADDRESS__)
#define _LIBCPP_HAS_NO_ASAN
#endif
@@ -597,16 +533,12 @@ typedef __char32_t char32_t;
#error "MSVC versions prior to Visual Studio 2015 are not supported"
#endif
-#define _LIBCPP_HAS_IS_BASE_OF
-#define _LIBCPP_HAS_NO_CONSTEXPR
#define _LIBCPP_HAS_NO_CXX14_CONSTEXPR
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
-#define _LIBCPP_HAS_NO_NOEXCEPT
#define __alignof__ __alignof
#define _LIBCPP_NORETURN __declspec(noreturn)
#define _ALIGNAS(x) __declspec(align(x))
#define _ALIGNAS_TYPE(x) alignas(x)
-#define _LIBCPP_HAS_NO_VARIADICS
#define _LIBCPP_WEAK
@@ -623,12 +555,7 @@ typedef __char32_t char32_t;
#define _ATTRIBUTE(x) __attribute__((x))
#define _LIBCPP_NORETURN __attribute__((noreturn))
-#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
-#define _LIBCPP_HAS_NO_NOEXCEPT
-#define _LIBCPP_HAS_NO_NULLPTR
#define _LIBCPP_HAS_NO_UNICODE_CHARS
-#define _LIBCPP_HAS_IS_BASE_OF
-#define _LIBCPP_HAS_IS_FINAL
#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES
#if defined(_AIX)
@@ -659,8 +586,13 @@ typedef __char32_t char32_t;
# define _LIBCPP_EXPORTED_FROM_ABI
#elif defined(_LIBCPP_BUILDING_LIBRARY)
# define _LIBCPP_DLL_VIS __declspec(dllexport)
-# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
-# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+# if defined(__MINGW32__)
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS _LIBCPP_DLL_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+# else
+# define _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS
+# define _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS _LIBCPP_DLL_VIS
+# endif
# define _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_DLL_VIS
# define _LIBCPP_EXPORTED_FROM_ABI __declspec(dllexport)
#else
@@ -777,7 +709,7 @@ typedef __char32_t char32_t;
#else
// Try to approximate the effect of exclude_from_explicit_instantiation
// (which is that entities are not assumed to be provided by explicit
- // template instantitations in the dylib) by always inlining those entities.
+ // template instantiations in the dylib) by always inlining those entities.
# define _LIBCPP_EXCLUDE_FROM_EXPLICIT_INSTANTIATION _LIBCPP_ALWAYS_INLINE
#endif
@@ -789,6 +721,16 @@ typedef __char32_t char32_t;
# endif
#endif
+#ifndef _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT
+# ifdef _LIBCPP_OBJECT_FORMAT_COFF // Windows binaries can't merge typeinfos.
+# define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 0
+#else
+// TODO: This isn't strictly correct on ELF platforms due to llvm.org/PR37398
+// And we should consider defaulting to OFF.
+# define _LIBCPP_HAS_MERGED_TYPEINFO_NAMES_DEFAULT 1
+#endif
+#endif
+
#ifndef _LIBCPP_HIDE_FROM_ABI
# if _LIBCPP_HIDE_FROM_ABI_PER_TU
# define _LIBCPP_HIDE_FROM_ABI _LIBCPP_HIDDEN _LIBCPP_INTERNAL_LINKAGE
@@ -843,22 +785,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
# define _NOEXCEPT_(x)
#endif
-#if defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
-# if !defined(_LIBCPP_DEBUG)
-# error cannot use _LIBCPP_DEBUG_USE_EXCEPTIONS unless _LIBCPP_DEBUG is defined
-# endif
-# ifdef _LIBCPP_HAS_NO_NOEXCEPT
-# define _NOEXCEPT_DEBUG
-# define _NOEXCEPT_DEBUG_(x)
-# else
-# define _NOEXCEPT_DEBUG noexcept(false)
-# define _NOEXCEPT_DEBUG_(x) noexcept(false)
-# endif
-#else
-# define _NOEXCEPT_DEBUG _NOEXCEPT
-# define _NOEXCEPT_DEBUG_(x) _NOEXCEPT_(x)
-#endif
-
#ifdef _LIBCPP_HAS_NO_UNICODE_CHARS
typedef unsigned short char16_t;
typedef unsigned int char32_t;
@@ -869,30 +795,11 @@ typedef unsigned int char32_t;
#endif
#ifdef _LIBCPP_CXX03_LANG
-# if __has_extension(c_static_assert)
-# define static_assert(__b, __m) _Static_assert(__b, __m)
-# else
-extern "C++" {
-template <bool> struct __static_assert_test;
-template <> struct __static_assert_test<true> {};
-template <unsigned> struct __static_assert_check {};
-}
-# define static_assert(__b, __m) \
- typedef __static_assert_check<sizeof(__static_assert_test<(__b)>)> \
- _LIBCPP_CONCAT(__t, __LINE__)
-# endif // __has_extension(c_static_assert)
+# define static_assert(...) _Static_assert(__VA_ARGS__)
+# define decltype(...) __decltype(__VA_ARGS__)
#endif // _LIBCPP_CXX03_LANG
-#ifdef _LIBCPP_HAS_NO_DECLTYPE
-// GCC 4.6 provides __decltype in all standard modes.
-# if __has_keyword(__decltype) || _LIBCPP_CLANG_VER >= 304 || _GNUC_VER >= 406
-# define decltype(__x) __decltype(__x)
-# else
-# define decltype(__x) __typeof__(__x)
-# endif
-#endif
-
-#ifdef _LIBCPP_HAS_NO_CONSTEXPR
+#ifdef _LIBCPP_CXX03_LANG
# define _LIBCPP_CONSTEXPR
#else
# define _LIBCPP_CONSTEXPR constexpr
@@ -911,9 +818,9 @@ template <unsigned> struct __static_assert_check {};
#endif
#ifdef __GNUC__
-# define _NOALIAS __attribute__((__malloc__))
+# define _LIBCPP_NOALIAS __attribute__((__malloc__))
#else
-# define _NOALIAS
+# define _LIBCPP_NOALIAS
#endif
#if __has_feature(cxx_explicit_conversions) || defined(__IBMCPP__) || \
@@ -966,10 +873,6 @@ template <unsigned> struct __static_assert_check {};
#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__;
#endif
-#if defined(__APPLE__) && defined(__LP64__) && !defined(__x86_64__)
-#define _LIBCPP_NONUNIQUE_RTTI_BIT (1ULL << 63)
-#endif
-
#if defined(__APPLE__) || defined(__FreeBSD__) || defined(_LIBCPP_MSVCRT_LIKE) || \
defined(__sun__) || defined(__NetBSD__) || defined(__CloudABI__)
#define _LIBCPP_LOCALE__L_EXTENSIONS 1
@@ -990,13 +893,10 @@ template <unsigned> struct __static_assert_check {};
// for align_val_t were added in 19.12, aka VS 2017 version 15.3.
#if defined(_LIBCPP_MSVCRT) && defined(_MSC_VER) && _MSC_VER < 1912
# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-#elif defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
-# define _LIBCPP_DEFER_NEW_TO_VCRUNTIME
-# if !defined(__cpp_aligned_new)
- // We're defering to Microsoft's STL to provide aligned new et al. We don't
- // have it unless the language feature test macro is defined.
-# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
-# endif
+#elif defined(_LIBCPP_ABI_VCRUNTIME) && !defined(__cpp_aligned_new)
+ // We're deferring to Microsoft's STL to provide aligned new et al. We don't
+ // have it unless the language feature test macro is defined.
+# define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
#endif
#if defined(__APPLE__)
@@ -1025,8 +925,10 @@ template <unsigned> struct __static_assert_check {};
#endif
// Deprecation macros.
-// Deprecations warnings are only enabled when _LIBCPP_ENABLE_DEPRECATION_WARNINGS is defined.
-#if defined(_LIBCPP_ENABLE_DEPRECATION_WARNINGS)
+//
+// Deprecations warnings are always enabled, except when users explicitly opt-out
+// by defining _LIBCPP_DISABLE_DEPRECATION_WARNINGS.
+#if !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS)
# if __has_attribute(deprecated)
# define _LIBCPP_DEPRECATED __attribute__ ((deprecated))
# elif _LIBCPP_STD_VER > 11
@@ -1128,6 +1030,12 @@ template <unsigned> struct __static_assert_check {};
#endif
#endif
+#if __has_attribute(no_destroy)
+# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
+#else
+# define _LIBCPP_NO_DESTROY
+#endif
+
#ifndef _LIBCPP_HAS_NO_ASAN
_LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
const void *, const void *, const void *, const void *);
@@ -1158,6 +1066,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
!defined(_LIBCPP_HAS_THREAD_API_EXTERNAL)
# if defined(__FreeBSD__) || \
defined(__Fuchsia__) || \
+ defined(__wasi__) || \
defined(__NetBSD__) || \
defined(__linux__) || \
defined(__GNU__) || \
@@ -1188,6 +1097,23 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
_LIBCPP_HAS_NO_THREADS is defined.
#endif
+// The Apple, glibc, and Bionic implementation of pthreads implements
+// pthread_mutex_destroy as nop for regular mutexes. Additionally, Win32
+// mutexes have no destroy mechanism.
+// TODO(EricWF): Enable this optimization on Apple and Bionic platforms after
+// speaking to their respective stakeholders.
+#if (defined(_LIBCPP_HAS_THREAD_API_PTHREAD) && defined(__GLIBC__)) \
+ || defined(_LIBCPP_HAS_THREAD_API_WIN32)
+# define _LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION
+#endif
+
+// Destroying a condvar is a nop on Windows.
+// TODO(EricWF): This is potentially true for some pthread implementations
+// as well.
+#if defined(_LIBCPP_HAS_THREAD_API_WIN32)
+# define _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
+#endif
+
// Systems that use capability-based security (FreeBSD with Capsicum,
// Nuxi CloudABI) may only provide local filesystem access (using *at()).
// Functions like open(), rename(), unlink() and stat() should not be
@@ -1204,7 +1130,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#endif
#if defined(__BIONIC__) || defined(__CloudABI__) || \
- defined(__Fuchsia__) || defined(_LIBCPP_HAS_MUSL_LIBC)
+ defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC)
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
#endif
@@ -1216,13 +1142,22 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#if __has_feature(cxx_atomic) || __has_extension(c_atomic) || __has_keyword(_Atomic)
# define _LIBCPP_HAS_C_ATOMIC_IMP
-#elif _GNUC_VER > 407
+#elif defined(_LIBCPP_COMPILER_GCC)
# define _LIBCPP_HAS_GCC_ATOMIC_IMP
#endif
-#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \
+#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && \
+ !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) && \
+ !defined(_LIBCPP_HAS_EXTERNAL_ATOMIC_IMP)) \
|| defined(_LIBCPP_HAS_NO_THREADS)
-#define _LIBCPP_HAS_NO_ATOMIC_HEADER
+# define _LIBCPP_HAS_NO_ATOMIC_HEADER
+#else
+# ifndef _LIBCPP_ATOMIC_FLAG_TYPE
+# define _LIBCPP_ATOMIC_FLAG_TYPE bool
+# endif
+# ifdef _LIBCPP_FREESTANDING
+# define _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+# endif
#endif
#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
@@ -1250,6 +1185,10 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#define _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF
#endif
+#if !__has_builtin(__builtin_is_constant_evaluated) && _GNUC_VER < 900
+#define _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED
+#endif
+
#if !defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
# if defined(_LIBCPP_MSVCRT) || defined(_NEWLIB_VERSION)
# define _LIBCPP_HAS_NO_OFF_T_FUNCTIONS
@@ -1277,6 +1216,21 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_FALLTHROUGH() ((void)0)
#endif
+#if __has_attribute(__nodebug__)
+#define _LIBCPP_NODEBUG __attribute__((__nodebug__))
+#else
+#define _LIBCPP_NODEBUG
+#endif
+
+#ifndef _LIBCPP_NODEBUG_TYPE
+#if __has_attribute(__nodebug__) && \
+ (defined(_LIBCPP_COMPILER_CLANG) && _LIBCPP_CLANG_VER >= 900)
+#define _LIBCPP_NODEBUG_TYPE __attribute__((nodebug))
+#else
+#define _LIBCPP_NODEBUG_TYPE
+#endif
+#endif // !defined(_LIBCPP_NODEBUG_TYPE)
+
#if defined(_LIBCPP_ABI_MICROSOFT) && \
(defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
# define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
@@ -1312,7 +1266,8 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
#if !defined(_LIBCPP_BUILDING_LIBRARY) && \
!defined(_LIBCPP_DISABLE_AVAILABILITY) && \
__has_feature(attribute_availability_with_strict) && \
- __has_feature(attribute_availability_in_templates)
+ __has_feature(attribute_availability_in_templates) && \
+ __has_extension(pragma_clang_attribute_external_declaration)
# ifdef __APPLE__
# define _LIBCPP_USE_AVAILABILITY_APPLE
# endif
@@ -1355,6 +1310,21 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR \
__attribute__((availability(macosx,strict,introduced=10.9))) \
__attribute__((availability(ios,strict,introduced=7.0)))
+# define _LIBCPP_AVAILABILITY_FILESYSTEM \
+ __attribute__((availability(macosx,strict,introduced=10.15))) \
+ __attribute__((availability(ios,strict,introduced=13.0))) \
+ __attribute__((availability(tvos,strict,introduced=13.0))) \
+ __attribute__((availability(watchos,strict,introduced=6.0)))
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH \
+ _Pragma("clang attribute push(__attribute__((availability(macosx,strict,introduced=10.15))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(ios,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(tvos,strict,introduced=13.0))), apply_to=any(function,record))") \
+ _Pragma("clang attribute push(__attribute__((availability(watchos,strict,introduced=6.0))), apply_to=any(function,record))")
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop") \
+ _Pragma("clang attribute pop")
#else
# define _LIBCPP_AVAILABILITY_SHARED_MUTEX
# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS
@@ -1366,6 +1336,9 @@ _LIBCPP_FUNC_VIS extern "C" void __sanitizer_annotate_contiguous_container(
# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE
# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY
# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR
+# define _LIBCPP_AVAILABILITY_FILESYSTEM
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP
#endif
// Define availability that depends on _LIBCPP_NO_EXCEPTIONS.
diff --git a/include/__debug b/include/__debug
index a8788f68f8f4..524c5ff02847 100644
--- a/include/__debug
+++ b/include/__debug
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- __debug ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -12,6 +11,7 @@
#define _LIBCPP_DEBUG_H
#include <__config>
+#include <iosfwd>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -25,7 +25,6 @@
# include <cstdlib>
# include <cstdio>
# include <cstddef>
-# include <exception>
#endif
#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT)
@@ -50,10 +49,6 @@
#define _LIBCPP_DEBUG_MODE(...) ((void)0)
#endif
-#if _LIBCPP_DEBUG_LEVEL < 1
-class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception;
-#endif
-
_LIBCPP_BEGIN_NAMESPACE_STD
struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
@@ -63,6 +58,9 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info {
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
__libcpp_debug_info(const char* __f, int __l, const char* __p, const char* __m)
: __file_(__f), __line_(__l), __pred_(__p), __msg_(__m) {}
+
+ _LIBCPP_FUNC_VIS std::string what() const;
+
const char* __file_;
int __line_;
const char* __pred_;
@@ -80,38 +78,11 @@ extern _LIBCPP_EXPORTED_FROM_ABI __libcpp_debug_function_type __libcpp_debug_fun
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS
void __libcpp_abort_debug_function(__libcpp_debug_info const&);
-/// __libcpp_throw_debug_function - A debug handler that throws
-/// an instance of __libcpp_debug_exception when called.
- _LIBCPP_NORETURN _LIBCPP_FUNC_VIS
-void __libcpp_throw_debug_function(__libcpp_debug_info const&);
-
/// __libcpp_set_debug_function - Set the debug handler to the specified
/// function.
_LIBCPP_FUNC_VIS
bool __libcpp_set_debug_function(__libcpp_debug_function_type __func);
-// Setup the throwing debug handler during dynamic initialization.
-#if _LIBCPP_DEBUG_LEVEL >= 1 && defined(_LIBCPP_DEBUG_USE_EXCEPTIONS)
-# if defined(_LIBCPP_NO_EXCEPTIONS)
-# error _LIBCPP_DEBUG_USE_EXCEPTIONS cannot be used when exceptions are disabled.
-# endif
-static bool __init_dummy = __libcpp_set_debug_function(__libcpp_throw_debug_function);
-#endif
-
-#if _LIBCPP_DEBUG_LEVEL >= 1 || defined(_LIBCPP_BUILDING_LIBRARY)
-class _LIBCPP_EXCEPTION_ABI __libcpp_debug_exception : public exception {
-public:
- __libcpp_debug_exception() _NOEXCEPT;
- explicit __libcpp_debug_exception(__libcpp_debug_info const& __i);
- __libcpp_debug_exception(__libcpp_debug_exception const&);
- ~__libcpp_debug_exception() _NOEXCEPT;
- const char* what() const _NOEXCEPT;
-private:
- struct __libcpp_debug_exception_imp;
- __libcpp_debug_exception_imp *__imp_;
-};
-#endif
-
#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY)
struct _LIBCPP_TYPE_VIS __c_node;
@@ -251,16 +222,22 @@ public:
__db_c_const_iterator __c_end() const;
__db_i_const_iterator __i_end() const;
+ typedef __c_node*(_InsertConstruct)(void*, void*, __c_node*);
+
+ template <class _Cont>
+ _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) {
+ return ::new(__mem) _C_node<_Cont>(__c, __next);
+ }
+
template <class _Cont>
_LIBCPP_INLINE_VISIBILITY
void __insert_c(_Cont* __c)
{
- __c_node* __n = __insert_c(static_cast<void*>(__c));
- ::new(__n) _C_node<_Cont>(__n->__c_, __n->__next_);
+ __insert_c(static_cast<void*>(__c), &__create_C_node<_Cont>);
}
void __insert_i(void* __i);
- __c_node* __insert_c(void* __c);
+ void __insert_c(void* __c, _InsertConstruct* __fn);
void __erase_c(void* __c);
void __insert_ic(void* __i, const void* __c);
diff --git a/include/__errc b/include/__errc
index d0f00b7f0be0..a8ad29f364ac 100644
--- a/include/__errc
+++ b/include/__errc
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- __errc ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__functional_03 b/include/__functional_03
index 0a3bfbaa3d2c..a90cbb75b2ad 100644
--- a/include/__functional_03
+++ b/include/__functional_03
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__functional_base b/include/__functional_base
index 032be99bf6a5..9587d7ab15a1 100644
--- a/include/__functional_base
+++ b/include/__functional_base
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -126,7 +125,7 @@ struct __weak_result_type_imp // bool is true
: public __maybe_derive_from_unary_function<_Tp>,
public __maybe_derive_from_binary_function<_Tp>
{
- typedef typename _Tp::result_type result_type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type;
};
template <class _Tp>
@@ -147,19 +146,19 @@ struct __weak_result_type
template <class _Rp>
struct __weak_result_type<_Rp ()>
{
- typedef _Rp result_type;
+ typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
};
template <class _Rp>
struct __weak_result_type<_Rp (&)()>
{
- typedef _Rp result_type;
+ typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
};
template <class _Rp>
struct __weak_result_type<_Rp (*)()>
{
- typedef _Rp result_type;
+ typedef _LIBCPP_NODEBUG_TYPE _Rp result_type;
};
// 1 argument case
@@ -611,7 +610,7 @@ _LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Allo
template <class _Tp, class _Alloc, class ..._Args>
struct __uses_alloc_ctor_imp
{
- typedef typename __uncvref<_Alloc>::type _RawAlloc;
+ typedef _LIBCPP_NODEBUG_TYPE typename __uncvref<_Alloc>::type _RawAlloc;
static const bool __ua = uses_allocator<_Tp, _RawAlloc>::value;
static const bool __ic =
is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value;
diff --git a/include/__functional_base_03 b/include/__functional_base_03
index 8407dcfa39ca..e6dac90c84f7 100644
--- a/include/__functional_base_03
+++ b/include/__functional_base_03
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__hash_table b/include/__hash_table
index 6f5b183105e6..0b953f58e99e 100644
--- a/include/__hash_table
+++ b/include/__hash_table
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -123,7 +122,7 @@ inline _LIBCPP_INLINE_VISIBILITY
size_t
__next_hash_pow2(size_t __n)
{
- return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1)));
+ return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __libcpp_clz(__n-1)));
}
@@ -876,9 +875,9 @@ struct __enforce_unordered_container_requirements {
template <class _Key, class _Hash, class _Equal>
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Equal const&, _Key const&, _Key const&>::value,
- "the specified comparator type does not provide a const call operator")
+ "the specified comparator type does not provide a viable const call operator")
_LIBCPP_DIAGNOSE_WARNING(!__invokable<_Hash const&, _Key const&>::value,
- "the specified hash functor does not provide a const call operator")
+ "the specified hash functor does not provide a viable const call operator")
#endif
typename __enforce_unordered_container_requirements<_Key, _Hash, _Equal>::type
__diagnose_unordered_container_requirements(int);
@@ -1261,7 +1260,7 @@ public:
void swap(__hash_table& __u)
#if _LIBCPP_STD_VER <= 11
- _NOEXCEPT_DEBUG_(
+ _NOEXCEPT_(
__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
&& (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
|| __is_nothrow_swappable<__pointer_allocator>::value)
@@ -1269,7 +1268,7 @@ public:
|| __is_nothrow_swappable<__node_allocator>::value)
);
#else
- _NOEXCEPT_DEBUG_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value);
+ _NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value);
#endif
_LIBCPP_INLINE_VISIBILITY
@@ -2249,7 +2248,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
return _InsertReturnType{end(), false, _NodeHandle()};
pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
if (__result.second)
- __nh.__release();
+ __nh.__release_ptr();
return _InsertReturnType{__result.first, __result.second, _VSTD::move(__nh)};
}
@@ -2264,7 +2263,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_unique(
return end();
pair<iterator, bool> __result = __node_insert_unique(__nh.__ptr_);
if (__result.second)
- __nh.__release();
+ __nh.__release_ptr();
return __result.first;
}
@@ -2328,7 +2327,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
if (__nh.empty())
return end();
iterator __result = __node_insert_multi(__nh.__ptr_);
- __nh.__release();
+ __nh.__release_ptr();
return __result;
}
@@ -2342,7 +2341,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_insert_multi(
if (__nh.empty())
return end();
iterator __result = __node_insert_multi(__hint, __nh.__ptr_);
- __nh.__release();
+ __nh.__release_ptr();
return __result;
}
@@ -2372,6 +2371,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi(
template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::rehash(size_type __n)
+_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
{
if (__n == 1)
__n = 2;
@@ -2807,7 +2807,7 @@ template <class _Tp, class _Hash, class _Equal, class _Alloc>
void
__hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
#if _LIBCPP_STD_VER <= 11
- _NOEXCEPT_DEBUG_(
+ _NOEXCEPT_(
__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value
&& (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value
|| __is_nothrow_swappable<__pointer_allocator>::value)
@@ -2815,7 +2815,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u)
|| __is_nothrow_swappable<__node_allocator>::value)
)
#else
- _NOEXCEPT_DEBUG_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value)
+ _NOEXCEPT_(__is_nothrow_swappable<hasher>::value && __is_nothrow_swappable<key_equal>::value)
#endif
{
_LIBCPP_ASSERT(__node_traits::propagate_on_container_swap::value ||
diff --git a/include/__libcpp_version b/include/__libcpp_version
index e002b3628b34..d58c55a31dc7 100644
--- a/include/__libcpp_version
+++ b/include/__libcpp_version
@@ -1 +1 @@
-8000
+9000
diff --git a/include/__locale b/include/__locale
index cde9cc85f6b5..d382e4d8a94b 100644
--- a/include/__locale
+++ b/include/__locale
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -20,6 +19,7 @@
#include <cctype>
#include <locale.h>
#if defined(_LIBCPP_MSVCRT_LIKE)
+# include <cstring>
# include <support/win32/locale_win32.h>
#elif defined(_AIX)
# include <support/ibm/xlocale.h>
@@ -35,6 +35,9 @@
# include <xlocale.h>
#elif defined(__Fuchsia__)
# include <support/fuchsia/xlocale.h>
+#elif defined(__wasi__)
+// WASI libc uses musl's locales support.
+# include <support/musl/xlocale.h>
#elif defined(_LIBCPP_HAS_MUSL_LIBC)
# include <support/musl/xlocale.h>
#endif
@@ -64,28 +67,41 @@ private:
#elif defined(_LIBCPP_MSVCRT_LIKE)
struct __libcpp_locale_guard {
__libcpp_locale_guard(locale_t __l) :
- __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)),
- __locale_collate(setlocale(LC_COLLATE, __l.__get_locale())),
- __locale_ctype(setlocale(LC_CTYPE, __l.__get_locale())),
- __locale_monetary(setlocale(LC_MONETARY, __l.__get_locale())),
- __locale_numeric(setlocale(LC_NUMERIC, __l.__get_locale())),
- __locale_time(setlocale(LC_TIME, __l.__get_locale()))
- // LC_MESSAGES is not supported on Windows.
- {}
+ __status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)) {
+ // Setting the locale can be expensive even when the locale given is
+ // already the current locale, so do an explicit check to see if the
+ // current locale is already the one we want.
+ const char* __lc = __setlocale(nullptr);
+ // If every category is the same, the locale string will simply be the
+ // locale name, otherwise it will be a semicolon-separated string listing
+ // each category. In the second case, we know at least one category won't
+ // be what we want, so we only have to check the first case.
+ if (strcmp(__l.__get_locale(), __lc) != 0) {
+ __locale_all = _strdup(__lc);
+ if (__locale_all == nullptr)
+ __throw_bad_alloc();
+ __setlocale(__l.__get_locale());
+ }
+ }
~__libcpp_locale_guard() {
- setlocale(LC_COLLATE, __locale_collate);
- setlocale(LC_CTYPE, __locale_ctype);
- setlocale(LC_MONETARY, __locale_monetary);
- setlocale(LC_NUMERIC, __locale_numeric);
- setlocale(LC_TIME, __locale_time);
- _configthreadlocale(__status);
+ // The CRT documentation doesn't explicitly say, but setlocale() does the
+ // right thing when given a semicolon-separated list of locale settings
+ // for the different categories in the same format as returned by
+ // setlocale(LC_ALL, nullptr).
+ if (__locale_all != nullptr) {
+ __setlocale(__locale_all);
+ free(__locale_all);
+ }
+ _configthreadlocale(__status);
+ }
+ static const char* __setlocale(const char* __locale) {
+ const char* __new_locale = setlocale(LC_ALL, __locale);
+ if (__new_locale == nullptr)
+ __throw_bad_alloc();
+ return __new_locale;
}
int __status;
- char* __locale_collate;
- char* __locale_ctype;
- char* __locale_monetary;
- char* __locale_numeric;
- char* __locale_time;
+ char* __locale_all = nullptr;
};
#endif
@@ -255,7 +271,10 @@ public:
return do_compare(__lo1, __hi1, __lo2, __hi2);
}
+ // FIXME(EricWF): The _LIBCPP_ALWAYS_INLINE is needed on Windows to work
+ // around a dllimport bug that expects an external instantiation.
_LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_ALWAYS_INLINE
string_type transform(const char_type* __lo, const char_type* __hi) const
{
return do_transform(__lo, __hi);
@@ -389,6 +408,11 @@ public:
static const mask punct = _ISpunct;
static const mask xdigit = _ISxdigit;
static const mask blank = _ISblank;
+#if defined(__mips__)
+ static const mask __regex_word = static_cast<char_class_type>(_ISbit(15));
+#else
+ static const mask __regex_word = 0x80;
+#endif
#elif defined(_LIBCPP_MSVCRT_LIKE)
typedef unsigned short mask;
static const mask space = _SPACE;
@@ -401,6 +425,7 @@ public:
static const mask punct = _PUNCT;
static const mask xdigit = _HEX;
static const mask blank = _BLANK;
+ static const mask __regex_word = 0x80;
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__)
# ifdef __APPLE__
@@ -422,8 +447,12 @@ public:
# if defined(__NetBSD__)
static const mask blank = _CTYPE_BL;
+ // NetBSD defines classes up to 0x2000
+ // see sys/ctype_bits.h, _CTYPE_Q
+ static const mask __regex_word = 0x8000;
# else
static const mask blank = _CTYPE_B;
+ static const mask __regex_word = 0x80;
# endif
#elif defined(__sun__) || defined(_AIX)
typedef unsigned int mask;
@@ -437,6 +466,7 @@ public:
static const mask punct = _ISPUNCT;
static const mask xdigit = _ISXDIGIT;
static const mask blank = _ISBLANK;
+ static const mask __regex_word = 0x80;
#elif defined(_NEWLIB_VERSION)
// Same type as Newlib's _ctype_ array in newlib/libc/include/ctype.h.
typedef char mask;
@@ -450,6 +480,7 @@ public:
static const mask punct = _P;
static const mask xdigit = _X | _N;
static const mask blank = _B;
+ static const mask __regex_word = 0x80;
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
# define _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
@@ -465,6 +496,7 @@ public:
static const mask punct = 1<<7;
static const mask xdigit = 1<<8;
static const mask blank = 1<<9;
+ static const mask __regex_word = 1<<10;
#endif
static const mask alnum = alpha | digit;
static const mask graph = alnum | punct;
@@ -1230,8 +1262,6 @@ _LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<w
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>)
_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>)
-_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*);
-
template <size_t _Np>
struct __narrow_to_utf8
{
diff --git a/include/__mutex_base b/include/__mutex_base
index da21a5f8eb6a..f828beaf780d 100644
--- a/include/__mutex_base
+++ b/include/__mutex_base
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,28 +36,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD
# endif
#endif // _LIBCPP_THREAD_SAFETY_ANNOTATION
+
class _LIBCPP_TYPE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(capability("mutex")) mutex
{
-#ifndef _LIBCPP_CXX03_LANG
__libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
-#else
- __libcpp_mutex_t __m_;
-#endif
public:
_LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_CXX03_LANG
- constexpr mutex() = default;
+ _LIBCPP_CONSTEXPR mutex() = default;
+
+ mutex(const mutex&) = delete;
+ mutex& operator=(const mutex&) = delete;
+
+#if defined(_LIBCPP_HAS_TRIVIAL_MUTEX_DESTRUCTION)
+ ~mutex() = default;
#else
- mutex() _NOEXCEPT {__m_ = (__libcpp_mutex_t)_LIBCPP_MUTEX_INITIALIZER;}
+ ~mutex() _NOEXCEPT;
#endif
- ~mutex();
-private:
- mutex(const mutex&);// = delete;
- mutex& operator=(const mutex&);// = delete;
-
-public:
void lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability());
bool try_lock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(try_acquire_capability(true));
void unlock() _NOEXCEPT _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability());
@@ -287,26 +282,20 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(cv_status)
class _LIBCPP_TYPE_VIS condition_variable
{
-#ifndef _LIBCPP_CXX03_LANG
__libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
-#else
- __libcpp_condvar_t __cv_;
-#endif
-
public:
_LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_CXX03_LANG
- constexpr condition_variable() _NOEXCEPT = default;
+ _LIBCPP_CONSTEXPR condition_variable() _NOEXCEPT = default;
+
+#ifdef _LIBCPP_HAS_TRIVIAL_CONDVAR_DESTRUCTION
+ ~condition_variable() = default;
#else
- condition_variable() _NOEXCEPT {__cv_ = (__libcpp_condvar_t)_LIBCPP_CONDVAR_INITIALIZER;}
-#endif
~condition_variable();
+#endif
-private:
- condition_variable(const condition_variable&); // = delete;
- condition_variable& operator=(const condition_variable&); // = delete;
+ condition_variable(const condition_variable&) = delete;
+ condition_variable& operator=(const condition_variable&) = delete;
-public:
void notify_one() _NOEXCEPT;
void notify_all() _NOEXCEPT;
diff --git a/include/__node_handle b/include/__node_handle
index a9cf3b7217a3..be1fe17a8728 100644
--- a/include/__node_handle
+++ b/include/__node_handle
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -57,7 +56,7 @@ private:
optional<allocator_type> __alloc_;
_LIBCPP_INLINE_VISIBILITY
- void __release()
+ void __release_ptr()
{
__ptr_ = nullptr;
__alloc_ = _VSTD::nullopt;
@@ -194,8 +193,7 @@ using __map_node_handle =
__basic_node_handle< _NodeType, _Alloc, __map_node_handle_specifics>;
template <class _Iterator, class _NodeType>
-_LIBCPP_TEMPLATE_VIS
-struct __insert_return_type
+struct _LIBCPP_TEMPLATE_VIS __insert_return_type
{
_Iterator position;
bool inserted;
diff --git a/include/__nullptr b/include/__nullptr
index aa3b4d2145a5..45529a710b63 100644
--- a/include/__nullptr
+++ b/include/__nullptr
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- __nullptr --------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__sso_allocator b/include/__sso_allocator
index 8aca0495d756..393012873848 100644
--- a/include/__sso_allocator
+++ b/include/__sso_allocator
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__std_stream b/include/__std_stream
index db90795f66fc..5a9a470a9787 100644
--- a/include/__std_stream
+++ b/include/__std_stream
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__string b/include/__string
index 1ddeec7149fb..a88b976be3c9 100644
--- a/include/__string
+++ b/include/__string
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- __string ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/__threading_support b/include/__threading_support
index 202490062729..589fe2096fd4 100644
--- a/include/__threading_support
+++ b/include/__threading_support
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -23,6 +22,8 @@
# include <__external_threading>
#elif !defined(_LIBCPP_HAS_NO_THREADS)
+typedef ::timespec __libcpp_timespec_t;
+
#if defined(_LIBCPP_HAS_THREAD_API_PTHREAD)
# include <pthread.h>
# include <sched.h>
@@ -149,7 +150,7 @@ int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m);
_LIBCPP_THREAD_ABI_VISIBILITY _LIBCPP_NO_THREAD_SAFETY_ANALYSIS
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
- timespec *__ts);
+ __libcpp_timespec_t *__ts);
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
@@ -157,7 +158,7 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv);
// Execute once
_LIBCPP_THREAD_ABI_VISIBILITY
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
- void (*init_routine)(void));
+ void (*init_routine)());
// Thread id
_LIBCPP_THREAD_ABI_VISIBILITY
@@ -288,7 +289,7 @@ int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
}
int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
- timespec *__ts)
+ __libcpp_timespec_t *__ts)
{
return pthread_cond_timedwait(__cv, __m, __ts);
}
@@ -300,7 +301,7 @@ int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
// Execute once
int __libcpp_execute_once(__libcpp_exec_once_flag *flag,
- void (*init_routine)(void)) {
+ void (*init_routine)()) {
return pthread_once(flag, init_routine);
}
@@ -357,7 +358,7 @@ void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
{
using namespace chrono;
seconds __s = duration_cast<seconds>(__ns);
- timespec __ts;
+ __libcpp_timespec_t __ts;
typedef decltype(__ts.tv_sec) ts_sec;
_LIBCPP_CONSTEXPR ts_sec __ts_sec_max = numeric_limits<ts_sec>::max();
diff --git a/include/__tree b/include/__tree
index 814851085b98..15b03ec857f6 100644
--- a/include/__tree
+++ b/include/__tree
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -27,6 +26,13 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
+#if defined(__GNUC__) && !defined(__clang__) // gcc.gnu.org/PR37804
+template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS map;
+template <class, class, class, class> class _LIBCPP_TEMPLATE_VIS multimap;
+template <class, class, class> class _LIBCPP_TEMPLATE_VIS set;
+template <class, class, class> class _LIBCPP_TEMPLATE_VIS multiset;
+#endif
+
template <class _Tp, class _Compare, class _Allocator> class __tree;
template <class _Tp, class _NodePtr, class _DiffType>
class _LIBCPP_TEMPLATE_VIS __tree_iterator;
@@ -965,7 +971,7 @@ private:
template<class _Tp, class _Compare>
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_DIAGNOSE_WARNING(!std::__invokable<_Compare const&, _Tp const&, _Tp const&>::value,
- "the specified comparator type does not provide a const call operator")
+ "the specified comparator type does not provide a viable const call operator")
#endif
int __diagnose_non_const_comparator();
@@ -1090,8 +1096,8 @@ public:
__tree(const value_compare& __comp, const allocator_type& __a);
__tree(const __tree& __t);
__tree& operator=(const __tree& __t);
- template <class _InputIterator>
- void __assign_unique(_InputIterator __first, _InputIterator __last);
+ template <class _ForwardIterator>
+ void __assign_unique(_ForwardIterator __first, _ForwardIterator __last);
template <class _InputIterator>
void __assign_multi(_InputIterator __first, _InputIterator __last);
#ifndef _LIBCPP_CXX03_LANG
@@ -1326,10 +1332,7 @@ public:
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, bool> __node_insert_unique(__node_pointer __nd);
- _LIBCPP_INLINE_VISIBILITY
- iterator __node_insert_unique(const_iterator __p,
- __node_pointer __nd);
+ pair<iterator, bool> __node_assign_unique(const __container_value_type& __v, __node_pointer __dest);
_LIBCPP_INLINE_VISIBILITY
iterator __node_insert_multi(__node_pointer __nd);
@@ -1509,8 +1512,50 @@ private:
_LIBCPP_INLINE_VISIBILITY
void __move_assign_alloc(__tree&, false_type) _NOEXCEPT {}
- __node_pointer __detach();
- static __node_pointer __detach(__node_pointer);
+ struct _DetachedTreeCache {
+ _LIBCPP_INLINE_VISIBILITY
+ explicit _DetachedTreeCache(__tree *__t) _NOEXCEPT : __t_(__t),
+ __cache_root_(__detach_from_tree(__t)) {
+ __advance();
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __node_pointer __get() const _NOEXCEPT {
+ return __cache_elem_;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void __advance() _NOEXCEPT {
+ __cache_elem_ = __cache_root_;
+ if (__cache_root_) {
+ __cache_root_ = __detach_next(__cache_root_);
+ }
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ ~_DetachedTreeCache() {
+ __t_->destroy(__cache_elem_);
+ if (__cache_root_) {
+ while (__cache_root_->__parent_ != nullptr)
+ __cache_root_ = static_cast<__node_pointer>(__cache_root_->__parent_);
+ __t_->destroy(__cache_root_);
+ }
+ }
+
+ _DetachedTreeCache(_DetachedTreeCache const&) = delete;
+ _DetachedTreeCache& operator=(_DetachedTreeCache const&) = delete;
+
+ private:
+ _LIBCPP_INLINE_VISIBILITY
+ static __node_pointer __detach_from_tree(__tree *__t) _NOEXCEPT;
+ _LIBCPP_INLINE_VISIBILITY
+ static __node_pointer __detach_next(__node_pointer) _NOEXCEPT;
+
+ __tree *__t_;
+ __node_pointer __cache_root_;
+ __node_pointer __cache_elem_;
+ };
+
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS map;
template <class, class, class, class> friend class _LIBCPP_TEMPLATE_VIS multimap;
@@ -1548,13 +1593,13 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp,
// Precondition: size() != 0
template <class _Tp, class _Compare, class _Allocator>
typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
-__tree<_Tp, _Compare, _Allocator>::__detach()
+__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_from_tree(__tree *__t) _NOEXCEPT
{
- __node_pointer __cache = static_cast<__node_pointer>(__begin_node());
- __begin_node() = __end_node();
- __end_node()->__left_->__parent_ = nullptr;
- __end_node()->__left_ = nullptr;
- size() = 0;
+ __node_pointer __cache = static_cast<__node_pointer>(__t->__begin_node());
+ __t->__begin_node() = __t->__end_node();
+ __t->__end_node()->__left_->__parent_ = nullptr;
+ __t->__end_node()->__left_ = nullptr;
+ __t->size() = 0;
// __cache->__left_ == nullptr
if (__cache->__right_ != nullptr)
__cache = static_cast<__node_pointer>(__cache->__right_);
@@ -1569,7 +1614,7 @@ __tree<_Tp, _Compare, _Allocator>::__detach()
// This is no longer a red-black tree
template <class _Tp, class _Compare, class _Allocator>
typename __tree<_Tp, _Compare, _Allocator>::__node_pointer
-__tree<_Tp, _Compare, _Allocator>::__detach(__node_pointer __cache)
+__tree<_Tp, _Compare, _Allocator>::_DetachedTreeCache::__detach_next(__node_pointer __cache) _NOEXCEPT
{
if (__cache->__parent_ == nullptr)
return nullptr;
@@ -1603,45 +1648,23 @@ __tree<_Tp, _Compare, _Allocator>::operator=(const __tree& __t)
}
template <class _Tp, class _Compare, class _Allocator>
-template <class _InputIterator>
+template <class _ForwardIterator>
void
-__tree<_Tp, _Compare, _Allocator>::__assign_unique(_InputIterator __first, _InputIterator __last)
+__tree<_Tp, _Compare, _Allocator>::__assign_unique(_ForwardIterator __first, _ForwardIterator __last)
{
- typedef iterator_traits<_InputIterator> _ITraits;
+ typedef iterator_traits<_ForwardIterator> _ITraits;
typedef typename _ITraits::value_type _ItValueType;
static_assert((is_same<_ItValueType, __container_value_type>::value),
"__assign_unique may only be called with the containers value type");
-
+ static_assert(__is_forward_iterator<_ForwardIterator>::value,
+ "__assign_unique requires a forward iterator");
if (size() != 0)
{
- __node_pointer __cache = __detach();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- for (; __cache != nullptr && __first != __last; ++__first)
- {
- __cache->__value_ = *__first;
- __node_pointer __next = __detach(__cache);
- __node_insert_unique(__cache);
- __cache = __next;
+ _DetachedTreeCache __cache(this);
+ for (; __cache.__get() != nullptr && __first != __last; ++__first) {
+ if (__node_assign_unique(*__first, __cache.__get()).second)
+ __cache.__advance();
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- while (__cache->__parent_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__parent_);
- destroy(__cache);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
- if (__cache != nullptr)
- {
- while (__cache->__parent_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__parent_);
- destroy(__cache);
- }
}
for (; __first != __last; ++__first)
__insert_unique(*__first);
@@ -1660,33 +1683,11 @@ __tree<_Tp, _Compare, _Allocator>::__assign_multi(_InputIterator __first, _Input
" or the nodes value type");
if (size() != 0)
{
- __node_pointer __cache = __detach();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- for (; __cache != nullptr && __first != __last; ++__first)
- {
- __cache->__value_ = *__first;
- __node_pointer __next = __detach(__cache);
- __node_insert_multi(__cache);
- __cache = __next;
- }
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- while (__cache->__parent_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__parent_);
- destroy(__cache);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
- if (__cache != nullptr)
- {
- while (__cache->__parent_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__parent_);
- destroy(__cache);
+ _DetachedTreeCache __cache(this);
+ for (; __cache.__get() && __first != __last; ++__first) {
+ __cache.__get()->__value_ = *__first;
+ __node_insert_multi(__cache.__get());
+ __cache.__advance();
}
}
for (; __first != __last; ++__first)
@@ -1784,33 +1785,11 @@ __tree<_Tp, _Compare, _Allocator>::__move_assign(__tree& __t, false_type)
const_iterator __e = end();
if (size() != 0)
{
- __node_pointer __cache = __detach();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
-#endif // _LIBCPP_NO_EXCEPTIONS
- while (__cache != nullptr && __t.size() != 0)
- {
- __cache->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_);
- __node_pointer __next = __detach(__cache);
- __node_insert_multi(__cache);
- __cache = __next;
- }
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- while (__cache->__parent_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__parent_);
- destroy(__cache);
- throw;
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
- if (__cache != nullptr)
- {
- while (__cache->__parent_ != nullptr)
- __cache = static_cast<__node_pointer>(__cache->__parent_);
- destroy(__cache);
+ _DetachedTreeCache __cache(this);
+ while (__cache.__get() != nullptr && __t.size() != 0) {
+ __cache.__get()->__value_ = _VSTD::move(__t.remove(__t.begin())->__value_);
+ __node_insert_multi(__cache.__get());
+ __cache.__advance();
}
}
while (__t.size() != 0)
@@ -2319,14 +2298,15 @@ __tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, const __co
template <class _Tp, class _Compare, class _Allocator>
pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, bool>
-__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd)
+__tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const __container_value_type& __v, __node_pointer __nd)
{
__parent_pointer __parent;
- __node_base_pointer& __child = __find_equal(__parent, __nd->__value_);
+ __node_base_pointer& __child = __find_equal(__parent, _NodeTypes::__get_key(__v));
__node_pointer __r = static_cast<__node_pointer>(__child);
bool __inserted = false;
if (__child == nullptr)
{
+ __nd->__value_ = __v;
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
__r = __nd;
__inserted = true;
@@ -2334,22 +2314,6 @@ __tree<_Tp, _Compare, _Allocator>::__node_insert_unique(__node_pointer __nd)
return pair<iterator, bool>(iterator(__r), __inserted);
}
-template <class _Tp, class _Compare, class _Allocator>
-typename __tree<_Tp, _Compare, _Allocator>::iterator
-__tree<_Tp, _Compare, _Allocator>::__node_insert_unique(const_iterator __p,
- __node_pointer __nd)
-{
- __parent_pointer __parent;
- __node_base_pointer __dummy;
- __node_base_pointer& __child = __find_equal(__p, __parent, __nd->__value_);
- __node_pointer __r = static_cast<__node_pointer>(__child);
- if (__child == nullptr)
- {
- __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__nd));
- __r = __nd;
- }
- return iterator(__r);
-}
template <class _Tp, class _Compare, class _Allocator>
typename __tree<_Tp, _Compare, _Allocator>::iterator
@@ -2408,7 +2372,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(
__insert_node_at(__parent, __child,
static_cast<__node_base_pointer>(__ptr));
- __nh.__release();
+ __nh.__release_ptr();
return _InsertReturnType{iterator(__ptr), true, _NodeHandle()};
}
@@ -2433,7 +2397,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(
__insert_node_at(__parent, __child,
static_cast<__node_base_pointer>(__ptr));
__r = __ptr;
- __nh.__release();
+ __nh.__release_ptr();
}
return iterator(__r);
}
@@ -2498,7 +2462,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh
__node_base_pointer& __child = __find_leaf_high(
__parent, _NodeTypes::__get_key(__ptr->__value_));
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
- __nh.__release();
+ __nh.__release_ptr();
return iterator(__ptr);
}
@@ -2517,7 +2481,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(
__node_base_pointer& __child = __find_leaf(__hint, __parent,
_NodeTypes::__get_key(__ptr->__value_));
__insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__ptr));
- __nh.__release();
+ __nh.__release_ptr();
return iterator(__ptr);
}
diff --git a/include/__tuple b/include/__tuple
index 3b23d78afa1b..196f3c2b5aa5 100644
--- a/include/__tuple
+++ b/include/__tuple
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -54,27 +53,24 @@ template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<volatile _Tp> : publ
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_size<const volatile _Tp> : public tuple_size<_Tp> {};
#endif
-template <size_t _Ip, class _Tp> class _LIBCPP_TEMPLATE_VIS tuple_element;
+template <size_t _Ip, class _Tp> struct _LIBCPP_TEMPLATE_VIS tuple_element;
template <size_t _Ip, class _Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const _Tp>
{
-public:
- typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, volatile _Tp>
{
-public:
- typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <size_t _Ip, class _Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, const volatile _Tp>
{
-public:
- typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type;
};
template <class _Tp> struct __tuple_like : false_type {};
@@ -103,7 +99,7 @@ namespace __detail {
template<typename _Tp, size_t ..._Extra> struct __repeat;
template<typename _Tp, _Tp ..._Np, size_t ..._Extra> struct __repeat<__integer_sequence<_Tp, _Np...>, _Extra...> {
- typedef __integer_sequence<_Tp,
+ typedef _LIBCPP_NODEBUG_TYPE __integer_sequence<_Tp,
_Np...,
sizeof...(_Np) + _Np...,
2 * sizeof...(_Np) + _Np...,
@@ -257,7 +253,7 @@ template <class ..._Tp> struct __tuple_types {};
namespace __indexer_detail {
template <size_t _Idx, class _Tp>
-struct __indexed { using type = _Tp; };
+struct __indexed { using type _LIBCPP_NODEBUG_TYPE = _Tp; };
template <class _Types, class _Indexes> struct __indexer;
@@ -272,7 +268,7 @@ __indexed<_Idx, _Tp> __at_index(__indexed<_Idx, _Tp> const&);
} // namespace __indexer_detail
template <size_t _Idx, class ..._Types>
-using __type_pack_element = typename decltype(
+using __type_pack_element _LIBCPP_NODEBUG_TYPE = typename decltype(
__indexer_detail::__at_index<_Idx>(
__indexer_detail::__indexer<
__tuple_types<_Types...>,
@@ -282,11 +278,10 @@ using __type_pack_element = typename decltype(
#endif
template <size_t _Ip, class ..._Types>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, __tuple_types<_Types...>>
{
-public:
static_assert(_Ip < sizeof...(_Types), "tuple_element index out of range");
- typedef __type_pack_element<_Ip, _Types...> type;
+ typedef _LIBCPP_NODEBUG_TYPE __type_pack_element<_Ip, _Types...> type;
};
@@ -306,34 +301,34 @@ struct __apply_cv_mf<false, false, false> {
};
template <>
struct __apply_cv_mf<false, true, false> {
- template <class _Tp> using __apply = const _Tp;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const _Tp;
};
template <>
struct __apply_cv_mf<false, false, true> {
- template <class _Tp> using __apply = volatile _Tp;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp;
};
template <>
struct __apply_cv_mf<false, true, true> {
- template <class _Tp> using __apply = const volatile _Tp;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp;
};
template <>
struct __apply_cv_mf<true, false, false> {
- template <class _Tp> using __apply = _Tp&;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = _Tp&;
};
template <>
struct __apply_cv_mf<true, true, false> {
- template <class _Tp> using __apply = const _Tp&;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const _Tp&;
};
template <>
struct __apply_cv_mf<true, false, true> {
- template <class _Tp> using __apply = volatile _Tp&;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = volatile _Tp&;
};
template <>
struct __apply_cv_mf<true, true, true> {
- template <class _Tp> using __apply = const volatile _Tp&;
+ template <class _Tp> using __apply _LIBCPP_NODEBUG_TYPE = const volatile _Tp&;
};
template <class _Tp, class _RawTp = typename remove_reference<_Tp>::type>
-using __apply_cv_t = __apply_cv_mf<
+using __apply_cv_t _LIBCPP_NODEBUG_TYPE = __apply_cv_mf<
is_lvalue_reference<_Tp>::value,
is_const<_RawTp>::value,
is_volatile<_RawTp>::value>;
@@ -352,7 +347,7 @@ template <template <class...> class _Tuple, class ..._Types, size_t ..._Idx>
struct __make_tuple_types_flat<_Tuple<_Types...>, __tuple_indices<_Idx...>> {
// Specialization for pair, tuple, and __tuple_types
template <class _Tp, class _ApplyFn = __apply_cv_t<_Tp>>
- using __apply_quals = __tuple_types<
+ using __apply_quals _LIBCPP_NODEBUG_TYPE = __tuple_types<
typename _ApplyFn::template __apply<__type_pack_element<_Idx, _Types...>>...
>;
};
@@ -380,19 +375,19 @@ struct __make_tuple_types
template <class ..._Types, size_t _Ep>
struct __make_tuple_types<tuple<_Types...>, _Ep, 0, true> {
- typedef __tuple_types<_Types...> type;
+ typedef _LIBCPP_NODEBUG_TYPE __tuple_types<_Types...> type;
};
template <class ..._Types, size_t _Ep>
struct __make_tuple_types<__tuple_types<_Types...>, _Ep, 0, true> {
- typedef __tuple_types<_Types...> type;
+ typedef _LIBCPP_NODEBUG_TYPE __tuple_types<_Types...> type;
};
template <bool ..._Preds>
struct __all_dummy;
template <bool ..._Pred>
-using __all = is_same<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
+using __all = _IsSame<__all_dummy<_Pred...>, __all_dummy<((void)_Pred, true)...>>;
struct __tuple_sfinae_base {
template <template <class, class...> class _Trait,
@@ -457,15 +452,14 @@ struct __tuple_assignable<_Tp, _Up, true, true>
template <size_t _Ip, class ..._Tp>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, tuple<_Tp...> >
{
-public:
- typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type;
};
#if _LIBCPP_STD_VER > 11
template <size_t _Ip, class ..._Tp>
-using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type;
+using tuple_element_t _LIBCPP_NODEBUG_TYPE = typename tuple_element <_Ip, _Tp...>::type;
#endif
template <bool _IsTuple, class _SizeTrait, size_t _Expected>
@@ -477,7 +471,7 @@ struct __tuple_like_with_size_imp<true, _SizeTrait, _Expected>
template <class _Tuple, size_t _ExpectedSize,
class _RawTuple = typename __uncvref<_Tuple>::type>
-using __tuple_like_with_size = __tuple_like_with_size_imp<
+using __tuple_like_with_size _LIBCPP_NODEBUG_TYPE = __tuple_like_with_size_imp<
__tuple_like<_RawTuple>::value,
tuple_size<_RawTuple>, _ExpectedSize
>;
diff --git a/include/__undef_macros b/include/__undef_macros
index 60ab1dbfb5f7..4923ee6b4a1a 100644
--- a/include/__undef_macros
+++ b/include/__undef_macros
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------ __undef_macros ------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/algorithm b/include/algorithm
index d102899f2dfc..0d7862675588 100644
--- a/include/algorithm
+++ b/include/algorithm
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- algorithm ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -781,11 +780,23 @@ __half_positive(_Tp __value)
template <class _Compare>
struct __debug_less
{
- _Compare __comp_;
+ _Compare &__comp_;
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
__debug_less(_Compare& __c) : __comp_(__c) {}
template <class _Tp, class _Up>
- bool operator()(const _Tp& __x, const _Up& __y)
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ bool operator()(const _Tp& __x, const _Up& __y)
+ {
+ bool __r = __comp_(__x, __y);
+ if (__r)
+ __do_compare_assert(0, __y, __x);
+ return __r;
+ }
+
+ template <class _Tp, class _Up>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
+ bool operator()(_Tp& __x, _Up& __y)
{
bool __r = __comp_(__x, __y);
if (__r)
@@ -794,25 +805,39 @@ struct __debug_less
}
template <class _LHS, class _RHS>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
decltype((void)_VSTD::declval<_Compare&>()(
- _VSTD::declval<_LHS const&>(), _VSTD::declval<_RHS const&>()))
- __do_compare_assert(int, _LHS const& __l, _RHS const& __r) {
+ _VSTD::declval<_LHS &>(), _VSTD::declval<_RHS &>()))
+ __do_compare_assert(int, _LHS & __l, _RHS & __r) {
_LIBCPP_ASSERT(!__comp_(__l, __r),
"Comparator does not induce a strict weak ordering");
}
template <class _LHS, class _RHS>
+ _LIBCPP_CONSTEXPR_AFTER_CXX17
inline _LIBCPP_INLINE_VISIBILITY
- void __do_compare_assert(long, _LHS const&, _RHS const&) {}
+ void __do_compare_assert(long, _LHS &, _RHS &) {}
};
-#endif // _LIBCPP_DEBUG
+#endif // _LIBCPP_DEBUG
+
+template <class _Comp>
+struct __comp_ref_type {
+ // Pass the comparator by lvalue reference. Or in debug mode, using a
+ // debugging wrapper that stores a reference.
+#ifndef _LIBCPP_DEBUG
+ typedef typename add_lvalue_reference<_Comp>::type type;
+#else
+ typedef __debug_less<_Comp> type;
+#endif
+};
// all_of
template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
@@ -825,7 +850,8 @@ all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
// any_of
template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
@@ -838,7 +864,8 @@ any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
// none_of
template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
@@ -883,7 +910,8 @@ for_each_n(_InputIterator __first, _Size __orig_n, _Function __f)
// find
template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_InputIterator
find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
{
@@ -896,7 +924,8 @@ find(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
// find_if
template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_InputIterator
find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
@@ -909,7 +938,8 @@ find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
// find_if_not
template<class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_InputIterator
find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
@@ -1044,7 +1074,8 @@ __find_end(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator1
find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
@@ -1056,7 +1087,8 @@ find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator1
find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1082,7 +1114,8 @@ __find_first_of_ce(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator1
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
@@ -1091,7 +1124,8 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator1
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1104,7 +1138,8 @@ find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
// adjacent_find
template <class _ForwardIterator, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
{
@@ -1122,7 +1157,8 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicat
}
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -1133,7 +1169,8 @@ adjacent_find(_ForwardIterator __first, _ForwardIterator __last)
// count
template <class _InputIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename iterator_traits<_InputIterator>::difference_type
count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
{
@@ -1147,7 +1184,8 @@ count(_InputIterator __first, _InputIterator __last, const _Tp& __value_)
// count_if
template <class _InputIterator, class _Predicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
typename iterator_traits<_InputIterator>::difference_type
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
@@ -1161,7 +1199,8 @@ count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred)
// mismatch
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _BinaryPredicate __pred)
@@ -1173,7 +1212,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
{
@@ -1184,7 +1224,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __fi
#if _LIBCPP_STD_VER > 11
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2,
@@ -1197,7 +1238,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_InputIterator1, _InputIterator2>
mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
@@ -1211,7 +1253,8 @@ mismatch(_InputIterator1 __first1, _InputIterator1 __last1,
// equal
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred)
{
@@ -1222,7 +1265,8 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2)
{
@@ -1260,7 +1304,8 @@ __equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
@@ -1272,7 +1317,8 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
equal(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
@@ -1288,7 +1334,7 @@ equal(_InputIterator1 __first1, _InputIterator1 __last1,
// is_permutation
template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _BinaryPredicate __pred)
{
@@ -1335,7 +1381,8 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template<class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2)
@@ -1414,7 +1461,8 @@ __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1
}
template<class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2,
@@ -1427,7 +1475,8 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template<class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1445,7 +1494,8 @@ is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
// __search is in <functional>
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator1
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2, _BinaryPredicate __pred)
@@ -1458,7 +1508,8 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
}
template <class _ForwardIterator1, class _ForwardIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator1
search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
_ForwardIterator2 __first2, _ForwardIterator2 __last2)
@@ -1471,7 +1522,7 @@ search(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
#if _LIBCPP_STD_VER > 14
template <class _ForwardIterator, class _Searcher>
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s)
{ return __s(__f, __l).first; }
#endif
@@ -1556,7 +1607,8 @@ __search_n(_RandomAccessIterator __first, _RandomAccessIterator __last,
}
template <class _ForwardIterator, class _Size, class _Tp, class _BinaryPredicate>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last,
_Size __count, const _Tp& __value_, _BinaryPredicate __pred)
@@ -1567,7 +1619,8 @@ search_n(_ForwardIterator __first, _ForwardIterator __last,
}
template <class _ForwardIterator, class _Size, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_)
{
@@ -1611,6 +1664,18 @@ __unwrap_iter(__wrap_iter<_Tp*> __i)
return __i.base();
}
+template <class _Tp>
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
+typename enable_if
+<
+ is_trivially_copy_assignable<_Tp>::value,
+ const _Tp*
+>::type
+__unwrap_iter(__wrap_iter<const _Tp*> __i)
+{
+ return __i.base();
+}
+
#else
template <class _Tp>
@@ -1984,7 +2049,7 @@ generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen)
// generate_n
template <class _OutputIterator, class _Size, class _Generator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_OutputIterator
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
{
@@ -1998,7 +2063,7 @@ generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen)
// remove
template <class _ForwardIterator, class _Tp>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
__first = _VSTD::find(__first, __last, __value_);
@@ -2020,7 +2085,7 @@ remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
// remove_if
template <class _ForwardIterator, class _Predicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
remove_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred)
{
__first = _VSTD::find_if<_ForwardIterator, typename add_lvalue_reference<_Predicate>::type>
@@ -2079,7 +2144,7 @@ remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __
// unique
template <class _ForwardIterator, class _BinaryPredicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred)
{
__first = _VSTD::adjacent_find<_ForwardIterator, typename add_lvalue_reference<_BinaryPredicate>::type>
@@ -2098,7 +2163,8 @@ unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pre
}
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
unique(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -2421,7 +2487,8 @@ rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterato
// min_element
template <class _ForwardIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
@@ -2438,7 +2505,8 @@ min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
}
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
min_element(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -2449,7 +2517,8 @@ min_element(_ForwardIterator __first, _ForwardIterator __last)
// min
template <class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
@@ -2457,7 +2526,8 @@ min(const _Tp& __a, const _Tp& __b, _Compare __comp)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
min(const _Tp& __a, const _Tp& __b)
{
@@ -2467,7 +2537,8 @@ min(const _Tp& __a, const _Tp& __b)
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
min(initializer_list<_Tp> __t, _Compare __comp)
{
@@ -2475,7 +2546,8 @@ min(initializer_list<_Tp> __t, _Compare __comp)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
min(initializer_list<_Tp> __t)
{
@@ -2487,7 +2559,8 @@ min(initializer_list<_Tp> __t)
// max_element
template <class _ForwardIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
@@ -2505,7 +2578,8 @@ max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_ForwardIterator
max_element(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -2516,7 +2590,8 @@ max_element(_ForwardIterator __first, _ForwardIterator __last)
// max
template <class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
@@ -2524,7 +2599,8 @@ max(const _Tp& __a, const _Tp& __b, _Compare __comp)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
const _Tp&
max(const _Tp& __a, const _Tp& __b)
{
@@ -2534,7 +2610,8 @@ max(const _Tp& __a, const _Tp& __b)
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
max(initializer_list<_Tp> __t, _Compare __comp)
{
@@ -2542,7 +2619,8 @@ max(initializer_list<_Tp> __t, _Compare __comp)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp
max(initializer_list<_Tp> __t)
{
@@ -2554,7 +2632,8 @@ max(initializer_list<_Tp> __t)
#if _LIBCPP_STD_VER > 14
// clamp
template<class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
{
@@ -2564,7 +2643,8 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
const _Tp&
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
{
@@ -2575,7 +2655,7 @@ clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi)
// minmax_element
template <class _ForwardIterator, class _Compare>
-_LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11
std::pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
@@ -2625,7 +2705,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __com
}
template <class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
std::pair<_ForwardIterator, _ForwardIterator>
minmax_element(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -2636,7 +2717,8 @@ minmax_element(_ForwardIterator __first, _ForwardIterator __last)
// minmax
template<class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
{
@@ -2645,7 +2727,8 @@ minmax(const _Tp& __a, const _Tp& __b, _Compare __comp)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<const _Tp&, const _Tp&>
minmax(const _Tp& __a, const _Tp& __b)
{
@@ -2655,7 +2738,8 @@ minmax(const _Tp& __a, const _Tp& __b)
#ifndef _LIBCPP_CXX03_LANG
template<class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t, _Compare __comp)
{
@@ -2692,7 +2776,8 @@ minmax(initializer_list<_Tp> __t, _Compare __comp)
}
template<class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
pair<_Tp, _Tp>
minmax(initializer_list<_Tp> __t)
{
@@ -2936,7 +3021,7 @@ _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
typedef __independent_bits_engine<_URNG, _UIntType> _Eng;
if (_Rp == 0)
return static_cast<result_type>(_Eng(__g, _Dt)());
- size_t __w = _Dt - __clz(_Rp) - 1;
+ size_t __w = _Dt - __libcpp_clz(_Rp) - 1;
if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0)
++__w;
_Eng __e(__g, __w);
@@ -2990,7 +3075,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
_Dp __uid;
__rs_default __g = __rs_get();
- for (--__last, --__d; __first < __last; ++__first, --__d)
+ for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d)
{
difference_type __i = __uid(__g, _Pp(0, __d));
if (__i != difference_type(0))
@@ -3012,7 +3097,7 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
difference_type __d = __last - __first;
if (__d > 1)
{
- for (--__last; __first < __last; ++__first, --__d)
+ for (--__last; __first < __last; ++__first, (void) --__d)
{
difference_type __i = __rand(__d);
if (__i != difference_type(0))
@@ -3096,11 +3181,7 @@ _SampleIterator sample(_PopulationIterator __first,
template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
-#ifndef _LIBCPP_CXX03_LANG
_UniformRandomNumberGenerator&& __g)
-#else
- _UniformRandomNumberGenerator& __g)
-#endif
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef uniform_int_distribution<ptrdiff_t> _Dp;
@@ -3119,7 +3200,7 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
}
template <class _InputIterator, class _Predicate>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 bool
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred)
{
for (; __first != __last; ++__first)
@@ -3527,7 +3608,7 @@ stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate _
// is_sorted_until
template <class _ForwardIterator, class _Compare>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
if (__first != __last)
@@ -3544,7 +3625,8 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __co
}
template<class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -3554,7 +3636,8 @@ is_sorted_until(_ForwardIterator __first, _ForwardIterator __last)
// is_sorted
template <class _ForwardIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
{
@@ -3562,7 +3645,8 @@ is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp)
}
template<class _ForwardIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_sorted(_ForwardIterator __first, _ForwardIterator __last)
{
@@ -4009,14 +4093,8 @@ inline _LIBCPP_INLINE_VISIBILITY
void
sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __sort<_Comp_ref>(__first, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
- __sort<_Comp_ref>(__first, __last, __comp);
-#endif // _LIBCPP_DEBUG
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
+ _VSTD::__sort<_Comp_ref>(__first, __last, _Comp_ref(__comp));
}
template <class _RandomAccessIterator>
@@ -4111,7 +4189,8 @@ __lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
}
template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
@@ -4120,7 +4199,8 @@ lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
@@ -4153,7 +4233,8 @@ __upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
}
template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
@@ -4162,7 +4243,8 @@ upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __valu
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_ForwardIterator
upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
@@ -4207,22 +4289,18 @@ __equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __va
}
template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __equal_range<_Comp_ref>(__first, __last, __value_, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __equal_range<_Comp_ref>(__first, __last, __value_, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
pair<_ForwardIterator, _ForwardIterator>
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
@@ -4242,22 +4320,18 @@ __binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __
}
template <class _ForwardIterator, class _Tp, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __binary_search<_Comp_ref>(__first, __last, __value_, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __binary_search<_Comp_ref>(__first, __last, __value_, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _ForwardIterator, class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_)
{
@@ -4296,14 +4370,8 @@ _OutputIterator
merge(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
@@ -4478,17 +4546,9 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _
difference_type __buf_size = _VSTD::min(__len1, __len2);
pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size);
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first);
-
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2,
- __buf.first, __buf.second);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2,
__buf.first, __buf.second);
-#endif // _LIBCPP_DEBUG
}
template <class _BidirectionalIterator>
@@ -4690,14 +4750,8 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar
__buf = _VSTD::get_temporary_buffer<value_type>(__len);
__h.reset(__buf.first);
}
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -4711,7 +4765,7 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
// is_heap_until
template <class _RandomAccessIterator, class _Compare>
-_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
+_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
typedef typename _VSTD::iterator_traits<_RandomAccessIterator>::difference_type difference_type;
@@ -4738,7 +4792,8 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Comp
}
template<class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
_RandomAccessIterator
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
@@ -4748,7 +4803,8 @@ is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last)
// is_heap
template <class _RandomAccessIterator, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
@@ -4756,7 +4812,8 @@ is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __
}
template<class _RandomAccessIterator>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last)
{
@@ -4797,14 +4854,8 @@ inline _LIBCPP_INLINE_VISIBILITY
void
push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __sift_up<_Comp_ref>(__first, __last, __c, __last - __first);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -4890,14 +4941,8 @@ inline _LIBCPP_INLINE_VISIBILITY
void
pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -4931,14 +4976,8 @@ inline _LIBCPP_INLINE_VISIBILITY
void
make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __make_heap<_Comp_ref>(__first, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__make_heap<_Comp_ref>(__first, __last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -4965,14 +5004,8 @@ inline _LIBCPP_INLINE_VISIBILITY
void
sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __sort_heap<_Comp_ref>(__first, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__sort_heap<_Comp_ref>(__first, __last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -5009,14 +5042,8 @@ void
partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last,
_Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __partial_sort<_Comp_ref>(__first, __middle, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__partial_sort<_Comp_ref>(__first, __middle, __last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -5059,14 +5086,8 @@ _RandomAccessIterator
partial_sort_copy(_InputIterator __first, _InputIterator __last,
_RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator, class _RandomAccessIterator>
@@ -5273,14 +5294,8 @@ inline _LIBCPP_INLINE_VISIBILITY
void
nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- __nth_element<_Comp_ref>(__first, __nth, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
__nth_element<_Comp_ref>(__first, __nth, __last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _RandomAccessIterator>
@@ -5309,23 +5324,19 @@ __includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __
}
template <class _InputIterator1, class _InputIterator2, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2,
_Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2)
{
@@ -5367,14 +5378,8 @@ _OutputIterator
set_union(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
@@ -5419,14 +5424,8 @@ _OutputIterator
set_intersection(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
@@ -5473,14 +5472,8 @@ _OutputIterator
set_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
@@ -5532,14 +5525,8 @@ _OutputIterator
set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2, class _OutputIterator>
@@ -5571,23 +5558,19 @@ __lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
}
template <class _InputIterator1, class _InputIterator2, class _Compare>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _InputIterator1, class _InputIterator2>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
+_LIBCPP_NODISCARD_EXT inline
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
bool
lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _InputIterator2 __last2)
@@ -5631,14 +5614,8 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __next_permutation<_Comp_ref>(__first, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __next_permutation<_Comp_ref>(__first, __last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _BidirectionalIterator>
@@ -5684,14 +5661,8 @@ inline _LIBCPP_INLINE_VISIBILITY
bool
prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp)
{
-#ifdef _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref;
- __debug_less<_Compare> __c(__comp);
- return __prev_permutation<_Comp_ref>(__first, __last, __c);
-#else // _LIBCPP_DEBUG
- typedef typename add_lvalue_reference<_Compare>::type _Comp_ref;
+ typedef typename __comp_ref_type<_Compare>::type _Comp_ref;
return __prev_permutation<_Comp_ref>(__first, __last, __comp);
-#endif // _LIBCPP_DEBUG
}
template <class _BidirectionalIterator>
diff --git a/include/any b/include/any
index 781eee7869c0..36b07c9d7e75 100644
--- a/include/any
+++ b/include/any
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------------ any -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -508,7 +507,7 @@ any::any(_ValueType && __v) : __h(nullptr)
template <class _ValueType, class ..._Args, class _Tp, class>
any::any(in_place_type_t<_ValueType>, _Args&&... __args) {
__any_imp::_Handler<_Tp>::__create(*this, _VSTD::forward<_Args>(__args)...);
-};
+}
template <class _ValueType, class _Up, class ..._Args, class _Tp, class>
any::any(in_place_type_t<_ValueType>, initializer_list<_Up> __il, _Args&&... __args) {
diff --git a/include/array b/include/array
index 56f6887655aa..88e9d57ff783 100644
--- a/include/array
+++ b/include/array
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- array -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -92,7 +91,7 @@ template <class T, size_t N >
void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // C++17
template <class T> struct tuple_size;
-template <size_t I, class T> class tuple_element;
+template <size_t I, class T> struct tuple_element;
template <class T, size_t N> struct tuple_size<array<T, N>>;
template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
@@ -191,17 +190,17 @@ struct _LIBCPP_TEMPLATE_VIS array
// element access:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](size_type __n) {return __elems_[__n];}
+ reference operator[](size_type __n) _NOEXCEPT {return __elems_[__n];}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference operator[](size_type __n) const {return __elems_[__n];}
+ const_reference operator[](size_type __n) const _NOEXCEPT {return __elems_[__n];}
_LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n);
_LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const;
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size - 1];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size - 1];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return __elems_[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return __elems_[0];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return __elems_[_Size - 1];}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return __elems_[_Size - 1];}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
value_type* data() _NOEXCEPT {return __elems_;}
@@ -304,13 +303,13 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
// element access:
_LIBCPP_INLINE_VISIBILITY
- reference operator[](size_type) {
+ reference operator[](size_type) _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
_LIBCPP_UNREACHABLE();
}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference operator[](size_type) const {
+ const_reference operator[](size_type) const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
_LIBCPP_UNREACHABLE();
}
@@ -328,25 +327,25 @@ struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
}
_LIBCPP_INLINE_VISIBILITY
- reference front() {
+ reference front() _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
_LIBCPP_UNREACHABLE();
}
_LIBCPP_INLINE_VISIBILITY
- const_reference front() const {
+ const_reference front() const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
_LIBCPP_UNREACHABLE();
}
_LIBCPP_INLINE_VISIBILITY
- reference back() {
+ reference back() _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
_LIBCPP_UNREACHABLE();
}
_LIBCPP_INLINE_VISIBILITY
- const_reference back() const {
+ const_reference back() const _NOEXCEPT {
_LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
_LIBCPP_UNREACHABLE();
}
@@ -434,10 +433,9 @@ struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
: public integral_constant<size_t, _Size> {};
template <size_t _Ip, class _Tp, size_t _Size>
-class _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
+struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
{
static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
-public:
typedef _Tp type;
};
diff --git a/include/atomic b/include/atomic
index d37e7b4b035c..afb431eda11d 100644
--- a/include/atomic
+++ b/include/atomic
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- atomic -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -21,17 +20,24 @@ namespace std
#define __cpp_lib_atomic_is_always_lock_free // as specified by SG10
-// order and consistency
-
-typedef enum memory_order
-{
- memory_order_relaxed,
- memory_order_consume, // load-consume
- memory_order_acquire, // load-acquire
- memory_order_release, // store-release
- memory_order_acq_rel, // store-release load-acquire
- memory_order_seq_cst // store-release load-acquire
-} memory_order;
+ // order and consistency
+
+ enum memory_order: unspecified // enum class in C++20
+ {
+ relaxed,
+ consume, // load-consume
+ acquire, // load-acquire
+ release, // store-release
+ acq_rel, // store-release load-acquire
+ seq_cst // store-release load-acquire
+ };
+
+ inline constexpr auto memory_order_relaxed = memory_order::relaxed;
+ inline constexpr auto memory_order_consume = memory_order::consume;
+ inline constexpr auto memory_order_acquire = memory_order::acquire;
+ inline constexpr auto memory_order_release = memory_order::release;
+ inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
+ inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
template <class T> T kill_dependency(T y) noexcept;
@@ -551,13 +557,13 @@ void atomic_signal_fence(memory_order m) noexcept;
#endif
#ifdef _LIBCPP_HAS_NO_THREADS
-#error <atomic> is not supported on this single threaded system
+# error <atomic> is not supported on this single threaded system
#endif
-#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
-#error <atomic> is not implemented
+#ifdef _LIBCPP_HAS_NO_ATOMIC_HEADER
+# error <atomic> is not implemented
#endif
#ifdef kill_dependency
-#error C++ standard library is incompatible with <stdatomic.h>
+# error C++ standard library is incompatible with <stdatomic.h>
#endif
#define _LIBCPP_CHECK_STORE_MEMORY_ORDER(__m) \
@@ -578,49 +584,94 @@ void atomic_signal_fence(memory_order m) noexcept;
_LIBCPP_BEGIN_NAMESPACE_STD
-typedef enum memory_order
-{
- memory_order_relaxed, memory_order_consume, memory_order_acquire,
- memory_order_release, memory_order_acq_rel, memory_order_seq_cst
+// Figure out what the underlying type for `memory_order` would be if it were
+// declared as an unscoped enum (accounting for -fshort-enums). Use this result
+// to pin the underlying type in C++20.
+enum __legacy_memory_order {
+ __mo_relaxed,
+ __mo_consume,
+ __mo_acquire,
+ __mo_release,
+ __mo_acq_rel,
+ __mo_seq_cst
+};
+
+typedef underlying_type<__legacy_memory_order>::type __memory_order_underlying_t;
+
+#if _LIBCPP_STD_VER > 17
+
+enum class memory_order : __memory_order_underlying_t {
+ relaxed = __mo_relaxed,
+ consume = __mo_consume,
+ acquire = __mo_acquire,
+ release = __mo_release,
+ acq_rel = __mo_acq_rel,
+ seq_cst = __mo_seq_cst
+};
+
+inline constexpr auto memory_order_relaxed = memory_order::relaxed;
+inline constexpr auto memory_order_consume = memory_order::consume;
+inline constexpr auto memory_order_acquire = memory_order::acquire;
+inline constexpr auto memory_order_release = memory_order::release;
+inline constexpr auto memory_order_acq_rel = memory_order::acq_rel;
+inline constexpr auto memory_order_seq_cst = memory_order::seq_cst;
+
+#else
+
+typedef enum memory_order {
+ memory_order_relaxed = __mo_relaxed,
+ memory_order_consume = __mo_consume,
+ memory_order_acquire = __mo_acquire,
+ memory_order_release = __mo_release,
+ memory_order_acq_rel = __mo_acq_rel,
+ memory_order_seq_cst = __mo_seq_cst,
} memory_order;
-#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
-namespace __gcc_atomic {
-template <typename _Tp>
-struct __gcc_atomic_t {
+#endif // _LIBCPP_STD_VER > 17
+
+static_assert((is_same<underlying_type<memory_order>::type, __memory_order_underlying_t>::value),
+ "unexpected underlying type for std::memory_order");
+
+#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) || \
+ defined(_LIBCPP_ATOMIC_ONLY_USE_BUILTINS)
+
+// [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
+// the default operator= in an object is not volatile, a byte-by-byte copy
+// is required.
+template <typename _Tp, typename _Tv> _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_assignable<_Tp&, _Tv>::value>::type
+__cxx_atomic_assign_volatile(_Tp& __a_value, _Tv const& __val) {
+ __a_value = __val;
+}
+template <typename _Tp, typename _Tv> _LIBCPP_INLINE_VISIBILITY
+typename enable_if<is_assignable<_Tp&, _Tv>::value>::type
+__cxx_atomic_assign_volatile(_Tp volatile& __a_value, _Tv volatile const& __val) {
+ volatile char* __to = reinterpret_cast<volatile char*>(&__a_value);
+ volatile char* __end = __to + sizeof(_Tp);
+ volatile const char* __from = reinterpret_cast<volatile const char*>(&__val);
+ while (__to != __end)
+ *__to++ = *__from++;
+}
-#if _GNUC_VER >= 501
- static_assert(is_trivially_copyable<_Tp>::value,
- "std::atomic<Tp> requires that 'Tp' be a trivially copyable type");
#endif
+#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)
+
+template <typename _Tp>
+struct __cxx_atomic_base_impl {
+
_LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_CXX03_LANG
- __gcc_atomic_t() _NOEXCEPT = default;
+ __cxx_atomic_base_impl() _NOEXCEPT = default;
#else
- __gcc_atomic_t() _NOEXCEPT : __a_value() {}
+ __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
#endif // _LIBCPP_CXX03_LANG
- _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT
+ _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT
: __a_value(value) {}
_Tp __a_value;
};
-#define _Atomic(x) __gcc_atomic::__gcc_atomic_t<x>
-
-template <typename _Tp> _Tp __create();
-
-template <typename _Tp, typename _Td>
-typename enable_if<sizeof(_Tp()->__a_value = __create<_Td>()), char>::type
- __test_atomic_assignable(int);
-template <typename _Tp, typename _Up>
-__two __test_atomic_assignable(...);
-
-template <typename _Tp, typename _Td>
-struct __can_assign {
- static const bool value =
- sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char);
-};
-static inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
// Avoid switch statement to make this a constexpr.
return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
(__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
@@ -630,7 +681,7 @@ static inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) {
__ATOMIC_CONSUME))));
}
-static inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) {
// Avoid switch statement to make this a constexpr.
return __order == memory_order_relaxed ? __ATOMIC_RELAXED:
(__order == memory_order_acquire ? __ATOMIC_ACQUIRE:
@@ -640,133 +691,125 @@ static inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order)
__ATOMIC_CONSUME))));
}
-} // namespace __gcc_atomic
-
-template <typename _Tp>
-static inline
-typename enable_if<
- __gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value>::type
-__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
- __a->__a_value = __val;
-}
-
template <typename _Tp>
-static inline
-typename enable_if<
- !__gcc_atomic::__can_assign<volatile _Atomic(_Tp)*, _Tp>::value &&
- __gcc_atomic::__can_assign< _Atomic(_Tp)*, _Tp>::value>::type
-__c11_atomic_init(volatile _Atomic(_Tp)* __a, _Tp __val) {
- // [atomics.types.generic]p1 guarantees _Tp is trivially copyable. Because
- // the default operator= in an object is not volatile, a byte-by-byte copy
- // is required.
- volatile char* to = reinterpret_cast<volatile char*>(&__a->__a_value);
- volatile char* end = to + sizeof(_Tp);
- char* from = reinterpret_cast<char*>(&__val);
- while (to != end) {
- *to++ = *from++;
- }
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
+ __cxx_atomic_assign_volatile(__a->__a_value, __val);
}
template <typename _Tp>
-static inline void __c11_atomic_init(_Atomic(_Tp)* __a, _Tp __val) {
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val) {
__a->__a_value = __val;
}
-static inline void __c11_atomic_thread_fence(memory_order __order) {
- __atomic_thread_fence(__gcc_atomic::__to_gcc_order(__order));
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_thread_fence(memory_order __order) {
+ __atomic_thread_fence(__to_gcc_order(__order));
}
-static inline void __c11_atomic_signal_fence(memory_order __order) {
- __atomic_signal_fence(__gcc_atomic::__to_gcc_order(__order));
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_signal_fence(memory_order __order) {
+ __atomic_signal_fence(__to_gcc_order(__order));
}
template <typename _Tp>
-static inline void __c11_atomic_store(volatile _Atomic(_Tp)* __a, _Tp __val,
- memory_order __order) {
- return __atomic_store(&__a->__a_value, &__val,
- __gcc_atomic::__to_gcc_order(__order));
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
+ memory_order __order) {
+ __atomic_store(&__a->__a_value, &__val,
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline void __c11_atomic_store(_Atomic(_Tp)* __a, _Tp __val,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp>* __a, _Tp __val,
+ memory_order __order) {
__atomic_store(&__a->__a_value, &__val,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_load(const volatile _Atomic(_Tp)* __a,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const volatile __cxx_atomic_base_impl<_Tp>* __a,
+ memory_order __order) {
_Tp __ret;
__atomic_load(&__a->__a_value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
return __ret;
}
template <typename _Tp>
-static inline _Tp __c11_atomic_load(const _Atomic(_Tp)* __a, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const __cxx_atomic_base_impl<_Tp>* __a, memory_order __order) {
_Tp __ret;
__atomic_load(&__a->__a_value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
return __ret;
}
template <typename _Tp>
-static inline _Tp __c11_atomic_exchange(volatile _Atomic(_Tp)* __a,
- _Tp __value, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __value, memory_order __order) {
_Tp __ret;
__atomic_exchange(&__a->__a_value, &__value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
return __ret;
}
template <typename _Tp>
-static inline _Tp __c11_atomic_exchange(_Atomic(_Tp)* __a, _Tp __value,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp>* __a, _Tp __value,
+ memory_order __order) {
_Tp __ret;
__atomic_exchange(&__a->__a_value, &__value, &__ret,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
return __ret;
}
template <typename _Tp>
-static inline bool __c11_atomic_compare_exchange_strong(
- volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(
+ volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value,
memory_order __success, memory_order __failure) {
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
false,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
}
template <typename _Tp>
-static inline bool __c11_atomic_compare_exchange_strong(
- _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success,
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(
+ __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success,
memory_order __failure) {
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
false,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
}
template <typename _Tp>
-static inline bool __c11_atomic_compare_exchange_weak(
- volatile _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value,
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(
+ volatile __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value,
memory_order __success, memory_order __failure) {
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
true,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
}
template <typename _Tp>
-static inline bool __c11_atomic_compare_exchange_weak(
- _Atomic(_Tp)* __a, _Tp* __expected, _Tp __value, memory_order __success,
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(
+ __cxx_atomic_base_impl<_Tp>* __a, _Tp* __expected, _Tp __value, memory_order __success,
memory_order __failure) {
return __atomic_compare_exchange(&__a->__a_value, __expected, &__value,
true,
- __gcc_atomic::__to_gcc_order(__success),
- __gcc_atomic::__to_gcc_failure_order(__failure));
+ __to_gcc_order(__success),
+ __to_gcc_failure_order(__failure));
}
template <typename _Tp>
@@ -783,80 +826,264 @@ template <typename _Tp, int n>
struct __skip_amt<_Tp[n]> { };
template <typename _Tp, typename _Td>
-static inline _Tp __c11_atomic_fetch_add(volatile _Atomic(_Tp)* __a,
- _Td __delta, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Td __delta, memory_order __order) {
return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp, typename _Td>
-static inline _Tp __c11_atomic_fetch_add(_Atomic(_Tp)* __a, _Td __delta,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
+ memory_order __order) {
return __atomic_fetch_add(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp, typename _Td>
-static inline _Tp __c11_atomic_fetch_sub(volatile _Atomic(_Tp)* __a,
- _Td __delta, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Td __delta, memory_order __order) {
return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp, typename _Td>
-static inline _Tp __c11_atomic_fetch_sub(_Atomic(_Tp)* __a, _Td __delta,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp>* __a, _Td __delta,
+ memory_order __order) {
return __atomic_fetch_sub(&__a->__a_value, __delta * __skip_amt<_Tp>::value,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_fetch_and(volatile _Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_and(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_fetch_and(_Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_and(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_fetch_or(volatile _Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_or(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_fetch_or(_Atomic(_Tp)* __a, _Tp __pattern,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
+ memory_order __order) {
return __atomic_fetch_or(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_fetch_xor(volatile _Atomic(_Tp)* __a,
- _Tp __pattern, memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(volatile __cxx_atomic_base_impl<_Tp>* __a,
+ _Tp __pattern, memory_order __order) {
return __atomic_fetch_xor(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
}
template <typename _Tp>
-static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern,
- memory_order __order) {
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp>* __a, _Tp __pattern,
+ memory_order __order) {
return __atomic_fetch_xor(&__a->__a_value, __pattern,
- __gcc_atomic::__to_gcc_order(__order));
+ __to_gcc_order(__order));
+}
+
+#define __cxx_atomic_is_lock_free(__s) __atomic_is_lock_free(__s, 0)
+
+#elif defined(_LIBCPP_HAS_C_ATOMIC_IMP)
+
+template <typename _Tp>
+struct __cxx_atomic_base_impl {
+
+ _LIBCPP_INLINE_VISIBILITY
+#ifndef _LIBCPP_CXX03_LANG
+ __cxx_atomic_base_impl() _NOEXCEPT = default;
+#else
+ __cxx_atomic_base_impl() _NOEXCEPT : __a_value() {}
+#endif // _LIBCPP_CXX03_LANG
+ _LIBCPP_CONSTEXPR explicit __cxx_atomic_base_impl(_Tp value) _NOEXCEPT
+ : __a_value(value) {}
+ _Atomic(_Tp) __a_value;
+};
+
+#define __cxx_atomic_is_lock_free(__s) __c11_atomic_is_lock_free(__s)
+
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_thread_fence(memory_order __order) _NOEXCEPT {
+ __c11_atomic_thread_fence(static_cast<__memory_order_underlying_t>(__order));
+}
+
+_LIBCPP_INLINE_VISIBILITY inline
+void __cxx_atomic_signal_fence(memory_order __order) _NOEXCEPT {
+ __c11_atomic_signal_fence(static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val) _NOEXCEPT {
+ __c11_atomic_init(&__a->__a_value, __val);
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val) _NOEXCEPT {
+ __c11_atomic_init(&__a->__a_value, __val);
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __val, memory_order __order) _NOEXCEPT {
+ __c11_atomic_store(&__a->__a_value, __val, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_base_impl<_Tp> * __a, _Tp __val, memory_order __order) _NOEXCEPT {
+ __c11_atomic_store(&__a->__a_value, __val, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const volatile* __a, memory_order __order) _NOEXCEPT {
+ using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
+ return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(__cxx_atomic_base_impl<_Tp> const* __a, memory_order __order) _NOEXCEPT {
+ using __ptr_type = typename remove_const<decltype(__a->__a_value)>::type*;
+ return __c11_atomic_load(const_cast<__ptr_type>(&__a->__a_value), static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __value, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_exchange(&__a->__a_value, __value, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_base_impl<_Tp> * __a, _Tp __value, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_exchange(&__a->__a_value, __value, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
+ return __c11_atomic_compare_exchange_strong(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_base_impl<_Tp> * __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
+ return __c11_atomic_compare_exchange_strong(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
+ return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_base_impl<_Tp> * __a, _Tp* __expected, _Tp __value, memory_order __success, memory_order __failure) _NOEXCEPT {
+ return __c11_atomic_compare_exchange_weak(&__a->__a_value, __expected, __value, static_cast<__memory_order_underlying_t>(__success), static_cast<__memory_order_underlying_t>(__failure));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp> * __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
}
-#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(__cxx_atomic_base_impl<_Tp*> * __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_add(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp> * __a, _Tp __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> volatile* __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_sub(__cxx_atomic_base_impl<_Tp*> * __a, ptrdiff_t __delta, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_sub(&__a->__a_value, __delta, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_and(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_base_impl<_Tp> * __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_and(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_or(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_base_impl<_Tp> * __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_or(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> volatile* __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_xor(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_base_impl<_Tp> * __a, _Tp __pattern, memory_order __order) _NOEXCEPT {
+ return __c11_atomic_fetch_xor(&__a->__a_value, __pattern, static_cast<__memory_order_underlying_t>(__order));
+}
+
+#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP, _LIBCPP_HAS_C_ATOMIC_IMP
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
-_Tp
-kill_dependency(_Tp __y) _NOEXCEPT
+_LIBCPP_INLINE_VISIBILITY
+_Tp kill_dependency(_Tp __y) _NOEXCEPT
{
return __y;
}
@@ -872,7 +1099,7 @@ kill_dependency(_Tp __y) _NOEXCEPT
# define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE
# define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE
# define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
-#else
+#elif defined(__GCC_ATOMIC_BOOL_LOCK_FREE)
# define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
# define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
# define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
@@ -885,12 +1112,352 @@ kill_dependency(_Tp __y) _NOEXCEPT
# define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#endif
+#ifdef _LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+
+template<typename _Tp>
+struct __cxx_atomic_lock_impl {
+
+ _LIBCPP_INLINE_VISIBILITY
+ __cxx_atomic_lock_impl() _NOEXCEPT
+ : __a_value(), __a_lock(0) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit
+ __cxx_atomic_lock_impl(_Tp value) _NOEXCEPT
+ : __a_value(value), __a_lock(0) {}
+
+ _Tp __a_value;
+ mutable __cxx_atomic_base_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_lock;
+
+ _LIBCPP_INLINE_VISIBILITY void __lock() const volatile {
+ while(1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire))
+ /*spin*/;
+ }
+ _LIBCPP_INLINE_VISIBILITY void __lock() const {
+ while(1 == __cxx_atomic_exchange(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(true), memory_order_acquire))
+ /*spin*/;
+ }
+ _LIBCPP_INLINE_VISIBILITY void __unlock() const volatile {
+ __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release);
+ }
+ _LIBCPP_INLINE_VISIBILITY void __unlock() const {
+ __cxx_atomic_store(&__a_lock, _LIBCPP_ATOMIC_FLAG_TYPE(false), memory_order_release);
+ }
+ _LIBCPP_INLINE_VISIBILITY _Tp __read() const volatile {
+ __lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a_value);
+ __unlock();
+ return __old;
+ }
+ _LIBCPP_INLINE_VISIBILITY _Tp __read() const {
+ __lock();
+ _Tp __old = __a_value;
+ __unlock();
+ return __old;
+ }
+};
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) {
+ __cxx_atomic_assign_volatile(__a->__a_value, __val);
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_init(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val) {
+ __a->__a_value = __val;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) {
+ __a->__lock();
+ __cxx_atomic_assign_volatile(__a->__a_value, __val);
+ __a->__unlock();
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+void __cxx_atomic_store(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __val, memory_order) {
+ __a->__lock();
+ __a->__a_value = __val;
+ __a->__unlock();
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const volatile __cxx_atomic_lock_impl<_Tp>* __a, memory_order) {
+ return __a->__read();
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_load(const __cxx_atomic_lock_impl<_Tp>* __a, memory_order) {
+ return __a->__read();
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(volatile __cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, __value);
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_exchange(__cxx_atomic_lock_impl<_Tp>* __a, _Tp __value, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value = __value;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ __a->__lock();
+ _Tp temp;
+ __cxx_atomic_assign_volatile(temp, __a->__a_value);
+ bool __ret = temp == *__expected;
+ if(__ret)
+ __cxx_atomic_assign_volatile(__a->__a_value, __value);
+ else
+ __cxx_atomic_assign_volatile(*__expected, __a->__a_value);
+ __a->__unlock();
+ return __ret;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_strong(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ __a->__lock();
+ bool __ret = __a->__a_value == *__expected;
+ if(__ret)
+ __a->__a_value = __value;
+ else
+ *__expected = __a->__a_value;
+ __a->__unlock();
+ return __ret;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ __a->__lock();
+ _Tp temp;
+ __cxx_atomic_assign_volatile(temp, __a->__a_value);
+ bool __ret = temp == *__expected;
+ if(__ret)
+ __cxx_atomic_assign_volatile(__a->__a_value, __value);
+ else
+ __cxx_atomic_assign_volatile(*__expected, __a->__a_value);
+ __a->__unlock();
+ return __ret;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+bool __cxx_atomic_compare_exchange_weak(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp* __expected, _Tp __value, memory_order, memory_order) {
+ __a->__lock();
+ bool __ret = __a->__a_value == *__expected;
+ if(__ret)
+ __a->__a_value = __value;
+ else
+ *__expected = __a->__a_value;
+ __a->__unlock();
+ return __ret;
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old + __delta));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value += __delta;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(volatile __cxx_atomic_lock_impl<_Tp*>* __a,
+ ptrdiff_t __delta, memory_order) {
+ __a->__lock();
+ _Tp* __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, __old + __delta);
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp* __cxx_atomic_fetch_add(__cxx_atomic_lock_impl<_Tp*>* __a,
+ ptrdiff_t __delta, memory_order) {
+ __a->__lock();
+ _Tp* __old = __a->__a_value;
+ __a->__a_value += __delta;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old - __delta));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp, typename _Td>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_sub(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Td __delta, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value -= __delta;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old & __pattern));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_and(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value &= __pattern;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old | __pattern));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_or(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value |= __pattern;
+ __a->__unlock();
+ return __old;
+}
+
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(volatile __cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old;
+ __cxx_atomic_assign_volatile(__old, __a->__a_value);
+ __cxx_atomic_assign_volatile(__a->__a_value, _Tp(__old ^ __pattern));
+ __a->__unlock();
+ return __old;
+}
+template <typename _Tp>
+_LIBCPP_INLINE_VISIBILITY
+_Tp __cxx_atomic_fetch_xor(__cxx_atomic_lock_impl<_Tp>* __a,
+ _Tp __pattern, memory_order) {
+ __a->__lock();
+ _Tp __old = __a->__a_value;
+ __a->__a_value ^= __pattern;
+ __a->__unlock();
+ return __old;
+}
+
+#ifdef __cpp_lib_atomic_is_always_lock_free
+
+template<typename _Tp> struct __cxx_is_always_lock_free {
+ enum { __value = __atomic_always_lock_free(sizeof(_Tp), 0) }; };
+
+#else
+
+template<typename _Tp> struct __cxx_is_always_lock_free { enum { __value = false }; };
+// Implementations must match the C ATOMIC_*_LOCK_FREE macro values.
+template<> struct __cxx_is_always_lock_free<bool> { enum { __value = 2 == ATOMIC_BOOL_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<signed char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned char> { enum { __value = 2 == ATOMIC_CHAR_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<char16_t> { enum { __value = 2 == ATOMIC_CHAR16_T_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<char32_t> { enum { __value = 2 == ATOMIC_CHAR32_T_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<wchar_t> { enum { __value = 2 == ATOMIC_WCHAR_T_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<short> { enum { __value = 2 == ATOMIC_SHORT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned short> { enum { __value = 2 == ATOMIC_SHORT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<int> { enum { __value = 2 == ATOMIC_INT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned int> { enum { __value = 2 == ATOMIC_INT_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<long> { enum { __value = 2 == ATOMIC_LONG_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned long> { enum { __value = 2 == ATOMIC_LONG_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<long long> { enum { __value = 2 == ATOMIC_LLONG_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<unsigned long long> { enum { __value = 2 == ATOMIC_LLONG_LOCK_FREE }; };
+template<typename _Tp> struct __cxx_is_always_lock_free<_Tp*> { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; };
+template<> struct __cxx_is_always_lock_free<std::nullptr_t> { enum { __value = 2 == ATOMIC_POINTER_LOCK_FREE }; };
+
+#endif //__cpp_lib_atomic_is_always_lock_free
+
+template <typename _Tp,
+ typename _Base = typename conditional<__cxx_is_always_lock_free<_Tp>::__value,
+ __cxx_atomic_base_impl<_Tp>,
+ __cxx_atomic_lock_impl<_Tp> >::type>
+#else
+template <typename _Tp,
+ typename _Base = __cxx_atomic_base_impl<_Tp> >
+#endif //_LIBCPP_ATOMIC_ONLY_USE_BUILTINS
+struct __cxx_atomic_impl : public _Base {
+
+#if _GNUC_VER >= 501
+ static_assert(is_trivially_copyable<_Tp>::value,
+ "std::atomic<Tp> requires that 'Tp' be a trivially copyable type");
+#endif
+
+ _LIBCPP_INLINE_VISIBILITY __cxx_atomic_impl() _NOEXCEPT _LIBCPP_DEFAULT
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR explicit __cxx_atomic_impl(_Tp value) _NOEXCEPT
+ : _Base(value) {}
+};
+
// general atomic<T>
template <class _Tp, bool = is_integral<_Tp>::value && !is_same<_Tp, bool>::value>
struct __atomic_base // false
{
- mutable _Atomic(_Tp) __a_;
+ mutable __cxx_atomic_impl<_Tp> __a_;
#if defined(__cpp_lib_atomic_is_always_lock_free)
static _LIBCPP_CONSTEXPR bool is_always_lock_free = __atomic_always_lock_free(sizeof(__a_), 0);
@@ -898,88 +1465,79 @@ struct __atomic_base // false
_LIBCPP_INLINE_VISIBILITY
bool is_lock_free() const volatile _NOEXCEPT
- {
-#if defined(_LIBCPP_HAS_C_ATOMIC_IMP)
- return __c11_atomic_is_lock_free(sizeof(_Tp));
-#else
- return __atomic_is_lock_free(sizeof(_Tp), 0);
-#endif
- }
+ {return __cxx_atomic_is_lock_free(sizeof(_Tp));}
_LIBCPP_INLINE_VISIBILITY
bool is_lock_free() const _NOEXCEPT
{return static_cast<__atomic_base const volatile*>(this)->is_lock_free();}
_LIBCPP_INLINE_VISIBILITY
void store(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
- {__c11_atomic_store(&__a_, __d, __m);}
+ {__cxx_atomic_store(&__a_, __d, __m);}
_LIBCPP_INLINE_VISIBILITY
void store(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
- {__c11_atomic_store(&__a_, __d, __m);}
+ {__cxx_atomic_store(&__a_, __d, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp load(memory_order __m = memory_order_seq_cst) const volatile _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
- {return __c11_atomic_load(&__a_, __m);}
+ {return __cxx_atomic_load(&__a_, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp load(memory_order __m = memory_order_seq_cst) const _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
- {return __c11_atomic_load(&__a_, __m);}
+ {return __cxx_atomic_load(&__a_, __m);}
_LIBCPP_INLINE_VISIBILITY
operator _Tp() const volatile _NOEXCEPT {return load();}
_LIBCPP_INLINE_VISIBILITY
operator _Tp() const _NOEXCEPT {return load();}
_LIBCPP_INLINE_VISIBILITY
_Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, __d, __m);}
+ {return __cxx_atomic_exchange(&__a_, __d, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp exchange(_Tp __d, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, __d, __m);}
+ {return __cxx_atomic_exchange(&__a_, __d, __m);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) volatile _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_strong(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) volatile _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_strong(_Tp& __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT
_LIBCPP_CHECK_EXCHANGE_MEMORY_ORDER(__s, __f)
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __s, __f);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_weak(_Tp& __e, _Tp __d,
memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
+ {return __cxx_atomic_compare_exchange_weak(&__a_, &__e, __d, __m, __m);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_strong(_Tp& __e, _Tp __d,
memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
_LIBCPP_INLINE_VISIBILITY
bool compare_exchange_strong(_Tp& __e, _Tp __d,
memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
+ {return __cxx_atomic_compare_exchange_strong(&__a_, &__e, __d, __m, __m);}
_LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_CXX03_LANG
- __atomic_base() _NOEXCEPT = default;
-#else
- __atomic_base() _NOEXCEPT : __a_() {}
-#endif // _LIBCPP_CXX03_LANG
+ __atomic_base() _NOEXCEPT _LIBCPP_DEFAULT
+
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+ __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}
#ifndef _LIBCPP_CXX03_LANG
__atomic_base(const __atomic_base&) = delete;
__atomic_base& operator=(const __atomic_base&) = delete;
@@ -1011,34 +1569,34 @@ struct __atomic_base<_Tp, true>
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_add(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_sub(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_and(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_and(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_and(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_and(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_or(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_or(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_or(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_or(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp fetch_xor(_Tp __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_xor(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_xor(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp operator++(int) volatile _NOEXCEPT {return fetch_add(_Tp(1));}
@@ -1120,17 +1678,17 @@ struct atomic<_Tp*>
_LIBCPP_INLINE_VISIBILITY
_Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
volatile _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp* fetch_add(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_add(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_add(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst)
volatile _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp* fetch_sub(ptrdiff_t __op, memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_fetch_sub(&this->__a_, __op, __m);}
+ {return __cxx_atomic_fetch_sub(&this->__a_, __op, __m);}
_LIBCPP_INLINE_VISIBILITY
_Tp* operator++(int) volatile _NOEXCEPT {return fetch_add(1);}
@@ -1161,7 +1719,7 @@ struct atomic<_Tp*>
// atomic_is_lock_free
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
{
@@ -1169,7 +1727,7 @@ atomic_is_lock_free(const volatile atomic<_Tp>* __o) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
{
@@ -1179,25 +1737,25 @@ atomic_is_lock_free(const atomic<_Tp>* __o) _NOEXCEPT
// atomic_init
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
void
atomic_init(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
{
- __c11_atomic_init(&__o->__a_, __d);
+ __cxx_atomic_init(&__o->__a_, __d);
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
void
atomic_init(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
{
- __c11_atomic_init(&__o->__a_, __d);
+ __cxx_atomic_init(&__o->__a_, __d);
}
// atomic_store
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
void
atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
{
@@ -1205,7 +1763,7 @@ atomic_store(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
void
atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
{
@@ -1215,7 +1773,7 @@ atomic_store(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
// atomic_store_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
void
atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
@@ -1224,7 +1782,7 @@ atomic_store_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOE
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
void
atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_STORE_MEMORY_ORDER(__m)
@@ -1235,7 +1793,7 @@ atomic_store_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
// atomic_load
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
{
@@ -1243,7 +1801,7 @@ atomic_load(const volatile atomic<_Tp>* __o) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
{
@@ -1253,7 +1811,7 @@ atomic_load(const atomic<_Tp>* __o) _NOEXCEPT
// atomic_load_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
@@ -1262,7 +1820,7 @@ atomic_load_explicit(const volatile atomic<_Tp>* __o, memory_order __m) _NOEXCEP
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
_LIBCPP_CHECK_LOAD_MEMORY_ORDER(__m)
@@ -1273,7 +1831,7 @@ atomic_load_explicit(const atomic<_Tp>* __o, memory_order __m) _NOEXCEPT
// atomic_exchange
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
{
@@ -1281,7 +1839,7 @@ atomic_exchange(volatile atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
{
@@ -1291,7 +1849,7 @@ atomic_exchange(atomic<_Tp>* __o, _Tp __d) _NOEXCEPT
// atomic_exchange_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
{
@@ -1299,7 +1857,7 @@ atomic_exchange_explicit(volatile atomic<_Tp>* __o, _Tp __d, memory_order __m) _
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp
atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
{
@@ -1309,7 +1867,7 @@ atomic_exchange_explicit(atomic<_Tp>* __o, _Tp __d, memory_order __m) _NOEXCEPT
// atomic_compare_exchange_weak
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
{
@@ -1317,7 +1875,7 @@ atomic_compare_exchange_weak(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEX
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
{
@@ -1327,7 +1885,7 @@ atomic_compare_exchange_weak(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
// atomic_compare_exchange_strong
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
{
@@ -1335,7 +1893,7 @@ atomic_compare_exchange_strong(volatile atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NO
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
{
@@ -1345,7 +1903,7 @@ atomic_compare_exchange_strong(atomic<_Tp>* __o, _Tp* __e, _Tp __d) _NOEXCEPT
// atomic_compare_exchange_weak_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
_Tp __d,
@@ -1356,7 +1914,7 @@ atomic_compare_exchange_weak_explicit(volatile atomic<_Tp>* __o, _Tp* __e,
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
memory_order __s, memory_order __f) _NOEXCEPT
@@ -1368,7 +1926,7 @@ atomic_compare_exchange_weak_explicit(atomic<_Tp>* __o, _Tp* __e, _Tp __d,
// atomic_compare_exchange_strong_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
_Tp* __e, _Tp __d,
@@ -1379,7 +1937,7 @@ atomic_compare_exchange_strong_explicit(volatile atomic<_Tp>* __o,
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
bool
atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
_Tp __d,
@@ -1392,7 +1950,7 @@ atomic_compare_exchange_strong_explicit(atomic<_Tp>* __o, _Tp* __e,
// atomic_fetch_add
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1404,7 +1962,7 @@ atomic_fetch_add(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1416,7 +1974,7 @@ atomic_fetch_add(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
{
@@ -1424,7 +1982,7 @@ atomic_fetch_add(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
{
@@ -1434,7 +1992,7 @@ atomic_fetch_add(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
// atomic_fetch_add_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1446,7 +2004,7 @@ atomic_fetch_add_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1458,7 +2016,7 @@ atomic_fetch_add_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
memory_order __m) _NOEXCEPT
@@ -1467,7 +2025,7 @@ atomic_fetch_add_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
{
@@ -1477,7 +2035,7 @@ atomic_fetch_add_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _
// atomic_fetch_sub
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1489,7 +2047,7 @@ atomic_fetch_sub(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1501,7 +2059,7 @@ atomic_fetch_sub(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
{
@@ -1509,7 +2067,7 @@ atomic_fetch_sub(volatile atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
{
@@ -1519,7 +2077,7 @@ atomic_fetch_sub(atomic<_Tp*>* __o, ptrdiff_t __op) _NOEXCEPT
// atomic_fetch_sub_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1531,7 +2089,7 @@ atomic_fetch_sub_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1543,7 +2101,7 @@ atomic_fetch_sub_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
memory_order __m) _NOEXCEPT
@@ -1552,7 +2110,7 @@ atomic_fetch_sub_explicit(volatile atomic<_Tp*>* __o, ptrdiff_t __op,
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
_Tp*
atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _NOEXCEPT
{
@@ -1562,7 +2120,7 @@ atomic_fetch_sub_explicit(atomic<_Tp*>* __o, ptrdiff_t __op, memory_order __m) _
// atomic_fetch_and
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1574,7 +2132,7 @@ atomic_fetch_and(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1588,7 +2146,7 @@ atomic_fetch_and(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
// atomic_fetch_and_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1600,7 +2158,7 @@ atomic_fetch_and_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1614,7 +2172,7 @@ atomic_fetch_and_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
// atomic_fetch_or
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1626,7 +2184,7 @@ atomic_fetch_or(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1640,7 +2198,7 @@ atomic_fetch_or(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
// atomic_fetch_or_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1652,7 +2210,7 @@ atomic_fetch_or_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1666,7 +2224,7 @@ atomic_fetch_or_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEPT
// atomic_fetch_xor
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1678,7 +2236,7 @@ atomic_fetch_xor(volatile atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1692,7 +2250,7 @@ atomic_fetch_xor(atomic<_Tp>* __o, _Tp __op) _NOEXCEPT
// atomic_fetch_xor_explicit
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1704,7 +2262,7 @@ atomic_fetch_xor_explicit(volatile atomic<_Tp>* __o, _Tp __op, memory_order __m)
}
template <class _Tp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename enable_if
<
is_integral<_Tp>::value && !is_same<_Tp, bool>::value,
@@ -1719,27 +2277,23 @@ atomic_fetch_xor_explicit(atomic<_Tp>* __o, _Tp __op, memory_order __m) _NOEXCEP
typedef struct atomic_flag
{
- _Atomic(bool) __a_;
+ __cxx_atomic_impl<_LIBCPP_ATOMIC_FLAG_TYPE> __a_;
_LIBCPP_INLINE_VISIBILITY
bool test_and_set(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, true, __m);}
+ {return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);}
_LIBCPP_INLINE_VISIBILITY
bool test_and_set(memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {return __c11_atomic_exchange(&__a_, true, __m);}
+ {return __cxx_atomic_exchange(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(true), __m);}
_LIBCPP_INLINE_VISIBILITY
void clear(memory_order __m = memory_order_seq_cst) volatile _NOEXCEPT
- {__c11_atomic_store(&__a_, false, __m);}
+ {__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);}
_LIBCPP_INLINE_VISIBILITY
void clear(memory_order __m = memory_order_seq_cst) _NOEXCEPT
- {__c11_atomic_store(&__a_, false, __m);}
+ {__cxx_atomic_store(&__a_, _LIBCPP_ATOMIC_FLAG_TYPE(false), __m);}
_LIBCPP_INLINE_VISIBILITY
-#ifndef _LIBCPP_CXX03_LANG
- atomic_flag() _NOEXCEPT = default;
-#else
- atomic_flag() _NOEXCEPT : __a_() {}
-#endif // _LIBCPP_CXX03_LANG
+ atomic_flag() _NOEXCEPT _LIBCPP_DEFAULT
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
atomic_flag(bool __b) _NOEXCEPT : __a_(__b) {} // EXTENSION
@@ -1818,14 +2372,14 @@ inline _LIBCPP_INLINE_VISIBILITY
void
atomic_thread_fence(memory_order __m) _NOEXCEPT
{
- __c11_atomic_thread_fence(__m);
+ __cxx_atomic_thread_fence(__m);
}
inline _LIBCPP_INLINE_VISIBILITY
void
atomic_signal_fence(memory_order __m) _NOEXCEPT
{
- __c11_atomic_signal_fence(__m);
+ __cxx_atomic_signal_fence(__m);
}
// Atomics for standard typedef types
diff --git a/include/bit b/include/bit
index db3812e5b5b2..1c0e8ad3ba8b 100644
--- a/include/bit
+++ b/include/bit
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------------ bit ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===---------------------------------------------------------------------===//
@@ -16,12 +15,42 @@
namespace std {
+ template <class T>
+ constexpr bool ispow2(T x) noexcept; // C++20
+ template <class T>
+ constexpr T ceil2(T x); // C++20
+ template <class T>
+ constexpr T floor2(T x) noexcept; // C++20
+ template <class T>
+ constexpr T log2p1(T x) noexcept; // C++20
+
+ // 23.20.2, rotating
+ template<class T>
+ constexpr T rotl(T x, unsigned int s) noexcept; // C++20
+ template<class T>
+ constexpr T rotr(T x, unsigned int s) noexcept; // C++20
+
+ // 23.20.3, counting
+ template<class T>
+ constexpr int countl_zero(T x) noexcept; // C++20
+ template<class T>
+ constexpr int countl_one(T x) noexcept; // C++20
+ template<class T>
+ constexpr int countr_zero(T x) noexcept; // C++20
+ template<class T>
+ constexpr int countr_one(T x) noexcept; // C++20
+ template<class T>
+ constexpr int popcount(T x) noexcept; // C++20
+
} // namespace std
*/
#include <__config>
+#include <limits>
+#include <type_traits>
#include <version>
+#include <__debug>
#if defined(__IBMCPP__)
#include "support/ibm/support.h"
@@ -34,44 +63,47 @@ namespace std {
#pragma GCC system_header
#endif
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
_LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_COMPILER_MSVC
-inline _LIBCPP_INLINE_VISIBILITY
-int __ctz(unsigned __x) { return __builtin_ctz(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __ctz(unsigned long __x) { return __builtin_ctzl(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __ctz(unsigned long long __x) { return __builtin_ctzll(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __clz(unsigned __x) { return __builtin_clz(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __clz(unsigned long __x) { return __builtin_clzl(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __clz(unsigned long long __x) { return __builtin_clzll(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __popcount(unsigned __x) { return __builtin_popcount(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __popcount(unsigned long __x) { return __builtin_popcountl(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
-inline _LIBCPP_INLINE_VISIBILITY
-int __popcount(unsigned long long __x) { return __builtin_popcountll(__x); }
+inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
#else // _LIBCPP_COMPILER_MSVC
// Precondition: __x != 0
inline _LIBCPP_INLINE_VISIBILITY
-int __ctz(unsigned __x) {
+int __libcpp_ctz(unsigned __x) {
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
static_assert(sizeof(unsigned long) == 4, "");
unsigned long __where;
@@ -81,13 +113,13 @@ int __ctz(unsigned __x) {
}
inline _LIBCPP_INLINE_VISIBILITY
-int __ctz(unsigned long __x) {
+int __libcpp_ctz(unsigned long __x) {
static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
return __ctz(static_cast<unsigned>(__x));
}
inline _LIBCPP_INLINE_VISIBILITY
-int __ctz(unsigned long long __x) {
+int __libcpp_ctz(unsigned long long __x) {
unsigned long __where;
#if defined(_LIBCPP_HAS_BITSCAN64)
(defined(_M_AMD64) || defined(__x86_64__))
@@ -105,7 +137,7 @@ int __ctz(unsigned long long __x) {
// Precondition: __x != 0
inline _LIBCPP_INLINE_VISIBILITY
-int __clz(unsigned __x) {
+int __libcpp_clz(unsigned __x) {
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
static_assert(sizeof(unsigned long) == 4, "");
unsigned long __where;
@@ -115,13 +147,13 @@ int __clz(unsigned __x) {
}
inline _LIBCPP_INLINE_VISIBILITY
-int __clz(unsigned long __x) {
+int __libcpp_clz(unsigned long __x) {
static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
- return __clz(static_cast<unsigned>(__x));
+ return __libcpp_clz(static_cast<unsigned>(__x));
}
inline _LIBCPP_INLINE_VISIBILITY
-int __clz(unsigned long long __x) {
+int __libcpp_clz(unsigned long long __x) {
unsigned long __where;
#if defined(_LIBCPP_HAS_BITSCAN64)
if (_BitScanReverse64(&__where, __x))
@@ -136,23 +168,298 @@ int __clz(unsigned long long __x) {
return 64; // Undefined Behavior.
}
-inline _LIBCPP_INLINE_VISIBILITY int __popcount(unsigned __x) {
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) {
static_assert(sizeof(unsigned) == 4, "");
return __popcnt(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY int __popcount(unsigned long __x) {
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
static_assert(sizeof(unsigned long) == 4, "");
return __popcnt(__x);
}
-inline _LIBCPP_INLINE_VISIBILITY int __popcount(unsigned long long __x) {
+inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
static_assert(sizeof(unsigned long long) == 8, "");
return __popcnt64(__x);
}
#endif // _LIBCPP_COMPILER_MSVC
+template <class _Tp>
+using __bitop_unsigned_integer _LIBCPP_NODEBUG_TYPE = integral_constant<bool,
+ is_integral<_Tp>::value &&
+ is_unsigned<_Tp>::value &&
+ _IsNotSame<typename remove_cv<_Tp>::type, bool>::value &&
+ _IsNotSame<typename remove_cv<_Tp>::type, signed char>::value &&
+ _IsNotSame<typename remove_cv<_Tp>::type, wchar_t>::value &&
+ _IsNotSame<typename remove_cv<_Tp>::type, char16_t>::value &&
+ _IsNotSame<typename remove_cv<_Tp>::type, char32_t>::value
+ >;
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp __rotl(_Tp __t, unsigned int __cnt) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__rotl requires unsigned");
+ const unsigned int __dig = numeric_limits<_Tp>::digits;
+ if ((__cnt % __dig) == 0)
+ return __t;
+ return (__t << (__cnt % __dig)) | (__t >> (__dig - (__cnt % __dig)));
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_Tp __rotr(_Tp __t, unsigned int __cnt) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__rotr requires unsigned");
+ const unsigned int __dig = numeric_limits<_Tp>::digits;
+ if ((__cnt % __dig) == 0)
+ return __t;
+ return (__t >> (__cnt % __dig)) | (__t << (__dig - (__cnt % __dig)));
+}
+
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int __countr_zero(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__countr_zero requires unsigned");
+ if (__t == 0)
+ return numeric_limits<_Tp>::digits;
+
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return __libcpp_ctz(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return __libcpp_ctz(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __libcpp_ctz(static_cast<unsigned long long>(__t));
+ else
+ {
+ int __ret = 0;
+ int __iter = 0;
+ const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
+ while ((__iter = __libcpp_ctz(static_cast<unsigned long long>(__t))) == __ulldigits)
+ {
+ __ret += __iter;
+ __t >>= __ulldigits;
+ }
+ return __ret + __iter;
+ }
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int __countl_zero(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__countl_zero requires unsigned");
+ if (__t == 0)
+ return numeric_limits<_Tp>::digits;
+
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return __libcpp_clz(static_cast<unsigned int>(__t))
+ - (numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return __libcpp_clz(static_cast<unsigned long>(__t))
+ - (numeric_limits<unsigned long>::digits - numeric_limits<_Tp>::digits);
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __libcpp_clz(static_cast<unsigned long long>(__t))
+ - (numeric_limits<unsigned long long>::digits - numeric_limits<_Tp>::digits);
+ else
+ {
+ int __ret = 0;
+ int __iter = 0;
+ const unsigned int __ulldigits = numeric_limits<unsigned long long>::digits;
+ while (true) {
+ __t = __rotr(__t, __ulldigits);
+ if ((__iter = __countl_zero(static_cast<unsigned long long>(__t))) != __ulldigits)
+ break;
+ __ret += __iter;
+ }
+ return __ret + __iter;
+ }
+}
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int __countl_one(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__countl_one requires unsigned");
+ return __t != numeric_limits<_Tp>::max()
+ ? __countl_zero(static_cast<_Tp>(~__t))
+ : numeric_limits<_Tp>::digits;
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int __countr_one(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__countr_one requires unsigned");
+ return __t != numeric_limits<_Tp>::max()
+ ? __countr_zero(static_cast<_Tp>(~__t))
+ : numeric_limits<_Tp>::digits;
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+int
+__popcount(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__libcpp_popcount requires unsigned");
+ if (sizeof(_Tp) <= sizeof(unsigned int))
+ return __libcpp_popcount(static_cast<unsigned int>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long))
+ return __libcpp_popcount(static_cast<unsigned long>(__t));
+ else if (sizeof(_Tp) <= sizeof(unsigned long long))
+ return __libcpp_popcount(static_cast<unsigned long long>(__t));
+ else
+ {
+ int __ret = 0;
+ while (__t != 0)
+ {
+ __ret += __libcpp_popcount(static_cast<unsigned long long>(__t));
+ __t >>= numeric_limits<unsigned long long>::digits;
+ }
+ return __ret;
+ }
+}
+
+
+// integral log base 2
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+unsigned __bit_log2(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__bit_log2 requires unsigned");
+ return std::numeric_limits<_Tp>::digits - 1 - __countl_zero(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
+bool __ispow2(_Tp __t) _NOEXCEPT
+{
+ static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned");
+ return __t != 0 && (((__t & (__t - 1)) == 0));
+}
+
+
+#if _LIBCPP_STD_VER > 17
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+rotl(_Tp __t, unsigned int __cnt) noexcept
+{
+ return __rotl(__t, __cnt);
+}
+
+
+// rotr
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+rotr(_Tp __t, unsigned int __cnt) noexcept
+{
+ return __rotr(__t, __cnt);
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+countl_zero(_Tp __t) noexcept
+{
+ return __countl_zero(__t);
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+countl_one(_Tp __t) noexcept
+{
+ return __countl_one(__t);
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+countr_zero(_Tp __t) noexcept
+{
+ return __countr_zero(__t);
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+countr_one(_Tp __t) noexcept
+{
+ return __countr_one(__t);
+}
+
+
+template<class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
+popcount(_Tp __t) noexcept
+{
+ return __popcount(__t);
+}
+
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, bool>
+ispow2(_Tp __t) noexcept
+{
+ return __ispow2(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+floor2(_Tp __t) noexcept
+{
+ return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+ceil2(_Tp __t) noexcept
+{
+ if (__t < 2) return 1;
+ const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
+ _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to ceil2");
+
+ if constexpr (sizeof(_Tp) >= sizeof(unsigned))
+ return _Tp{1} << __n;
+ else
+ {
+ const unsigned __extra = numeric_limits<unsigned>::digits - numeric_limits<_Tp>::digits;
+ const unsigned __retVal = 1u << (__n + __extra);
+ return (_Tp) (__retVal >> __extra);
+ }
+}
+
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
+log2p1(_Tp __t) noexcept
+{
+ return __t == 0 ? 0 : __bit_log2(__t) + 1;
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
+_LIBCPP_POP_MACROS
+
#endif // _LIBCPP_BIT
diff --git a/include/bitset b/include/bitset
index 98947e027c1c..4755fbeb2152 100644
--- a/include/bitset
+++ b/include/bitset
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- bitset ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -680,7 +679,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR bitset() _NOEXCEPT {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
bitset(unsigned long long __v) _NOEXCEPT : base(__v) {}
- template<class _CharT>
+ template<class _CharT, class = _EnableIf<_IsCharLikeType<_CharT>::value> >
explicit bitset(const _CharT* __str,
typename basic_string<_CharT>::size_type __n = basic_string<_CharT>::npos,
_CharT __zero = _CharT('0'), _CharT __one = _CharT('1'));
@@ -761,7 +760,7 @@ private:
};
template <size_t _Size>
-template<class _CharT>
+template<class _CharT, class>
bitset<_Size>::bitset(const _CharT* __str,
typename basic_string<_CharT>::size_type __n,
_CharT __zero, _CharT __one)
diff --git a/include/cassert b/include/cassert
index 3775990640a9..25a0a746b8d1 100644
--- a/include/cassert
+++ b/include/cassert
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- cassert -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/ccomplex b/include/ccomplex
index 6ed116445e64..0d2e0f5a0f2c 100644
--- a/include/ccomplex
+++ b/include/ccomplex
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- ccomplex ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cctype b/include/cctype
index 7fc81344696d..55fc9ebc66ce 100644
--- a/include/cctype
+++ b/include/cctype
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- cctype ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cerrno b/include/cerrno
index bab13b8aa861..a9268a281f4e 100644
--- a/include/cerrno
+++ b/include/cerrno
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- cerrno ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cfenv b/include/cfenv
index 4fc630419bde..6cd91db5a463 100644
--- a/include/cfenv
+++ b/include/cfenv
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- cfenv -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cfloat b/include/cfloat
index 0abe84bf175d..da22c6f60a2a 100644
--- a/include/cfloat
+++ b/include/cfloat
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cfloat -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/charconv b/include/charconv
index 064f2e11c3f3..a644fe094846 100644
--- a/include/charconv
+++ b/include/charconv
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------------ charconv ------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -97,7 +96,7 @@ _LIBCPP_FUNC_VIS char* __u64toa(uint64_t __value, char* __buffer);
_LIBCPP_FUNC_VIS char* __u32toa(uint32_t __value, char* __buffer);
}
-#if _LIBCPP_STD_VER > 11
+#ifndef _LIBCPP_CXX03_LANG
enum class _LIBCPP_ENUM_VIS chars_format
{
@@ -125,7 +124,7 @@ void from_chars(const char*, const char*, bool, int = 10) = delete;
namespace __itoa
{
-static constexpr uint64_t __pow10_64[] = {
+static _LIBCPP_CONSTEXPR uint64_t __pow10_64[] = {
UINT64_C(0),
UINT64_C(10),
UINT64_C(100),
@@ -148,7 +147,7 @@ static constexpr uint64_t __pow10_64[] = {
UINT64_C(10000000000000000000),
};
-static constexpr uint32_t __pow10_32[] = {
+static _LIBCPP_CONSTEXPR uint32_t __pow10_32[] = {
UINT32_C(0), UINT32_C(10), UINT32_C(100),
UINT32_C(1000), UINT32_C(10000), UINT32_C(100000),
UINT32_C(1000000), UINT32_C(10000000), UINT32_C(100000000),
@@ -173,7 +172,7 @@ struct _LIBCPP_HIDDEN __traits_base
return __u64toa(__v, __p);
}
- static _LIBCPP_INLINE_VISIBILITY auto& __pow() { return __pow10_64; }
+ static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_64)& __pow() { return __pow10_64; }
};
template <typename _Tp>
@@ -195,7 +194,7 @@ struct _LIBCPP_HIDDEN
return __u32toa(__v, __p);
}
- static _LIBCPP_INLINE_VISIBILITY auto& __pow() { return __pow10_32; }
+ static _LIBCPP_INLINE_VISIBILITY decltype(__pow10_32)& __pow() { return __pow10_32; }
};
template <typename _Tp>
@@ -240,7 +239,7 @@ __mul_overflowed(_Tp __a, _Up __b, _Tp& __r)
template <typename _Tp>
struct _LIBCPP_HIDDEN __traits : __traits_base<_Tp>
{
- static constexpr int digits = numeric_limits<_Tp>::digits10 + 1;
+ static _LIBCPP_CONSTEXPR int digits = numeric_limits<_Tp>::digits10 + 1;
using __traits_base<_Tp>::__pow;
using typename __traits_base<_Tp>::type;
@@ -286,10 +285,10 @@ __complement(_Tp __x)
}
template <typename _Tp>
-inline _LIBCPP_INLINE_VISIBILITY auto
+inline _LIBCPP_INLINE_VISIBILITY typename make_unsigned<_Tp>::type
__to_unsigned(_Tp __x)
{
- return static_cast<make_unsigned_t<_Tp>>(__x);
+ return static_cast<typename make_unsigned<_Tp>::type>(__x);
}
template <typename _Tp>
@@ -315,7 +314,7 @@ __to_chars_itoa(char* __first, char* __last, _Tp __value, false_type)
#if !defined(_LIBCPP_COMPILER_MSVC)
if (__tx::digits <= __diff || __tx::__width(__value) <= __diff)
- return {__tx::__convert(__value, __first), {}};
+ return {__tx::__convert(__value, __first), errc(0)};
else
return {__last, errc::value_too_large};
#else
@@ -380,14 +379,14 @@ __to_chars_integral(char* __first, char* __last, _Tp __value, int __base,
}
}
-template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
to_chars(char* __first, char* __last, _Tp __value)
{
return __to_chars_itoa(__first, __last, __value, is_signed<_Tp>());
}
-template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY to_chars_result
to_chars(char* __first, char* __last, _Tp __value, int __base)
{
@@ -502,7 +501,7 @@ __subject_seq_combinator(_It __first, _It __last, _Tp& __value, _Fn __f,
return __r;
}
-template <typename _Tp, enable_if_t<is_unsigned<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
{
@@ -528,7 +527,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
});
}
-template <typename _Tp, enable_if_t<is_signed<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
{
@@ -536,7 +535,7 @@ __from_chars_atoi(const char* __first, const char* __last, _Tp& __value)
return __sign_combinator(__first, __last, __value, __from_chars_atoi<__t>);
}
-template <typename _Tp, enable_if_t<is_unsigned<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_unsigned<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
int __base)
@@ -583,7 +582,7 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
__base);
}
-template <typename _Tp, enable_if_t<is_signed<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_signed<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
__from_chars_integral(const char* __first, const char* __last, _Tp& __value,
int __base)
@@ -593,14 +592,14 @@ __from_chars_integral(const char* __first, const char* __last, _Tp& __value,
__from_chars_integral<__t>, __base);
}
-template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
from_chars(const char* __first, const char* __last, _Tp& __value)
{
return __from_chars_atoi(__first, __last, __value);
}
-template <typename _Tp, enable_if_t<is_integral<_Tp>::value, int> = 0>
+template <typename _Tp, typename enable_if<is_integral<_Tp>::value, int>::type = 0>
inline _LIBCPP_INLINE_VISIBILITY from_chars_result
from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
{
@@ -608,7 +607,7 @@ from_chars(const char* __first, const char* __last, _Tp& __value, int __base)
return __from_chars_integral(__first, __last, __value, __base);
}
-#endif // _LIBCPP_STD_VER > 11
+#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
diff --git a/include/chrono b/include/chrono
index 96759f9860ee..1b907571aa14 100644
--- a/include/chrono
+++ b/include/chrono
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- chrono ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1263,34 +1262,15 @@ operator*(const _Rep1& __s, const duration<_Rep2, _Period>& __d)
// Duration /
-template <class _Duration, class _Rep, bool = __is_duration<_Rep>::value>
-struct __duration_divide_result
-{
-};
-
-template <class _Duration, class _Rep2,
- bool = is_convertible<_Rep2,
- typename common_type<typename _Duration::rep, _Rep2>::type>::value>
-struct __duration_divide_imp
-{
-};
-
-template <class _Rep1, class _Period, class _Rep2>
-struct __duration_divide_imp<duration<_Rep1, _Period>, _Rep2, true>
-{
- typedef duration<typename common_type<_Rep1, _Rep2>::type, _Period> type;
-};
-
-template <class _Rep1, class _Period, class _Rep2>
-struct __duration_divide_result<duration<_Rep1, _Period>, _Rep2, false>
- : __duration_divide_imp<duration<_Rep1, _Period>, _Rep2>
-{
-};
-
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
-typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
+typename enable_if
+<
+ !__is_duration<_Rep2>::value &&
+ is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
+ duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
operator/(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
@@ -1313,7 +1293,12 @@ operator/(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2
template <class _Rep1, class _Period, class _Rep2>
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
-typename __duration_divide_result<duration<_Rep1, _Period>, _Rep2>::type
+typename enable_if
+<
+ !__is_duration<_Rep2>::value &&
+ is_convertible<_Rep2, typename common_type<_Rep1, _Rep2>::type>::value,
+ duration<typename common_type<_Rep1, _Rep2>::type, _Period>
+>::type
operator%(const duration<_Rep1, _Period>& __d, const _Rep2& __s)
{
typedef typename common_type<_Rep1, _Rep2>::type _Cr;
@@ -1605,9 +1590,9 @@ using local_seconds = local_time<seconds>;
using local_days = local_time<days>;
-struct _LIBCPP_TYPE_VIS last_spec { explicit last_spec() = default; };
+struct last_spec { explicit last_spec() = default; };
-class _LIBCPP_TYPE_VIS day {
+class day {
private:
unsigned char __d;
public:
@@ -1672,7 +1657,7 @@ inline constexpr day& day::operator-=(const days& __dd) noexcept
{ *this = *this - __dd; return *this; }
-class _LIBCPP_TYPE_VIS month {
+class month {
private:
unsigned char __m;
public:
@@ -1743,21 +1728,21 @@ inline constexpr month& month::operator-=(const months& __dm) noexcept
{ *this = *this - __dm; return *this; }
-class _LIBCPP_TYPE_VIS year {
+class year {
private:
short __y;
public:
year() = default;
explicit inline constexpr year(int __val) noexcept : __y(static_cast<short>(__val)) {}
- inline constexpr year& operator++() noexcept { ++__y; return *this; };
- inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; };
- inline constexpr year& operator--() noexcept { --__y; return *this; };
- inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; };
+ inline constexpr year& operator++() noexcept { ++__y; return *this; }
+ inline constexpr year operator++(int) noexcept { year __tmp = *this; ++(*this); return __tmp; }
+ inline constexpr year& operator--() noexcept { --__y; return *this; }
+ inline constexpr year operator--(int) noexcept { year __tmp = *this; --(*this); return __tmp; }
constexpr year& operator+=(const years& __dy) noexcept;
constexpr year& operator-=(const years& __dy) noexcept;
inline constexpr year operator+() const noexcept { return *this; }
- inline constexpr year operator-() const noexcept { return year{-__y}; };
+ inline constexpr year operator-() const noexcept { return year{-__y}; }
inline constexpr bool is_leap() const noexcept { return __y % 4 == 0 && (__y % 100 != 0 || __y % 400 == 0); }
explicit inline constexpr operator int() const noexcept { return __y; }
@@ -1817,10 +1802,10 @@ inline constexpr year& year::operator-=(const years& __dy) noexcept
inline constexpr bool year::ok() const noexcept
{ return static_cast<int>(min()) <= __y && __y <= static_cast<int>(max()); }
-class _LIBCPP_TYPE_VIS weekday_indexed;
-class _LIBCPP_TYPE_VIS weekday_last;
+class weekday_indexed;
+class weekday_last;
-class _LIBCPP_TYPE_VIS weekday {
+class weekday {
private:
unsigned char __wd;
public:
@@ -1906,7 +1891,7 @@ inline constexpr weekday& weekday::operator-=(const days& __dd) noexcept
{ *this = *this - __dd; return *this; }
-class _LIBCPP_TYPE_VIS weekday_indexed {
+class weekday_indexed {
private:
_VSTD::chrono::weekday __wd;
unsigned char __idx;
@@ -1928,7 +1913,7 @@ bool operator!=(const weekday_indexed& __lhs, const weekday_indexed& __rhs) noex
{ return !(__lhs == __rhs); }
-class _LIBCPP_TYPE_VIS weekday_last {
+class weekday_last {
private:
_VSTD::chrono::weekday __wd;
public:
@@ -1949,7 +1934,7 @@ bool operator!=(const weekday_last& __lhs, const weekday_last& __rhs) noexcept
inline constexpr
weekday_indexed weekday::operator[](unsigned __index) const noexcept { return weekday_indexed{*this, __index}; }
-inline constexpr
+inline constexpr
weekday_last weekday::operator[](last_spec) const noexcept { return weekday_last{*this}; }
@@ -1976,7 +1961,7 @@ inline constexpr month November{11};
inline constexpr month December{12};
-class _LIBCPP_TYPE_VIS month_day {
+class month_day {
private:
chrono::month __m;
chrono::day __d;
@@ -2051,7 +2036,7 @@ bool operator>=(const month_day& __lhs, const month_day& __rhs) noexcept
-class _LIBCPP_TYPE_VIS month_day_last {
+class month_day_last {
private:
chrono::month __m;
public:
@@ -2102,7 +2087,7 @@ month_day_last operator/(last_spec, int __rhs) noexcept
{ return month_day_last{month(__rhs)}; }
-class _LIBCPP_TYPE_VIS month_weekday {
+class month_weekday {
private:
chrono::month __m;
chrono::weekday_indexed __wdi;
@@ -2140,7 +2125,7 @@ month_weekday operator/(const weekday_indexed& __lhs, int __rhs) noexcept
{ return month_weekday{month(__rhs), __lhs}; }
-class _LIBCPP_TYPE_VIS month_weekday_last {
+class month_weekday_last {
chrono::month __m;
chrono::weekday_last __wdl;
public:
@@ -2177,7 +2162,7 @@ month_weekday_last operator/(const weekday_last& __lhs, int __rhs) noexcept
{ return month_weekday_last{month(__rhs), __lhs}; }
-class _LIBCPP_TYPE_VIS year_month {
+class year_month {
chrono::year __y;
chrono::month __m;
public:
@@ -2251,7 +2236,7 @@ constexpr year_month operator-(const year_month& __lhs, const years& __rhs) noex
class year_month_day_last;
-class _LIBCPP_TYPE_VIS year_month_day {
+class year_month_day {
private:
chrono::year __y;
chrono::month __m;
@@ -2260,7 +2245,7 @@ public:
year_month_day() = default;
inline constexpr year_month_day(
const chrono::year& __yval, const chrono::month& __mval, const chrono::day& __dval) noexcept
- : __y{__yval}, __m{__mval}, __d{__dval} {}
+ : __y{__yval}, __m{__mval}, __d{__dval} {}
constexpr year_month_day(const year_month_day_last& __ymdl) noexcept;
inline constexpr year_month_day(const sys_days& __sysd) noexcept
: year_month_day(__from_days(__sysd.time_since_epoch())) {}
@@ -2405,7 +2390,7 @@ inline constexpr year_month_day& year_month_day::operator-=(const months& __dm)
inline constexpr year_month_day& year_month_day::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
inline constexpr year_month_day& year_month_day::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-class _LIBCPP_TYPE_VIS year_month_day_last {
+class year_month_day_last {
private:
chrono::year __y;
chrono::month_day_last __mdl;
@@ -2515,7 +2500,7 @@ inline constexpr year_month_day_last& year_month_day_last::operator+=(const year
inline constexpr year_month_day_last& year_month_day_last::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
inline constexpr year_month_day::year_month_day(const year_month_day_last& __ymdl) noexcept
- : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
+ : __y{__ymdl.year()}, __m{__ymdl.month()}, __d{__ymdl.day()} {}
inline constexpr bool year_month_day::ok() const noexcept
{
@@ -2523,7 +2508,7 @@ inline constexpr bool year_month_day::ok() const noexcept
return chrono::day{1} <= __d && __d <= (__y / __m / last).day();
}
-class _LIBCPP_TYPE_VIS year_month_weekday {
+class year_month_weekday {
chrono::year __y;
chrono::month __m;
chrono::weekday_indexed __wdi;
@@ -2566,7 +2551,7 @@ year_month_weekday year_month_weekday::__from_days(days __d) noexcept
const sys_days __sysd{__d};
const chrono::weekday __wd = chrono::weekday(__sysd);
const year_month_day __ymd = year_month_day(__sysd);
- return year_month_weekday{__ymd.year(), __ymd.month(),
+ return year_month_weekday{__ymd.year(), __ymd.month(),
__wd[(static_cast<unsigned>(__ymd.day())-1)/7+1]};
}
@@ -2637,7 +2622,7 @@ inline constexpr year_month_weekday& year_month_weekday::operator-=(const months
inline constexpr year_month_weekday& year_month_weekday::operator+=(const years& __dy) noexcept { *this = *this + __dy; return *this; }
inline constexpr year_month_weekday& year_month_weekday::operator-=(const years& __dy) noexcept { *this = *this - __dy; return *this; }
-class _LIBCPP_TYPE_VIS year_month_weekday_last {
+class year_month_weekday_last {
private:
chrono::year __y;
chrono::month __m;
@@ -2658,9 +2643,9 @@ public:
inline constexpr operator sys_days() const noexcept { return sys_days{__to_days()}; }
inline explicit constexpr operator local_days() const noexcept { return local_days{__to_days()}; }
inline constexpr bool ok() const noexcept { return __y.ok() && __m.ok() && __wdl.ok(); }
-
+
constexpr days __to_days() const noexcept;
-
+
};
inline constexpr
@@ -2698,7 +2683,7 @@ year_month_weekday_last operator/(const month_weekday_last& __lhs, const year& _
inline constexpr
year_month_weekday_last operator/(const month_weekday_last& __lhs, int __rhs) noexcept
-{ return year(__rhs) / __lhs; }
+{ return year(__rhs) / __lhs; }
inline constexpr
@@ -2810,7 +2795,7 @@ inline namespace literals
{
return chrono::day(static_cast<unsigned>(__d));
}
-
+
constexpr chrono::year operator ""y(unsigned long long __y) noexcept
{
return chrono::year(static_cast<int>(__y));
@@ -2842,7 +2827,7 @@ struct _FilesystemClock {
static _LIBCPP_CONSTEXPR_AFTER_CXX11 const bool is_steady = false;
- _LIBCPP_FUNC_VIS static time_point now() noexcept;
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_FUNC_VIS static time_point now() noexcept;
_LIBCPP_INLINE_VISIBILITY
static time_t to_time_t(const time_point& __t) noexcept {
diff --git a/include/cinttypes b/include/cinttypes
index 3f61b0634b17..55af85cc395d 100644
--- a/include/cinttypes
+++ b/include/cinttypes
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cinttypes --------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/ciso646 b/include/ciso646
index b2efc72a9aa1..172f1676ad9b 100644
--- a/include/ciso646
+++ b/include/ciso646
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- ciso646 ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/climits b/include/climits
index 81ffecdf6eef..43eb2d3f1520 100644
--- a/include/climits
+++ b/include/climits
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- climits ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/clocale b/include/clocale
index 05fa9c6edda8..bff4e92f99ff 100644
--- a/include/clocale
+++ b/include/clocale
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- clocale ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cmath b/include/cmath
index f5f62adcfb8d..f5864be5e11a 100644
--- a/include/cmath
+++ b/include/cmath
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- cmath -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -530,7 +529,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double hypot( long double x, long double y
template <class _A1, class _A2, class _A3>
inline _LIBCPP_INLINE_VISIBILITY
-typename __lazy_enable_if
+typename _EnableIf
<
is_arithmetic<_A1>::value &&
is_arithmetic<_A2>::value &&
@@ -607,6 +606,32 @@ __libcpp_isfinite_or_builtin(_A1 __lcpp_x) _NOEXCEPT
return isfinite(__lcpp_x);
}
+#if _LIBCPP_STD_VER > 17
+template <typename _Fp>
+constexpr
+_Fp __lerp(_Fp __a, _Fp __b, _Fp __t) noexcept {
+ if ((__a <= 0 && __b >= 0) || (__a >= 0 && __b <= 0))
+ return __t * __b + (1 - __t) * __a;
+
+ if (__t == 1) return __b;
+ const _Fp __x = __a + __t * (__b - __a);
+ if (__t > 1 == __b > __a)
+ return __b < __x ? __x : __b;
+ else
+ return __x < __b ? __x : __b;
+}
+
+constexpr float
+lerp(float __a, float __b, float __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
+
+constexpr double
+lerp(double __a, double __b, double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
+
+constexpr long double
+lerp(long double __a, long double __b, long double __t) _NOEXCEPT { return __lerp(__a, __b, __t); }
+
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP_CMATH
diff --git a/include/codecvt b/include/codecvt
index 5eb9d1549118..5ea411ea781b 100644
--- a/include/codecvt
+++ b/include/codecvt
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- codecvt -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/compare b/include/compare
index 07f88f09cb37..e05257bebfa5 100644
--- a/include/compare
+++ b/include/compare
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- compare -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/complex b/include/complex
index 8cf6a946d711..c168406befbd 100644
--- a/include/complex
+++ b/include/complex
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- complex ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1450,10 +1449,10 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x)
return __os << __s.str();
}
-#if _LIBCPP_STD_VER > 11
+#if _LIBCPP_STD_VER > 11
// Literal suffix for complex number literals [complex.literals]
inline namespace literals
-{
+{
inline namespace complex_literals
{
constexpr complex<long double> operator""il(long double __im)
diff --git a/include/complex.h b/include/complex.h
index c2359665add5..b78733b8093a 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- complex.h --------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/condition_variable b/include/condition_variable
index c45a326d8985..8c733448e3c5 100644
--- a/include/condition_variable
+++ b/include/condition_variable
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------- condition_variable ----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/csetjmp b/include/csetjmp
index 58a9c73ab56f..ed94b50d1618 100644
--- a/include/csetjmp
+++ b/include/csetjmp
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- csetjmp ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/csignal b/include/csignal
index 97282661872a..99abd02de066 100644
--- a/include/csignal
+++ b/include/csignal
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- csignal ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstdarg b/include/cstdarg
index c8b6999242f7..e8147d496a77 100644
--- a/include/cstdarg
+++ b/include/cstdarg
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cstdarg ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstdbool b/include/cstdbool
index 2c764a61f211..fad47141476c 100644
--- a/include/cstdbool
+++ b/include/cstdbool
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cstdbool ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstddef b/include/cstddef
index b4c42b19ddb2..bd62d6db39e8 100644
--- a/include/cstddef
+++ b/include/cstddef
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cstddef ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstdint b/include/cstdint
index 7a187d3ebf28..f72fa067373e 100644
--- a/include/cstdint
+++ b/include/cstdint
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cstdint ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstdio b/include/cstdio
index 00b989fad7c8..675569382344 100644
--- a/include/cstdio
+++ b/include/cstdio
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- cstdio ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstdlib b/include/cstdlib
index 00c604e67623..68b3ded3fd51 100644
--- a/include/cstdlib
+++ b/include/cstdlib
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cstdlib ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cstring b/include/cstring
index d550695caa42..8bc96a023302 100644
--- a/include/cstring
+++ b/include/cstring
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cstring ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/ctgmath b/include/ctgmath
index 535eb7dccd15..ba1eeeac9f70 100644
--- a/include/ctgmath
+++ b/include/ctgmath
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- ctgmath -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/ctime b/include/ctime
index 8264fe33b964..cb8474f8f0b5 100644
--- a/include/ctime
+++ b/include/ctime
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- ctime -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/ctype.h b/include/ctype.h
index e97ff3c48876..dcc7935a29a0 100644
--- a/include/ctype.h
+++ b/include/ctype.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- ctype.h ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cwchar b/include/cwchar
index d268e8bbd393..451c621f9c06 100644
--- a/include/cwchar
+++ b/include/cwchar
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cwchar -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/cwctype b/include/cwctype
index 25b2489edf2c..575fd5661293 100644
--- a/include/cwctype
+++ b/include/cwctype
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- cwctype ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/deque b/include/deque
index 6f7d04be52be..d3ccf2ef6f71 100644
--- a/include/deque
+++ b/include/deque
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- deque -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -1331,21 +1330,21 @@ public:
// element access:
_LIBCPP_INLINE_VISIBILITY
- reference operator[](size_type __i);
+ reference operator[](size_type __i) _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- const_reference operator[](size_type __i) const;
+ const_reference operator[](size_type __i) const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
reference at(size_type __i);
_LIBCPP_INLINE_VISIBILITY
const_reference at(size_type __i) const;
_LIBCPP_INLINE_VISIBILITY
- reference front();
+ reference front() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- const_reference front() const;
+ const_reference front() const _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- reference back();
+ reference back() _NOEXCEPT;
_LIBCPP_INLINE_VISIBILITY
- const_reference back() const;
+ const_reference back() const _NOEXCEPT;
// 23.2.2.3 modifiers:
void push_front(const value_type& __v);
@@ -1746,7 +1745,7 @@ deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT
template <class _Tp, class _Allocator>
inline
typename deque<_Tp, _Allocator>::reference
-deque<_Tp, _Allocator>::operator[](size_type __i)
+deque<_Tp, _Allocator>::operator[](size_type __i) _NOEXCEPT
{
size_type __p = __base::__start_ + __i;
return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
@@ -1755,7 +1754,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i)
template <class _Tp, class _Allocator>
inline
typename deque<_Tp, _Allocator>::const_reference
-deque<_Tp, _Allocator>::operator[](size_type __i) const
+deque<_Tp, _Allocator>::operator[](size_type __i) const _NOEXCEPT
{
size_type __p = __base::__start_ + __i;
return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
@@ -1786,7 +1785,7 @@ deque<_Tp, _Allocator>::at(size_type __i) const
template <class _Tp, class _Allocator>
inline
typename deque<_Tp, _Allocator>::reference
-deque<_Tp, _Allocator>::front()
+deque<_Tp, _Allocator>::front() _NOEXCEPT
{
return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
+ __base::__start_ % __base::__block_size);
@@ -1795,7 +1794,7 @@ deque<_Tp, _Allocator>::front()
template <class _Tp, class _Allocator>
inline
typename deque<_Tp, _Allocator>::const_reference
-deque<_Tp, _Allocator>::front() const
+deque<_Tp, _Allocator>::front() const _NOEXCEPT
{
return *(*(__base::__map_.begin() + __base::__start_ / __base::__block_size)
+ __base::__start_ % __base::__block_size);
@@ -1804,7 +1803,7 @@ deque<_Tp, _Allocator>::front() const
template <class _Tp, class _Allocator>
inline
typename deque<_Tp, _Allocator>::reference
-deque<_Tp, _Allocator>::back()
+deque<_Tp, _Allocator>::back() _NOEXCEPT
{
size_type __p = __base::size() + __base::__start_ - 1;
return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
@@ -1813,7 +1812,7 @@ deque<_Tp, _Allocator>::back()
template <class _Tp, class _Allocator>
inline
typename deque<_Tp, _Allocator>::const_reference
-deque<_Tp, _Allocator>::back() const
+deque<_Tp, _Allocator>::back() const _NOEXCEPT
{
size_type __p = __base::size() + __base::__start_ - 1;
return *(*(__base::__map_.begin() + __p / __base::__block_size) + __p % __base::__block_size);
diff --git a/include/errno.h b/include/errno.h
index ee6429110cc1..447319effd35 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- errno.h -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/exception b/include/exception
index fdd83d10c3da..c7dcac2b2b33 100644
--- a/include/exception
+++ b/include/exception
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- exception ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -83,7 +82,7 @@ template <class E> void rethrow_if_nested(const E& e);
#include <type_traits>
#include <version>
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
+#if defined(_LIBCPP_ABI_VCRUNTIME)
#include <vcruntime_exception.h>
#endif
@@ -94,7 +93,7 @@ template <class E> void rethrow_if_nested(const E& e);
namespace std // purposefully not using versioning namespace
{
-#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
class _LIBCPP_EXCEPTION_ABI exception
{
public:
@@ -111,7 +110,7 @@ public:
virtual ~bad_exception() _NOEXCEPT;
virtual const char* what() const _NOEXCEPT;
};
-#endif // !_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME
+#endif // !_LIBCPP_ABI_VCRUNTIME
#if _LIBCPP_STD_VER <= 14 \
|| defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS) \
@@ -261,11 +260,7 @@ struct __throw_with_nested;
template <class _Tp, class _Up>
struct __throw_with_nested<_Tp, _Up, true> {
_LIBCPP_NORETURN static inline _LIBCPP_INLINE_VISIBILITY void
-#ifndef _LIBCPP_CXX03_LANG
__do_throw(_Tp&& __t)
-#else
- __do_throw (_Tp& __t)
-#endif // _LIBCPP_CXX03_LANG
{
throw __nested<_Up>(_VSTD::forward<_Tp>(__t));
}
@@ -288,11 +283,7 @@ struct __throw_with_nested<_Tp, _Up, false> {
template <class _Tp>
_LIBCPP_NORETURN
void
-#ifndef _LIBCPP_CXX03_LANG
throw_with_nested(_Tp&& __t)
-#else
-throw_with_nested (_Tp& __t)
-#endif // _LIBCPP_CXX03_LANG
{
#ifndef _LIBCPP_NO_EXCEPTIONS
typedef typename decay<_Tp>::type _Up;
diff --git a/include/experimental/__config b/include/experimental/__config
index c6f177620224..375dc3743fcf 100644
--- a/include/experimental/__config
+++ b/include/experimental/__config
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- __config ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -37,8 +36,14 @@
namespace chrono { namespace experimental { inline namespace fundamentals_v1 {
#define _LIBCPP_END_NAMESPACE_CHRONO_LFTS _LIBCPP_END_NAMESPACE_STD } } }
+#if defined(_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM)
+# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM /* nothing */
+#else
+# define _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM __attribute__((deprecated("std::experimental::filesystem has now been deprecated in favor of C++17's std::filesystem. Please stop using it and start using std::filesystem. This experimental version will be removed in LLVM 11. You can remove this warning by defining the _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM macro.")))
+#endif
+
#define _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
- _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem { \
+ _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL namespace filesystem _LIBCPP_DEPRECATED_EXPERIMENTAL_FILESYSTEM { \
inline namespace v1 {
#define _LIBCPP_END_NAMESPACE_EXPERIMENTAL_FILESYSTEM \
diff --git a/include/experimental/__memory b/include/experimental/__memory
index 229fea605bfd..4cf8978468ce 100644
--- a/include/experimental/__memory
+++ b/include/experimental/__memory
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/algorithm b/include/experimental/algorithm
index eb3bad6ef98c..79fd7b1b22de 100644
--- a/include/experimental/algorithm
+++ b/include/experimental/algorithm
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- algorithm ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/any b/include/experimental/any
deleted file mode 100644
index d9c95342589f..000000000000
--- a/include/experimental/any
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===------------------------------- any ----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_ANY
-#define _LIBCPP_EXPERIMENTAL_ANY
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/any> has been removed. Use <any> instead.")
-#else
-# warning "<experimental/any> has been removed. Use <any> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_ANY
diff --git a/include/experimental/chrono b/include/experimental/chrono
deleted file mode 100644
index 30c7e4a9d5ac..000000000000
--- a/include/experimental/chrono
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===---------------------------- chrono ----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_CHRONO
-#define _LIBCPP_EXPERIMENTAL_CHRONO
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/chrono> has been removed. Use <chrono> instead.")
-#else
-# warning "<experimental/chrono> has been removed. Use <chrono> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_CHRONO
diff --git a/include/experimental/coroutine b/include/experimental/coroutine
index 7cb39b81b48f..e2f0a25f77ed 100644
--- a/include/experimental/coroutine
+++ b/include/experimental/coroutine
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------- coroutine -----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -82,7 +81,7 @@ struct __coroutine_traits_sfinae<
};
template <typename _Ret, typename... _Args>
-struct _LIBCPP_TEMPLATE_VIS coroutine_traits
+struct coroutine_traits
: public __coroutine_traits_sfinae<_Ret>
{
};
@@ -299,7 +298,7 @@ noop_coroutine_handle noop_coroutine() _NOEXCEPT {
}
#endif // __has_builtin(__builtin_coro_noop)
-struct _LIBCPP_TYPE_VIS suspend_never {
+struct suspend_never {
_LIBCPP_INLINE_VISIBILITY
bool await_ready() const _NOEXCEPT { return true; }
_LIBCPP_INLINE_VISIBILITY
@@ -308,7 +307,7 @@ struct _LIBCPP_TYPE_VIS suspend_never {
void await_resume() const _NOEXCEPT {}
};
-struct _LIBCPP_TYPE_VIS suspend_always {
+struct suspend_always {
_LIBCPP_INLINE_VISIBILITY
bool await_ready() const _NOEXCEPT { return false; }
_LIBCPP_INLINE_VISIBILITY
diff --git a/include/experimental/deque b/include/experimental/deque
index f8495743c1f9..73c2787c7a04 100644
--- a/include/experimental/deque
+++ b/include/experimental/deque
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- deque ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/filesystem b/include/experimental/filesystem
index 28d8dcf4fc13..d2e6237df348 100644
--- a/include/experimental/filesystem
+++ b/include/experimental/filesystem
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- filesystem -------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_FILESYSTEM
diff --git a/include/experimental/forward_list b/include/experimental/forward_list
index 55e195f446f5..93f6debe9cb3 100644
--- a/include/experimental/forward_list
+++ b/include/experimental/forward_list
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- forward_list -----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/functional b/include/experimental/functional
index f63dfb07bb06..755eda641556 100644
--- a/include/experimental/functional
+++ b/include/experimental/functional
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- functional --------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -110,8 +109,7 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
#if _LIBCPP_STD_VER > 11
// default searcher
template<class _ForwardIterator, class _BinaryPredicate = equal_to<>>
-_LIBCPP_TYPE_VIS
-class default_searcher {
+class _LIBCPP_TYPE_VIS default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
@@ -209,8 +207,7 @@ public:
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
-_LIBCPP_TYPE_VIS
-class boyer_moore_searcher {
+class _LIBCPP_TYPE_VIS boyer_moore_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
@@ -361,8 +358,7 @@ make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l,
template <class _RandomAccessIterator1,
class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
class _BinaryPredicate = equal_to<>>
-_LIBCPP_TYPE_VIS
-class boyer_moore_horspool_searcher {
+class _LIBCPP_TYPE_VIS boyer_moore_horspool_searcher {
private:
typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type;
typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type;
diff --git a/include/experimental/iterator b/include/experimental/iterator
index ea672e966315..6a6e51d820d1 100644
--- a/include/experimental/iterator
+++ b/include/experimental/iterator
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------- iterator -------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/list b/include/experimental/list
index 1678ee3e93cb..adc64a8b537a 100644
--- a/include/experimental/list
+++ b/include/experimental/list
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- list ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/map b/include/experimental/map
index cff2c5e52c0d..965d7582c9dd 100644
--- a/include/experimental/map
+++ b/include/experimental/map
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------- map ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/memory_resource b/include/experimental/memory_resource
index 83781d462034..f999fb9befda 100644
--- a/include/experimental/memory_resource
+++ b/include/experimental/memory_resource
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------ memory_resource -----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/numeric b/include/experimental/numeric
deleted file mode 100644
index 19c65313f0f2..000000000000
--- a/include/experimental/numeric
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===--------------------------- numeric ----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_NUMERIC
-#define _LIBCPP_EXPERIMENTAL_NUMERIC
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/numeric> has been removed. Use <numeric> instead.")
-#else
-# warning "<experimental/numeric> has been removed. Use <numeric> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_NUMERIC
diff --git a/include/experimental/optional b/include/experimental/optional
deleted file mode 100644
index 6eb4a2618d2c..000000000000
--- a/include/experimental/optional
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===-------------------------- optional ----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_OPTIONAL
-#define _LIBCPP_EXPERIMENTAL_OPTIONAL
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/optional> has been removed. Use <optional> instead.")
-#else
-# warning "<experimental/optional> has been removed. Use <optional> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_OPTIONAL
diff --git a/include/experimental/propagate_const b/include/experimental/propagate_const
index 188548596b84..092b013bb904 100644
--- a/include/experimental/propagate_const
+++ b/include/experimental/propagate_const
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------ propagate_const -----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/ratio b/include/experimental/ratio
deleted file mode 100644
index 52c12004dba0..000000000000
--- a/include/experimental/ratio
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===----------------------------- ratio ----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_RATIO
-#define _LIBCPP_EXPERIMENTAL_RATIO
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/ratio> has been removed. Use <ratio> instead.")
-#else
-# warning "<experimental/ratio> has been removed. Use <ratio> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_RATIO
diff --git a/include/experimental/regex b/include/experimental/regex
index d38891c374bb..17193cf2f6f6 100644
--- a/include/experimental/regex
+++ b/include/experimental/regex
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------- regex ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/set b/include/experimental/set
index 20cf6d4a3890..52f4df384278 100644
--- a/include/experimental/set
+++ b/include/experimental/set
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- list ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/simd b/include/experimental/simd
index 6580443f7b03..39ac35e4eb0a 100644
--- a/include/experimental/simd
+++ b/include/experimental/simd
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------------- simd ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_EXPERIMENTAL_SIMD
diff --git a/include/experimental/string b/include/experimental/string
index 8b8545128f2a..264ff9236822 100644
--- a/include/experimental/string
+++ b/include/experimental/string
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- string ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/string_view b/include/experimental/string_view
deleted file mode 100644
index 100bdfe72735..000000000000
--- a/include/experimental/string_view
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===------------------------ string_view ---------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_STRING_VIEW
-#define _LIBCPP_EXPERIMENTAL_STRING_VIEW
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/string_view> has been removed. Use <string_view> instead.")
-#else
-# warning "<experimental/string_view> has been removed. Use <string_view> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_STRING_VIEW
diff --git a/include/experimental/system_error b/include/experimental/system_error
deleted file mode 100644
index 1cf84ee01251..000000000000
--- a/include/experimental/system_error
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===-------------------------- system_error ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
-#define _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/system_error> has been removed. Use <system_error> instead.")
-#else
-# warning "<experimental/system_error> has been removed. Use <system_error> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_SYSTEM_ERROR
diff --git a/include/experimental/tuple b/include/experimental/tuple
deleted file mode 100644
index 6d71bb559b02..000000000000
--- a/include/experimental/tuple
+++ /dev/null
@@ -1,21 +0,0 @@
-// -*- C++ -*-
-//===----------------------------- tuple ----------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#ifndef _LIBCPP_EXPERIMENTAL_TUPLE
-#define _LIBCPP_EXPERIMENTAL_TUPLE
-
-#include <__config>
-
-#ifdef _LIBCPP_WARNING
-_LIBCPP_WARNING("<experimental/tuple> has been removed. Use <tuple> instead.")
-#else
-# warning "<experimental/tuple> has been removed. Use <tuple> instead."
-#endif
-
-#endif // _LIBCPP_EXPERIMENTAL_TUPLE
diff --git a/include/experimental/type_traits b/include/experimental/type_traits
index afe491567cec..19466e9a5a5d 100644
--- a/include/experimental/type_traits
+++ b/include/experimental/type_traits
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- type_traits -------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -73,6 +72,7 @@ inline namespace fundamentals_v1 {
#if _LIBCPP_STD_VER > 11
+#include <initializer_list>
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -105,11 +105,10 @@ using raw_invocation_type_t = typename raw_invocation_type<_Tp>::type;
// 3.3.4, Detection idiom
template <class...> using void_t = void;
-struct nonesuch {
- nonesuch() = delete;
- ~nonesuch() = delete;
- nonesuch (nonesuch const&) = delete;
- void operator=(nonesuch const&) = delete;
+struct nonesuch : private _VSTD::__nat { // make nonesuch "not an aggregate"
+ ~nonesuch() = delete;
+ nonesuch (nonesuch const&) = delete;
+ void operator=(nonesuch const&) = delete;
};
template <class _Default, class _AlwaysVoid, template <class...> class _Op, class... _Args>
diff --git a/include/experimental/unordered_map b/include/experimental/unordered_map
index 1f998c2d4c7e..eca9cea793a4 100644
--- a/include/experimental/unordered_map
+++ b/include/experimental/unordered_map
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------- unordered_map ------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/unordered_set b/include/experimental/unordered_set
index d00a83753401..323868f785a5 100644
--- a/include/experimental/unordered_set
+++ b/include/experimental/unordered_set
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------- unordered_set ------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/utility b/include/experimental/utility
index 8effa71c1316..0bca0f7c9c46 100644
--- a/include/experimental/utility
+++ b/include/experimental/utility
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- utility ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/experimental/vector b/include/experimental/vector
index bd10492bfefc..9b810120695a 100644
--- a/include/experimental/vector
+++ b/include/experimental/vector
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- vector ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/ext/__hash b/include/ext/__hash
index 318cb1f97b02..d03f101e95a1 100644
--- a/include/ext/__hash
+++ b/include/ext/__hash
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------- hash_set ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -17,32 +16,31 @@
#include <cstring>
namespace __gnu_cxx {
-using namespace std;
template <typename _Tp> struct _LIBCPP_TEMPLATE_VIS hash { };
template <> struct _LIBCPP_TEMPLATE_VIS hash<const char*>
- : public unary_function<const char*, size_t>
+ : public std::unary_function<const char*, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(const char *__c) const _NOEXCEPT
{
- return __do_string_hash(__c, __c + strlen(__c));
+ return std::__do_string_hash(__c, __c + strlen(__c));
}
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<char *>
- : public unary_function<char*, size_t>
+ : public std::unary_function<char*, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char *__c) const _NOEXCEPT
{
- return __do_string_hash<const char *>(__c, __c + strlen(__c));
+ return std::__do_string_hash<const char *>(__c, __c + strlen(__c));
}
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
- : public unary_function<char, size_t>
+ : public std::unary_function<char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(char __c) const _NOEXCEPT
@@ -52,7 +50,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<char>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
- : public unary_function<signed char, size_t>
+ : public std::unary_function<signed char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(signed char __c) const _NOEXCEPT
@@ -62,7 +60,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<signed char>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
- : public unary_function<unsigned char, size_t>
+ : public std::unary_function<unsigned char, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned char __c) const _NOEXCEPT
@@ -72,7 +70,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
- : public unary_function<short, size_t>
+ : public std::unary_function<short, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(short __c) const _NOEXCEPT
@@ -82,7 +80,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<short>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
- : public unary_function<unsigned short, size_t>
+ : public std::unary_function<unsigned short, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned short __c) const _NOEXCEPT
@@ -92,7 +90,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
- : public unary_function<int, size_t>
+ : public std::unary_function<int, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(int __c) const _NOEXCEPT
@@ -102,7 +100,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<int>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
- : public unary_function<unsigned int, size_t>
+ : public std::unary_function<unsigned int, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned int __c) const _NOEXCEPT
@@ -112,7 +110,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
- : public unary_function<long, size_t>
+ : public std::unary_function<long, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(long __c) const _NOEXCEPT
@@ -122,7 +120,7 @@ template <> struct _LIBCPP_TEMPLATE_VIS hash<long>
};
template <> struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
- : public unary_function<unsigned long, size_t>
+ : public std::unary_function<unsigned long, size_t>
{
_LIBCPP_INLINE_VISIBILITY
size_t operator()(unsigned long __c) const _NOEXCEPT
diff --git a/include/ext/hash_map b/include/ext/hash_map
index 998e8f65994e..24823c6bf0cc 100644
--- a/include/ext/hash_map
+++ b/include/ext/hash_map
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- hash_map ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -220,10 +219,8 @@ template <class Key, class T, class Hash, class Pred, class Alloc>
namespace __gnu_cxx {
-using namespace std;
-
template <class _Tp, class _Hash,
- bool = is_empty<_Hash>::value && !__libcpp_is_final<_Hash>::value
+ bool = std::is_empty<_Hash>::value && !std::__libcpp_is_final<_Hash>::value
>
class __hash_map_hasher
: private _Hash
@@ -257,7 +254,7 @@ public:
};
template <class _Tp, class _Pred,
- bool = is_empty<_Pred>::value && !__libcpp_is_final<_Pred>::value
+ bool = std::is_empty<_Pred>::value && !std::__libcpp_is_final<_Pred>::value
>
class __hash_map_equal
: private _Pred
@@ -308,7 +305,7 @@ template <class _Alloc>
class __hash_map_node_destructor
{
typedef _Alloc allocator_type;
- typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef std::allocator_traits<allocator_type> __alloc_traits;
typedef typename __alloc_traits::value_type::__node_value_type value_type;
public:
typedef typename __alloc_traits::pointer pointer;
@@ -333,7 +330,7 @@ public:
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- __hash_map_node_destructor(__hash_node_destructor<allocator_type>&& __x)
+ __hash_map_node_destructor(std::__hash_node_destructor<allocator_type>&& __x)
: __na_(__x.__na_),
__first_constructed(__x.__value_constructed),
__second_constructed(__x.__value_constructed)
@@ -342,7 +339,7 @@ public:
}
#else // _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
- __hash_map_node_destructor(const __hash_node_destructor<allocator_type>& __x)
+ __hash_map_node_destructor(const std::__hash_node_destructor<allocator_type>& __x)
: __na_(__x.__na_),
__first_constructed(__x.__value_constructed),
__second_constructed(__x.__value_constructed)
@@ -371,11 +368,11 @@ class _LIBCPP_TEMPLATE_VIS __hash_map_iterator
typedef const typename _HashIterator::value_type::first_type key_type;
typedef typename _HashIterator::value_type::second_type mapped_type;
public:
- typedef forward_iterator_tag iterator_category;
- typedef pair<key_type, mapped_type> value_type;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef std::pair<key_type, mapped_type> value_type;
typedef typename _HashIterator::difference_type difference_type;
typedef value_type& reference;
- typedef typename __rebind_pointer<typename _HashIterator::pointer, value_type>::type
+ typedef typename std::__rebind_pointer<typename _HashIterator::pointer, value_type>::type
pointer;
_LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {}
@@ -416,11 +413,11 @@ class _LIBCPP_TEMPLATE_VIS __hash_map_const_iterator
typedef const typename _HashIterator::value_type::first_type key_type;
typedef typename _HashIterator::value_type::second_type mapped_type;
public:
- typedef forward_iterator_tag iterator_category;
- typedef pair<key_type, mapped_type> value_type;
+ typedef std::forward_iterator_tag iterator_category;
+ typedef std::pair<key_type, mapped_type> value_type;
typedef typename _HashIterator::difference_type difference_type;
typedef const value_type& reference;
- typedef typename __rebind_pointer<typename _HashIterator::pointer, const value_type>::type
+ typedef typename std::__rebind_pointer<typename _HashIterator::pointer, const value_type>::type
pointer;
_LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {}
@@ -460,8 +457,8 @@ public:
template <class> friend class _LIBCPP_TEMPLATE_VIS __hash_const_local_iterator;
};
-template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
- class _Alloc = allocator<pair<const _Key, _Tp> > >
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = std::equal_to<_Key>,
+ class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
class _LIBCPP_TEMPLATE_VIS hash_map
{
public:
@@ -472,17 +469,18 @@ public:
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
- typedef pair<const key_type, mapped_type> value_type;
+ typedef std::pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
- typedef pair<key_type, mapped_type> __value_type;
+ typedef std::pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
- typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
+ typedef typename std::__rebind_alloc_helper<
+ std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
- typedef __hash_table<__value_type, __hasher,
+ typedef std::__hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
__table __table_;
@@ -493,8 +491,8 @@ private:
typedef typename __table::__node_allocator __node_allocator;
typedef typename __table::__node __node;
typedef __hash_map_node_destructor<__node_allocator> _Dp;
- typedef unique_ptr<__node, _Dp> __node_holder;
- typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef std::unique_ptr<__node, _Dp> __node_holder;
+ typedef std::allocator_traits<allocator_type> __alloc_traits;
public:
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
@@ -544,7 +542,7 @@ public:
const_iterator end() const {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, bool> insert(const value_type& __x)
+ std::pair<iterator, bool> insert(const value_type& __x)
{return __table_.__insert_unique(__x);}
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
@@ -579,10 +577,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, iterator> equal_range(const key_type& __k)
+ std::pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
mapped_type& operator[](const key_type& __k);
@@ -692,7 +690,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type& __k)
if (__i != end())
return __i->second;
__node_holder __h = __construct_node(__k);
- pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
+ std::pair<iterator, bool> __r = __table_.__node_insert_unique(__h.get());
__h.release();
return __r.first->second;
}
@@ -734,8 +732,8 @@ operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
return !(__x == __y);
}
-template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>,
- class _Alloc = allocator<pair<const _Key, _Tp> > >
+template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = std::equal_to<_Key>,
+ class _Alloc = std::allocator<std::pair<const _Key, _Tp> > >
class _LIBCPP_TEMPLATE_VIS hash_multimap
{
public:
@@ -746,17 +744,17 @@ public:
typedef _Hash hasher;
typedef _Pred key_equal;
typedef _Alloc allocator_type;
- typedef pair<const key_type, mapped_type> value_type;
+ typedef std::pair<const key_type, mapped_type> value_type;
typedef value_type& reference;
typedef const value_type& const_reference;
private:
- typedef pair<key_type, mapped_type> __value_type;
+ typedef std::pair<key_type, mapped_type> __value_type;
typedef __hash_map_hasher<__value_type, hasher> __hasher;
typedef __hash_map_equal<__value_type, key_equal> __key_equal;
- typedef typename __rebind_alloc_helper<allocator_traits<allocator_type>, __value_type>::type __allocator_type;
+ typedef typename std::__rebind_alloc_helper<std::allocator_traits<allocator_type>, __value_type>::type __allocator_type;
- typedef __hash_table<__value_type, __hasher,
+ typedef std::__hash_table<__value_type, __hasher,
__key_equal, __allocator_type> __table;
__table __table_;
@@ -765,8 +763,8 @@ private:
typedef typename __table::__node_allocator __node_allocator;
typedef typename __table::__node __node;
typedef __hash_map_node_destructor<__node_allocator> _Dp;
- typedef unique_ptr<__node, _Dp> __node_holder;
- typedef allocator_traits<allocator_type> __alloc_traits;
+ typedef std::unique_ptr<__node, _Dp> __node_holder;
+ typedef std::allocator_traits<allocator_type> __alloc_traits;
public:
typedef typename __alloc_traits::pointer pointer;
typedef typename __alloc_traits::const_pointer const_pointer;
@@ -851,10 +849,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, iterator> equal_range(const key_type& __k)
+ std::pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
@@ -956,7 +954,7 @@ operator==(const hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
return false;
typedef typename hash_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
- typedef pair<const_iterator, const_iterator> _EqRng;
+ typedef std::pair<const_iterator, const_iterator> _EqRng;
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
{
_EqRng __xeq = __x.equal_range(__i->first);
diff --git a/include/ext/hash_set b/include/ext/hash_set
index 38f81ed3b5c8..e5141824b601 100644
--- a/include/ext/hash_set
+++ b/include/ext/hash_set
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------- hash_set ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -208,10 +207,9 @@ template <class Value, class Hash, class Pred, class Alloc>
namespace __gnu_cxx {
-using namespace std;
-template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
- class _Alloc = allocator<_Value> >
+template <class _Value, class _Hash = hash<_Value>, class _Pred = std::equal_to<_Value>,
+ class _Alloc = std::allocator<_Value> >
class _LIBCPP_TEMPLATE_VIS hash_set
{
public:
@@ -225,7 +223,7 @@ public:
typedef const value_type& const_reference;
private:
- typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+ typedef std::__hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
@@ -277,7 +275,7 @@ public:
const_iterator end() const {return __table_.end();}
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, bool> insert(const value_type& __x)
+ std::pair<iterator, bool> insert(const value_type& __x)
{return __table_.__insert_unique(__x);}
_LIBCPP_INLINE_VISIBILITY
iterator insert(const_iterator, const value_type& __x) {return insert(__x).first;}
@@ -310,10 +308,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, iterator> equal_range(const key_type& __k)
+ std::pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_unique(__k);}
_LIBCPP_INLINE_VISIBILITY
@@ -432,8 +430,8 @@ operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x,
return !(__x == __y);
}
-template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>,
- class _Alloc = allocator<_Value> >
+template <class _Value, class _Hash = hash<_Value>, class _Pred = std::equal_to<_Value>,
+ class _Alloc = std::allocator<_Value> >
class _LIBCPP_TEMPLATE_VIS hash_multiset
{
public:
@@ -447,7 +445,7 @@ public:
typedef const value_type& const_reference;
private:
- typedef __hash_table<value_type, hasher, key_equal, allocator_type> __table;
+ typedef std::__hash_table<value_type, hasher, key_equal, allocator_type> __table;
__table __table_;
@@ -531,10 +529,10 @@ public:
_LIBCPP_INLINE_VISIBILITY
size_type count(const key_type& __k) const {return __table_.__count_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<iterator, iterator> equal_range(const key_type& __k)
+ std::pair<iterator, iterator> equal_range(const key_type& __k)
{return __table_.__equal_range_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
- pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
+ std::pair<const_iterator, const_iterator> equal_range(const key_type& __k) const
{return __table_.__equal_range_multi(__k);}
_LIBCPP_INLINE_VISIBILITY
@@ -611,7 +609,7 @@ template <class _InputIterator>
inline
void
hash_multiset<_Value, _Hash, _Pred, _Alloc>::insert(_InputIterator __first,
- _InputIterator __last)
+ _InputIterator __last)
{
for (; __first != __last; ++__first)
__table_.__insert_multi(*__first);
@@ -635,7 +633,7 @@ operator==(const hash_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
return false;
typedef typename hash_multiset<_Value, _Hash, _Pred, _Alloc>::const_iterator
const_iterator;
- typedef pair<const_iterator, const_iterator> _EqRng;
+ typedef std::pair<const_iterator, const_iterator> _EqRng;
for (const_iterator __i = __x.begin(), __ex = __x.end(); __i != __ex;)
{
_EqRng __xeq = __x.equal_range(*__i);
diff --git a/include/fenv.h b/include/fenv.h
new file mode 100644
index 000000000000..988cd9b112fb
--- /dev/null
+++ b/include/fenv.h
@@ -0,0 +1,116 @@
+// -*- C++ -*-
+//===---------------------------- math.h ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _LIBCPP_FENV_H
+#define _LIBCPP_FENV_H
+
+
+/*
+ fenv.h synopsis
+
+This entire header is C99 / C++0X
+
+Macros:
+
+ FE_DIVBYZERO
+ FE_INEXACT
+ FE_INVALID
+ FE_OVERFLOW
+ FE_UNDERFLOW
+ FE_ALL_EXCEPT
+ FE_DOWNWARD
+ FE_TONEAREST
+ FE_TOWARDZERO
+ FE_UPWARD
+ FE_DFL_ENV
+
+Types:
+
+ fenv_t
+ fexcept_t
+
+int feclearexcept(int excepts);
+int fegetexceptflag(fexcept_t* flagp, int excepts);
+int feraiseexcept(int excepts);
+int fesetexceptflag(const fexcept_t* flagp, int excepts);
+int fetestexcept(int excepts);
+int fegetround();
+int fesetround(int round);
+int fegetenv(fenv_t* envp);
+int feholdexcept(fenv_t* envp);
+int fesetenv(const fenv_t* envp);
+int feupdateenv(const fenv_t* envp);
+
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
+#include_next <fenv.h>
+
+#ifdef __cplusplus
+
+extern "C++" {
+
+#ifdef feclearexcept
+#undef feclearexcept
+#endif
+
+#ifdef fegetexceptflag
+#undef fegetexceptflag
+#endif
+
+
+#ifdef feraiseexcept
+#undef feraiseexcept
+#endif
+
+#ifdef fesetexceptflag
+#undef fesetexceptflag
+#endif
+
+
+#ifdef fetestexcept
+#undef fetestexcept
+#endif
+
+#ifdef fegetround
+#undef fegetround
+#endif
+
+#ifdef fesetround
+#undef fesetround
+#endif
+
+#ifdef fegetenv
+#undef fegetenv
+#endif
+
+#ifdef feholdexcept
+#undef feholdexcept
+#endif
+
+
+#ifdef fesetenv
+#undef fesetenv
+#endif
+
+#ifdef feupdateenv
+#undef feupdateenv
+#endif
+
+} // extern "C++"
+
+#endif // defined(__cplusplus)
+
+#endif // _LIBCPP_FENV_H
diff --git a/include/filesystem b/include/filesystem
index af713a063587..3aaa7988a872 100644
--- a/include/filesystem
+++ b/include/filesystem
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- filesystem -------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_FILESYSTEM
@@ -259,6 +258,8 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
typedef chrono::time_point<_FilesystemClock> file_time_type;
struct _LIBCPP_TYPE_VIS space_info {
@@ -1311,7 +1312,11 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const path::iterator& __lhs,
return !(__lhs == __rhs);
}
-class _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error {
+// TODO(ldionne): We need to pop the pragma and push it again after
+// filesystem_error to work around PR41078.
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
+class _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_EXCEPTION_ABI filesystem_error : public system_error {
public:
_LIBCPP_INLINE_VISIBILITY
filesystem_error(const string& __what, error_code __ec)
@@ -1348,11 +1353,10 @@ public:
return __storage_->__what_.c_str();
}
- _LIBCPP_FUNC_VIS
void __create_what(int __num_paths);
private:
- struct _Storage {
+ struct _LIBCPP_HIDDEN _Storage {
_LIBCPP_INLINE_VISIBILITY
_Storage(const path& __p1, const path& __p2) : __p1_(__p1), __p2_(__p2) {}
@@ -1363,16 +1367,16 @@ private:
shared_ptr<_Storage> __storage_;
};
+_LIBCPP_AVAILABILITY_FILESYSTEM_PUSH
+
template <class... _Args>
_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
#ifndef _LIBCPP_NO_EXCEPTIONS
- void
- __throw_filesystem_error(_Args&&... __args) {
+void __throw_filesystem_error(_Args&&... __args) {
throw filesystem_error(std::forward<_Args>(__args)...);
}
#else
- void
- __throw_filesystem_error(_Args&&...) {
+void __throw_filesystem_error(_Args&&...) {
_VSTD::abort();
}
#endif
@@ -1938,7 +1942,7 @@ inline _LIBCPP_INLINE_VISIBILITY path weakly_canonical(path const& __p,
class directory_iterator;
class recursive_directory_iterator;
-class __dir_stream;
+class _LIBCPP_HIDDEN __dir_stream;
class directory_entry {
typedef _VSTD_FS::path _Path;
@@ -2601,7 +2605,7 @@ private:
operator==(const recursive_directory_iterator&,
const recursive_directory_iterator&) noexcept;
- struct __shared_imp;
+ struct _LIBCPP_HIDDEN __shared_imp;
shared_ptr<__shared_imp> __imp_;
bool __rec_;
}; // class recursive_directory_iterator
@@ -2628,6 +2632,8 @@ end(const recursive_directory_iterator&) noexcept {
return recursive_directory_iterator();
}
+_LIBCPP_AVAILABILITY_FILESYSTEM_POP
+
_LIBCPP_END_NAMESPACE_FILESYSTEM
#endif // !_LIBCPP_CXX03_LANG
diff --git a/include/float.h b/include/float.h
index 759ac8e79543..5c1e1db79766 100644
--- a/include/float.h
+++ b/include/float.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- float.h ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/forward_list b/include/forward_list
index b506acd1ff20..d59ddd4ef97a 100644
--- a/include/forward_list
+++ b/include/forward_list
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------- forward_list ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -121,10 +120,12 @@ public:
const_iterator first, const_iterator last);
void splice_after(const_iterator p, forward_list&& x,
const_iterator first, const_iterator last);
- void remove(const value_type& v);
- template <class Predicate> void remove_if(Predicate pred);
- void unique();
- template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
+ size_type remove(const value_type& v); // void before C++20
+ template <class Predicate>
+ size_type remove_if(Predicate pred); // void before C++20
+ size_type unique(); // void before C++20
+ template <class BinaryPredicate>
+ size_type unique(BinaryPredicate binary_pred); // void before C++20
void merge(forward_list& x);
void merge(forward_list&& x);
template <class Compare> void merge(forward_list& x, Compare comp);
@@ -531,7 +532,7 @@ public:
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT;
#else
- _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
+ _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
__is_nothrow_swappable<__node_allocator>::value);
#endif
protected:
@@ -596,11 +597,11 @@ __forward_list_base<_Tp, _Alloc>::swap(__forward_list_base& __x)
#if _LIBCPP_STD_VER >= 14
_NOEXCEPT
#else
- _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
+ _NOEXCEPT_(!__node_traits::propagate_on_container_move_assignment::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{
- __swap_allocator(__alloc(), __x.__alloc(),
+ __swap_allocator(__alloc(), __x.__alloc(),
integral_constant<bool, __node_traits::propagate_on_container_swap::value>());
using _VSTD::swap;
swap(__before_begin()->__next_, __x.__before_begin()->__next_);
@@ -648,6 +649,11 @@ public:
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator;
+#if _LIBCPP_STD_VER > 17
+ typedef size_type __remove_return_type;
+#else
+ typedef void __remove_return_type;
+#endif
_LIBCPP_INLINE_VISIBILITY
forward_list()
@@ -809,7 +815,6 @@ public:
_LIBCPP_INLINE_VISIBILITY
void clear() _NOEXCEPT {base::clear();}
-#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void splice_after(const_iterator __p, forward_list&& __x);
_LIBCPP_INLINE_VISIBILITY
@@ -817,16 +822,15 @@ public:
_LIBCPP_INLINE_VISIBILITY
void splice_after(const_iterator __p, forward_list&& __x,
const_iterator __f, const_iterator __l);
-#endif // _LIBCPP_CXX03_LANG
void splice_after(const_iterator __p, forward_list& __x);
void splice_after(const_iterator __p, forward_list& __x, const_iterator __i);
void splice_after(const_iterator __p, forward_list& __x,
const_iterator __f, const_iterator __l);
- void remove(const value_type& __v);
- template <class _Predicate> void remove_if(_Predicate __pred);
+ __remove_return_type remove(const value_type& __v);
+ template <class _Predicate> __remove_return_type remove_if(_Predicate __pred);
_LIBCPP_INLINE_VISIBILITY
- void unique() {unique(__equal_to<value_type>());}
- template <class _BinaryPredicate> void unique(_BinaryPredicate __binary_pred);
+ __remove_return_type unique() {return unique(__equal_to<value_type>());}
+ template <class _BinaryPredicate> __remove_return_type unique(_BinaryPredicate __binary_pred);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void merge(forward_list&& __x) {merge(__x, __less<value_type>());}
@@ -1469,8 +1473,6 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
}
}
-#ifndef _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Alloc>
inline _LIBCPP_INLINE_VISIBILITY
void
@@ -1500,21 +1502,21 @@ forward_list<_Tp, _Alloc>::splice_after(const_iterator __p,
splice_after(__p, __x, __f, __l);
}
-#endif // _LIBCPP_CXX03_LANG
-
template <class _Tp, class _Alloc>
-void
+typename forward_list<_Tp, _Alloc>::__remove_return_type
forward_list<_Tp, _Alloc>::remove(const value_type& __v)
{
- forward_list<_Tp, _Alloc> __deleted_nodes; // collect the nodes we're removing
- iterator __e = end();
+ forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
+ const iterator __e = end();
for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
{
if (__i.__get_begin()->__next_->__value_ == __v)
{
+ ++__count_removed;
iterator __j = _VSTD::next(__i, 2);
for (; __j != __e && *__j == __v; ++__j)
- ;
+ ++__count_removed;
__deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
if (__j == __e)
break;
@@ -1523,22 +1525,27 @@ forward_list<_Tp, _Alloc>::remove(const value_type& __v)
else
++__i;
}
+
+ return (__remove_return_type) __count_removed;
}
template <class _Tp, class _Alloc>
template <class _Predicate>
-void
+typename forward_list<_Tp, _Alloc>::__remove_return_type
forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
{
- iterator __e = end();
+ forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
+ const iterator __e = end();
for (iterator __i = before_begin(); __i.__get_begin()->__next_ != nullptr;)
{
if (__pred(__i.__get_begin()->__next_->__value_))
{
+ ++__count_removed;
iterator __j = _VSTD::next(__i, 2);
for (; __j != __e && __pred(*__j); ++__j)
- ;
- erase_after(__i, __j);
+ ++__count_removed;
+ __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
if (__j == __e)
break;
__i = __j;
@@ -1546,22 +1553,28 @@ forward_list<_Tp, _Alloc>::remove_if(_Predicate __pred)
else
++__i;
}
+
+ return (__remove_return_type) __count_removed;
}
template <class _Tp, class _Alloc>
template <class _BinaryPredicate>
-void
+typename forward_list<_Tp, _Alloc>::__remove_return_type
forward_list<_Tp, _Alloc>::unique(_BinaryPredicate __binary_pred)
{
+ forward_list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
+ typename forward_list<_Tp, _Alloc>::size_type __count_removed = 0;
for (iterator __i = begin(), __e = end(); __i != __e;)
{
iterator __j = _VSTD::next(__i);
for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
- ;
+ ++__count_removed;
if (__i.__get_begin()->__next_ != __j.__get_unsafe_node_pointer())
- erase_after(__i, __j);
+ __deleted_nodes.splice_after(__deleted_nodes.before_begin(), *this, __i, __j);
__i = __j;
}
+
+ return (__remove_return_type) __count_removed;
}
template <class _Tp, class _Alloc>
diff --git a/include/fstream b/include/fstream
index 711e484e2dcf..60a05b0d4b95 100644
--- a/include/fstream
+++ b/include/fstream
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------- fstream ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -236,7 +235,7 @@ public:
basic_filebuf* open(const string& __s, ios_base::openmode __mode);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
basic_filebuf* open(const _VSTD_FS::path& __p, ios_base::openmode __mode) {
return open(__p.c_str(), __mode);
}
@@ -758,7 +757,7 @@ basic_filebuf<_CharT, _Traits>::underflow()
this->eback() + __ibs_, __inext);
if (__r == codecvt_base::noconv)
{
- this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
+ this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
(char_type*)const_cast<char *>(__extbufend_));
__c = traits_type::to_int_type(*this->gptr());
}
@@ -1152,7 +1151,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const string& __s, ios_base::openmode __mode = ios_base::in);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
explicit basic_ifstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in)
: basic_ifstream(__p.c_str(), __mode) {}
#endif // _LIBCPP_STD_VER >= 17
@@ -1178,7 +1177,7 @@ public:
#endif
void open(const string& __s, ios_base::openmode __mode = ios_base::in);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
void open(const filesystem::path& __p,
ios_base::openmode __mode = ios_base::in) {
return open(__p.c_str(), __mode);
@@ -1366,7 +1365,7 @@ public:
explicit basic_ofstream(const string& __s, ios_base::openmode __mode = ios_base::out);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
explicit basic_ofstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
: basic_ofstream(__p.c_str(), __mode) {}
#endif // _LIBCPP_STD_VER >= 17
@@ -1393,7 +1392,7 @@ public:
void open(const string& __s, ios_base::openmode __mode = ios_base::out);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::out)
{ return open(__p.c_str(), __mode); }
#endif // _LIBCPP_STD_VER >= 17
@@ -1580,7 +1579,7 @@ public:
explicit basic_fstream(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
explicit basic_fstream(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in | ios_base::out)
: basic_fstream(__p.c_str(), __mode) {}
#endif // _LIBCPP_STD_VER >= 17
@@ -1608,7 +1607,7 @@ public:
void open(const string& __s, ios_base::openmode __mode = ios_base::in | ios_base::out);
#if _LIBCPP_STD_VER >= 17
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_AVAILABILITY_FILESYSTEM _LIBCPP_INLINE_VISIBILITY
void open(const filesystem::path& __p, ios_base::openmode __mode = ios_base::in|ios_base::out)
{ return open(__p.c_str(), __mode); }
#endif // _LIBCPP_STD_VER >= 17
diff --git a/include/functional b/include/functional
index 95491879b0c7..bcd74a9ee597 100644
--- a/include/functional
+++ b/include/functional
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===------------------------ functional ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -231,6 +230,10 @@ template<class Fn, class... BoundArgs>
template<class R, class Fn, class... BoundArgs>
unspecified bind(Fn&&, BoundArgs&&...);
+template<class F, class... Args>
+ invoke_result_t<F, Args...> invoke(F&& f, Args&&... args) // C++17
+ noexcept(is_nothrow_invocable_v<F, Args...>);
+
namespace placeholders {
// M is the implementation-defined number of placeholders
extern unspecified _1;
@@ -1476,6 +1479,8 @@ namespace __function {
// __alloc_func holds a functor and an allocator.
template <class _Fp, class _Ap, class _FB> class __alloc_func;
+template <class _Fp, class _FB>
+class __default_alloc_func;
template <class _Fp, class _Ap, class _Rp, class... _ArgTypes>
class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
@@ -1483,14 +1488,15 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
__compressed_pair<_Fp, _Ap> __f_;
public:
- typedef _Fp _Target;
- typedef _Ap _Alloc;
+ typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
+ typedef _LIBCPP_NODEBUG_TYPE _Ap _Alloc;
_LIBCPP_INLINE_VISIBILITY
const _Target& __target() const { return __f_.first(); }
+ // WIN32 APIs may define __allocator, so use __get_allocator instead.
_LIBCPP_INLINE_VISIBILITY
- const _Alloc& __allocator() const { return __f_.second(); }
+ const _Alloc& __get_allocator() const { return __f_.second(); }
_LIBCPP_INLINE_VISIBILITY
explicit __alloc_func(_Target&& __f)
@@ -1544,6 +1550,56 @@ class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)>
_LIBCPP_INLINE_VISIBILITY
void destroy() _NOEXCEPT { __f_.~__compressed_pair<_Target, _Alloc>(); }
+
+ static void __destroy_and_delete(__alloc_func* __f) {
+ typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type
+ _FunAlloc;
+ _FunAlloc __a(__f->__get_allocator());
+ __f->destroy();
+ __a.deallocate(__f, 1);
+ }
+};
+
+template <class _Fp, class _Rp, class... _ArgTypes>
+class __default_alloc_func<_Fp, _Rp(_ArgTypes...)> {
+ _Fp __f_;
+
+public:
+ typedef _LIBCPP_NODEBUG_TYPE _Fp _Target;
+
+ _LIBCPP_INLINE_VISIBILITY
+ const _Target& __target() const { return __f_; }
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __default_alloc_func(_Target&& __f) : __f_(std::move(__f)) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ explicit __default_alloc_func(const _Target& __f) : __f_(__f) {}
+
+ _LIBCPP_INLINE_VISIBILITY
+ _Rp operator()(_ArgTypes&&... __arg) {
+ typedef __invoke_void_return_wrapper<_Rp> _Invoker;
+ return _Invoker::__call(__f_, _VSTD::forward<_ArgTypes>(__arg)...);
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ __default_alloc_func* __clone() const {
+ __builtin_new_allocator::__holder_t __hold =
+ __builtin_new_allocator::__allocate_type<__default_alloc_func>(1);
+ __default_alloc_func* __res =
+ ::new (__hold.get()) __default_alloc_func(__f_);
+ (void)__hold.release();
+ return __res;
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
+ void destroy() _NOEXCEPT { __f_.~_Target(); }
+
+ static void __destroy_and_delete(__default_alloc_func* __f) {
+ __f->destroy();
+ __builtin_new_allocator::__deallocate_type<__default_alloc_func>(__f, 1);
+ }
};
// __base provides an abstract interface for copyable functors.
@@ -1612,7 +1668,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone() const
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
- _Ap __a(__f_.__allocator());
+ _Ap __a(__f_.__get_allocator());
typedef __allocator_destructor<_Ap> _Dp;
unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1));
::new ((void*)__hold.get()) __func(__f_.__target(), _Alloc(__a));
@@ -1623,7 +1679,7 @@ template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
void
__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const
{
- ::new (__p) __func(__f_.__target(), __f_.__allocator());
+ ::new (__p) __func(__f_.__target(), __f_.__get_allocator());
}
template<class _Fp, class _Alloc, class _Rp, class ..._ArgTypes>
@@ -1639,7 +1695,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy_deallocate() _NOEXCEPT
{
typedef allocator_traits<_Alloc> __alloc_traits;
typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap;
- _Ap __a(__f_.__allocator());
+ _Ap __a(__f_.__get_allocator());
__f_.destroy();
__a.deallocate(this, 1);
}
@@ -1692,7 +1748,7 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
__value_func() _NOEXCEPT : __f_(0) {}
template <class _Fp, class _Alloc>
- _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc __a)
+ _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a)
: __f_(0)
{
typedef allocator_traits<_Alloc> __alloc_traits;
@@ -1720,6 +1776,11 @@ template <class _Rp, class... _ArgTypes> class __value_func<_Rp(_ArgTypes...)>
}
}
+ template <class _Fp,
+ class = typename enable_if<!is_same<typename decay<_Fp>::type, __value_func>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f)
+ : __value_func(std::forward<_Fp>(__f), allocator<_Fp>()) {}
+
_LIBCPP_INLINE_VISIBILITY
__value_func(const __value_func& __f)
{
@@ -1919,29 +1980,22 @@ struct __policy
return __f->__clone();
}
- template <typename _Fun> static void __large_destroy(void* __s)
- {
- typedef allocator_traits<typename _Fun::_Alloc> __alloc_traits;
- typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type
- _FunAlloc;
- _Fun* __f = static_cast<_Fun*>(__s);
- _FunAlloc __a(__f->__allocator());
- __f->destroy();
- __a.deallocate(__f, 1);
+ template <typename _Fun>
+ static void __large_destroy(void* __s) {
+ _Fun::__destroy_and_delete(static_cast<_Fun*>(__s));
}
template <typename _Fun>
_LIBCPP_INLINE_VISIBILITY static const __policy*
- __choose_policy(/* is_small = */ false_type)
- {
- static const _LIBCPP_CONSTEXPR __policy __policy_ = {
- &__large_clone<_Fun>, &__large_destroy<_Fun>, false,
+ __choose_policy(/* is_small = */ false_type) {
+ static const _LIBCPP_CONSTEXPR __policy __policy_ = {
+ &__large_clone<_Fun>, &__large_destroy<_Fun>, false,
#ifndef _LIBCPP_NO_RTTI
- &typeid(typename _Fun::_Target)
+ &typeid(typename _Fun::_Target)
#else
- nullptr
+ nullptr
#endif
- };
+ };
return &__policy_;
}
@@ -2066,6 +2120,25 @@ template <class _Rp, class... _ArgTypes> class __policy_func<_Rp(_ArgTypes...)>
}
}
+ template <class _Fp, class = typename enable_if<!is_same<typename decay<_Fp>::type, __policy_func>::value>::type>
+ _LIBCPP_INLINE_VISIBILITY explicit __policy_func(_Fp&& __f)
+ : __policy_(__policy::__create_empty()) {
+ typedef __default_alloc_func<_Fp, _Rp(_ArgTypes...)> _Fun;
+
+ if (__function::__not_null(__f)) {
+ __invoker_ = __invoker::template __create<_Fun>();
+ __policy_ = __policy::__create<_Fun>();
+ if (__use_small_storage<_Fun>()) {
+ ::new ((void*)&__buf_.__small) _Fun(_VSTD::move(__f));
+ } else {
+ __builtin_new_allocator::__holder_t __hold =
+ __builtin_new_allocator::__allocate_type<_Fun>(1);
+ __buf_.__large = ::new (__hold.get()) _Fun(_VSTD::move(__f));
+ (void)__hold.release();
+ }
+ }
+ }
+
_LIBCPP_INLINE_VISIBILITY
__policy_func(const __policy_func& __f)
: __buf_(__f.__buf_), __invoker_(__f.__invoker_),
@@ -2173,8 +2246,8 @@ class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
__func __f_;
- template <class _Fp, bool = __lazy_and<
- integral_constant<bool, !is_same<__uncvref_t<_Fp>, function>::value>,
+ template <class _Fp, bool = _And<
+ _IsNotSame<__uncvref_t<_Fp>, function>,
__invokable<_Fp&, _ArgTypes...>
>::value>
struct __callable;
@@ -2286,8 +2359,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&,
template <class _Rp, class... _ArgTypes>
template <class _Fp, class>
-function<_Rp(_ArgTypes...)>::function(_Fp __f)
- : __f_(_VSTD::move(__f), allocator<_Fp>()) {}
+function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(_VSTD::move(__f)) {}
#if _LIBCPP_STD_VER <= 14
template <class _Rp, class... _ArgTypes>
@@ -2484,7 +2556,7 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
template <class _Ti, class ..._Uj>
inline _LIBCPP_INLINE_VISIBILITY
-typename __lazy_enable_if
+typename _EnableIf
<
is_bind_expression<_Ti>::value,
__invoke_of<_Ti&, _Uj...>
@@ -2769,9 +2841,9 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args)
#if _LIBCPP_STD_VER > 14
template <class _Fn, class ..._Args>
-result_of_t<_Fn&&(_Args&&...)>
+invoke_result_t<_Fn, _Args...>
invoke(_Fn&& __f, _Args&&... __args)
- noexcept(noexcept(_VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...)))
+ noexcept(is_nothrow_invocable_v<_Fn, _Args...>)
{
return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
}
diff --git a/include/future b/include/future
index b3ffc7e35177..6da88c6e62b2 100644
--- a/include/future
+++ b/include/future
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- future -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -409,11 +408,7 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(launch)
#ifndef _LIBCPP_HAS_NO_STRONG_ENUMS
-#ifdef _LIBCPP_UNDERLYING_TYPE
typedef underlying_type<launch>::type __launch_underlying_type;
-#else
-typedef int __launch_underlying_type;
-#endif
inline _LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR
@@ -2016,7 +2011,7 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
@@ -2027,7 +2022,7 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
@@ -2145,7 +2140,7 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
@@ -2156,11 +2151,11 @@ public:
class = typename enable_if
<
!is_same<
- typename __uncvref<_Fp>::type,
+ typename __uncvref<_Fp>::type,
packaged_task
>::value
>::type
- >
+ >
_LIBCPP_INLINE_VISIBILITY
packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
diff --git a/include/initializer_list b/include/initializer_list
index b934637b83d3..893736f57ead 100644
--- a/include/initializer_list
+++ b/include/initializer_list
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------- initializer_list -----------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -83,7 +82,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11
size_t size() const _NOEXCEPT {return __size_;}
-
+
_LIBCPP_INLINE_VISIBILITY
_LIBCPP_CONSTEXPR_AFTER_CXX11
const _Ep* begin() const _NOEXCEPT {return __begin_;}
diff --git a/include/inttypes.h b/include/inttypes.h
index 058f54b5161f..e136b234a4ae 100644
--- a/include/inttypes.h
+++ b/include/inttypes.h
@@ -1,15 +1,19 @@
// -*- C++ -*-
//===--------------------------- inttypes.h -------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_INTTYPES_H
+// AIX system headers need inttypes.h to be re-enterable while _STD_TYPES_T
+// is defined until an inclusion of it without _STD_TYPES_T occurs, in which
+// case the header guard macro is defined.
+#if !defined(_AIX) || !defined(_STD_TYPES_T)
#define _LIBCPP_INTTYPES_H
+#endif // _STD_TYPES_T
/*
inttypes.h synopsis
diff --git a/include/iomanip b/include/iomanip
index 36c11167a44e..3f78f4d02b3c 100644
--- a/include/iomanip
+++ b/include/iomanip
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- iomanip ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -516,7 +515,7 @@ put_time(const tm* __tm, const _CharT* __fmt)
template <class _CharT, class _Traits, class _ForwardIterator>
std::basic_ostream<_CharT, _Traits> &
-__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
+__quoted_output ( basic_ostream<_CharT, _Traits> &__os,
_ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape )
{
_VSTD::basic_string<_CharT, _Traits> __str;
@@ -571,7 +570,7 @@ __quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _Char
template <class _CharT, class _Traits, class _Iter>
basic_ostream<_CharT, _Traits>& operator<<(
- basic_ostream<_CharT, _Traits>& __os,
+ basic_ostream<_CharT, _Traits>& __os,
const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy)
{
return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape);
@@ -591,7 +590,7 @@ struct __quoted_proxy
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY
basic_ostream<_CharT, _Traits>& operator<<(
- basic_ostream<_CharT, _Traits>& __os,
+ basic_ostream<_CharT, _Traits>& __os,
const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
{
return __quoted_output (__os, __proxy.__string.cbegin (), __proxy.__string.cend (), __proxy.__delim, __proxy.__escape);
@@ -601,7 +600,7 @@ basic_ostream<_CharT, _Traits>& operator<<(
template <class _CharT, class _Traits, class _Allocator>
_LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>& operator>>(
- basic_istream<_CharT, _Traits>& __is,
+ basic_istream<_CharT, _Traits>& __is,
const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy)
{
return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape );
@@ -661,7 +660,7 @@ __quoted_output_proxy<_CharT, const _CharT *, _Traits>
quoted (basic_string_view <_CharT, _Traits> __sv,
_CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\'))
{
- return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
+ return __quoted_output_proxy<_CharT, const _CharT *, _Traits>
( __sv.data(), __sv.data() + __sv.size(), __delim, __escape );
}
#endif
diff --git a/include/ios b/include/ios
index 040b2d4e04f1..88efefb46ff2 100644
--- a/include/ios
+++ b/include/ios
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- ios -------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -203,8 +202,8 @@ enum class io_errc
};
concept_map ErrorCodeEnum<io_errc> { };
-error_code make_error_code(io_errc e) noexcept;
-error_condition make_error_condition(io_errc e) noexcept;
+error_code make_error_code(io_errc e) noexcept;
+error_condition make_error_condition(io_errc e) noexcept;
storage-class-specifier const error_category& iostream_category() noexcept;
} // std
@@ -331,6 +330,15 @@ public:
void __set_badbit_and_consider_rethrow();
void __set_failbit_and_consider_rethrow();
+ _LIBCPP_INLINE_VISIBILITY
+ void __setstate_nothrow(iostate __state)
+ {
+ if (__rdbuf_)
+ __rdstate_ |= __state;
+ else
+ __rdstate_ |= __state | ios_base::badbit;
+ }
+
protected:
_LIBCPP_INLINE_VISIBILITY
ios_base() {// purposefully does no initialization
@@ -426,6 +434,16 @@ public:
virtual ~failure() throw();
};
+_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY
+void __throw_failure(char const* __msg) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw ios_base::failure(__msg);
+#else
+ ((void)__msg);
+ _VSTD::abort();
+#endif
+}
+
class _LIBCPP_TYPE_VIS ios_base::Init
{
public:
@@ -626,47 +644,47 @@ public:
virtual ~basic_ios();
// 27.5.4.2 Members:
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_ostream<char_type, traits_type>* tie() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_ostream<char_type, traits_type>* tie(basic_ostream<char_type, traits_type>* __tiestr);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_streambuf<char_type, traits_type>* rdbuf() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
basic_streambuf<char_type, traits_type>* rdbuf(basic_streambuf<char_type, traits_type>* __sb);
basic_ios& copyfmt(const basic_ios& __rhs);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char_type fill() const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char_type fill(char_type __ch);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
locale imbue(const locale& __loc);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char narrow(char_type __c, char __dfault) const;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
char_type widen(char __c) const;
protected:
_LIBCPP_INLINE_VISIBILITY
basic_ios() {// purposefully does no initialization
}
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void init(basic_streambuf<char_type, traits_type>* __sb);
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void move(basic_ios& __rhs);
#ifndef _LIBCPP_CXX03_LANG
_LIBCPP_INLINE_VISIBILITY
void move(basic_ios&& __rhs) {move(__rhs);}
#endif
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void swap(basic_ios& __rhs) _NOEXCEPT;
- _LIBCPP_INLINE_VISIBILITY
+ _LIBCPP_INLINE_VISIBILITY
void set_rdbuf(basic_streambuf<char_type, traits_type>* __sb);
private:
basic_ostream<char_type, traits_type>* __tie_;
diff --git a/include/iosfwd b/include/iosfwd
index 31f1902e5f59..0ffe75f197c3 100644
--- a/include/iosfwd
+++ b/include/iosfwd
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- iosfwd -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/iostream b/include/iostream
index 136a849777fe..595620b8aa62 100644
--- a/include/iostream
+++ b/include/iostream
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- iostream ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/istream b/include/istream
index 30ee4f4b8710..d6217bbb8009 100644
--- a/include/istream
+++ b/include/istream
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- istream ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -363,26 +362,31 @@ template <class _Tp, class _CharT, class _Traits>
_LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
__input_arithmetic(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+ if (__s)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __s(__is);
- if (__s)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
- ios_base::iostate __err = ios_base::goodbit;
- use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __err, __n);
- __is.setstate(__err);
- }
+ use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __n);
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
}
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -467,39 +471,46 @@ template <class _Tp, class _CharT, class _Traits>
_LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
__input_arithmetic_with_numeric_limits(basic_istream<_CharT, _Traits>& __is, _Tp& __n) {
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __s(__is);
+ if (__s)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __s(__is);
- if (__s)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
typedef istreambuf_iterator<_CharT, _Traits> _Ip;
typedef num_get<_CharT, _Ip> _Fp;
- ios_base::iostate __err = ios_base::goodbit;
long __temp;
- use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __err, __temp);
+ use_facet<_Fp>(__is.getloc()).get(_Ip(__is), _Ip(), __is, __state, __temp);
if (__temp < numeric_limits<_Tp>::min())
{
- __err |= ios_base::failbit;
+ __state |= ios_base::failbit;
__n = numeric_limits<_Tp>::min();
}
else if (__temp > numeric_limits<_Tp>::max())
{
- __err |= ios_base::failbit;
+ __state |= ios_base::failbit;
__n = numeric_limits<_Tp>::max();
}
else
+ {
__n = static_cast<_Tp>(__temp);
- __is.setstate(__err);
- }
+ }
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ __is.setstate(__state);
+ }
return __is;
}
@@ -522,22 +533,22 @@ _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
__input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
- auto __s = __p;
+#endif
+ _CharT* __s = __p;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
- ios_base::iostate __err = ios_base::goodbit;
while (__s != __p + (__n-1))
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
_CharT __ch = _Traits::to_char_type(__i);
@@ -549,16 +560,21 @@ __input_c_string(basic_istream<_CharT, _Traits>& __is, _CharT* __p, size_t __n)
*__s = _CharT();
__is.width(0);
if (__s == __p)
- __err |= ios_base::failbit;
- __is.setstate(__err);
- }
+ __state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
}
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -569,7 +585,7 @@ inline _LIBCPP_INLINE_VISIBILITY
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT (&__buf)[_Np])
{
- auto __n = _Np;
+ size_t __n = _Np;
if (__is.width() > 0)
__n = _VSTD::min(size_t(__is.width()), _Np);
return _VSTD::__input_c_string(__is, __buf, __n);
@@ -626,26 +642,33 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif
typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
- __is.setstate(ios_base::eofbit | ios_base::failbit);
+ __state |= ios_base::eofbit | ios_base::failbit;
else
__c = _Traits::to_char_type(__i);
- }
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
}
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -669,58 +692,56 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::operator>>(basic_streambuf<char_type, traits_type>* __sb)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __s(*this, true);
+ if (__s)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __s(*this, true);
- if (__s)
+ if (__sb)
{
- if (__sb)
- {
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ try
+ {
+#endif // _LIBCPP_NO_EXCEPTIONS
+ while (true)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- ios_base::iostate __err = ios_base::goodbit;
- while (true)
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, _Traits::eof()))
{
- typename traits_type::int_type __i = this->rdbuf()->sgetc();
- if (traits_type::eq_int_type(__i, _Traits::eof()))
- {
- __err |= ios_base::eofbit;
- break;
- }
- if (traits_type::eq_int_type(
- __sb->sputc(traits_type::to_char_type(__i)),
- traits_type::eof()))
- break;
- ++__gc_;
- this->rdbuf()->sbumpc();
+ __state |= ios_base::eofbit;
+ break;
}
- if (__gc_ == 0)
- __err |= ios_base::failbit;
- this->setstate(__err);
-#ifndef _LIBCPP_NO_EXCEPTIONS
+ if (traits_type::eq_int_type(
+ __sb->sputc(traits_type::to_char_type(__i)),
+ traits_type::eof()))
+ break;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
}
- catch (...)
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::failbit || this->exceptions() & ios_base::badbit)
{
- if (__gc_ == 0)
- this->__set_failbit_and_consider_rethrow();
+ throw;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
}
- else
- this->setstate(ios_base::failbit);
+#endif // _LIBCPP_NO_EXCEPTIONS
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+ this->setstate(__state);
}
-#endif // _LIBCPP_NO_EXCEPTIONS
return *this;
}
@@ -728,28 +749,34 @@ template<class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::get()
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
int_type __r = traits_type::eof();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __s(*this, true);
+ if (__s)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __s(*this, true);
- if (__s)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif
__r = this->rdbuf()->sbumpc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
- this->setstate(ios_base::failbit | ios_base::eofbit);
+ __state |= ios_base::failbit | ios_base::eofbit;
else
__gc_ = 1;
- }
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ this->__setstate_nothrow(this->rdstate() | ios_base::badbit);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ this->setstate(__state);
}
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __r;
}
@@ -757,23 +784,23 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __dlm)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+ if (__n > 0)
{
- if (__n > 0)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
- ios_base::iostate __err = ios_base::goodbit;
+#endif
while (__gc_ < __n-1)
{
int_type __i = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__i, traits_type::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
char_type __ch = traits_type::to_char_type(__i);
@@ -784,23 +811,33 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __
this->rdbuf()->sbumpc();
}
if (__gc_ == 0)
- __err |= ios_base::failbit;
- this->setstate(__err);
+ __state |= ios_base::failbit;
+#ifndef _LIBCPP_NO_EXCEPTIONS
}
- else
- this->setstate(ios_base::failbit);
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ if (__n > 0)
+ *__s = char_type();
+ throw;
+ }
+ }
+#endif
}
+ else
+ {
+ __state |= ios_base::failbit;
+ }
+
if (__n > 0)
*__s = char_type();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- if (__n > 0)
- *__s = char_type();
- this->__set_badbit_and_consider_rethrow();
+ this->setstate(__state);
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+ if (__n > 0)
+ *__s = char_type();
return *this;
}
@@ -809,52 +846,43 @@ basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::get(basic_streambuf<char_type, traits_type>& __sb,
char_type __dlm)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
- {
- ios_base::iostate __err = ios_base::goodbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- try
- {
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
- while (true)
+ while (true)
+ {
+ typename traits_type::int_type __i = this->rdbuf()->sgetc();
+ if (traits_type::eq_int_type(__i, traits_type::eof()))
{
- typename traits_type::int_type __i = this->rdbuf()->sgetc();
- if (traits_type::eq_int_type(__i, traits_type::eof()))
- {
- __err |= ios_base::eofbit;
- break;
- }
- char_type __ch = traits_type::to_char_type(__i);
- if (traits_type::eq(__ch, __dlm))
- break;
- if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
- break;
- ++__gc_;
- this->rdbuf()->sbumpc();
+ __state |= ios_base::eofbit;
+ break;
}
-#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
+ char_type __ch = traits_type::to_char_type(__i);
+ if (traits_type::eq(__ch, __dlm))
+ break;
+ if (traits_type::eq_int_type(__sb.sputc(__ch), traits_type::eof()))
+ break;
+ ++__gc_;
+ this->rdbuf()->sbumpc();
}
-#endif // _LIBCPP_NO_EXCEPTIONS
- if (__gc_ == 0)
- __err |= ios_base::failbit;
- this->setstate(__err);
- }
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ // according to the spec, exceptions here are caught but not rethrown
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+ this->setstate(__state);
+ }
return *this;
}
@@ -862,21 +890,21 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_type __dlm)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
- ios_base::iostate __err = ios_base::goodbit;
+#endif // _LIBCPP_NO_EXCEPTIONS
while (true)
{
typename traits_type::int_type __i = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__i, traits_type::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
char_type __ch = traits_type::to_char_type(__i);
@@ -888,28 +916,35 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ
}
if (__gc_ >= __n-1)
{
- __err |= ios_base::failbit;
+ __state |= ios_base::failbit;
break;
}
*__s++ = __ch;
this->rdbuf()->sbumpc();
++__gc_;
}
- if (__gc_ == 0)
- __err |= ios_base::failbit;
- this->setstate(__err);
- }
- if (__n > 0)
- *__s = char_type();
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- if (__n > 0)
- *__s = char_type();
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ if (__n > 0)
+ *__s = char_type();
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ }
+ if (__n > 0)
+ *__s = char_type();
+ if (__gc_ == 0)
+ __state |= ios_base::failbit;
+ this->setstate(__state);
return *this;
}
@@ -917,15 +952,15 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
- ios_base::iostate __err = ios_base::goodbit;
+#endif // _LIBCPP_NO_EXCEPTIONS
if (__n == numeric_limits<streamsize>::max())
{
while (true)
@@ -933,7 +968,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
typename traits_type::int_type __i = this->rdbuf()->sbumpc();
if (traits_type::eq_int_type(__i, traits_type::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
++__gc_;
@@ -948,7 +983,7 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
typename traits_type::int_type __i = this->rdbuf()->sbumpc();
if (traits_type::eq_int_type(__i, traits_type::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
++__gc_;
@@ -956,15 +991,20 @@ basic_istream<_CharT, _Traits>::ignore(streamsize __n, int_type __dlm)
break;
}
}
- this->setstate(__err);
- }
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
return *this;
}
@@ -972,26 +1012,33 @@ template<class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::int_type
basic_istream<_CharT, _Traits>::peek()
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
int_type __r = traits_type::eof();
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
__r = this->rdbuf()->sgetc();
if (traits_type::eq_int_type(__r, traits_type::eof()))
- this->setstate(ios_base::eofbit);
- }
+ __state |= ios_base::eofbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
return __r;
}
@@ -999,27 +1046,36 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::read(char_type* __s, streamsize __n)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
__gc_ = this->rdbuf()->sgetn(__s, __n);
if (__gc_ != __n)
- this->setstate(ios_base::failbit | ios_base::eofbit);
- }
- else
- this->setstate(ios_base::failbit);
+ __state |= ios_base::failbit | ios_base::eofbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
}
- catch (...)
+ else
{
- this->__set_badbit_and_consider_rethrow();
+ __state |= ios_base::failbit;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
return *this;
}
@@ -1027,36 +1083,48 @@ template<class _CharT, class _Traits>
streamsize
basic_istream<_CharT, _Traits>::readsome(char_type* __s, streamsize __n)
{
+ ios_base::iostate __state = ios_base::goodbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
streamsize __c = this->rdbuf()->in_avail();
switch (__c)
{
case -1:
- this->setstate(ios_base::eofbit);
+ __state |= ios_base::eofbit;
break;
case 0:
break;
default:
- read(__s, _VSTD::min(__c, __n));
+ __n = _VSTD::min(__c, __n);
+ __gc_ = this->rdbuf()->sgetn(__s, __n);
+ if (__gc_ != __n)
+ __state |= ios_base::failbit | ios_base::eofbit;
break;
}
- }
- else
- this->setstate(ios_base::failbit);
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
}
- catch (...)
+ else
{
- this->__set_badbit_and_consider_rethrow();
+ __state |= ios_base::failbit;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
return __gc_;
}
@@ -1064,27 +1132,36 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::putback(char_type __c)
{
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == 0 || this->rdbuf()->sputbackc(__c) == traits_type::eof())
- this->setstate(ios_base::badbit);
- }
- else
- this->setstate(ios_base::failbit);
+ __state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
}
- catch (...)
+ else
{
- this->__set_badbit_and_consider_rethrow();
+ __state |= ios_base::failbit;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
return *this;
}
@@ -1092,27 +1169,36 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::unget()
{
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
__gc_ = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == 0 || this->rdbuf()->sungetc() == traits_type::eof())
- this->setstate(ios_base::badbit);
- }
- else
- this->setstate(ios_base::failbit);
+ __state |= ios_base::badbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif // _LIBCPP_NO_EXCEPTIONS
}
- catch (...)
+ else
{
- this->__set_badbit_and_consider_rethrow();
+ __state |= ios_base::failbit;
}
-#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
return *this;
}
@@ -1120,29 +1206,36 @@ template<class _CharT, class _Traits>
int
basic_istream<_CharT, _Traits>::sync()
{
+ ios_base::iostate __state = ios_base::goodbit;
int __r = 0;
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf() == 0)
return -1;
if (this->rdbuf()->pubsync() == -1)
{
- this->setstate(ios_base::badbit);
+ __state |= ios_base::badbit;
return -1;
}
- }
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
return __r;
}
@@ -1150,21 +1243,30 @@ template<class _CharT, class _Traits>
typename basic_istream<_CharT, _Traits>::pos_type
basic_istream<_CharT, _Traits>::tellg()
{
+ ios_base::iostate __state = ios_base::goodbit;
pos_type __r(-1);
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ sentry __sen(*this, true);
+ if (__sen)
{
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
+ {
#endif // _LIBCPP_NO_EXCEPTIONS
- sentry __sen(*this, true);
- if (__sen)
- __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
+ __r = this->rdbuf()->pubseekoff(0, ios_base::cur, ios_base::in);
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
return __r;
}
@@ -1172,24 +1274,31 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1))
- this->setstate(ios_base::failbit);
- }
+ __state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
return *this;
}
@@ -1197,24 +1306,31 @@ template<class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = this->rdstate() & ~ios_base::eofbit;
+ this->clear(__state);
+ sentry __sen(*this, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- this->clear(this->rdstate() & ~ios_base::eofbit);
- sentry __sen(*this, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1))
- this->setstate(ios_base::failbit);
- }
+ __state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- this->__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ this->__setstate_nothrow(__state);
+ if (this->exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ this->setstate(__state);
+ }
return *this;
}
@@ -1222,34 +1338,41 @@ template <class _CharT, class _Traits>
basic_istream<_CharT, _Traits>&
ws(basic_istream<_CharT, _Traits>& __is)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif // _LIBCPP_NO_EXCEPTIONS
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
while (true)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
{
- __is.setstate(ios_base::eofbit);
+ __state |= ios_base::eofbit;
break;
}
if (!__ct.is(__ct.space, _Traits::to_char_type(__i)))
break;
__is.rdbuf()->sbumpc();
}
- }
#ifndef _LIBCPP_NO_EXCEPTIONS
- }
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
#endif // _LIBCPP_NO_EXCEPTIONS
+ __is.setstate(__state);
+ }
return __is;
}
@@ -1298,7 +1421,6 @@ protected:
inline _LIBCPP_HIDE_FROM_ABI_AFTER_V1
void swap(basic_iostream& __rhs)
{ basic_istream<char_type, traits_type>::swap(__rhs); }
-public:
};
#ifndef _LIBCPP_CXX03_LANG
@@ -1329,13 +1451,14 @@ basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif
__str.clear();
streamsize __n = __is.width();
if (__n <= 0)
@@ -1344,13 +1467,12 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
__n = numeric_limits<streamsize>::max();
streamsize __c = 0;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
- ios_base::iostate __err = ios_base::goodbit;
while (__c < __n)
{
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
_CharT __ch = _Traits::to_char_type(__i);
@@ -1362,18 +1484,21 @@ operator>>(basic_istream<_CharT, _Traits>& __is,
}
__is.width(0);
if (__c == 0)
- __err |= ios_base::failbit;
- __is.setstate(__err);
- }
- else
- __is.setstate(ios_base::failbit);
+ __state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
}
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -1382,22 +1507,22 @@ basic_istream<_CharT, _Traits>&
getline(basic_istream<_CharT, _Traits>& __is,
basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is, true);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif
__str.clear();
- ios_base::iostate __err = ios_base::goodbit;
streamsize __extr = 0;
while (true)
{
typename _Traits::int_type __i = __is.rdbuf()->sbumpc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
++__extr;
@@ -1407,21 +1532,26 @@ getline(basic_istream<_CharT, _Traits>& __is,
__str.push_back(__ch);
if (__str.size() == __str.max_size())
{
- __err |= ios_base::failbit;
+ __state |= ios_base::failbit;
break;
}
}
if (__extr == 0)
- __err |= ios_base::failbit;
- __is.setstate(__err);
- }
+ __state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
}
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
@@ -1460,17 +1590,17 @@ template <class _CharT, class _Traits, size_t _Size>
basic_istream<_CharT, _Traits>&
operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
{
-#ifndef _LIBCPP_NO_EXCEPTIONS
- try
+ ios_base::iostate __state = ios_base::goodbit;
+ typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
+ if (__sen)
{
-#endif // _LIBCPP_NO_EXCEPTIONS
- typename basic_istream<_CharT, _Traits>::sentry __sen(__is);
- if (__sen)
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ try
{
+#endif
basic_string<_CharT, _Traits> __str;
const ctype<_CharT>& __ct = use_facet<ctype<_CharT> >(__is.getloc());
size_t __c = 0;
- ios_base::iostate __err = ios_base::goodbit;
_CharT __zero = __ct.widen('0');
_CharT __one = __ct.widen('1');
while (__c < _Size)
@@ -1478,7 +1608,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
typename _Traits::int_type __i = __is.rdbuf()->sgetc();
if (_Traits::eq_int_type(__i, _Traits::eof()))
{
- __err |= ios_base::eofbit;
+ __state |= ios_base::eofbit;
break;
}
_CharT __ch = _Traits::to_char_type(__i);
@@ -1490,18 +1620,21 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x)
}
__x = bitset<_Size>(__str);
if (__c == 0)
- __err |= ios_base::failbit;
- __is.setstate(__err);
- }
- else
- __is.setstate(ios_base::failbit);
+ __state |= ios_base::failbit;
#ifndef _LIBCPP_NO_EXCEPTIONS
+ }
+ catch (...)
+ {
+ __state |= ios_base::badbit;
+ __is.__setstate_nothrow(__state);
+ if (__is.exceptions() & ios_base::badbit)
+ {
+ throw;
+ }
+ }
+#endif
+ __is.setstate(__state);
}
- catch (...)
- {
- __is.__set_badbit_and_consider_rethrow();
- }
-#endif // _LIBCPP_NO_EXCEPTIONS
return __is;
}
diff --git a/include/iterator b/include/iterator
index bda177e11e6c..30801ea83dbd 100644
--- a/include/iterator
+++ b/include/iterator
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- iterator ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -70,7 +69,7 @@ typename iterator_traits<InputIterator>::difference_type n = 1);
template <class BidirectionalIterator> // constexpr in C++17
constexpr BidirectionalIterator prev(BidirectionalIterator x,
- typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
+ typename iterator_traits<BidirectionalIterator>::difference_type n = 1);
template <class Iterator>
class reverse_iterator
@@ -137,7 +136,7 @@ operator-(const reverse_iterator<Iterator1>& x, const reverse_iterator<Iterator2
template <class Iterator>
constexpr reverse_iterator<Iterator>
-operator+(typename reverse_iterator<Iterator>::difference_type n,
+operator+(typename reverse_iterator<Iterator>::difference_type n,
const reverse_iterator<Iterator>& x); // constexpr in C++17
template <class Iterator>
@@ -217,7 +216,7 @@ public:
typedef typename iterator_traits<Iterator>::value_type value_type;
typedef typename iterator_traits<Iterator>::iterator_category iterator_category;
typedef value_type&& reference;
-
+
constexpr move_iterator(); // all the constexprs are in C++17
constexpr explicit move_iterator(Iterator i);
template <class U>
@@ -231,10 +230,10 @@ public:
constexpr move_iterator operator++(int);
constexpr move_iterator& operator--();
constexpr move_iterator operator--(int);
- constexpr move_iterator operator+(difference_type n) const;
- constexpr move_iterator& operator+=(difference_type n);
- constexpr move_iterator operator-(difference_type n) const;
- constexpr move_iterator& operator-=(difference_type n);
+ constexpr move_iterator operator+(difference_type n) const;
+ constexpr move_iterator& operator+=(difference_type n);
+ constexpr move_iterator operator-(difference_type n) const;
+ constexpr move_iterator& operator-=(difference_type n);
constexpr unspecified operator[](difference_type n) const;
private:
Iterator current; // exposition only
@@ -271,7 +270,7 @@ operator-(const move_iterator<Iterator1>& x,
template <class Iterator>
constexpr move_iterator<Iterator> operator+( // constexpr in C++17
- typename move_iterator<Iterator>::difference_type n,
+ typename move_iterator<Iterator>::difference_type n,
const move_iterator<Iterator>& x);
template <class Iterator> // constexpr in C++17
@@ -400,6 +399,11 @@ template <class C> constexpr auto crend(const C& c) -> decltype(std::rend(c));
// 24.8, container access:
template <class C> constexpr auto size(const C& c) -> decltype(c.size()); // C++17
template <class T, size_t N> constexpr size_t size(const T (&array)[N]) noexcept; // C++17
+
+template <class C> constexpr auto ssize(const C& c)
+ -> common_type_t<ptrdiff_t, make_signed_t<decltype(c.size())>>; // C++20
+template <class T, ptrdiff_t> constexpr ptrdiff_t ssize(const T (&array)[N]) noexcept; // C++20
+
template <class C> constexpr auto empty(const C& c) -> decltype(c.empty()); // C++17
template <class T, size_t N> constexpr bool empty(const T (&array)[N]) noexcept; // C++17
template <class E> constexpr bool empty(initializer_list<E> il) noexcept; // C++17
@@ -530,10 +534,26 @@ struct __is_random_access_iterator : public __has_iterator_category_convertible_
template <class _Tp>
struct __is_exactly_input_iterator
- : public integral_constant<bool,
- __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
+ : public integral_constant<bool,
+ __has_iterator_category_convertible_to<_Tp, input_iterator_tag>::value &&
!__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {};
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _InputIterator>
+using __iter_value_type = typename iterator_traits<_InputIterator>::value_type;
+
+template<class _InputIterator>
+using __iter_key_type = remove_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>;
+
+template<class _InputIterator>
+using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type;
+
+template<class _InputIterator>
+using __iter_to_alloc_type = pair<
+ add_const_t<typename iterator_traits<_InputIterator>::value_type::first_type>,
+ typename iterator_traits<_InputIterator>::value_type::second_type>;
+#endif
+
template<class _Category, class _Tp, class _Distance = ptrdiff_t,
class _Pointer = _Tp*, class _Reference = _Tp&>
struct _LIBCPP_TEMPLATE_VIS iterator
@@ -580,6 +600,8 @@ inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
void advance(_InputIter& __i,
typename iterator_traits<_InputIter>::difference_type __n)
{
+ _LIBCPP_ASSERT(__n >= 0 || __is_bidirectional_iterator<_InputIter>::value,
+ "Attempt to advance(it, -n) on a non-bidi iterator");
__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category());
}
@@ -614,26 +636,31 @@ template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
- __is_input_iterator<_InputIter>::value,
+ __is_input_iterator<_InputIter>::value,
_InputIter
>::type
next(_InputIter __x,
typename iterator_traits<_InputIter>::difference_type __n = 1)
{
+ _LIBCPP_ASSERT(__n >= 0 || __is_bidirectional_iterator<_InputIter>::value,
+ "Attempt to next(it, -n) on a non-bidi iterator");
+
_VSTD::advance(__x, __n);
return __x;
}
-template <class _BidirectionalIter>
+template <class _InputIter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
typename enable_if
<
- __is_bidirectional_iterator<_BidirectionalIter>::value,
- _BidirectionalIter
+ __is_input_iterator<_InputIter>::value,
+ _InputIter
>::type
-prev(_BidirectionalIter __x,
- typename iterator_traits<_BidirectionalIter>::difference_type __n = 1)
+prev(_InputIter __x,
+ typename iterator_traits<_InputIter>::difference_type __n = 1)
{
+ _LIBCPP_ASSERT(__n <= 0 || __is_bidirectional_iterator<_InputIter>::value,
+ "Attempt to prev(it, +n) on a non-bidi iterator");
_VSTD::advance(__x, -__n);
return __x;
}
@@ -1079,10 +1106,6 @@ public:
_LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;}
_LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == 0;}
-#if !defined(__APPLE__) || \
- (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \
- (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0)
-
template <class _Ch, class _Tr>
friend
_LIBCPP_HIDDEN
@@ -1090,7 +1113,6 @@ public:
__pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s,
const _Ch* __ob, const _Ch* __op, const _Ch* __oe,
ios_base& __iob, _Ch __fl);
-#endif
};
template <class _Iter>
@@ -1123,7 +1145,7 @@ public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reference operator*() const { return static_cast<reference>(*__i); }
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
pointer operator->() const { return __i;}
@@ -1237,50 +1259,50 @@ template <class _Iter> class __wrap_iter;
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
auto
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-> decltype(__x.base() - __y.base());
#else
template <class _Iter1, class _Iter2>
_LIBCPP_INLINE_VISIBILITY
typename __wrap_iter<_Iter1>::difference_type
-operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
#endif
template <class _Iter>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
__wrap_iter<_Iter>
-operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT_DEBUG;
+operator+(typename __wrap_iter<_Iter>::difference_type, __wrap_iter<_Iter>) _NOEXCEPT;
template <class _Ip, class _Op> _Op _LIBCPP_INLINE_VISIBILITY copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> _B2 _LIBCPP_INLINE_VISIBILITY copy_backward(_B1, _B1, _B2);
@@ -1324,7 +1346,7 @@ public:
private:
iterator_type __i;
public:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT
#if _LIBCPP_STD_VER > 11
: __i{}
#endif
@@ -1335,7 +1357,7 @@ public:
}
template <class _Up> _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
__wrap_iter(const __wrap_iter<_Up>& __u,
- typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT_DEBUG
+ typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) _NOEXCEPT
: __i(__u.base())
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1365,7 +1387,7 @@ public:
__get_db()->__erase_i(this);
}
#endif
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
@@ -1373,7 +1395,7 @@ public:
#endif
return *__i;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
@@ -1381,7 +1403,7 @@ public:
#endif
return (pointer)_VSTD::addressof(*__i);
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this),
@@ -1390,10 +1412,10 @@ public:
++__i;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator++(int) _NOEXCEPT
{__wrap_iter __tmp(*this); ++(*this); return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator--() _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__decrementable(this),
@@ -1402,11 +1424,11 @@ public:
--__i;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator--(int) _NOEXCEPT
{__wrap_iter __tmp(*this); --(*this); return __tmp;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator+ (difference_type __n) const _NOEXCEPT
{__wrap_iter __w(*this); __w += __n; return __w;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator+=(difference_type __n) _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__addable(this, __n),
@@ -1415,11 +1437,11 @@ public:
__i += __n;
return *this;
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter operator- (difference_type __n) const _NOEXCEPT
{return *this + (-__n);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator-=(difference_type __n) _NOEXCEPT
{*this += -__n; return *this;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT_DEBUG
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator[](difference_type __n) const _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__subscriptable(this, __n),
@@ -1428,7 +1450,7 @@ public:
return __i[__n];
}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT_DEBUG {return __i;}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;}
private:
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1437,61 +1459,61 @@ private:
__get_db()->__insert_ic(this, __p);
}
#else
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT_DEBUG : __i(__x) {}
+ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {}
#endif
template <class _Up> friend class __wrap_iter;
template <class _CharT, class _Traits, class _Alloc> friend class basic_string;
template <class _Tp, class _Alloc> friend class _LIBCPP_TEMPLATE_VIS vector;
- template <class _Tp, ptrdiff_t> friend class _LIBCPP_TEMPLATE_VIS span;
+ template <class _Tp, size_t> friend class _LIBCPP_TEMPLATE_VIS span;
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
bool
- operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator==(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
bool
- operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator<(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
bool
- operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator!=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
bool
- operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator>(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
bool
- operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator>=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
bool
- operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator<=(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
#ifndef _LIBCPP_CXX03_LANG
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
auto
- operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-> decltype(__x.base() - __y.base());
#else
template <class _Iter1, class _Iter2>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
typename __wrap_iter<_Iter1>::difference_type
- operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT_DEBUG;
+ operator-(const __wrap_iter<_Iter1>&, const __wrap_iter<_Iter2>&) _NOEXCEPT;
#endif
template <class _Iter1>
_LIBCPP_CONSTEXPR_IF_NODEBUG friend
__wrap_iter<_Iter1>
- operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT_DEBUG;
+ operator+(typename __wrap_iter<_Iter1>::difference_type, __wrap_iter<_Iter1>) _NOEXCEPT;
template <class _Ip, class _Op> friend _Op copy(_Ip, _Ip, _Op);
template <class _B1, class _B2> friend _B2 copy_backward(_B1, _B1, _B2);
@@ -1522,7 +1544,7 @@ private:
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
return __x.base() == __y.base();
}
@@ -1530,7 +1552,7 @@ operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
@@ -1542,7 +1564,7 @@ operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
return !(__x == __y);
}
@@ -1550,7 +1572,7 @@ operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
return __y < __x;
}
@@ -1558,7 +1580,7 @@ operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
return !(__x < __y);
}
@@ -1566,7 +1588,7 @@ operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
return !(__y < __x);
}
@@ -1574,7 +1596,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEX
template <class _Iter1>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
+operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
{
return !(__x == __y);
}
@@ -1582,7 +1604,7 @@ operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
template <class _Iter1>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
+operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
{
return __y < __x;
}
@@ -1590,7 +1612,7 @@ operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXC
template <class _Iter1>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
+operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
{
return !(__x < __y);
}
@@ -1598,7 +1620,7 @@ operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
template <class _Iter1>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
bool
-operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT_DEBUG
+operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT
{
return !(__y < __x);
}
@@ -1607,7 +1629,7 @@ operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEX
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
auto
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
-> decltype(__x.base() - __y.base())
{
#if _LIBCPP_DEBUG_LEVEL >= 2
@@ -1620,7 +1642,7 @@ operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXC
template <class _Iter1, class _Iter2>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
typename __wrap_iter<_Iter1>::difference_type
-operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT_DEBUG
+operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT
{
#if _LIBCPP_DEBUG_LEVEL >= 2
_LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y),
@@ -1634,7 +1656,7 @@ template <class _Iter>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG
__wrap_iter<_Iter>
operator+(typename __wrap_iter<_Iter>::difference_type __n,
- __wrap_iter<_Iter> __x) _NOEXCEPT_DEBUG
+ __wrap_iter<_Iter> __x) _NOEXCEPT
{
__x += __n;
return __x;
@@ -1643,7 +1665,7 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n,
template <class _Iter>
struct __libcpp_is_trivial_iterator
: public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {};
-
+
template <class _Iter>
struct __libcpp_is_trivial_iterator<move_iterator<_Iter> >
: public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {};
@@ -1658,7 +1680,7 @@ struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> >
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp*
begin(_Tp (&__array)[_Np])
{
@@ -1666,7 +1688,7 @@ begin(_Tp (&__array)[_Np])
}
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
_Tp*
end(_Tp (&__array)[_Np])
{
@@ -1676,7 +1698,7 @@ end(_Tp (&__array)[_Np])
#if !defined(_LIBCPP_CXX03_LANG)
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
begin(_Cp& __c) -> decltype(__c.begin())
{
@@ -1684,7 +1706,7 @@ begin(_Cp& __c) -> decltype(__c.begin())
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
begin(const _Cp& __c) -> decltype(__c.begin())
{
@@ -1692,7 +1714,7 @@ begin(const _Cp& __c) -> decltype(__c.begin())
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
end(_Cp& __c) -> decltype(__c.end())
{
@@ -1700,7 +1722,7 @@ end(_Cp& __c) -> decltype(__c.end())
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto
end(const _Cp& __c) -> decltype(__c.end())
{
@@ -1710,84 +1732,84 @@ end(const _Cp& __c) -> decltype(__c.end())
#if _LIBCPP_STD_VER > 11
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array + _Np);
}
template <class _Tp, size_t _Np>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np])
{
return reverse_iterator<_Tp*>(__array);
}
template <class _Ep>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il)
{
return reverse_iterator<const _Ep*>(__il.end());
}
template <class _Ep>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il)
{
return reverse_iterator<const _Ep*>(__il.begin());
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c))
{
return _VSTD::begin(__c);
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c))
{
return _VSTD::end(__c);
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rbegin(_Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rbegin(const _Cp& __c) -> decltype(__c.rbegin())
{
return __c.rbegin();
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rend(_Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto rend(const _Cp& __c) -> decltype(__c.rend())
{
return __c.rend();
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c))
{
return _VSTD::rbegin(__c);
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
{
return _VSTD::rend(__c);
@@ -1799,7 +1821,7 @@ auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c))
#else // defined(_LIBCPP_CXX03_LANG)
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename _Cp::iterator
begin(_Cp& __c)
{
@@ -1807,7 +1829,7 @@ begin(_Cp& __c)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename _Cp::const_iterator
begin(const _Cp& __c)
{
@@ -1815,7 +1837,7 @@ begin(const _Cp& __c)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename _Cp::iterator
end(_Cp& __c)
{
@@ -1823,7 +1845,7 @@ end(_Cp& __c)
}
template <class _Cp>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
typename _Cp::const_iterator
end(const _Cp& __c)
{
@@ -1849,51 +1871,64 @@ end(const _Cp& __c)
// #endif
template <class _Cont>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
constexpr auto size(const _Cont& __c)
_NOEXCEPT_(noexcept(__c.size()))
-> decltype (__c.size())
{ return __c.size(); }
template <class _Tp, size_t _Sz>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; }
+#if _LIBCPP_STD_VER > 17
template <class _Cont>
-_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
+constexpr auto ssize(const _Cont& __c)
+_NOEXCEPT_(noexcept(static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size())))
+-> common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>
+{ return static_cast<common_type_t<ptrdiff_t, make_signed_t<decltype(__c.size())>>>(__c.size()); }
+
+template <class _Tp, ptrdiff_t _Sz>
+_LIBCPP_INLINE_VISIBILITY
+constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; }
+#endif
+
+template <class _Cont>
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
constexpr auto empty(const _Cont& __c)
_NOEXCEPT_(noexcept(__c.empty()))
-> decltype (__c.empty())
{ return __c.empty(); }
template <class _Tp, size_t _Sz>
-_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; }
template <class _Ep>
-_LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; }
template <class _Cont> constexpr
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
auto data(_Cont& __c)
_NOEXCEPT_(noexcept(__c.data()))
-> decltype (__c.data())
{ return __c.data(); }
template <class _Cont> constexpr
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
auto data(const _Cont& __c)
_NOEXCEPT_(noexcept(__c.data()))
--> decltype (__c.data())
+-> decltype (__c.data())
{ return __c.data(); }
template <class _Tp, size_t _Sz>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; }
template <class _Ep>
-inline _LIBCPP_INLINE_VISIBILITY
+_LIBCPP_INLINE_VISIBILITY
constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); }
#endif
diff --git a/include/limits b/include/limits
index 5ea9a9e6fdfa..6d5d1e1aca75 100644
--- a/include/limits
+++ b/include/limits
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- limits ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -410,7 +409,7 @@ protected:
static _LIBCPP_CONSTEXPR const bool is_exact = false;
static _LIBCPP_CONSTEXPR const int radix = __FLT_RADIX__;
_LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {return __LDBL_EPSILON__;}
- _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5;}
+ _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {return 0.5L;}
static _LIBCPP_CONSTEXPR const int min_exponent = __LDBL_MIN_EXP__;
static _LIBCPP_CONSTEXPR const int min_exponent10 = __LDBL_MIN_10_EXP__;
diff --git a/include/limits.h b/include/limits.h
index 1867b1048574..4a212f8f35a8 100644
--- a/include/limits.h
+++ b/include/limits.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- limits.h ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/list b/include/list
index c69e31d93a44..c92ef79282ed 100644
--- a/include/list
+++ b/include/list
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- list ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -130,11 +129,12 @@ public:
void splice(const_iterator position, list&& x, const_iterator first,
const_iterator last);
- void remove(const value_type& value);
- template <class Pred> void remove_if(Pred pred);
- void unique();
+ size_type remove(const value_type& value); // void before C++20
+ template <class Pred>
+ size_type remove_if(Pred pred); // void before C++20
+ size_type unique(); // void before C++20
template <class BinaryPredicate>
- void unique(BinaryPredicate binary_pred);
+ size_type unique(BinaryPredicate binary_pred); // void before C++20
void merge(list& x);
void merge(list&& x);
template <class Compare>
@@ -648,9 +648,9 @@ protected:
void swap(__list_imp& __c)
#if _LIBCPP_STD_VER >= 14
- _NOEXCEPT_DEBUG;
+ _NOEXCEPT;
#else
- _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value);
#endif
@@ -770,9 +770,9 @@ template <class _Tp, class _Alloc>
void
__list_imp<_Tp, _Alloc>::swap(__list_imp& __c)
#if _LIBCPP_STD_VER >= 14
- _NOEXCEPT_DEBUG
+ _NOEXCEPT
#else
- _NOEXCEPT_DEBUG_(!__alloc_traits::propagate_on_container_swap::value ||
+ _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<allocator_type>::value)
#endif
{
@@ -858,6 +858,11 @@ public:
typedef typename base::const_iterator const_iterator;
typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
+#if _LIBCPP_STD_VER > 17
+ typedef size_type __remove_return_type;
+#else
+ typedef void __remove_return_type;
+#endif
_LIBCPP_INLINE_VISIBILITY
list()
@@ -1039,9 +1044,9 @@ public:
_LIBCPP_INLINE_VISIBILITY
void swap(list& __c)
#if _LIBCPP_STD_VER >= 14
- _NOEXCEPT_DEBUG
+ _NOEXCEPT
#else
- _NOEXCEPT_DEBUG_(!__node_alloc_traits::propagate_on_container_swap::value ||
+ _NOEXCEPT_(!__node_alloc_traits::propagate_on_container_swap::value ||
__is_nothrow_swappable<__node_allocator>::value)
#endif
{base::swap(__c);}
@@ -1071,12 +1076,12 @@ public:
void splice(const_iterator __p, list& __c, const_iterator __i);
void splice(const_iterator __p, list& __c, const_iterator __f, const_iterator __l);
- void remove(const value_type& __x);
- template <class _Pred> void remove_if(_Pred __pred);
+ __remove_return_type remove(const value_type& __x);
+ template <class _Pred> __remove_return_type remove_if(_Pred __pred);
_LIBCPP_INLINE_VISIBILITY
- void unique();
+ __remove_return_type unique() { return unique(__equal_to<value_type>()); }
template <class _BinaryPred>
- void unique(_BinaryPred __binary_pred);
+ __remove_return_type unique(_BinaryPred __binary_pred);
_LIBCPP_INLINE_VISIBILITY
void merge(list& __c);
#ifndef _LIBCPP_CXX03_LANG
@@ -2014,22 +2019,24 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c)
base::__sz() += __c.__sz();
__c.__sz() = 0;
#if _LIBCPP_DEBUG_LEVEL >= 2
- __libcpp_db* __db = __get_db();
- __c_node* __cn1 = __db->__find_c_and_lock(this);
- __c_node* __cn2 = __db->__find_c(&__c);
- for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
- {
- --__ip;
- iterator* __i = static_cast<iterator*>((*__ip)->__i_);
- if (__i->__ptr_ != __c.__end_as_link())
+ if (&__c != this) {
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(&__c);
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{
- __cn1->__add(*__ip);
- (*__ip)->__c_ = __cn1;
- if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ --__ip;
+ iterator* __i = static_cast<iterator*>((*__ip)->__i_);
+ if (__i->__ptr_ != __c.__end_as_link())
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
}
+ __db->unlock();
}
- __db->unlock();
#endif
}
}
@@ -2057,22 +2064,24 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i)
--__c.__sz();
++base::__sz();
#if _LIBCPP_DEBUG_LEVEL >= 2
- __libcpp_db* __db = __get_db();
- __c_node* __cn1 = __db->__find_c_and_lock(this);
- __c_node* __cn2 = __db->__find_c(&__c);
- for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
- {
- --__ip;
- iterator* __j = static_cast<iterator*>((*__ip)->__i_);
- if (__j->__ptr_ == __f)
+ if (&__c != this) {
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(&__c);
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{
- __cn1->__add(*__ip);
- (*__ip)->__c_ = __cn1;
- if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ --__ip;
+ iterator* __j = static_cast<iterator*>((*__ip)->__i_);
+ if (__j->__ptr_ == __f)
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
}
+ __db->unlock();
}
- __db->unlock();
#endif
}
}
@@ -2111,32 +2120,34 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con
base::__unlink_nodes(__first, __last);
__link_nodes(__p.__ptr_, __first, __last);
#if _LIBCPP_DEBUG_LEVEL >= 2
- __libcpp_db* __db = __get_db();
- __c_node* __cn1 = __db->__find_c_and_lock(this);
- __c_node* __cn2 = __db->__find_c(&__c);
- for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
- {
- --__ip;
- iterator* __j = static_cast<iterator*>((*__ip)->__i_);
- for (__link_pointer __k = __f.__ptr_;
- __k != __l.__ptr_; __k = __k->__next_)
+ if (&__c != this) {
+ __libcpp_db* __db = __get_db();
+ __c_node* __cn1 = __db->__find_c_and_lock(this);
+ __c_node* __cn2 = __db->__find_c(&__c);
+ for (__i_node** __ip = __cn2->end_; __ip != __cn2->beg_;)
{
- if (__j->__ptr_ == __k)
+ --__ip;
+ iterator* __j = static_cast<iterator*>((*__ip)->__i_);
+ for (__link_pointer __k = __f.__ptr_;
+ __k != __l.__ptr_; __k = __k->__next_)
{
- __cn1->__add(*__ip);
- (*__ip)->__c_ = __cn1;
- if (--__cn2->end_ != __ip)
- memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ if (__j->__ptr_ == __k)
+ {
+ __cn1->__add(*__ip);
+ (*__ip)->__c_ = __cn1;
+ if (--__cn2->end_ != __ip)
+ memmove(__ip, __ip+1, (__cn2->end_ - __ip)*sizeof(__i_node*));
+ }
}
}
+ __db->unlock();
}
- __db->unlock();
#endif
}
}
template <class _Tp, class _Alloc>
-void
+typename list<_Tp, _Alloc>::__remove_return_type
list<_Tp, _Alloc>::remove(const value_type& __x)
{
list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
@@ -2155,13 +2166,16 @@ list<_Tp, _Alloc>::remove(const value_type& __x)
else
++__i;
}
+
+ return (__remove_return_type) __deleted_nodes.size();
}
template <class _Tp, class _Alloc>
template <class _Pred>
-void
+typename list<_Tp, _Alloc>::__remove_return_type
list<_Tp, _Alloc>::remove_if(_Pred __pred)
{
+ list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
for (iterator __i = begin(), __e = end(); __i != __e;)
{
if (__pred(*__i))
@@ -2169,36 +2183,36 @@ list<_Tp, _Alloc>::remove_if(_Pred __pred)
iterator __j = _VSTD::next(__i);
for (; __j != __e && __pred(*__j); ++__j)
;
- __i = erase(__i, __j);
+ __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
+ __i = __j;
if (__i != __e)
++__i;
}
else
++__i;
}
-}
-template <class _Tp, class _Alloc>
-inline
-void
-list<_Tp, _Alloc>::unique()
-{
- unique(__equal_to<value_type>());
+ return (__remove_return_type) __deleted_nodes.size();
}
template <class _Tp, class _Alloc>
template <class _BinaryPred>
-void
+typename list<_Tp, _Alloc>::__remove_return_type
list<_Tp, _Alloc>::unique(_BinaryPred __binary_pred)
{
+ list<_Tp, _Alloc> __deleted_nodes(get_allocator()); // collect the nodes we're removing
for (iterator __i = begin(), __e = end(); __i != __e;)
{
iterator __j = _VSTD::next(__i);
for (; __j != __e && __binary_pred(*__i, *__j); ++__j)
;
- if (++__i != __j)
- __i = erase(__i, __j);
+ if (++__i != __j) {
+ __deleted_nodes.splice(__deleted_nodes.end(), *this, __i, __j);
+ __i = __j;
+ }
}
+
+ return (__remove_return_type) __deleted_nodes.size();
}
template <class _Tp, class _Alloc>
diff --git a/include/locale b/include/locale
index 2043892fa2dc..3fe44300227a 100644
--- a/include/locale
+++ b/include/locale
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- locale ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -127,7 +126,7 @@ public:
wbuffer_convert(const wbuffer_convert&) = delete; // C++14
wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14
~wbuffer_convert(); // C++14
-
+
streambuf* rdbuf() const;
streambuf* rdbuf(streambuf* bytebuf);
@@ -547,7 +546,7 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex
__exp = 'P';
else if ((__x & 0x5F) == __exp)
{
- __exp |= 0x80;
+ __exp |= (char) 0x80;
if (__in_units)
{
__in_units = false;
@@ -1373,10 +1372,6 @@ __pad_and_output(_OutputIterator __s,
return __s;
}
-#if !defined(__APPLE__) || \
- (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED > __MAC_10_8) || \
- (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED > __IPHONE_6_0)
-
template <class _CharT, class _Traits>
_LIBCPP_HIDDEN
ostreambuf_iterator<_CharT, _Traits>
@@ -1423,8 +1418,6 @@ __pad_and_output(ostreambuf_iterator<_CharT, _Traits> __s,
return __s;
}
-#endif
-
template <class _CharT, class _OutputIterator>
_OutputIterator
num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob,
@@ -3930,7 +3923,7 @@ private:
wbuffer_convert(const wbuffer_convert&);
wbuffer_convert& operator=(const wbuffer_convert&);
public:
- _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0,
+ _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0,
_Codecvt* __pcvt = new _Codecvt, state_type __state = state_type());
~wbuffer_convert();
@@ -4045,7 +4038,7 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::underflow()
this->egptr(), __inext);
if (__r == codecvt_base::noconv)
{
- this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
+ this->setg((char_type*)__extbuf_, (char_type*)__extbuf_,
(char_type*) const_cast<char *>(__extbufend_));
__c = *this->gptr();
}
diff --git a/include/locale.h b/include/locale.h
index cad7b8b53eb1..a21ee385c331 100644
--- a/include/locale.h
+++ b/include/locale.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- locale.h --------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
diff --git a/include/map b/include/map
index 616bb46cfccd..eb6ae57b011f 100644
--- a/include/map
+++ b/include/map
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------- map ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -194,8 +193,8 @@ public:
const_iterator find(const K& x) const; // C++14
template<typename K>
size_type count(const K& x) const; // C++14
-
size_type count(const key_type& k) const;
+ bool contains(const key_type& x) const; // C++20
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -408,8 +407,8 @@ public:
const_iterator find(const K& x) const; // C++14
template<typename K>
size_type count(const K& x) const; // C++14
-
size_type count(const key_type& k) const;
+ bool contains(const key_type& x) const; // C++20
iterator lower_bound(const key_type& k);
const_iterator lower_bound(const key_type& k) const;
template<typename K>
@@ -903,12 +902,11 @@ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type> value_type;
- typedef _Compare key_compare;
- typedef _Allocator allocator_type;
+ typedef typename __identity<_Compare>::type key_compare;
+ typedef typename __identity<_Allocator>::type allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
- static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -1087,6 +1085,11 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
+ ~map() {
+ static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return __tree_.begin();}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
@@ -1395,6 +1398,12 @@ public:
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
@@ -1462,6 +1471,32 @@ private:
#endif
};
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
+ -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
+
+template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
+ class _Allocator = allocator<pair<const _Key, _Tp>>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
+ -> map<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(_InputIterator, _InputIterator, _Allocator)
+ -> map<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ less<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+map(initializer_list<pair<_Key, _Tp>>, _Allocator)
+ -> map<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
+#endif
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator>
@@ -1536,10 +1571,8 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k)
{
__parent_pointer __parent;
__node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
- throw out_of_range("map::at: key not found");
-#endif // _LIBCPP_NO_EXCEPTIONS
+ __throw_out_of_range("map::at: key not found");
return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
}
@@ -1549,10 +1582,8 @@ map<_Key, _Tp, _Compare, _Allocator>::at(const key_type& __k) const
{
__parent_pointer __parent;
__node_base_pointer __child = __tree_.__find_equal(__parent, __k);
-#ifndef _LIBCPP_NO_EXCEPTIONS
if (__child == nullptr)
- throw out_of_range("map::at: key not found");
-#endif // _LIBCPP_NO_EXCEPTIONS
+ __throw_out_of_range("map::at: key not found");
return static_cast<__node_pointer>(__child)->__value_.__get_value().second;
}
@@ -1638,12 +1669,11 @@ public:
typedef _Key key_type;
typedef _Tp mapped_type;
typedef pair<const key_type, mapped_type> value_type;
- typedef _Compare key_compare;
- typedef _Allocator allocator_type;
+ typedef typename __identity<_Compare>::type key_compare;
+ typedef typename __identity<_Allocator>::type allocator_type;
typedef value_type& reference;
typedef const value_type& const_reference;
- static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
static_assert((is_same<typename allocator_type::value_type, value_type>::value),
"Allocator::value_type must be same type as value_type");
@@ -1823,6 +1853,11 @@ public:
}
_LIBCPP_INLINE_VISIBILITY
+ ~multimap() {
+ static_assert(sizeof(__diagnose_non_const_comparator<_Key, _Compare>()), "");
+ }
+
+ _LIBCPP_INLINE_VISIBILITY
iterator begin() _NOEXCEPT {return __tree_.begin();}
_LIBCPP_INLINE_VISIBILITY
const_iterator begin() const _NOEXCEPT {return __tree_.begin();}
@@ -2026,6 +2061,12 @@ public:
typename enable_if<__is_transparent<_Compare, _K2>::value,size_type>::type
count(const _K2& __k) const {return __tree_.__count_multi(__k);}
#endif
+
+#if _LIBCPP_STD_VER > 17
+ _LIBCPP_INLINE_VISIBILITY
+ bool contains(const key_type& __k) const {return find(__k) != end();}
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_INLINE_VISIBILITY
iterator lower_bound(const key_type& __k)
{return __tree_.lower_bound(__k);}
@@ -2087,6 +2128,33 @@ private:
typedef unique_ptr<__node, _Dp> __node_holder;
};
+#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES
+template<class _InputIterator, class _Compare = less<__iter_key_type<_InputIterator>>,
+ class _Allocator = allocator<__iter_to_alloc_type<_InputIterator>>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(_InputIterator, _InputIterator, _Compare = _Compare(), _Allocator = _Allocator())
+ -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>, _Compare, _Allocator>;
+
+template<class _Key, class _Tp, class _Compare = less<remove_const_t<_Key>>,
+ class _Allocator = allocator<pair<const _Key, _Tp>>,
+ class = enable_if_t<!__is_allocator<_Compare>::value, void>,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(initializer_list<pair<_Key, _Tp>>, _Compare = _Compare(), _Allocator = _Allocator())
+ -> multimap<remove_const_t<_Key>, _Tp, _Compare, _Allocator>;
+
+template<class _InputIterator, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(_InputIterator, _InputIterator, _Allocator)
+ -> multimap<__iter_key_type<_InputIterator>, __iter_mapped_type<_InputIterator>,
+ less<__iter_key_type<_InputIterator>>, _Allocator>;
+
+template<class _Key, class _Tp, class _Allocator,
+ class = enable_if_t<__is_allocator<_Allocator>::value, void>>
+multimap(initializer_list<pair<_Key, _Tp>>, _Allocator)
+ -> multimap<remove_const_t<_Key>, _Tp, less<remove_const_t<_Key>>, _Allocator>;
+#endif
+
#ifndef _LIBCPP_CXX03_LANG
template <class _Key, class _Tp, class _Compare, class _Allocator>
multimap<_Key, _Tp, _Compare, _Allocator>::multimap(multimap&& __m, const allocator_type& __a)
diff --git a/include/math.h b/include/math.h
index 3cc72aa2791e..194df2077bb1 100644
--- a/include/math.h
+++ b/include/math.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- math.h ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -298,6 +297,9 @@ long double truncl(long double x);
#pragma GCC system_header
#endif
+#define _LIBCPP_STDLIB_INCLUDE_NEXT
+#include <stdlib.h>
+
#include_next <math.h>
#ifdef __cplusplus
@@ -755,20 +757,61 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// abs
+#undef abs
+#undef labs
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+#undef llabs
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
+ return ::labs(__x);
+}
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
+ return ::llabs(__x);
+}
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+
+
#if !(defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY
-float
-abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
+ return ::fabsf(__lcpp_x);
+}
-inline _LIBCPP_INLINE_VISIBILITY
-double
-abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
+ return ::fabs(__lcpp_x);
+}
-inline _LIBCPP_INLINE_VISIBILITY
-long double
-abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double
+abs(long double __lcpp_x) _NOEXCEPT {
+ return ::fabsl(__lcpp_x);
+}
#endif // !(defined(_AIX) || defined(__sun__))
+// div
+
+#undef div
+#undef ldiv
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+#undef lldiv
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
+ return ::ldiv(__x, __y);
+}
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
+ long long __y) _NOEXCEPT {
+ return ::lldiv(__x, __y);
+}
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
+
// acos
#if !(defined(_AIX) || defined(__sun__))
@@ -814,7 +857,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long do
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -823,8 +866,8 @@ typename std::__lazy_enable_if
atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
}
@@ -909,7 +952,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -918,8 +961,8 @@ typename std::__lazy_enable_if
fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -987,7 +1030,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long doub
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -996,8 +1039,8 @@ typename std::__lazy_enable_if
pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1114,7 +1157,7 @@ copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1123,8 +1166,8 @@ typename std::__lazy_enable_if
copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1175,7 +1218,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1184,8 +1227,8 @@ typename std::__lazy_enable_if
fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1196,7 +1239,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long doub
template <class _A1, class _A2, class _A3>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value &&
@@ -1206,9 +1249,9 @@ typename std::__lazy_enable_if
fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value &&
- std::is_same<_A3, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value &&
+ std::_IsSame<_A3, __result_type>::value)), "");
return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
}
@@ -1219,7 +1262,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1228,8 +1271,8 @@ typename std::__lazy_enable_if
fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1240,7 +1283,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1249,8 +1292,8 @@ typename std::__lazy_enable_if
fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1261,7 +1304,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long do
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1270,8 +1313,8 @@ typename std::__lazy_enable_if
hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1384,7 +1427,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, lon
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1393,8 +1436,8 @@ typename std::__lazy_enable_if
nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1415,7 +1458,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, lon
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1424,8 +1467,8 @@ typename std::__lazy_enable_if
remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1436,7 +1479,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long d
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1445,8 +1488,8 @@ typename std::__lazy_enable_if
remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
}
diff --git a/include/memory b/include/memory
index ce2c35766233..d9222b3ada7e 100644
--- a/include/memory
+++ b/include/memory
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- memory ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -549,7 +548,7 @@ template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) noexcept;
template<class T> struct owner_less;
template<class T>
-struct owner_less<shared_ptr<T>>
+struct owner_less<shared_ptr<T> >
: binary_function<shared_ptr<T>, shared_ptr<T>, bool>
{
typedef bool result_type;
@@ -559,7 +558,7 @@ struct owner_less<shared_ptr<T>>
};
template<class T>
-struct owner_less<weak_ptr<T>>
+struct owner_less<weak_ptr<T> >
: binary_function<weak_ptr<T>, weak_ptr<T>, bool>
{
typedef bool result_type;
@@ -684,7 +683,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_ValueType __libcpp_relaxed_load(_ValueType const* __value) {
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
defined(__ATOMIC_RELAXED) && \
- (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407)
+ (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
return __atomic_load_n(__value, __ATOMIC_RELAXED);
#else
return *__value;
@@ -696,7 +695,7 @@ inline _LIBCPP_INLINE_VISIBILITY
_ValueType __libcpp_acquire_load(_ValueType const* __value) {
#if !defined(_LIBCPP_HAS_NO_THREADS) && \
defined(__ATOMIC_ACQUIRE) && \
- (__has_builtin(__atomic_load_n) || _GNUC_VER >= 407)
+ (__has_builtin(__atomic_load_n) || defined(_LIBCPP_COMPILER_GCC))
return __atomic_load_n(__value, __ATOMIC_ACQUIRE);
#else
return *__value;
@@ -744,7 +743,7 @@ struct __pointer_traits_element_type;
template <class _Ptr>
struct __pointer_traits_element_type<_Ptr, true>
{
- typedef typename _Ptr::element_type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::element_type type;
};
#ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -752,13 +751,13 @@ struct __pointer_traits_element_type<_Ptr, true>
template <template <class, class...> class _Sp, class _Tp, class ..._Args>
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true>
{
- typedef typename _Sp<_Tp, _Args...>::element_type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::element_type type;
};
template <template <class, class...> class _Sp, class _Tp, class ..._Args>
struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, false>
{
- typedef _Tp type;
+ typedef _LIBCPP_NODEBUG_TYPE _Tp type;
};
#else // _LIBCPP_HAS_NO_VARIADICS
@@ -825,13 +824,13 @@ struct __has_difference_type<_Tp,
template <class _Ptr, bool = __has_difference_type<_Ptr>::value>
struct __pointer_traits_difference_type
{
- typedef ptrdiff_t type;
+ typedef _LIBCPP_NODEBUG_TYPE ptrdiff_t type;
};
template <class _Ptr>
struct __pointer_traits_difference_type<_Ptr, true>
{
- typedef typename _Ptr::difference_type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Ptr::difference_type type;
};
template <class _Tp, class _Up>
@@ -849,9 +848,9 @@ template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
struct __pointer_traits_rebind
{
#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Tp::template rebind<_Up> type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up> type;
#else
- typedef typename _Tp::template rebind<_Up>::other type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
#endif
};
@@ -861,9 +860,9 @@ template <template <class, class...> class _Sp, class _Tp, class ..._Args, class
struct __pointer_traits_rebind<_Sp<_Tp, _Args...>, _Up, true>
{
#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up> type;
#else
- typedef typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Sp<_Tp, _Args...>::template rebind<_Up>::other type;
#endif
};
@@ -1014,13 +1013,13 @@ namespace __pointer_type_imp
template <class _Tp, class _Dp, bool = __has_pointer_type<_Dp>::value>
struct __pointer_type
{
- typedef typename _Dp::pointer type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Dp::pointer type;
};
template <class _Tp, class _Dp>
struct __pointer_type<_Tp, _Dp, false>
{
- typedef _Tp* type;
+ typedef _LIBCPP_NODEBUG_TYPE _Tp* type;
};
} // __pointer_type_imp
@@ -1028,7 +1027,7 @@ struct __pointer_type<_Tp, _Dp, false>
template <class _Tp, class _Dp>
struct __pointer_type
{
- typedef typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename __pointer_type_imp::__pointer_type<_Tp, typename remove_reference<_Dp>::type>::type type;
};
template <class _Tp, class = void>
@@ -1041,14 +1040,14 @@ struct __has_const_pointer<_Tp,
template <class _Tp, class _Ptr, class _Alloc, bool = __has_const_pointer<_Alloc>::value>
struct __const_pointer
{
- typedef typename _Alloc::const_pointer type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_pointer type;
};
template <class _Tp, class _Ptr, class _Alloc>
struct __const_pointer<_Tp, _Ptr, _Alloc, false>
{
#ifndef _LIBCPP_CXX03_LANG
- typedef typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
+ typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const _Tp> type;
#else
typedef typename pointer_traits<_Ptr>::template rebind<const _Tp>::other type;
#endif
@@ -1064,16 +1063,16 @@ struct __has_void_pointer<_Tp,
template <class _Ptr, class _Alloc, bool = __has_void_pointer<_Alloc>::value>
struct __void_pointer
{
- typedef typename _Alloc::void_pointer type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::void_pointer type;
};
template <class _Ptr, class _Alloc>
struct __void_pointer<_Ptr, _Alloc, false>
{
#ifndef _LIBCPP_CXX03_LANG
- typedef typename pointer_traits<_Ptr>::template rebind<void> type;
+ typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void> type;
#else
- typedef typename pointer_traits<_Ptr>::template rebind<void>::other type;
+ typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<void>::other type;
#endif
};
@@ -1087,16 +1086,16 @@ struct __has_const_void_pointer<_Tp,
template <class _Ptr, class _Alloc, bool = __has_const_void_pointer<_Alloc>::value>
struct __const_void_pointer
{
- typedef typename _Alloc::const_void_pointer type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::const_void_pointer type;
};
template <class _Ptr, class _Alloc>
struct __const_void_pointer<_Ptr, _Alloc, false>
{
#ifndef _LIBCPP_CXX03_LANG
- typedef typename pointer_traits<_Ptr>::template rebind<const void> type;
+ typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void> type;
#else
- typedef typename pointer_traits<_Ptr>::template rebind<const void>::other type;
+ typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::template rebind<const void>::other type;
#endif
};
@@ -1162,13 +1161,13 @@ struct __has_size_type<_Tp,
template <class _Alloc, class _DiffType, bool = __has_size_type<_Alloc>::value>
struct __size_type
{
- typedef typename make_unsigned<_DiffType>::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename make_unsigned<_DiffType>::type type;
};
template <class _Alloc, class _DiffType>
struct __size_type<_Alloc, _DiffType, true>
{
- typedef typename _Alloc::size_type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::size_type type;
};
template <class _Tp, class = void>
@@ -1182,13 +1181,13 @@ struct __has_propagate_on_container_copy_assignment<_Tp,
template <class _Alloc, bool = __has_propagate_on_container_copy_assignment<_Alloc>::value>
struct __propagate_on_container_copy_assignment
{
- typedef false_type type;
+ typedef _LIBCPP_NODEBUG_TYPE false_type type;
};
template <class _Alloc>
struct __propagate_on_container_copy_assignment<_Alloc, true>
{
- typedef typename _Alloc::propagate_on_container_copy_assignment type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_copy_assignment type;
};
template <class _Tp, class = void>
@@ -1208,7 +1207,7 @@ struct __propagate_on_container_move_assignment
template <class _Alloc>
struct __propagate_on_container_move_assignment<_Alloc, true>
{
- typedef typename _Alloc::propagate_on_container_move_assignment type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_move_assignment type;
};
template <class _Tp, class = void>
@@ -1228,7 +1227,7 @@ struct __propagate_on_container_swap
template <class _Alloc>
struct __propagate_on_container_swap<_Alloc, true>
{
- typedef typename _Alloc::propagate_on_container_swap type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::propagate_on_container_swap type;
};
template <class _Tp, class = void>
@@ -1242,13 +1241,13 @@ struct __has_is_always_equal<_Tp,
template <class _Alloc, bool = __has_is_always_equal<_Alloc>::value>
struct __is_always_equal
{
- typedef typename _VSTD::is_empty<_Alloc>::type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _VSTD::is_empty<_Alloc>::type type;
};
template <class _Alloc>
struct __is_always_equal<_Alloc, true>
{
- typedef typename _Alloc::is_always_equal type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::is_always_equal type;
};
template <class _Tp, class _Up, bool = __has_rebind<_Tp, _Up>::value>
@@ -1271,7 +1270,7 @@ struct __has_rebind_other<_Tp, _Up, false>
template <class _Tp, class _Up, bool = __has_rebind_other<_Tp, _Up>::value>
struct __allocator_traits_rebind
{
- typedef typename _Tp::template rebind<_Up>::other type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Tp::template rebind<_Up>::other type;
};
#ifndef _LIBCPP_HAS_NO_VARIADICS
@@ -1279,13 +1278,13 @@ struct __allocator_traits_rebind
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, true>
{
- typedef typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc<_Tp, _Args...>::template rebind<_Up>::other type;
};
template <template <class, class...> class _Alloc, class _Tp, class ..._Args, class _Up>
struct __allocator_traits_rebind<_Alloc<_Tp, _Args...>, _Up, false>
{
- typedef _Alloc<_Up, _Args...> type;
+ typedef _LIBCPP_NODEBUG_TYPE _Alloc<_Up, _Args...> type;
};
#else // _LIBCPP_HAS_NO_VARIADICS
@@ -1493,13 +1492,13 @@ struct __has_select_on_container_copy_construction
template <class _Alloc, class _Ptr, bool = __has_difference_type<_Alloc>::value>
struct __alloc_traits_difference_type
{
- typedef typename pointer_traits<_Ptr>::difference_type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename pointer_traits<_Ptr>::difference_type type;
};
template <class _Alloc, class _Ptr>
struct __alloc_traits_difference_type<_Alloc, _Ptr, true>
{
- typedef typename _Alloc::difference_type type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Alloc::difference_type type;
};
template <class _Tp>
@@ -1534,7 +1533,7 @@ struct _LIBCPP_TEMPLATE_VIS allocator_traits
#ifndef _LIBCPP_CXX03_LANG
template <class _Tp> using rebind_alloc =
typename __allocator_traits_rebind<allocator_type, _Tp>::type;
- template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp>>;
+ template <class _Tp> using rebind_traits = allocator_traits<rebind_alloc<_Tp> >;
#else // _LIBCPP_CXX03_LANG
template <class _Tp> struct rebind_alloc
{typedef typename __allocator_traits_rebind<allocator_type, _Tp>::type other;};
@@ -1769,7 +1768,7 @@ template <class _Traits, class _Tp>
struct __rebind_alloc_helper
{
#ifndef _LIBCPP_CXX03_LANG
- typedef typename _Traits::template rebind_alloc<_Tp> type;
+ typedef _LIBCPP_NODEBUG_TYPE typename _Traits::template rebind_alloc<_Tp> type;
#else
typedef typename _Traits::template rebind_alloc<_Tp>::other type;
#endif
@@ -2210,8 +2209,8 @@ struct __second_tag {};
template <class _T1, class _T2>
class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
private __compressed_pair_elem<_T2, 1> {
- typedef __compressed_pair_elem<_T1, 0> _Base1;
- typedef __compressed_pair_elem<_T2, 1> _Base2;
+ typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T1, 0> _Base1;
+ typedef _LIBCPP_NODEBUG_TYPE __compressed_pair_elem<_T2, 1> _Base2;
// NOTE: This static assert should never fire because __compressed_pair
// is *almost never* used in a scenario where it's possible for T1 == T2.
@@ -2321,7 +2320,7 @@ struct _LIBCPP_TEMPLATE_VIS default_delete {
static_assert(!is_function<_Tp>::value,
"default_delete cannot be instantiated for function types");
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY constexpr default_delete() noexcept = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr default_delete() _NOEXCEPT = default;
#else
_LIBCPP_INLINE_VISIBILITY default_delete() {}
#endif
@@ -2349,7 +2348,7 @@ private:
public:
#ifndef _LIBCPP_CXX03_LANG
- _LIBCPP_INLINE_VISIBILITY constexpr default_delete() noexcept = default;
+ _LIBCPP_INLINE_VISIBILITY constexpr default_delete() _NOEXCEPT = default;
#else
_LIBCPP_INLINE_VISIBILITY default_delete() {}
#endif
@@ -2371,9 +2370,6 @@ public:
}
};
-
-
-#ifndef _LIBCPP_CXX03_LANG
template <class _Deleter>
struct __unique_ptr_deleter_sfinae {
static_assert(!is_reference<_Deleter>::value, "incorrect specialization");
@@ -2395,14 +2391,13 @@ struct __unique_ptr_deleter_sfinae<_Deleter&> {
typedef _Deleter&& __bad_rval_ref_type;
typedef false_type __enable_rval_overload;
};
-#endif // !defined(_LIBCPP_CXX03_LANG)
template <class _Tp, class _Dp = default_delete<_Tp> >
class _LIBCPP_TEMPLATE_VIS unique_ptr {
public:
typedef _Tp element_type;
typedef _Dp deleter_type;
- typedef typename __pointer_type<_Tp, deleter_type>::type pointer;
+ typedef _LIBCPP_NODEBUG_TYPE typename __pointer_type<_Tp, deleter_type>::type pointer;
static_assert(!is_rvalue_reference<deleter_type>::value,
"the specified deleter type cannot be an rvalue reference");
@@ -2412,39 +2407,38 @@ private:
struct __nat { int __for_bool_; };
-#ifndef _LIBCPP_CXX03_LANG
- typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
+ typedef _LIBCPP_NODEBUG_TYPE __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
template <bool _Dummy>
- using _LValRefType =
+ using _LValRefType _LIBCPP_NODEBUG_TYPE =
typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
template <bool _Dummy>
- using _GoodRValRefType =
+ using _GoodRValRefType _LIBCPP_NODEBUG_TYPE =
typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
template <bool _Dummy>
- using _BadRValRefType =
+ using _BadRValRefType _LIBCPP_NODEBUG_TYPE =
typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
template <bool _Dummy, class _Deleter = typename __dependent_type<
__identity<deleter_type>, _Dummy>::type>
- using _EnableIfDeleterDefaultConstructible =
+ using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE =
typename enable_if<is_default_constructible<_Deleter>::value &&
!is_pointer<_Deleter>::value>::type;
template <class _ArgType>
- using _EnableIfDeleterConstructible =
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE =
typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
template <class _UPtr, class _Up>
- using _EnableIfMoveConvertible = typename enable_if<
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
is_convertible<typename _UPtr::pointer, pointer>::value &&
!is_array<_Up>::value
>::type;
template <class _UDel>
- using _EnableIfDeleterConvertible = typename enable_if<
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
(is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
(!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
>::type;
@@ -2456,42 +2450,42 @@ private:
public:
template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy>>
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- constexpr unique_ptr() noexcept : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {}
template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy>>
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- constexpr unique_ptr(nullptr_t) noexcept : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {}
template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy>>
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(pointer __p) noexcept : __ptr_(__p) {}
+ explicit unique_ptr(pointer __p) _NOEXCEPT : __ptr_(__p) {}
template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_LValRefType<_Dummy>>>
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, _LValRefType<_Dummy> __d) noexcept
+ unique_ptr(pointer __p, _LValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(__p, __d) {}
template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy>>>
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) noexcept
+ unique_ptr(pointer __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(__p, _VSTD::move(__d)) {
static_assert(!is_reference<deleter_type>::value,
"rvalue deleter bound to reference");
}
template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy>>>
+ class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> > >
_LIBCPP_INLINE_VISIBILITY
unique_ptr(pointer __p, _BadRValRefType<_Dummy> __d) = delete;
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr&& __u) noexcept
+ unique_ptr(unique_ptr&& __u) _NOEXCEPT
: __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
}
@@ -2508,7 +2502,7 @@ public:
_LIBCPP_INLINE_VISIBILITY
unique_ptr(auto_ptr<_Up>&& __p,
typename enable_if<is_convertible<_Up*, _Tp*>::value &&
- is_same<_Dp, default_delete<_Tp>>::value,
+ is_same<_Dp, default_delete<_Tp> >::value,
__nat>::type = __nat()) _NOEXCEPT
: __ptr_(__p.release()) {}
#endif
@@ -2531,65 +2525,6 @@ public:
return *this;
}
-#else // _LIBCPP_CXX03_LANG
-private:
- unique_ptr(unique_ptr&);
- template <class _Up, class _Ep> unique_ptr(unique_ptr<_Up, _Ep>&);
-
- unique_ptr& operator=(unique_ptr&);
- template <class _Up, class _Ep> unique_ptr& operator=(unique_ptr<_Up, _Ep>&);
-
-public:
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr() : __ptr_(pointer())
- {
- static_assert(!is_pointer<deleter_type>::value,
- "unique_ptr constructed with null function pointer deleter");
- static_assert(is_default_constructible<deleter_type>::value,
- "unique_ptr::deleter_type is not default constructible");
- }
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t) : __ptr_(pointer())
- {
- static_assert(!is_pointer<deleter_type>::value,
- "unique_ptr constructed with null function pointer deleter");
- }
- _LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(pointer __p)
- : __ptr_(_VSTD::move(__p)) {
- static_assert(!is_pointer<deleter_type>::value,
- "unique_ptr constructed with null function pointer deleter");
- }
-
- _LIBCPP_INLINE_VISIBILITY
- operator __rv<unique_ptr>() {
- return __rv<unique_ptr>(*this);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(__rv<unique_ptr> __u)
- : __ptr_(__u->release(),
- _VSTD::forward<deleter_type>(__u->get_deleter())) {}
-
- template <class _Up, class _Ep>
- _LIBCPP_INLINE_VISIBILITY
- typename enable_if<
- !is_array<_Up>::value &&
- is_convertible<typename unique_ptr<_Up, _Ep>::pointer,
- pointer>::value &&
- is_assignable<deleter_type&, _Ep&>::value,
- unique_ptr&>::type
- operator=(unique_ptr<_Up, _Ep> __u) {
- reset(__u.release());
- __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
- return *this;
- }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, deleter_type __d)
- : __ptr_(_VSTD::move(__p), _VSTD::move(__d)) {}
-#endif // _LIBCPP_CXX03_LANG
-
#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
template <class _Up>
_LIBCPP_INLINE_VISIBILITY
@@ -2602,6 +2537,12 @@ public:
}
#endif
+#ifdef _LIBCPP_CXX03_LANG
+ unique_ptr(unique_ptr const&) = delete;
+ unique_ptr& operator=(unique_ptr const&) = delete;
+#endif
+
+
_LIBCPP_INLINE_VISIBILITY
~unique_ptr() { reset(); }
@@ -2681,39 +2622,38 @@ private:
>
{};
-#ifndef _LIBCPP_CXX03_LANG
typedef __unique_ptr_deleter_sfinae<_Dp> _DeleterSFINAE;
template <bool _Dummy>
- using _LValRefType =
+ using _LValRefType _LIBCPP_NODEBUG_TYPE =
typename __dependent_type<_DeleterSFINAE, _Dummy>::__lval_ref_type;
template <bool _Dummy>
- using _GoodRValRefType =
+ using _GoodRValRefType _LIBCPP_NODEBUG_TYPE =
typename __dependent_type<_DeleterSFINAE, _Dummy>::__good_rval_ref_type;
template <bool _Dummy>
- using _BadRValRefType =
+ using _BadRValRefType _LIBCPP_NODEBUG_TYPE =
typename __dependent_type<_DeleterSFINAE, _Dummy>::__bad_rval_ref_type;
template <bool _Dummy, class _Deleter = typename __dependent_type<
__identity<deleter_type>, _Dummy>::type>
- using _EnableIfDeleterDefaultConstructible =
+ using _EnableIfDeleterDefaultConstructible _LIBCPP_NODEBUG_TYPE =
typename enable_if<is_default_constructible<_Deleter>::value &&
!is_pointer<_Deleter>::value>::type;
template <class _ArgType>
- using _EnableIfDeleterConstructible =
+ using _EnableIfDeleterConstructible _LIBCPP_NODEBUG_TYPE =
typename enable_if<is_constructible<deleter_type, _ArgType>::value>::type;
template <class _Pp>
- using _EnableIfPointerConvertible = typename enable_if<
+ using _EnableIfPointerConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
_CheckArrayPointerConversion<_Pp>::value
>::type;
template <class _UPtr, class _Up,
class _ElemT = typename _UPtr::element_type>
- using _EnableIfMoveConvertible = typename enable_if<
+ using _EnableIfMoveConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
is_array<_Up>::value &&
is_same<pointer, element_type*>::value &&
is_same<typename _UPtr::pointer, _ElemT*>::value &&
@@ -2721,79 +2661,79 @@ private:
>::type;
template <class _UDel>
- using _EnableIfDeleterConvertible = typename enable_if<
+ using _EnableIfDeleterConvertible _LIBCPP_NODEBUG_TYPE = typename enable_if<
(is_reference<_Dp>::value && is_same<_Dp, _UDel>::value) ||
(!is_reference<_Dp>::value && is_convertible<_UDel, _Dp>::value)
>::type;
template <class _UDel>
- using _EnableIfDeleterAssignable = typename enable_if<
+ using _EnableIfDeleterAssignable _LIBCPP_NODEBUG_TYPE = typename enable_if<
is_assignable<_Dp&, _UDel&&>::value
>::type;
public:
template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy>>
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- constexpr unique_ptr() noexcept : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr() _NOEXCEPT : __ptr_(pointer()) {}
template <bool _Dummy = true,
- class = _EnableIfDeleterDefaultConstructible<_Dummy>>
+ class = _EnableIfDeleterDefaultConstructible<_Dummy> >
_LIBCPP_INLINE_VISIBILITY
- constexpr unique_ptr(nullptr_t) noexcept : __ptr_(pointer()) {}
+ _LIBCPP_CONSTEXPR unique_ptr(nullptr_t) _NOEXCEPT : __ptr_(pointer()) {}
template <class _Pp, bool _Dummy = true,
class = _EnableIfDeleterDefaultConstructible<_Dummy>,
- class = _EnableIfPointerConvertible<_Pp>>
+ class = _EnableIfPointerConvertible<_Pp> >
_LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(_Pp __p) noexcept
+ explicit unique_ptr(_Pp __p) _NOEXCEPT
: __ptr_(__p) {}
template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_LValRefType<_Dummy>>,
- class = _EnableIfPointerConvertible<_Pp>>
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) noexcept
+ unique_ptr(_Pp __p, _LValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(__p, __d) {}
template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_LValRefType<_Dummy>>>
+ class = _EnableIfDeleterConstructible<_LValRefType<_Dummy> > >
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) noexcept
+ unique_ptr(nullptr_t, _LValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(nullptr, __d) {}
template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy>>,
- class = _EnableIfPointerConvertible<_Pp>>
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) noexcept
+ unique_ptr(_Pp __p, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(__p, _VSTD::move(__d)) {
static_assert(!is_reference<deleter_type>::value,
"rvalue deleter bound to reference");
}
template <bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy>>>
+ class = _EnableIfDeleterConstructible<_GoodRValRefType<_Dummy> > >
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) noexcept
+ unique_ptr(nullptr_t, _GoodRValRefType<_Dummy> __d) _NOEXCEPT
: __ptr_(nullptr, _VSTD::move(__d)) {
static_assert(!is_reference<deleter_type>::value,
"rvalue deleter bound to reference");
}
template <class _Pp, bool _Dummy = true,
- class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy>>,
- class = _EnableIfPointerConvertible<_Pp>>
+ class = _EnableIfDeleterConstructible<_BadRValRefType<_Dummy> >,
+ class = _EnableIfPointerConvertible<_Pp> >
_LIBCPP_INLINE_VISIBILITY
unique_ptr(_Pp __p, _BadRValRefType<_Dummy> __d) = delete;
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr&& __u) noexcept
+ unique_ptr(unique_ptr&& __u) _NOEXCEPT
: __ptr_(__u.release(), _VSTD::forward<deleter_type>(__u.get_deleter())) {
}
_LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(unique_ptr&& __u) noexcept {
+ unique_ptr& operator=(unique_ptr&& __u) _NOEXCEPT {
reset(__u.release());
__ptr_.second() = _VSTD::forward<deleter_type>(__u.get_deleter());
return *this;
@@ -2804,7 +2744,7 @@ public:
class = _EnableIfDeleterConvertible<_Ep>
>
_LIBCPP_INLINE_VISIBILITY
- unique_ptr(unique_ptr<_Up, _Ep>&& __u) noexcept
+ unique_ptr(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT
: __ptr_(__u.release(), _VSTD::forward<_Ep>(__u.get_deleter())) {
}
@@ -2814,73 +2754,16 @@ public:
>
_LIBCPP_INLINE_VISIBILITY
unique_ptr&
- operator=(unique_ptr<_Up, _Ep>&& __u) noexcept {
+ operator=(unique_ptr<_Up, _Ep>&& __u) _NOEXCEPT {
reset(__u.release());
__ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter());
return *this;
}
-#else // _LIBCPP_CXX03_LANG
-private:
- template <class _Up> explicit unique_ptr(_Up);
-
- unique_ptr(unique_ptr&);
- template <class _Up> unique_ptr(unique_ptr<_Up>&);
-
- unique_ptr& operator=(unique_ptr&);
- template <class _Up> unique_ptr& operator=(unique_ptr<_Up>&);
-
- template <class _Up>
- unique_ptr(_Up __u,
- typename conditional<
- is_reference<deleter_type>::value, deleter_type,
- typename add_lvalue_reference<const deleter_type>::type>::type,
- typename enable_if<is_convertible<_Up, pointer>::value,
- __nat>::type = __nat());
-public:
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr() : __ptr_(pointer()) {
- static_assert(!is_pointer<deleter_type>::value,
- "unique_ptr constructed with null function pointer deleter");
- }
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t) : __ptr_(pointer()) {
- static_assert(!is_pointer<deleter_type>::value,
- "unique_ptr constructed with null function pointer deleter");
- }
-
- _LIBCPP_INLINE_VISIBILITY
- explicit unique_ptr(pointer __p) : __ptr_(__p) {
- static_assert(!is_pointer<deleter_type>::value,
- "unique_ptr constructed with null function pointer deleter");
- }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(pointer __p, deleter_type __d)
- : __ptr_(__p, _VSTD::forward<deleter_type>(__d)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(nullptr_t, deleter_type __d)
- : __ptr_(pointer(), _VSTD::forward<deleter_type>(__d)) {}
-
- _LIBCPP_INLINE_VISIBILITY
- operator __rv<unique_ptr>() {
- return __rv<unique_ptr>(*this);
- }
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr(__rv<unique_ptr> __u)
- : __ptr_(__u->release(),
- _VSTD::forward<deleter_type>(__u->get_deleter())) {}
-
- _LIBCPP_INLINE_VISIBILITY
- unique_ptr& operator=(__rv<unique_ptr> __u) {
- reset(__u->release());
- __ptr_.second() = _VSTD::forward<deleter_type>(__u->get_deleter());
- return *this;
- }
-
-#endif // _LIBCPP_CXX03_LANG
+#ifdef _LIBCPP_CXX03_LANG
+ unique_ptr(unique_ptr const&) = delete;
+ unique_ptr& operator=(unique_ptr const&) = delete;
+#endif
public:
_LIBCPP_INLINE_VISIBILITY
@@ -3092,18 +2975,6 @@ operator>=(nullptr_t, const unique_ptr<_T1, _D1>& __x)
return !(nullptr < __x);
}
-#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
-template <class _Tp, class _Dp>
-inline _LIBCPP_INLINE_VISIBILITY
-unique_ptr<_Tp, _Dp>
-move(unique_ptr<_Tp, _Dp>& __t)
-{
- return unique_ptr<_Tp, _Dp>(__rv<unique_ptr<_Tp, _Dp> >(__t));
-}
-
-#endif
-
#if _LIBCPP_STD_VER > 11
template<class _Tp>
@@ -3152,7 +3023,7 @@ template <class _Tp, class _Dp>
struct _LIBCPP_TEMPLATE_VIS hash<unique_ptr<_Tp, _Dp> >
#else
struct _LIBCPP_TEMPLATE_VIS hash<__enable_hash_helper<
- unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer>>
+ unique_ptr<_Tp, _Dp>, typename unique_ptr<_Tp, _Dp>::pointer> >
#endif
{
typedef unique_ptr<_Tp, _Dp> argument_type;
@@ -3207,10 +3078,10 @@ public:
template <class _Alloc>
class __allocator_destructor
{
- typedef allocator_traits<_Alloc> __alloc_traits;
+ typedef _LIBCPP_NODEBUG_TYPE allocator_traits<_Alloc> __alloc_traits;
public:
- typedef typename __alloc_traits::pointer pointer;
- typedef typename __alloc_traits::size_type size_type;
+ typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::pointer pointer;
+ typedef _LIBCPP_NODEBUG_TYPE typename __alloc_traits::size_type size_type;
private:
_Alloc& __alloc_;
size_type __s_;
@@ -3467,7 +3338,7 @@ uninitialized_move_n(_InputIt __first, _Size __n, _ForwardIt __first_res) {
&& defined(__ATOMIC_RELAXED) \
&& defined(__ATOMIC_ACQ_REL)
# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
-#elif !defined(__clang__) && defined(_GNUC_VER) && _GNUC_VER >= 407
+#elif defined(_LIBCPP_COMPILER_GCC)
# define _LIBCPP_HAS_BUILTIN_ATOMIC_SUPPORT
#endif
@@ -5669,6 +5540,52 @@ struct __is_allocator<_Alloc,
>
: true_type {};
+// __builtin_new_allocator -- A non-templated helper for allocating and
+// deallocating memory using __builtin_operator_new and
+// __builtin_operator_delete. It should be used in preference to
+// `std::allocator<T>` to avoid additional instantiations.
+struct __builtin_new_allocator {
+ struct __builtin_new_deleter {
+ typedef void* pointer_type;
+
+ _LIBCPP_CONSTEXPR explicit __builtin_new_deleter(size_t __size, size_t __align)
+ : __size_(__size), __align_(__align) {}
+
+ void operator()(void* p) const _NOEXCEPT {
+ std::__libcpp_deallocate(p, __size_, __align_);
+ }
+
+ private:
+ size_t __size_;
+ size_t __align_;
+ };
+
+ typedef unique_ptr<void, __builtin_new_deleter> __holder_t;
+
+ static __holder_t __allocate_bytes(size_t __s, size_t __align) {
+ return __holder_t(std::__libcpp_allocate(__s, __align),
+ __builtin_new_deleter(__s, __align));
+ }
+
+ static void __deallocate_bytes(void* __p, size_t __s,
+ size_t __align) _NOEXCEPT {
+ std::__libcpp_deallocate(__p, __s, __align);
+ }
+
+ template <class _Tp>
+ _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
+ static __holder_t __allocate_type(size_t __n) {
+ return __allocate_bytes(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+
+ template <class _Tp>
+ _LIBCPP_NODEBUG _LIBCPP_ALWAYS_INLINE
+ static void __deallocate_type(void* __p, size_t __n) _NOEXCEPT {
+ __deallocate_bytes(__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp));
+ }
+};
+
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
diff --git a/include/module.modulemap b/include/module.modulemap
index 6d88f52113cb..bbfe90ed57f5 100644
--- a/include/module.modulemap
+++ b/include/module.modulemap
@@ -24,7 +24,10 @@ module std [system] {
header "errno.h"
export *
}
- // <fenv.h> provided by C library.
+ module fenv_h {
+ header "fenv.h"
+ export *
+ }
// <float.h> provided by compiler or C library.
module inttypes_h {
header "inttypes.h"
diff --git a/include/mutex b/include/mutex
index 6d2de2b460e2..20c3ffc38b63 100644
--- a/include/mutex
+++ b/include/mutex
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- mutex ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -189,6 +188,7 @@ template<class Callable, class ...Args>
#include <__config>
#include <__mutex_base>
+#include <cstdint>
#include <functional>
#include <memory>
#ifndef _LIBCPP_CXX03_LANG
@@ -576,11 +576,18 @@ struct _LIBCPP_TEMPLATE_VIS once_flag
_LIBCPP_CONSTEXPR
once_flag() _NOEXCEPT : __state_(0) {}
+#if defined(_LIBCPP_ABI_MICROSOFT)
+ typedef uintptr_t _State_type;
+#else
+ typedef unsigned long _State_type;
+#endif
+
+
private:
once_flag(const once_flag&); // = delete;
once_flag& operator=(const once_flag&); // = delete;
- unsigned long __state_;
+ _State_type __state_;
#ifndef _LIBCPP_CXX03_LANG
template<class _Callable, class... _Args>
@@ -650,7 +657,8 @@ __call_once_proxy(void* __vp)
(*__p)();
}
-_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*));
+_LIBCPP_FUNC_VIS void __call_once(volatile once_flag::_State_type&, void*,
+ void (*)(void*));
#ifndef _LIBCPP_CXX03_LANG
@@ -659,7 +667,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable&& __func, _Args&&... __args)
{
- if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
+ if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
{
typedef tuple<_Callable&&, _Args&&...> _Gp;
_Gp __f(_VSTD::forward<_Callable>(__func), _VSTD::forward<_Args>(__args)...);
@@ -675,7 +683,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, _Callable& __func)
{
- if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
+ if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
{
__call_once_param<_Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<_Callable>);
@@ -687,7 +695,7 @@ inline _LIBCPP_INLINE_VISIBILITY
void
call_once(once_flag& __flag, const _Callable& __func)
{
- if (__libcpp_acquire_load(&__flag.__state_) != ~0ul)
+ if (__libcpp_acquire_load(&__flag.__state_) != ~once_flag::_State_type(0))
{
__call_once_param<const _Callable> __p(__func);
__call_once(__flag.__state_, &__p, &__call_once_proxy<const _Callable>);
diff --git a/include/new b/include/new
index 24ffcad5a6bc..85e4c4b3fcf2 100644
--- a/include/new
+++ b/include/new
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===----------------------------- new ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -34,6 +33,12 @@ public:
};
enum class align_val_t : size_t {}; // C++17
+
+struct destroying_delete_t { // C++20
+ explicit destroying_delete_t() = default;
+};
+inline constexpr destroying_delete_t destroying_delete{}; // C++20
+
struct nothrow_t {};
extern const nothrow_t nothrow;
typedef void (*new_handler)();
@@ -90,7 +95,7 @@ void operator delete[](void* ptr, void*) noexcept;
#include <cstdlib>
#endif
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_NO_VCRUNTIME)
+#if defined(_LIBCPP_ABI_VCRUNTIME)
#include <new.h>
#endif
@@ -120,7 +125,7 @@ void operator delete[](void* ptr, void*) noexcept;
namespace std // purposefully not using versioning namespace
{
-#if !defined(_LIBCPP_ABI_MICROSOFT) || defined(_LIBCPP_NO_VCRUNTIME)
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
struct _LIBCPP_TYPE_VIS nothrow_t {};
extern _LIBCPP_FUNC_VIS const nothrow_t nothrow;
@@ -146,12 +151,12 @@ typedef void (*new_handler)();
_LIBCPP_FUNC_VIS new_handler set_new_handler(new_handler) _NOEXCEPT;
_LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT;
-#endif // !_LIBCPP_ABI_MICROSOFT || _LIBCPP_NO_VCRUNTIME
+#endif // !_LIBCPP_ABI_VCRUNTIME
_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec
#if !defined(_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION) && \
- !defined(_LIBCPP_DEFER_NEW_TO_VCRUNTIME)
+ !defined(_LIBCPP_ABI_VCRUNTIME)
#ifndef _LIBCPP_CXX03_LANG
enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
#else
@@ -159,6 +164,15 @@ enum align_val_t { __zero = 0, __max = (size_t)-1 };
#endif
#endif
+#if _LIBCPP_STD_VER > 17
+// Enable the declaration even if the compiler doesn't support the language
+// feature.
+struct destroying_delete_t {
+ explicit destroying_delete_t() = default;
+};
+_LIBCPP_INLINE_VAR constexpr destroying_delete_t destroying_delete{};
+#endif // _LIBCPP_STD_VER > 17
+
} // std
#if defined(_LIBCPP_CXX03_LANG)
@@ -167,10 +181,10 @@ enum align_val_t { __zero = 0, __max = (size_t)-1 };
#define _THROW_BAD_ALLOC
#endif
-#if !defined(_LIBCPP_DEFER_NEW_TO_VCRUNTIME)
+#if !defined(_LIBCPP_ABI_VCRUNTIME)
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
@@ -178,7 +192,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operato
#endif
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz) _THROW_BAD_ALLOC;
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
@@ -187,7 +201,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operato
#ifndef _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete(void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
@@ -195,7 +209,7 @@ _LIBCPP_OVERRIDABLE_FUNC_VIS _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE void operato
#endif
_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t) _THROW_BAD_ALLOC;
-_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _NOALIAS;
+_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new[](std::size_t __sz, std::align_val_t, const std::nothrow_t&) _NOEXCEPT _LIBCPP_NOALIAS;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t) _NOEXCEPT;
_LIBCPP_OVERRIDABLE_FUNC_VIS void operator delete[](void* __p, std::align_val_t, const std::nothrow_t&) _NOEXCEPT;
#ifndef _LIBCPP_HAS_NO_LIBRARY_SIZED_DEALLOCATION
@@ -208,7 +222,7 @@ _LIBCPP_NODISCARD_AFTER_CXX17 inline _LIBCPP_INLINE_VISIBILITY void* operator ne
inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {}
inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {}
-#endif // !_LIBCPP_DEFER_NEW_TO_VCRUNTIME
+#endif // !_LIBCPP_ABI_VCRUNTIME
_LIBCPP_BEGIN_NAMESPACE_STD
diff --git a/include/numeric b/include/numeric
index 4e68239d059e..2118704d57f3 100644
--- a/include/numeric
+++ b/include/numeric
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- numeric ---------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -134,6 +133,10 @@ template <class M, class N>
template <class M, class N>
constexpr common_type_t<M,N> lcm(M m, N n); // C++17
+integer midpoint(integer a, integer b); // C++20
+pointer midpoint(pointer a, pointer b); // C++20
+floating_point midpoint(floating_point a, floating_point b); // C++20
+
} // std
*/
@@ -142,6 +145,7 @@ template <class M, class N>
#include <iterator>
#include <limits> // for numeric_limits
#include <functional>
+#include <cmath> // for isnormal
#include <version>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@@ -456,10 +460,10 @@ iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value_)
#if _LIBCPP_STD_VER > 14
-template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __abs;
+template <typename _Result, typename _Source, bool _IsSigned = is_signed<_Source>::value> struct __ct_abs;
template <typename _Result, typename _Source>
-struct __abs<_Result, _Source, true> {
+struct __ct_abs<_Result, _Source, true> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept
{
@@ -470,7 +474,7 @@ struct __abs<_Result, _Source, true> {
};
template <typename _Result, typename _Source>
-struct __abs<_Result, _Source, false> {
+struct __ct_abs<_Result, _Source, false> {
_LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
_Result operator()(_Source __t) const noexcept { return __t; }
};
@@ -496,8 +500,8 @@ gcd(_Tp __m, _Up __n)
using _Rp = common_type_t<_Tp,_Up>;
using _Wp = make_unsigned_t<_Rp>;
return static_cast<_Rp>(_VSTD::__gcd(
- static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
- static_cast<_Wp>(__abs<_Rp, _Up>()(__n))));
+ static_cast<_Wp>(__ct_abs<_Rp, _Tp>()(__m)),
+ static_cast<_Wp>(__ct_abs<_Rp, _Up>()(__n))));
}
template<class _Tp, class _Up>
@@ -512,14 +516,72 @@ lcm(_Tp __m, _Up __n)
return 0;
using _Rp = common_type_t<_Tp,_Up>;
- _Rp __val1 = __abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n);
- _Rp __val2 = __abs<_Rp, _Up>()(__n);
+ _Rp __val1 = __ct_abs<_Rp, _Tp>()(__m) / _VSTD::gcd(__m, __n);
+ _Rp __val2 = __ct_abs<_Rp, _Up>()(__n);
_LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow in lcm");
return __val1 * __val2;
}
#endif /* _LIBCPP_STD_VER > 14 */
+#if _LIBCPP_STD_VER > 17
+template <class _Tp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<is_integral_v<_Tp> && !is_same_v<bool, _Tp> && !is_null_pointer_v<_Tp>, _Tp>
+midpoint(_Tp __a, _Tp __b) noexcept
+_LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK
+{
+ using _Up = std::make_unsigned_t<_Tp>;
+
+ int __sign = 1;
+ _Up __m = __a;
+ _Up __M = __b;
+ if (__a > __b)
+ {
+ __sign = -1;
+ __m = __b;
+ __M = __a;
+ }
+ return __a + __sign * _Tp(_Up(__M-__m) >> 1);
+}
+
+
+template <class _TPtr>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<is_pointer_v<_TPtr>
+ && is_object_v<remove_pointer_t<_TPtr>>
+ && ! is_void_v<remove_pointer_t<_TPtr>>
+ && (sizeof(remove_pointer_t<_TPtr>) > 0), _TPtr>
+midpoint(_TPtr __a, _TPtr __b) noexcept
+{
+ return __a + _VSTD::midpoint(ptrdiff_t(0), __b - __a);
+}
+
+
+template <typename _Tp>
+constexpr int __sign(_Tp __val) {
+ return (_Tp(0) < __val) - (__val < _Tp(0));
+}
+
+template <typename _Fp>
+constexpr _Fp __fp_abs(_Fp __f) { return __f >= 0 ? __f : -__f; }
+
+template <class _Fp>
+_LIBCPP_INLINE_VISIBILITY constexpr
+enable_if_t<is_floating_point_v<_Fp>, _Fp>
+midpoint(_Fp __a, _Fp __b) noexcept
+{
+ constexpr _Fp __lo = numeric_limits<_Fp>::min()*2;
+ constexpr _Fp __hi = numeric_limits<_Fp>::max()/2;
+ return __fp_abs(__a) <= __hi && __fp_abs(__b) <= __hi ? // typical case: overflow is impossible
+ (__a + __b)/2 : // always correctly rounded
+ __fp_abs(__a) < __lo ? __a + __b/2 : // not safe to halve a
+ __fp_abs(__a) < __lo ? __a/2 + __b : // not safe to halve b
+ __a/2 + __b/2; // otherwise correctly rounded
+}
+
+#endif // _LIBCPP_STD_VER > 17
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS
diff --git a/include/optional b/include/optional
index 70422068e285..a147d69da00f 100644
--- a/include/optional
+++ b/include/optional
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- optional ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -593,7 +592,7 @@ public:
private:
// Disable the reference extension using this static assert.
- static_assert(!is_same_v<value_type, in_place_t>,
+ static_assert(!is_same_v<__uncvref_t<value_type>, in_place_t>,
"instantiation of optional with in_place_t is ill-formed");
static_assert(!is_same_v<__uncvref_t<value_type>, nullopt_t>,
"instantiation of optional with nullopt_t is ill-formed");
@@ -601,6 +600,8 @@ private:
"instantiation of optional with a reference type is ill-formed");
static_assert(is_destructible_v<value_type>,
"instantiation of optional with a non-destructible type is ill-formed");
+ static_assert(!is_array_v<value_type>,
+ "instantiation of optional with an array type is ill-formed");
// LWG2756: conditionally explicit conversion from _Up
struct _CheckOptionalArgsConstructor {
@@ -617,16 +618,16 @@ private:
}
};
template <class _Up>
- using _CheckOptionalArgsCtor = conditional_t<
- !is_same_v<__uncvref_t<_Up>, in_place_t> &&
- !is_same_v<__uncvref_t<_Up>, optional>,
+ using _CheckOptionalArgsCtor = _If<
+ _IsNotSame<__uncvref_t<_Up>, in_place_t>::value &&
+ _IsNotSame<__uncvref_t<_Up>, optional>::value,
_CheckOptionalArgsConstructor,
__check_tuple_constructor_fail
>;
template <class _QualUp>
struct _CheckOptionalLikeConstructor {
template <class _Up, class _Opt = optional<_Up>>
- using __check_constructible_from_opt = __lazy_or<
+ using __check_constructible_from_opt = _Or<
is_constructible<_Tp, _Opt&>,
is_constructible<_Tp, _Opt const&>,
is_constructible<_Tp, _Opt&&>,
@@ -637,7 +638,7 @@ private:
is_convertible<_Opt const&&, _Tp>
>;
template <class _Up, class _Opt = optional<_Up>>
- using __check_assignable_from_opt = __lazy_or<
+ using __check_assignable_from_opt = _Or<
is_assignable<_Tp&, _Opt&>,
is_assignable<_Tp&, _Opt const&>,
is_assignable<_Tp&, _Opt&&>,
@@ -663,18 +664,18 @@ private:
};
template <class _Up, class _QualUp>
- using _CheckOptionalLikeCtor = conditional_t<
- __lazy_and<
- __lazy_not<is_same<_Up, _Tp>>,
+ using _CheckOptionalLikeCtor = _If<
+ _And<
+ _IsNotSame<_Up, _Tp>,
is_constructible<_Tp, _QualUp>
>::value,
_CheckOptionalLikeConstructor<_QualUp>,
__check_tuple_constructor_fail
>;
template <class _Up, class _QualUp>
- using _CheckOptionalLikeAssign = conditional_t<
- __lazy_and<
- __lazy_not<is_same<_Up, _Tp>>,
+ using _CheckOptionalLikeAssign = _If<
+ _And<
+ _IsNotSame<_Up, _Tp>,
is_constructible<_Tp, _QualUp>,
is_assignable<_Tp&, _QualUp>
>::value,
@@ -688,28 +689,32 @@ public:
_LIBCPP_INLINE_VISIBILITY constexpr optional(optional&&) = default;
_LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {}
- template <class... _Args, class = enable_if_t<
- is_constructible_v<value_type, _Args...>>
+ template <class _InPlaceT, class... _Args, class = _EnableIf<
+ _And<
+ _IsSame<_InPlaceT, in_place_t>,
+ is_constructible<value_type, _Args...>
+ >::value
+ >
>
_LIBCPP_INLINE_VISIBILITY
- constexpr explicit optional(in_place_t, _Args&&... __args)
+ constexpr explicit optional(_InPlaceT, _Args&&... __args)
: __base(in_place, _VSTD::forward<_Args>(__args)...) {}
- template <class _Up, class... _Args, class = enable_if_t<
+ template <class _Up, class... _Args, class = _EnableIf<
is_constructible_v<value_type, initializer_list<_Up>&, _Args...>>
>
_LIBCPP_INLINE_VISIBILITY
constexpr explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args)
: __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {}
- template <class _Up = value_type, enable_if_t<
+ template <class _Up = value_type, _EnableIf<
_CheckOptionalArgsCtor<_Up>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
constexpr optional(_Up&& __v)
: __base(in_place, _VSTD::forward<_Up>(__v)) {}
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalArgsCtor<_Up>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -717,7 +722,7 @@ public:
: __base(in_place, _VSTD::forward<_Up>(__v)) {}
// LWG2756: conditionally explicit conversion from const optional<_Up>&
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -725,7 +730,7 @@ public:
{
this->__construct_from(__v);
}
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalLikeCtor<_Up, _Up const&>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -735,7 +740,7 @@ public:
}
// LWG2756: conditionally explicit conversion from optional<_Up>&&
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_implicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -743,7 +748,7 @@ public:
{
this->__construct_from(_VSTD::move(__v));
}
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_explicit<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -764,11 +769,12 @@ public:
// LWG2756
template <class _Up = value_type,
- class = enable_if_t
- <__lazy_and<
- integral_constant<bool,
- !is_same_v<__uncvref_t<_Up>, optional> &&
- !(is_same_v<_Up, value_type> && is_scalar_v<value_type>)
+ class = _EnableIf<
+ _And<
+ _IsNotSame<__uncvref_t<_Up>, optional>,
+ _Or<
+ _IsNotSame<__uncvref_t<_Up>, value_type>,
+ _Not<is_scalar<value_type>>
>,
is_constructible<value_type, _Up>,
is_assignable<value_type&, _Up>
@@ -786,7 +792,7 @@ public:
}
// LWG2756
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalLikeAssign<_Up, _Up const&>::template __enable_assign<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -798,7 +804,7 @@ public:
}
// LWG2756
- template <class _Up, enable_if_t<
+ template <class _Up, _EnableIf<
_CheckOptionalLikeCtor<_Up, _Up &&>::template __enable_assign<_Up>()
, int> = 0>
_LIBCPP_INLINE_VISIBILITY
@@ -810,7 +816,7 @@ public:
}
template <class... _Args,
- class = enable_if_t
+ class = _EnableIf
<
is_constructible_v<value_type, _Args...>
>
@@ -825,7 +831,7 @@ public:
}
template <class _Up, class... _Args,
- class = enable_if_t
+ class = _EnableIf
<
is_constructible_v<value_type, initializer_list<_Up>&, _Args...>
>
@@ -1021,7 +1027,7 @@ template<class T>
// Comparisons between optionals
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() ==
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1037,7 +1043,7 @@ operator==(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() !=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1053,7 +1059,7 @@ operator!=(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1069,7 +1075,7 @@ operator<(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1085,7 +1091,7 @@ operator>(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1101,7 +1107,7 @@ operator<=(const optional<_Tp>& __x, const optional<_Up>& __y)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1215,7 +1221,7 @@ operator>=(nullopt_t, const optional<_Tp>& __x) noexcept
// Comparisons with T
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() ==
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1227,7 +1233,7 @@ operator==(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() ==
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1239,7 +1245,7 @@ operator==(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() !=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1251,7 +1257,7 @@ operator!=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() !=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1263,7 +1269,7 @@ operator!=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1275,7 +1281,7 @@ operator<(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1287,7 +1293,7 @@ operator<(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1299,7 +1305,7 @@ operator<=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() <=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1311,7 +1317,7 @@ operator<=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1323,7 +1329,7 @@ operator>(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1335,7 +1341,7 @@ operator>(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1347,7 +1353,7 @@ operator>=(const optional<_Tp>& __x, const _Up& __v)
template <class _Tp, class _Up>
_LIBCPP_INLINE_VISIBILITY constexpr
-enable_if_t<
+_EnableIf<
is_convertible_v<decltype(_VSTD::declval<const _Tp&>() >=
_VSTD::declval<const _Up&>()), bool>,
bool
@@ -1360,7 +1366,7 @@ operator>=(const _Tp& __v, const optional<_Up>& __x)
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY
-enable_if_t<
+_EnableIf<
is_move_constructible_v<_Tp> && is_swappable_v<_Tp>,
void
>
diff --git a/include/ostream b/include/ostream
index d700a369b34a..e6cf9c970f72 100644
--- a/include/ostream
+++ b/include/ostream
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===-------------------------- ostream -----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -57,6 +56,7 @@ public:
basic_ostream& operator<<(long double f);
basic_ostream& operator<<(const void* p);
basic_ostream& operator<<(basic_streambuf<char_type,traits>* sb);
+ basic_ostream& operator<<(nullptr_t);
// 27.7.2.7 Unformatted output:
basic_ostream& put(char_type c);
@@ -219,6 +219,10 @@ public:
basic_ostream& operator<<(const void* __p);
basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
+ _LIBCPP_INLINE_VISIBILITY
+ basic_ostream& operator<<(nullptr_t)
+ { return *this << "nullptr"; }
+
// 27.7.2.7 Unformatted output:
basic_ostream& put(char_type __c);
basic_ostream& write(const char_type* __s, streamsize __n);
diff --git a/include/queue b/include/queue
index 4677e52ae3a7..97ec6f633c51 100644
--- a/include/queue
+++ b/include/queue
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===--------------------------- queue ------------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -71,8 +70,8 @@ public:
template<class Container>
queue(Container) -> queue<typename Container::value_type, Container>; // C++17
-
-template<class Container, class Allocator>
+
+template<class Container, class Allocator>
queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17
template <class T, class Container>
@@ -166,13 +165,13 @@ public:
template <class Compare, class Container>
priority_queue(Compare, Container)
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17
-
-template<class InputIterator,
+
+template<class InputIterator,
class Compare = less<typename iterator_traits<InputIterator>::value_type>,
class Container = vector<typename iterator_traits<InputIterator>::value_type>>
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
-> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17
-
+