From 76d0caaeb19ae0808d90af1d0b3b7b50b3e5383f Mon Sep 17 00:00:00 2001 From: patrick Date: Fri, 17 Dec 2021 12:26:13 +0000 Subject: [PATCH] Import LLVM 13.0.0 release. --- gnu/llvm/libcxx/.clang-format | 3 + gnu/llvm/libcxx/.gitignore | 55 + gnu/llvm/libcxx/CMakeLists.txt | 272 +- gnu/llvm/libcxx/appveyor-reqs-install.cmd | 53 + gnu/llvm/libcxx/appveyor.yml | 71 + gnu/llvm/libcxx/benchmarks/CMakeLists.txt | 31 +- .../libcxx/benchmarks/VariantBenchmarks.h | 58 + .../libcxx/benchmarks/filesystem.bench.cpp | 2 +- gnu/llvm/libcxx/benchmarks/map.bench.cpp | 1037 ++++ gnu/llvm/libcxx/benchmarks/to_chars.bench.cpp | 58 + .../benchmarks/variant_visit_1.bench.cpp | 27 + .../benchmarks/variant_visit_2.bench.cpp | 22 + .../benchmarks/variant_visit_3.bench.cpp | 20 + .../cmake/Modules/DefineLinkerScript.cmake | 15 +- .../cmake/Modules/HandleLibCXXABI.cmake | 20 +- .../cmake/Modules/HandleLibcxxFlags.cmake | 11 + .../cmake/Modules/HandleOutOfTreeLLVM.cmake | 12 +- gnu/llvm/libcxx/cmake/caches/AArch64.cmake | 2 + gnu/llvm/libcxx/cmake/caches/Apple.cmake | 12 +- gnu/llvm/libcxx/cmake/caches/Armv7Arm.cmake | 4 + .../caches/Armv7Thumb-noexceptions.cmake | 6 + gnu/llvm/libcxx/cmake/caches/Armv8Arm.cmake | 4 + .../caches/Armv8Thumb-noexceptions.cmake | 6 + gnu/llvm/libcxx/cmake/caches/FreeBSD.cmake | 9 + .../cmake/caches/Generic-assertions.cmake | 1 + .../libcxx/cmake/caches/Generic-cxx20.cmake | 2 + .../libcxx/cmake/caches/Generic-cxx2b.cmake | 2 + .../caches/Generic-debug-iterators.cmake | 2 + .../libcxx/cmake/caches/Generic-modules.cmake | 2 + .../cmake/caches/Generic-no-debug.cmake | 1 + .../cmake/caches/Generic-no-filesystem.cmake | 1 + .../caches/Generic-no-localization.cmake | 1 + .../caches/Generic-no-random_device.cmake | 1 + .../libcxx/cmake/caches/Generic-static.cmake | 3 + gnu/llvm/libcxx/cmake/config-ix.cmake | 24 +- gnu/llvm/libcxx/docs/AddingNewCIJobs.rst | 68 + gnu/llvm/libcxx/docs/BuildingLibcxx.rst | 336 +- gnu/llvm/libcxx/docs/Contributing.rst | 68 + .../libcxx/docs/DesignDocs/ABIVersioning.rst | 27 +- .../libcxx/docs/DesignDocs/AtomicDesign.rst | 797 +++ gnu/llvm/libcxx/docs/DesignDocs/DebugMode.rst | 97 +- .../docs/DesignDocs/FeatureTestMacros.rst | 8 +- .../libcxx/docs/DesignDocs/FileTimeType.rst | 2 +- .../libcxx/docs/DesignDocs/NoexceptPolicy.rst | 13 + .../docs/DesignDocs/UniquePtrTrivialAbi.rst | 149 + .../docs/DesignDocs/VisibilityMacros.rst | 12 +- .../libcxx/docs/FeatureTestMacroTable.rst | 283 +- gnu/llvm/libcxx/docs/Helpers/Styles.rst | 31 + gnu/llvm/libcxx/docs/README.txt | 4 + gnu/llvm/libcxx/docs/ReleaseNotes.rst | 85 +- gnu/llvm/libcxx/docs/Status/Cxx14.rst | 52 + gnu/llvm/libcxx/docs/Status/Cxx14Issues.csv | 157 + gnu/llvm/libcxx/docs/Status/Cxx14Papers.csv | 32 + gnu/llvm/libcxx/docs/Status/Cxx17.rst | 57 + gnu/llvm/libcxx/docs/Status/Cxx17Issues.csv | 318 + gnu/llvm/libcxx/docs/Status/Cxx17Papers.csv | 113 + gnu/llvm/libcxx/docs/Status/Cxx20.rst | 59 + gnu/llvm/libcxx/docs/Status/Cxx20Issues.csv | 300 + gnu/llvm/libcxx/docs/Status/Cxx20Papers.csv | 202 + gnu/llvm/libcxx/docs/Status/Cxx2b.rst | 50 + gnu/llvm/libcxx/docs/Status/Cxx2bIssues.csv | 99 + gnu/llvm/libcxx/docs/Status/Cxx2bPapers.csv | 25 + gnu/llvm/libcxx/docs/Status/Format.rst | 53 + gnu/llvm/libcxx/docs/Status/FormatIssues.csv | 31 + gnu/llvm/libcxx/docs/Status/FormatPaper.csv | 48 + gnu/llvm/libcxx/docs/Status/Ranges.rst | 51 + gnu/llvm/libcxx/docs/Status/RangesIssues.csv | 80 + gnu/llvm/libcxx/docs/Status/RangesPaper.csv | 149 + gnu/llvm/libcxx/docs/TestingLibcxx.rst | 39 +- gnu/llvm/libcxx/docs/UsingLibcxx.rst | 242 +- gnu/llvm/libcxx/docs/conf.py | 9 +- gnu/llvm/libcxx/docs/index.rst | 142 +- gnu/llvm/libcxx/include/CMakeLists.txt | 360 +- .../include/__algorithm/adjacent_find.h | 51 + gnu/llvm/libcxx/include/__algorithm/all_of.h | 37 + gnu/llvm/libcxx/include/__algorithm/any_of.h | 37 + .../include/__algorithm/binary_search.h | 61 + gnu/llvm/libcxx/include/__algorithm/clamp.h | 52 + gnu/llvm/libcxx/include/__algorithm/comp.h | 97 + .../include/__algorithm/comp_ref_type.h | 87 + gnu/llvm/libcxx/include/__algorithm/copy.h | 82 + .../include/__algorithm/copy_backward.h | 84 + gnu/llvm/libcxx/include/__algorithm/copy_if.h | 48 + gnu/llvm/libcxx/include/__algorithm/copy_n.h | 72 + gnu/llvm/libcxx/include/__algorithm/count.h | 40 + .../libcxx/include/__algorithm/count_if.h | 40 + gnu/llvm/libcxx/include/__algorithm/equal.h | 90 + .../libcxx/include/__algorithm/equal_range.h | 87 + gnu/llvm/libcxx/include/__algorithm/fill.h | 55 + gnu/llvm/libcxx/include/__algorithm/fill_n.h | 47 + gnu/llvm/libcxx/include/__algorithm/find.h | 37 + .../libcxx/include/__algorithm/find_end.h | 154 + .../include/__algorithm/find_first_of.h | 57 + gnu/llvm/libcxx/include/__algorithm/find_if.h | 37 + .../libcxx/include/__algorithm/find_if_not.h | 37 + .../libcxx/include/__algorithm/for_each.h | 37 + .../libcxx/include/__algorithm/for_each_n.h | 47 + .../libcxx/include/__algorithm/generate.h | 36 + .../libcxx/include/__algorithm/generate_n.h | 40 + .../include/__algorithm/half_positive.h | 54 + .../libcxx/include/__algorithm/includes.h | 67 + .../include/__algorithm/inplace_merge.h | 231 + gnu/llvm/libcxx/include/__algorithm/is_heap.h | 48 + .../include/__algorithm/is_heap_until.h | 65 + .../include/__algorithm/is_partitioned.h | 43 + .../include/__algorithm/is_permutation.h | 168 + .../libcxx/include/__algorithm/is_sorted.h | 48 + .../include/__algorithm/is_sorted_until.h | 55 + .../libcxx/include/__algorithm/iter_swap.h | 37 + .../__algorithm/lexicographical_compare.h | 68 + .../libcxx/include/__algorithm/lower_bound.h | 72 + .../libcxx/include/__algorithm/make_heap.h | 64 + gnu/llvm/libcxx/include/__algorithm/max.h | 70 + .../libcxx/include/__algorithm/max_element.h | 58 + gnu/llvm/libcxx/include/__algorithm/merge.h | 76 + gnu/llvm/libcxx/include/__algorithm/min.h | 70 + .../libcxx/include/__algorithm/min_element.h | 57 + gnu/llvm/libcxx/include/__algorithm/minmax.h | 101 + .../include/__algorithm/minmax_element.h | 90 + .../libcxx/include/__algorithm/mismatch.h | 72 + gnu/llvm/libcxx/include/__algorithm/move.h | 83 + .../include/__algorithm/move_backward.h | 84 + .../include/__algorithm/next_permutation.h | 77 + gnu/llvm/libcxx/include/__algorithm/none_of.h | 37 + .../libcxx/include/__algorithm/nth_element.h | 244 + .../libcxx/include/__algorithm/partial_sort.h | 71 + .../include/__algorithm/partial_sort_copy.h | 77 + .../libcxx/include/__algorithm/partition.h | 88 + .../include/__algorithm/partition_copy.h | 52 + .../include/__algorithm/partition_point.h | 51 + .../libcxx/include/__algorithm/pop_heap.h | 62 + .../include/__algorithm/prev_permutation.h | 77 + .../libcxx/include/__algorithm/push_heap.h | 75 + gnu/llvm/libcxx/include/__algorithm/remove.h | 50 + .../libcxx/include/__algorithm/remove_copy.h | 43 + .../include/__algorithm/remove_copy_if.h | 43 + .../libcxx/include/__algorithm/remove_if.h | 51 + gnu/llvm/libcxx/include/__algorithm/replace.h | 37 + .../libcxx/include/__algorithm/replace_copy.h | 41 + .../include/__algorithm/replace_copy_if.h | 41 + .../libcxx/include/__algorithm/replace_if.h | 37 + gnu/llvm/libcxx/include/__algorithm/reverse.h | 61 + .../libcxx/include/__algorithm/reverse_copy.h | 37 + gnu/llvm/libcxx/include/__algorithm/rotate.h | 205 + .../libcxx/include/__algorithm/rotate_copy.h | 38 + gnu/llvm/libcxx/include/__algorithm/sample.h | 101 + gnu/llvm/libcxx/include/__algorithm/search.h | 131 + .../libcxx/include/__algorithm/search_n.h | 116 + .../include/__algorithm/set_difference.h | 77 + .../include/__algorithm/set_intersection.h | 74 + .../__algorithm/set_symmetric_difference.h | 82 + .../libcxx/include/__algorithm/set_union.h | 77 + .../libcxx/include/__algorithm/shift_left.h | 61 + .../libcxx/include/__algorithm/shift_right.h | 106 + gnu/llvm/libcxx/include/__algorithm/shuffle.h | 127 + .../libcxx/include/__algorithm/sift_down.h | 84 + gnu/llvm/libcxx/include/__algorithm/sort.h | 530 ++ .../libcxx/include/__algorithm/sort_heap.h | 58 + .../include/__algorithm/stable_partition.h | 305 + .../libcxx/include/__algorithm/stable_sort.h | 235 + .../libcxx/include/__algorithm/swap_ranges.h | 37 + .../libcxx/include/__algorithm/transform.h | 48 + gnu/llvm/libcxx/include/__algorithm/unique.h | 63 + .../libcxx/include/__algorithm/unique_copy.h | 114 + .../libcxx/include/__algorithm/unwrap_iter.h | 87 + .../libcxx/include/__algorithm/upper_bound.h | 72 + gnu/llvm/libcxx/include/__availability | 270 + gnu/llvm/libcxx/include/__bit_reference | 66 +- gnu/llvm/libcxx/include/__bits | 145 + .../libcxx/include/__bsd_locale_fallbacks.h | 4 +- gnu/llvm/libcxx/include/__config_site.in | 8 +- gnu/llvm/libcxx/include/__debug | 41 +- gnu/llvm/libcxx/include/__errc | 2 +- .../libcxx/include/__format/format_error.h | 56 + .../include/__format/format_parse_context.h | 113 + gnu/llvm/libcxx/include/__function_like.h | 56 + .../include/__functional/binary_function.h | 31 + .../include/__functional/binary_negate.h | 50 + gnu/llvm/libcxx/include/__functional/bind.h | 386 ++ .../libcxx/include/__functional/bind_front.h | 52 + .../libcxx/include/__functional/binder1st.h | 54 + .../libcxx/include/__functional/binder2nd.h | 54 + .../include/__functional/default_searcher.h | 56 + .../libcxx/include/__functional/function.h | 2809 +++++++++ gnu/llvm/libcxx/include/__functional/hash.h | 873 +++ .../libcxx/include/__functional/identity.h | 37 + gnu/llvm/libcxx/include/__functional/invoke.h | 100 + .../include/__functional/is_transparent.h | 36 + gnu/llvm/libcxx/include/__functional/mem_fn.h | 161 + .../libcxx/include/__functional/mem_fun_ref.h | 173 + gnu/llvm/libcxx/include/__functional/not_fn.h | 47 + .../libcxx/include/__functional/operations.h | 729 +++ .../include/__functional/perfect_forward.h | 88 + .../__functional/pointer_to_binary_function.h | 46 + .../__functional/pointer_to_unary_function.h | 46 + .../include/__functional/ranges_operations.h | 97 + .../include/__functional/reference_wrapper.h | 223 + .../include/__functional/unary_function.h | 34 + .../include/__functional/unary_negate.h | 47 + .../libcxx/include/__functional/unwrap_ref.h | 62 + .../include/__functional/weak_result_type.h | 481 ++ gnu/llvm/libcxx/include/__functional_base | 642 +- gnu/llvm/libcxx/include/__hash_table | 292 +- gnu/llvm/libcxx/include/__iterator/access.h | 134 + gnu/llvm/libcxx/include/__iterator/advance.h | 200 + .../include/__iterator/back_insert_iterator.h | 75 + .../include/__iterator/common_iterator.h | 301 + gnu/llvm/libcxx/include/__iterator/concepts.h | 272 + .../include/__iterator/counted_iterator.h | 306 + gnu/llvm/libcxx/include/__iterator/data.h | 56 + .../include/__iterator/default_sentinel.h | 35 + gnu/llvm/libcxx/include/__iterator/distance.h | 56 + gnu/llvm/libcxx/include/__iterator/empty.h | 49 + .../include/__iterator/erase_if_container.h | 45 + .../__iterator/front_insert_iterator.h | 75 + .../include/__iterator/incrementable_traits.h | 77 + .../include/__iterator/insert_iterator.h | 77 + .../include/__iterator/istream_iterator.h | 103 + .../include/__iterator/istreambuf_iterator.h | 110 + .../libcxx/include/__iterator/iter_move.h | 91 + .../libcxx/include/__iterator/iter_swap.h | 107 + gnu/llvm/libcxx/include/__iterator/iterator.h | 40 + .../include/__iterator/iterator_traits.h | 500 ++ .../libcxx/include/__iterator/move_iterator.h | 189 + gnu/llvm/libcxx/include/__iterator/next.h | 87 + .../include/__iterator/ostream_iterator.h | 75 + .../include/__iterator/ostreambuf_iterator.h | 81 + gnu/llvm/libcxx/include/__iterator/prev.h | 79 + .../libcxx/include/__iterator/projected.h | 45 + .../include/__iterator/readable_traits.h | 91 + .../include/__iterator/reverse_access.h | 109 + .../include/__iterator/reverse_iterator.h | 239 + gnu/llvm/libcxx/include/__iterator/size.h | 58 + .../libcxx/include/__iterator/wrap_iter.h | 300 + gnu/llvm/libcxx/include/__libcpp_version | 2 +- gnu/llvm/libcxx/include/__memory/addressof.h | 96 + .../include/__memory/allocation_guard.h | 89 + gnu/llvm/libcxx/include/__memory/allocator.h | 254 + .../libcxx/include/__memory/allocator_arg_t.h | 78 + .../include/__memory/allocator_traits.h | 405 ++ gnu/llvm/libcxx/include/__memory/auto_ptr.h | 86 + .../libcxx/include/__memory/compressed_pair.h | 201 + .../libcxx/include/__memory/construct_at.h | 59 + .../libcxx/include/__memory/pointer_safety.h | 57 + .../libcxx/include/__memory/pointer_traits.h | 216 + .../include/__memory/raw_storage_iterator.h | 73 + gnu/llvm/libcxx/include/__memory/shared_ptr.h | 1879 ++++++ .../include/__memory/temporary_buffer.h | 89 + .../__memory/uninitialized_algorithms.h | 261 + gnu/llvm/libcxx/include/__memory/unique_ptr.h | 773 +++ .../libcxx/include/__memory/uses_allocator.h | 60 + gnu/llvm/libcxx/include/__mutex_base | 23 +- gnu/llvm/libcxx/include/__node_handle | 3 +- gnu/llvm/libcxx/include/__nullptr | 4 +- .../__random/uniform_int_distribution.h | 316 + gnu/llvm/libcxx/include/__ranges/access.h | 222 + gnu/llvm/libcxx/include/__ranges/all.h | 86 + .../libcxx/include/__ranges/common_view.h | 113 + gnu/llvm/libcxx/include/__ranges/concepts.h | 138 + .../libcxx/include/__ranges/copyable_box.h | 175 + gnu/llvm/libcxx/include/__ranges/dangling.h | 47 + gnu/llvm/libcxx/include/__ranges/data.h | 86 + gnu/llvm/libcxx/include/__ranges/drop_view.h | 131 + gnu/llvm/libcxx/include/__ranges/empty.h | 86 + gnu/llvm/libcxx/include/__ranges/empty_view.h | 46 + .../include/__ranges/enable_borrowed_range.h | 46 + .../libcxx/include/__ranges/enable_view.h | 42 + .../include/__ranges/non_propagating_cache.h | 99 + gnu/llvm/libcxx/include/__ranges/ref_view.h | 87 + gnu/llvm/libcxx/include/__ranges/size.h | 132 + gnu/llvm/libcxx/include/__ranges/subrange.h | 267 + .../libcxx/include/__ranges/transform_view.h | 408 ++ .../libcxx/include/__ranges/view_interface.h | 198 + gnu/llvm/libcxx/include/__split_buffer | 37 +- gnu/llvm/libcxx/include/__std_stream | 6 +- gnu/llvm/libcxx/include/__string | 162 +- .../include/__support/android/locale_bionic.h | 69 + .../include/__support/fuchsia/xlocale.h | 22 + .../libcxx/include/__support/ibm/gettod_zos.h | 53 + .../libcxx/include/__support/ibm/limits.h | 98 + .../include/__support/ibm/locale_mgmt_aix.h | 84 + .../include/__support/ibm/locale_mgmt_zos.h | 53 + .../libcxx/include/__support/ibm/nanosleep.h | 56 + .../libcxx/include/__support/ibm/support.h | 53 + .../libcxx/include/__support/ibm/xlocale.h | 334 ++ .../libcxx/include/__support/musl/xlocale.h | 57 + .../libcxx/include/__support/newlib/xlocale.h | 27 + .../libcxx/include/__support/nuttx/xlocale.h | 18 + .../include/__support/openbsd/xlocale.h | 19 + .../include/__support/solaris/floatingpoint.h | 13 + .../libcxx/include/__support/solaris/wchar.h | 46 + .../include/__support/solaris/xlocale.h | 76 + .../__support/win32/limits_msvc_win32.h | 71 + .../include/__support/win32/locale_win32.h | 283 + .../__support/xlocale/__nop_locale_mgmt.h | 51 + .../__support/xlocale/__posix_l_fallback.h | 164 + .../__support/xlocale/__strtonum_fallback.h | 66 + gnu/llvm/libcxx/include/__threading_support | 79 +- gnu/llvm/libcxx/include/__tree | 232 +- gnu/llvm/libcxx/include/__tuple | 4 +- .../libcxx/include/__utility/__decay_copy.h | 39 + gnu/llvm/libcxx/include/__utility/as_const.h | 38 + gnu/llvm/libcxx/include/__utility/cmp.h | 107 + gnu/llvm/libcxx/include/__utility/declval.h | 39 + gnu/llvm/libcxx/include/__utility/exchange.h | 40 + gnu/llvm/libcxx/include/__utility/forward.h | 42 + gnu/llvm/libcxx/include/__utility/in_place.h | 63 + .../include/__utility/integer_sequence.h | 83 + gnu/llvm/libcxx/include/__utility/move.h | 52 + gnu/llvm/libcxx/include/__utility/pair.h | 585 ++ .../include/__utility/piecewise_construct.h | 34 + gnu/llvm/libcxx/include/__utility/rel_ops.h | 67 + gnu/llvm/libcxx/include/__utility/swap.h | 55 + .../libcxx/include/__utility/to_underlying.h | 45 + gnu/llvm/libcxx/include/__variant/monostate.h | 65 + gnu/llvm/libcxx/include/algorithm | 5327 +---------------- gnu/llvm/libcxx/include/any | 37 +- gnu/llvm/libcxx/include/array | 35 +- gnu/llvm/libcxx/include/atomic | 237 +- gnu/llvm/libcxx/include/barrier | 19 +- gnu/llvm/libcxx/include/bit | 226 +- gnu/llvm/libcxx/include/bitset | 36 +- gnu/llvm/libcxx/include/ccomplex | 2 +- gnu/llvm/libcxx/include/cctype | 30 +- gnu/llvm/libcxx/include/cerrno | 2 +- gnu/llvm/libcxx/include/cfenv | 30 +- gnu/llvm/libcxx/include/cfloat | 2 +- gnu/llvm/libcxx/include/charconv | 160 +- gnu/llvm/libcxx/include/chrono | 38 +- gnu/llvm/libcxx/include/cinttypes | 16 +- gnu/llvm/libcxx/include/ciso646 | 2 +- gnu/llvm/libcxx/include/climits | 2 +- gnu/llvm/libcxx/include/clocale | 8 +- gnu/llvm/libcxx/include/cmath | 432 +- gnu/llvm/libcxx/include/codecvt | 26 +- gnu/llvm/libcxx/include/compare | 569 +- gnu/llvm/libcxx/include/complex | 23 +- gnu/llvm/libcxx/include/complex.h | 4 +- gnu/llvm/libcxx/include/concepts | 307 +- gnu/llvm/libcxx/include/condition_variable | 2 +- gnu/llvm/libcxx/include/csetjmp | 6 +- gnu/llvm/libcxx/include/csignal | 8 +- gnu/llvm/libcxx/include/cstdarg | 4 +- gnu/llvm/libcxx/include/cstdbool | 2 +- gnu/llvm/libcxx/include/cstddef | 14 +- gnu/llvm/libcxx/include/cstdint | 72 +- gnu/llvm/libcxx/include/cstdio | 102 +- gnu/llvm/libcxx/include/cstdlib | 88 +- gnu/llvm/libcxx/include/cstring | 48 +- gnu/llvm/libcxx/include/ctgmath | 2 +- gnu/llvm/libcxx/include/ctime | 48 +- gnu/llvm/libcxx/include/ctype.h | 2 +- gnu/llvm/libcxx/include/cwchar | 130 +- gnu/llvm/libcxx/include/cwctype | 46 +- gnu/llvm/libcxx/include/deque | 64 +- gnu/llvm/libcxx/include/errno.h | 6 +- gnu/llvm/libcxx/include/exception | 16 +- gnu/llvm/libcxx/include/experimental/__config | 4 - gnu/llvm/libcxx/include/experimental/__memory | 27 +- .../libcxx/include/experimental/functional | 45 +- gnu/llvm/libcxx/include/experimental/iterator | 3 + .../include/experimental/memory_resource | 5 +- .../include/experimental/propagate_const | 2 +- gnu/llvm/libcxx/include/experimental/simd | 9 +- .../libcxx/include/experimental/type_traits | 2 +- gnu/llvm/libcxx/include/ext/__hash | 3 +- gnu/llvm/libcxx/include/ext/hash_map | 8 +- gnu/llvm/libcxx/include/ext/hash_set | 4 +- gnu/llvm/libcxx/include/filesystem | 517 +- gnu/llvm/libcxx/include/float.h | 2 +- gnu/llvm/libcxx/include/format | 86 + gnu/llvm/libcxx/include/forward_list | 65 +- gnu/llvm/libcxx/include/fstream | 198 +- gnu/llvm/libcxx/include/functional | 2798 +-------- gnu/llvm/libcxx/include/future | 301 +- gnu/llvm/libcxx/include/initializer_list | 4 +- gnu/llvm/libcxx/include/inttypes.h | 2 +- gnu/llvm/libcxx/include/iomanip | 24 +- gnu/llvm/libcxx/include/ios | 57 +- gnu/llvm/libcxx/include/iosfwd | 74 +- gnu/llvm/libcxx/include/iostream | 6 +- gnu/llvm/libcxx/include/istream | 125 +- gnu/llvm/libcxx/include/iterator | 1893 +----- gnu/llvm/libcxx/include/latch | 8 + gnu/llvm/libcxx/include/limits | 6 +- gnu/llvm/libcxx/include/limits.h | 2 +- gnu/llvm/libcxx/include/list | 266 +- gnu/llvm/libcxx/include/locale.h | 8 +- gnu/llvm/libcxx/include/map | 136 +- gnu/llvm/libcxx/include/memory | 4726 +-------------- gnu/llvm/libcxx/include/module.modulemap | 292 +- gnu/llvm/libcxx/include/mutex | 19 +- gnu/llvm/libcxx/include/new | 175 +- gnu/llvm/libcxx/include/numbers | 37 +- gnu/llvm/libcxx/include/numeric | 202 +- gnu/llvm/libcxx/include/optional | 196 +- gnu/llvm/libcxx/include/ostream | 143 +- gnu/llvm/libcxx/include/queue | 143 +- gnu/llvm/libcxx/include/random | 586 +- gnu/llvm/libcxx/include/ranges | 209 + gnu/llvm/libcxx/include/ratio | 12 +- gnu/llvm/libcxx/include/regex | 213 +- gnu/llvm/libcxx/include/scoped_allocator | 7 +- gnu/llvm/libcxx/include/semaphore | 13 +- gnu/llvm/libcxx/include/set | 98 +- gnu/llvm/libcxx/include/setjmp.h | 2 +- gnu/llvm/libcxx/include/shared_mutex | 7 +- gnu/llvm/libcxx/include/span | 40 +- gnu/llvm/libcxx/include/sstream | 478 +- gnu/llvm/libcxx/include/stack | 36 +- gnu/llvm/libcxx/include/stdbool.h | 2 +- gnu/llvm/libcxx/include/stddef.h | 2 +- gnu/llvm/libcxx/include/stdexcept | 4 +- gnu/llvm/libcxx/include/stdint.h | 2 +- gnu/llvm/libcxx/include/streambuf | 22 +- gnu/llvm/libcxx/include/string | 696 ++- gnu/llvm/libcxx/include/string.h | 2 +- gnu/llvm/libcxx/include/string_view | 147 +- gnu/llvm/libcxx/include/strstream | 40 +- gnu/llvm/libcxx/include/system_error | 19 +- gnu/llvm/libcxx/include/tgmath.h | 4 +- gnu/llvm/libcxx/include/thread | 72 +- gnu/llvm/libcxx/include/tuple | 1083 ++-- gnu/llvm/libcxx/include/type_traits | 918 +-- gnu/llvm/libcxx/include/typeindex | 6 +- gnu/llvm/libcxx/include/typeinfo | 81 +- gnu/llvm/libcxx/include/unordered_map | 317 +- gnu/llvm/libcxx/include/unordered_set | 201 +- gnu/llvm/libcxx/include/utility | 1459 +---- gnu/llvm/libcxx/include/valarray | 395 +- gnu/llvm/libcxx/include/variant | 245 +- gnu/llvm/libcxx/include/vector | 217 +- gnu/llvm/libcxx/include/version | 198 +- gnu/llvm/libcxx/include/wchar.h | 4 +- gnu/llvm/libcxx/include/wctype.h | 18 +- gnu/llvm/libcxx/lib/abi/CHANGELOG.TXT | 321 +- gnu/llvm/libcxx/lib/abi/CMakeLists.txt | 99 +- gnu/llvm/libcxx/lib/abi/README.TXT | 11 +- ...stable.exceptions.no_new_in_libcxx.abilist | 2540 ++++++++ ...stable.exceptions.no_new_in_libcxx.abilist | 2570 ++++++++ ...stable.exceptions.no_new_in_libcxx.abilist | 2030 +++++++ gnu/llvm/libcxx/src/CMakeLists.txt | 140 +- gnu/llvm/libcxx/src/any.cpp | 6 +- gnu/llvm/libcxx/src/atomic.cpp | 8 +- gnu/llvm/libcxx/src/barrier.cpp | 12 +- gnu/llvm/libcxx/src/charconv.cpp | 4 +- gnu/llvm/libcxx/src/chrono.cpp | 182 +- gnu/llvm/libcxx/src/condition_variable.cpp | 8 +- gnu/llvm/libcxx/src/debug.cpp | 2 +- .../src/experimental/memory_resource.cpp | 31 +- .../src/filesystem/directory_iterator.cpp | 73 +- .../libcxx/src/filesystem/filesystem_common.h | 323 +- gnu/llvm/libcxx/src/filesystem/operations.cpp | 701 ++- gnu/llvm/libcxx/src/filesystem/posix_compat.h | 521 ++ gnu/llvm/libcxx/src/format.cpp | 19 + gnu/llvm/libcxx/src/functional.cpp | 4 +- gnu/llvm/libcxx/src/future.cpp | 10 +- gnu/llvm/libcxx/src/include/config_elast.h | 8 + gnu/llvm/libcxx/src/include/refstring.h | 33 +- gnu/llvm/libcxx/src/include/sso_allocator.h | 77 + gnu/llvm/libcxx/src/ios.cpp | 30 +- gnu/llvm/libcxx/src/ios.instantiations.cpp | 43 + gnu/llvm/libcxx/src/iostream.cpp | 2 +- gnu/llvm/libcxx/src/locale.cpp | 351 +- gnu/llvm/libcxx/src/memory.cpp | 37 +- gnu/llvm/libcxx/src/mutex.cpp | 24 +- gnu/llvm/libcxx/src/mutex_destructor.cpp | 2 +- gnu/llvm/libcxx/src/new.cpp | 80 +- gnu/llvm/libcxx/src/optional.cpp | 9 +- gnu/llvm/libcxx/src/string.cpp | 8 +- .../libcxx/src/support/ibm/xlocale_zos.cpp | 137 + .../support/runtime/exception_fallback.ipp | 54 +- .../src/support/runtime/exception_glibcxx.ipp | 8 +- .../support/runtime/exception_libcxxabi.ipp | 4 +- .../support/runtime/exception_libcxxrt.ipp | 4 +- .../src/support/runtime/exception_msvc.ipp | 50 +- .../runtime/exception_pointer_cxxabi.ipp | 12 +- .../runtime/exception_pointer_glibcxx.ipp | 14 +- .../runtime/exception_pointer_msvc.ipp | 24 +- .../exception_pointer_unimplemented.ipp | 12 +- .../support/runtime/new_handler_fallback.ipp | 4 +- .../src/support/runtime/stdexcept_default.ipp | 30 +- .../libcxx/src/support/solaris/xlocale.cpp | 2 +- .../libcxx/src/support/win32/locale_win32.cpp | 2 +- gnu/llvm/libcxx/src/support/win32/support.cpp | 7 +- .../libcxx/src/support/win32/thread_win32.cpp | 46 +- gnu/llvm/libcxx/src/system_error.cpp | 34 +- gnu/llvm/libcxx/src/typeinfo.cpp | 6 +- gnu/llvm/libcxx/utils/CMakeLists.txt | 23 + gnu/llvm/libcxx/utils/ci/Dockerfile | 84 + .../libcxx/utils/ci/apple-install-libcxx.sh | 66 +- .../utils/ci/buildkite-pipeline-premerge.sh | 42 + .../utils/ci/buildkite-pipeline-snapshot.sh | 25 + .../libcxx/utils/ci/buildkite-pipeline.yml | 615 ++ gnu/llvm/libcxx/utils/ci/macos-ci-setup | 100 + gnu/llvm/libcxx/utils/ci/oss-fuzz.sh | 33 + gnu/llvm/libcxx/utils/ci/run-buildbot | 558 ++ .../libcxx/utils/ci/run-buildbot-container | 24 + .../libcxx/utils/ci/runtimes/CMakeLists.txt | 50 +- gnu/llvm/libcxx/utils/gdb/libcxx/printers.py | 44 +- gnu/llvm/libcxx/utils/generate_abi_list.py | 40 + .../generate_feature_test_macro_components.py | 1414 +++-- .../utils/generate_header_inclusion_tests.py | 205 + .../libcxx/utils/generate_header_tests.py | 208 + .../utils/generate_private_header_tests.py | 83 + .../utils/google-benchmark/.clang-format | 1 + .../google-benchmark/.github/.libcxx-setup.sh | 24 + .../.github/ISSUE_TEMPLATE/bug_report.md | 32 + .../.github/ISSUE_TEMPLATE/feature_request.md | 20 + .../.github/workflows/bazel.yml | 30 + .../workflows/build-and-test-perfcounters.yml | 44 + .../.github/workflows/build-and-test.yml | 110 + .../.github/workflows/pylint.yml | 26 + .../.github/workflows/sanitizer.yml | 78 + .../.github/workflows/test_bindings.yml | 24 + .../libcxx/utils/google-benchmark/.gitignore | 8 + .../libcxx/utils/google-benchmark/.travis.yml | 93 +- .../libcxx/utils/google-benchmark/AUTHORS | 12 + .../libcxx/utils/google-benchmark/BUILD.bazel | 44 + .../utils/google-benchmark/CMakeLists.txt | 68 +- .../utils/google-benchmark/CONTRIBUTORS | 19 +- .../libcxx/utils/google-benchmark/README.md | 1528 +++-- .../libcxx/utils/google-benchmark/WORKSPACE | 50 +- .../libcxx/utils/google-benchmark/_config.yml | 2 + .../utils/google-benchmark/appveyor.yml | 2 +- .../google-benchmark/bindings/python/BUILD | 3 + .../bindings/python/build_defs.bzl | 25 + .../bindings/python/google_benchmark/BUILD | 38 + .../python/google_benchmark/__init__.py | 158 + .../python/google_benchmark/benchmark.cc | 181 + .../python/google_benchmark/example.py | 136 + .../bindings/python/pybind11.BUILD | 20 + .../bindings/python/python_headers.BUILD | 6 + .../bindings/python/requirements.txt | 2 + .../cmake/AddCXXCompilerFlag.cmake | 12 +- .../cmake/CXXFeatureCheck.cmake | 9 +- .../cmake/GetGitVersion.cmake | 22 +- .../google-benchmark/cmake/GoogleTest.cmake | 41 + .../cmake/GoogleTest.cmake.in | 58 + .../google-benchmark/cmake/benchmark.pc.in | 5 +- .../cmake/gnu_posix_regex.cpp | 1 + .../google-benchmark/cmake/posix_regex.cpp | 1 + .../google-benchmark/cmake/std_regex.cpp | 1 + .../utils/google-benchmark/dependencies.md | 18 + .../google-benchmark/docs/AssemblyTests.md | 1 + .../utils/google-benchmark/docs/_config.yml | 1 + .../google-benchmark/docs/perf_counters.md | 34 + .../docs/random_interleaving.md | 13 + .../utils/google-benchmark/docs/releasing.md | 22 + .../utils/google-benchmark/docs/tools.md | 6 +- .../include/benchmark/benchmark.h | 291 +- .../utils/google-benchmark/requirements.txt | 2 + .../libcxx/utils/google-benchmark/setup.py | 140 + .../utils/google-benchmark/src/CMakeLists.txt | 40 +- .../utils/google-benchmark/src/benchmark.cc | 342 +- .../src/benchmark_api_internal.cc | 91 +- .../src/benchmark_api_internal.h | 74 +- .../google-benchmark/src/benchmark_name.cc | 58 + .../src/benchmark_register.cc | 135 +- .../google-benchmark/src/benchmark_register.h | 93 +- .../google-benchmark/src/benchmark_runner.cc | 409 +- .../google-benchmark/src/benchmark_runner.h | 61 +- .../google-benchmark/src/commandlineflags.cc | 132 +- .../google-benchmark/src/commandlineflags.h | 79 +- .../utils/google-benchmark/src/complexity.cc | 34 +- .../google-benchmark/src/console_reporter.cc | 25 +- .../utils/google-benchmark/src/counter.cc | 9 +- .../utils/google-benchmark/src/counter.h | 8 +- .../google-benchmark/src/csv_reporter.cc | 29 +- .../utils/google-benchmark/src/cycleclock.h | 25 +- .../google-benchmark/src/internal_macros.h | 12 +- .../google-benchmark/src/json_reporter.cc | 89 +- .../libcxx/utils/google-benchmark/src/mutex.h | 44 +- .../google-benchmark/src/perf_counters.cc | 132 + .../google-benchmark/src/perf_counters.h | 172 + .../utils/google-benchmark/src/reporter.cc | 17 +- .../utils/google-benchmark/src/sleep.cc | 16 + .../utils/google-benchmark/src/statistics.cc | 9 +- .../utils/google-benchmark/src/string_util.cc | 19 +- .../utils/google-benchmark/src/string_util.h | 7 +- .../utils/google-benchmark/src/sysinfo.cc | 108 +- .../google-benchmark/src/thread_manager.h | 4 +- .../utils/google-benchmark/src/thread_timer.h | 29 +- .../utils/google-benchmark/src/timers.cc | 80 +- .../google-benchmark/test/AssemblyTests.cmake | 1 + .../libcxx/utils/google-benchmark/test/BUILD | 74 + .../google-benchmark/test/CMakeLists.txt | 83 +- .../test/args_product_test.cc | 77 + .../utils/google-benchmark/test/basic_test.cc | 27 +- .../google-benchmark/test/benchmark_gtest.cc | 134 +- .../test/benchmark_name_gtest.cc | 74 + .../benchmark_random_interleaving_gtest.cc | 126 + .../test/commandlineflags_gtest.cc | 228 + .../google-benchmark/test/complexity_test.cc | 95 +- .../utils/google-benchmark/test/cxx03_test.cc | 2 +- .../google-benchmark/test/filter_test.cc | 26 +- .../google-benchmark/test/fixture_test.cc | 18 +- .../test/internal_threading_test.cc | 184 + .../utils/google-benchmark/test/map_test.cc | 4 +- .../test/memory_manager_test.cc | 12 +- .../test/multiple_ranges_test.cc | 5 +- .../google-benchmark/test/options_test.cc | 11 + .../utils/google-benchmark/test/output_test.h | 12 +- .../test/output_test_helper.cc | 21 +- .../test/perf_counters_gtest.cc | 145 + .../test/perf_counters_test.cc | 27 + .../test/register_benchmark_test.cc | 2 +- .../google-benchmark/test/repetitions_test.cc | 208 + .../test/reporter_output_test.cc | 372 +- .../test/skip_with_error_test.cc | 10 +- .../test/state_assembly_test.cc | 2 +- .../google-benchmark/test/statistics_gtest.cc | 4 +- .../test/string_util_gtest.cc | 15 + .../test/user_counters_tabular_test.cc | 268 +- .../test/user_counters_test.cc | 147 + .../test/user_counters_thousands_test.cc | 22 + .../utils/google-benchmark/tools/BUILD.bazel | 19 + .../utils/google-benchmark/tools/compare.py | 37 +- .../tools/gbench/Inputs/test1_run1.json | 19 +- .../tools/gbench/Inputs/test1_run2.json | 19 +- .../tools/gbench/Inputs/test4_run.json | 96 + .../google-benchmark/tools/gbench/report.py | 753 ++- .../google-benchmark/tools/gbench/util.py | 23 +- .../google-benchmark/tools/requirements.txt | 1 + gnu/llvm/libcxx/utils/graph_header_deps.py | 400 +- gnu/llvm/libcxx/utils/libcxx/compiler.py | 1 - .../libcxx/utils/libcxx/sym_check/util.py | 12 +- gnu/llvm/libcxx/utils/libcxx/test/config.py | 417 +- gnu/llvm/libcxx/utils/libcxx/test/dsl.py | 471 +- gnu/llvm/libcxx/utils/libcxx/test/features.py | 95 +- gnu/llvm/libcxx/utils/libcxx/test/format.py | 31 +- .../libcxx/utils/libcxx/test/newconfig.py | 38 + gnu/llvm/libcxx/utils/libcxx/test/params.py | 205 +- .../libcxx/utils/libcxx/test/target_info.py | 110 +- gnu/llvm/libcxx/utils/merge_archives.py | 4 +- gnu/llvm/libcxx/utils/run.py | 40 +- gnu/llvm/libcxx/utils/ssh.py | 46 +- 637 files changed, 64881 insertions(+), 26884 deletions(-) create mode 100644 gnu/llvm/libcxx/.gitignore create mode 100644 gnu/llvm/libcxx/appveyor-reqs-install.cmd create mode 100644 gnu/llvm/libcxx/appveyor.yml create mode 100644 gnu/llvm/libcxx/benchmarks/VariantBenchmarks.h create mode 100644 gnu/llvm/libcxx/benchmarks/map.bench.cpp create mode 100644 gnu/llvm/libcxx/benchmarks/to_chars.bench.cpp create mode 100644 gnu/llvm/libcxx/benchmarks/variant_visit_1.bench.cpp create mode 100644 gnu/llvm/libcxx/benchmarks/variant_visit_2.bench.cpp create mode 100644 gnu/llvm/libcxx/benchmarks/variant_visit_3.bench.cpp create mode 100644 gnu/llvm/libcxx/cmake/caches/AArch64.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Armv7Arm.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Armv7Thumb-noexceptions.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Armv8Arm.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Armv8Thumb-noexceptions.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/FreeBSD.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-assertions.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-cxx20.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-cxx2b.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-debug-iterators.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-modules.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-no-debug.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-no-filesystem.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-no-localization.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-no-random_device.cmake create mode 100644 gnu/llvm/libcxx/cmake/caches/Generic-static.cmake create mode 100644 gnu/llvm/libcxx/docs/AddingNewCIJobs.rst create mode 100644 gnu/llvm/libcxx/docs/Contributing.rst create mode 100644 gnu/llvm/libcxx/docs/DesignDocs/AtomicDesign.rst create mode 100644 gnu/llvm/libcxx/docs/DesignDocs/NoexceptPolicy.rst create mode 100644 gnu/llvm/libcxx/docs/DesignDocs/UniquePtrTrivialAbi.rst create mode 100644 gnu/llvm/libcxx/docs/Helpers/Styles.rst create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx14.rst create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx14Issues.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx14Papers.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx17.rst create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx17Issues.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx17Papers.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx20.rst create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx20Issues.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx20Papers.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx2b.rst create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx2bIssues.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Cxx2bPapers.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Format.rst create mode 100644 gnu/llvm/libcxx/docs/Status/FormatIssues.csv create mode 100644 gnu/llvm/libcxx/docs/Status/FormatPaper.csv create mode 100644 gnu/llvm/libcxx/docs/Status/Ranges.rst create mode 100644 gnu/llvm/libcxx/docs/Status/RangesIssues.csv create mode 100644 gnu/llvm/libcxx/docs/Status/RangesPaper.csv create mode 100644 gnu/llvm/libcxx/include/__algorithm/adjacent_find.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/all_of.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/any_of.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/binary_search.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/clamp.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/comp.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/comp_ref_type.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/copy_backward.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/copy_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/copy_n.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/count.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/count_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/equal.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/equal_range.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/fill.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/fill_n.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/find.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/find_end.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/find_first_of.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/find_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/find_if_not.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/for_each.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/for_each_n.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/generate.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/generate_n.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/half_positive.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/includes.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/inplace_merge.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/is_heap.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/is_heap_until.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/is_partitioned.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/is_permutation.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/is_sorted.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/is_sorted_until.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/iter_swap.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/lexicographical_compare.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/lower_bound.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/make_heap.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/max.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/max_element.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/merge.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/min.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/min_element.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/minmax.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/minmax_element.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/mismatch.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/move.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/move_backward.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/next_permutation.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/none_of.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/nth_element.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/partial_sort.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/partial_sort_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/partition.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/partition_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/partition_point.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/pop_heap.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/prev_permutation.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/push_heap.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/remove.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/remove_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/remove_copy_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/remove_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/replace.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/replace_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/replace_copy_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/replace_if.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/reverse.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/reverse_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/rotate.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/rotate_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/sample.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/search.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/search_n.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/set_difference.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/set_intersection.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/set_symmetric_difference.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/set_union.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/shift_left.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/shift_right.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/shuffle.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/sift_down.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/sort.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/sort_heap.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/stable_partition.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/stable_sort.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/swap_ranges.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/transform.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/unique.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/unique_copy.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/unwrap_iter.h create mode 100644 gnu/llvm/libcxx/include/__algorithm/upper_bound.h create mode 100644 gnu/llvm/libcxx/include/__availability create mode 100644 gnu/llvm/libcxx/include/__bits create mode 100644 gnu/llvm/libcxx/include/__format/format_error.h create mode 100644 gnu/llvm/libcxx/include/__format/format_parse_context.h create mode 100644 gnu/llvm/libcxx/include/__function_like.h create mode 100644 gnu/llvm/libcxx/include/__functional/binary_function.h create mode 100644 gnu/llvm/libcxx/include/__functional/binary_negate.h create mode 100644 gnu/llvm/libcxx/include/__functional/bind.h create mode 100644 gnu/llvm/libcxx/include/__functional/bind_front.h create mode 100644 gnu/llvm/libcxx/include/__functional/binder1st.h create mode 100644 gnu/llvm/libcxx/include/__functional/binder2nd.h create mode 100644 gnu/llvm/libcxx/include/__functional/default_searcher.h create mode 100644 gnu/llvm/libcxx/include/__functional/function.h create mode 100644 gnu/llvm/libcxx/include/__functional/hash.h create mode 100644 gnu/llvm/libcxx/include/__functional/identity.h create mode 100644 gnu/llvm/libcxx/include/__functional/invoke.h create mode 100644 gnu/llvm/libcxx/include/__functional/is_transparent.h create mode 100644 gnu/llvm/libcxx/include/__functional/mem_fn.h create mode 100644 gnu/llvm/libcxx/include/__functional/mem_fun_ref.h create mode 100644 gnu/llvm/libcxx/include/__functional/not_fn.h create mode 100644 gnu/llvm/libcxx/include/__functional/operations.h create mode 100644 gnu/llvm/libcxx/include/__functional/perfect_forward.h create mode 100644 gnu/llvm/libcxx/include/__functional/pointer_to_binary_function.h create mode 100644 gnu/llvm/libcxx/include/__functional/pointer_to_unary_function.h create mode 100644 gnu/llvm/libcxx/include/__functional/ranges_operations.h create mode 100644 gnu/llvm/libcxx/include/__functional/reference_wrapper.h create mode 100644 gnu/llvm/libcxx/include/__functional/unary_function.h create mode 100644 gnu/llvm/libcxx/include/__functional/unary_negate.h create mode 100644 gnu/llvm/libcxx/include/__functional/unwrap_ref.h create mode 100644 gnu/llvm/libcxx/include/__functional/weak_result_type.h create mode 100644 gnu/llvm/libcxx/include/__iterator/access.h create mode 100644 gnu/llvm/libcxx/include/__iterator/advance.h create mode 100644 gnu/llvm/libcxx/include/__iterator/back_insert_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/common_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/concepts.h create mode 100644 gnu/llvm/libcxx/include/__iterator/counted_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/data.h create mode 100644 gnu/llvm/libcxx/include/__iterator/default_sentinel.h create mode 100644 gnu/llvm/libcxx/include/__iterator/distance.h create mode 100644 gnu/llvm/libcxx/include/__iterator/empty.h create mode 100644 gnu/llvm/libcxx/include/__iterator/erase_if_container.h create mode 100644 gnu/llvm/libcxx/include/__iterator/front_insert_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/incrementable_traits.h create mode 100644 gnu/llvm/libcxx/include/__iterator/insert_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/istream_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/istreambuf_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/iter_move.h create mode 100644 gnu/llvm/libcxx/include/__iterator/iter_swap.h create mode 100644 gnu/llvm/libcxx/include/__iterator/iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/iterator_traits.h create mode 100644 gnu/llvm/libcxx/include/__iterator/move_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/next.h create mode 100644 gnu/llvm/libcxx/include/__iterator/ostream_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/ostreambuf_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/prev.h create mode 100644 gnu/llvm/libcxx/include/__iterator/projected.h create mode 100644 gnu/llvm/libcxx/include/__iterator/readable_traits.h create mode 100644 gnu/llvm/libcxx/include/__iterator/reverse_access.h create mode 100644 gnu/llvm/libcxx/include/__iterator/reverse_iterator.h create mode 100644 gnu/llvm/libcxx/include/__iterator/size.h create mode 100644 gnu/llvm/libcxx/include/__iterator/wrap_iter.h create mode 100644 gnu/llvm/libcxx/include/__memory/addressof.h create mode 100644 gnu/llvm/libcxx/include/__memory/allocation_guard.h create mode 100644 gnu/llvm/libcxx/include/__memory/allocator.h create mode 100644 gnu/llvm/libcxx/include/__memory/allocator_arg_t.h create mode 100644 gnu/llvm/libcxx/include/__memory/allocator_traits.h create mode 100644 gnu/llvm/libcxx/include/__memory/auto_ptr.h create mode 100644 gnu/llvm/libcxx/include/__memory/compressed_pair.h create mode 100644 gnu/llvm/libcxx/include/__memory/construct_at.h create mode 100644 gnu/llvm/libcxx/include/__memory/pointer_safety.h create mode 100644 gnu/llvm/libcxx/include/__memory/pointer_traits.h create mode 100644 gnu/llvm/libcxx/include/__memory/raw_storage_iterator.h create mode 100644 gnu/llvm/libcxx/include/__memory/shared_ptr.h create mode 100644 gnu/llvm/libcxx/include/__memory/temporary_buffer.h create mode 100644 gnu/llvm/libcxx/include/__memory/uninitialized_algorithms.h create mode 100644 gnu/llvm/libcxx/include/__memory/unique_ptr.h create mode 100644 gnu/llvm/libcxx/include/__memory/uses_allocator.h create mode 100644 gnu/llvm/libcxx/include/__random/uniform_int_distribution.h create mode 100644 gnu/llvm/libcxx/include/__ranges/access.h create mode 100644 gnu/llvm/libcxx/include/__ranges/all.h create mode 100644 gnu/llvm/libcxx/include/__ranges/common_view.h create mode 100644 gnu/llvm/libcxx/include/__ranges/concepts.h create mode 100644 gnu/llvm/libcxx/include/__ranges/copyable_box.h create mode 100644 gnu/llvm/libcxx/include/__ranges/dangling.h create mode 100644 gnu/llvm/libcxx/include/__ranges/data.h create mode 100644 gnu/llvm/libcxx/include/__ranges/drop_view.h create mode 100644 gnu/llvm/libcxx/include/__ranges/empty.h create mode 100644 gnu/llvm/libcxx/include/__ranges/empty_view.h create mode 100644 gnu/llvm/libcxx/include/__ranges/enable_borrowed_range.h create mode 100644 gnu/llvm/libcxx/include/__ranges/enable_view.h create mode 100644 gnu/llvm/libcxx/include/__ranges/non_propagating_cache.h create mode 100644 gnu/llvm/libcxx/include/__ranges/ref_view.h create mode 100644 gnu/llvm/libcxx/include/__ranges/size.h create mode 100644 gnu/llvm/libcxx/include/__ranges/subrange.h create mode 100644 gnu/llvm/libcxx/include/__ranges/transform_view.h create mode 100644 gnu/llvm/libcxx/include/__ranges/view_interface.h create mode 100644 gnu/llvm/libcxx/include/__support/android/locale_bionic.h create mode 100644 gnu/llvm/libcxx/include/__support/fuchsia/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/gettod_zos.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/limits.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/locale_mgmt_aix.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/locale_mgmt_zos.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/nanosleep.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/support.h create mode 100644 gnu/llvm/libcxx/include/__support/ibm/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/musl/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/newlib/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/nuttx/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/openbsd/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/solaris/floatingpoint.h create mode 100644 gnu/llvm/libcxx/include/__support/solaris/wchar.h create mode 100644 gnu/llvm/libcxx/include/__support/solaris/xlocale.h create mode 100644 gnu/llvm/libcxx/include/__support/win32/limits_msvc_win32.h create mode 100644 gnu/llvm/libcxx/include/__support/win32/locale_win32.h create mode 100644 gnu/llvm/libcxx/include/__support/xlocale/__nop_locale_mgmt.h create mode 100644 gnu/llvm/libcxx/include/__support/xlocale/__posix_l_fallback.h create mode 100644 gnu/llvm/libcxx/include/__support/xlocale/__strtonum_fallback.h create mode 100644 gnu/llvm/libcxx/include/__utility/__decay_copy.h create mode 100644 gnu/llvm/libcxx/include/__utility/as_const.h create mode 100644 gnu/llvm/libcxx/include/__utility/cmp.h create mode 100644 gnu/llvm/libcxx/include/__utility/declval.h create mode 100644 gnu/llvm/libcxx/include/__utility/exchange.h create mode 100644 gnu/llvm/libcxx/include/__utility/forward.h create mode 100644 gnu/llvm/libcxx/include/__utility/in_place.h create mode 100644 gnu/llvm/libcxx/include/__utility/integer_sequence.h create mode 100644 gnu/llvm/libcxx/include/__utility/move.h create mode 100644 gnu/llvm/libcxx/include/__utility/pair.h create mode 100644 gnu/llvm/libcxx/include/__utility/piecewise_construct.h create mode 100644 gnu/llvm/libcxx/include/__utility/rel_ops.h create mode 100644 gnu/llvm/libcxx/include/__utility/swap.h create mode 100644 gnu/llvm/libcxx/include/__utility/to_underlying.h create mode 100644 gnu/llvm/libcxx/include/__variant/monostate.h create mode 100644 gnu/llvm/libcxx/include/format create mode 100644 gnu/llvm/libcxx/include/ranges create mode 100644 gnu/llvm/libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist create mode 100644 gnu/llvm/libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist create mode 100644 gnu/llvm/libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.no_new_in_libcxx.abilist create mode 100644 gnu/llvm/libcxx/src/filesystem/posix_compat.h create mode 100644 gnu/llvm/libcxx/src/format.cpp create mode 100644 gnu/llvm/libcxx/src/include/sso_allocator.h create mode 100644 gnu/llvm/libcxx/src/ios.instantiations.cpp create mode 100644 gnu/llvm/libcxx/src/support/ibm/xlocale_zos.cpp create mode 100644 gnu/llvm/libcxx/utils/CMakeLists.txt create mode 100644 gnu/llvm/libcxx/utils/ci/Dockerfile create mode 100755 gnu/llvm/libcxx/utils/ci/buildkite-pipeline-premerge.sh create mode 100755 gnu/llvm/libcxx/utils/ci/buildkite-pipeline-snapshot.sh create mode 100644 gnu/llvm/libcxx/utils/ci/buildkite-pipeline.yml create mode 100755 gnu/llvm/libcxx/utils/ci/macos-ci-setup create mode 100755 gnu/llvm/libcxx/utils/ci/oss-fuzz.sh create mode 100755 gnu/llvm/libcxx/utils/ci/run-buildbot create mode 100755 gnu/llvm/libcxx/utils/ci/run-buildbot-container create mode 100755 gnu/llvm/libcxx/utils/generate_abi_list.py create mode 100755 gnu/llvm/libcxx/utils/generate_header_inclusion_tests.py create mode 100755 gnu/llvm/libcxx/utils/generate_header_tests.py create mode 100755 gnu/llvm/libcxx/utils/generate_private_header_tests.py create mode 100755 gnu/llvm/libcxx/utils/google-benchmark/.github/.libcxx-setup.sh create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/ISSUE_TEMPLATE/bug_report.md create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/ISSUE_TEMPLATE/feature_request.md create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/workflows/bazel.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/workflows/build-and-test-perfcounters.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/workflows/build-and-test.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/workflows/pylint.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/workflows/sanitizer.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/.github/workflows/test_bindings.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/BUILD.bazel create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/_config.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/BUILD create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/build_defs.bzl create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/google_benchmark/BUILD create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/google_benchmark/__init__.py create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/google_benchmark/benchmark.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/google_benchmark/example.py create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/pybind11.BUILD create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/python_headers.BUILD create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/bindings/python/requirements.txt create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/cmake/GoogleTest.cmake create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/cmake/GoogleTest.cmake.in create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/dependencies.md create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/docs/_config.yml create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/docs/perf_counters.md create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/docs/random_interleaving.md create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/docs/releasing.md create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/requirements.txt create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/setup.py create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/src/benchmark_name.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/src/perf_counters.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/src/perf_counters.h create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/BUILD create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/args_product_test.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/benchmark_name_gtest.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/benchmark_random_interleaving_gtest.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/commandlineflags_gtest.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/internal_threading_test.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/perf_counters_gtest.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/perf_counters_test.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/test/repetitions_test.cc create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/tools/BUILD.bazel create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/tools/gbench/Inputs/test4_run.json create mode 100644 gnu/llvm/libcxx/utils/google-benchmark/tools/requirements.txt create mode 100644 gnu/llvm/libcxx/utils/libcxx/test/newconfig.py diff --git a/gnu/llvm/libcxx/.clang-format b/gnu/llvm/libcxx/.clang-format index dd596813fbb..cfa0c289635 100644 --- a/gnu/llvm/libcxx/.clang-format +++ b/gnu/llvm/libcxx/.clang-format @@ -10,4 +10,7 @@ PointerAlignment: Left # Disable formatting options which may break tests. SortIncludes: false ReflowComments: false + +# libc++ has some long names so we need more than the 80 column limit imposed by LLVM style, for sensible formatting +ColumnLimit: 120 --- diff --git a/gnu/llvm/libcxx/.gitignore b/gnu/llvm/libcxx/.gitignore new file mode 100644 index 00000000000..4b214ca4b3e --- /dev/null +++ b/gnu/llvm/libcxx/.gitignore @@ -0,0 +1,55 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +#lib/ # We actually have things checked in to lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo +*.pot + +# Django stuff: +*.log + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# MSVC libraries test harness +env.lst +keep.lst + +# Editor by-products +.vscode/ diff --git a/gnu/llvm/libcxx/CMakeLists.txt b/gnu/llvm/libcxx/CMakeLists.txt index 910d04b54b6..b1e25358d41 100644 --- a/gnu/llvm/libcxx/CMakeLists.txt +++ b/gnu/llvm/libcxx/CMakeLists.txt @@ -8,18 +8,7 @@ endif() #=============================================================================== # Setup Project #=============================================================================== -cmake_minimum_required(VERSION 3.4.3) - -if(POLICY CMP0042) - cmake_policy(SET CMP0042 NEW) # Set MACOSX_RPATH=YES by default -endif() -if(POLICY CMP0022) - cmake_policy(SET CMP0022 NEW) # Required when interacting with LLVM and Clang -endif() -if(POLICY CMP0068) - cmake_policy(SET CMP0068 NEW) - set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) -endif() +cmake_minimum_required(VERSION 3.13.4) # Add path for custom modules set(CMAKE_MODULE_PATH @@ -28,46 +17,44 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ) +set(CMAKE_FOLDER "libc++") + +set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) +set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") + if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR LIBCXX_STANDALONE_BUILD) project(libcxx CXX C) set(PACKAGE_NAME libcxx) - set(PACKAGE_VERSION 11.1.0) + set(PACKAGE_VERSION 13.0.0git) set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "llvm-bugs@lists.llvm.org") + # In a standalone build, we don't have llvm to automatically generate the + # llvm-lit script for us. So we need to provide an explicit directory that + # the configurator should write the script into. + set(LIBCXX_STANDALONE_BUILD 1) + set(LLVM_LIT_OUTPUT_DIR "${LIBCXX_BINARY_DIR}/bin") + # Find the LLVM sources and simulate LLVM CMake options. include(HandleOutOfTreeLLVM) endif() if (LIBCXX_STANDALONE_BUILD) - if(CMAKE_VERSION VERSION_LESS 3.12) - include(FindPythonInterp) - if( NOT PYTHONINTERP_FOUND ) - message(WARNING "Failed to find python interpreter. " - "The libc++ test suite will be disabled.") - set(LLVM_INCLUDE_TESTS OFF) - else() - add_executable(Python3::Interpreter IMPORTED) - set_target_properties(Python3::Interpreter PROPERTIES - IMPORTED_LOCATION ${PYTHON_EXECUTABLE}) - set(Python3_EXECUTABLE ${PYTHON_EXECUTABLE}) + find_package(Python3 COMPONENTS Interpreter) + if(NOT Python3_Interpreter_FOUND) + message(WARNING "Python3 not found, using python2 as a fallback") + find_package(Python2 COMPONENTS Interpreter REQUIRED) + if(Python2_VERSION VERSION_LESS 2.7) + message(SEND_ERROR "Python 2.7 or newer is required") endif() - else() - find_package(Python3 COMPONENTS Interpreter) - if(NOT Python3_Interpreter_FOUND) - message(WARNING "Python3 not found, using python2 as a fallback") - find_package(Python2 COMPONENTS Interpreter REQUIRED) - if(Python2_VERSION VERSION_LESS 2.7) - message(SEND_ERROR "Python 2.7 or newer is required") - endif() - # Treat python2 as python3 - add_executable(Python3::Interpreter IMPORTED) - set_target_properties(Python3::Interpreter PROPERTIES - IMPORTED_LOCATION ${Python2_EXECUTABLE}) - set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) - endif() + # Treat python2 as python3 + add_executable(Python3::Interpreter IMPORTED) + set_target_properties(Python3::Interpreter PROPERTIES + IMPORTED_LOCATION ${Python2_EXECUTABLE}) + set(Python3_EXECUTABLE ${Python2_EXECUTABLE}) endif() endif() @@ -101,15 +88,47 @@ option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) option(LIBCXX_ENABLE_STATIC "Build libc++ as a static library." ON) option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON) set(ENABLE_FILESYSTEM_DEFAULT ON) -if (WIN32) +if (WIN32 AND NOT MINGW) + # Filesystem is buildable for windows, but it requires __int128 helper + # functions, that currently are provided by libgcc or compiler_rt builtins. + # These are available in MinGW environments, but not currently in MSVC + # environments. set(ENABLE_FILESYSTEM_DEFAULT OFF) endif() option(LIBCXX_ENABLE_FILESYSTEM "Build filesystem as part of the main libc++ library" ${ENABLE_FILESYSTEM_DEFAULT}) option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) option(LIBCXX_ENABLE_PARALLEL_ALGORITHMS "Enable the parallel algorithms library. This requires the PSTL to be available." OFF) -option(LIBCXX_TEST_GDB_PRETTY_PRINTERS "Test gdb pretty printers." OFF) -set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/lit.site.cfg.in" CACHE STRING +option(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT + "Whether to include support for libc++'s debugging mode in the library. + By default, this is turned on. If you turn it off and try to enable the + debug mode when compiling a program against libc++, it will fail to link + since the required support isn't provided in the library." ON) +option(LIBCXX_ENABLE_RANDOM_DEVICE + "Whether to include support for std::random_device in the library. Disabling + this can be useful when building the library for platforms that don't have + a source of randomness, such as some embedded platforms. When this is not + supported, most of will still be available, but std::random_device + will not." ON) +option(LIBCXX_ENABLE_LOCALIZATION + "Whether to include support for localization in the library. Disabling + localization can be useful when porting to platforms that don't support + the C locale API (e.g. embedded). When localization is not supported, + several parts of the library will be disabled: , , + will be completely unusable, and other parts may be only partly available." ON) +option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS + "Whether to turn on vendor availability annotations on declarations that depend + on definitions in a shared library. By default, we assume that we're not building + libc++ for any specific vendor, and we disable those annotations. Vendors wishing + to provide compile-time errors when using features unavailable on some version of + the shared library they shipped should turn this on and see `include/__availability` + for more details." OFF) +option(LIBCXX_ENABLE_INCOMPLETE_FEATURES + "Whether to enable support for incomplete library features. Incomplete features + are new library features under development. These features don't guarantee + ABI stability nor the quality of completed library features. Vendors + shipping the library may want to disable this option." ON) +set(LIBCXX_TEST_CONFIG "${CMAKE_CURRENT_SOURCE_DIR}/test/configs/legacy.cfg.in" CACHE STRING "The Lit testing configuration to use when running the tests.") set(LIBCXX_TEST_PARAMS "" CACHE STRING "A list of parameters to run the Lit test suite with.") @@ -146,7 +165,6 @@ cmake_dependent_option(LIBCXX_INSTALL_STATIC_LIBRARY cmake_dependent_option(LIBCXX_INSTALL_SHARED_LIBRARY "Install the shared libc++ library." ON "LIBCXX_ENABLE_SHARED;LIBCXX_INSTALL_LIBRARY" OFF) -option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) cmake_dependent_option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" ON "LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY;LIBCXX_INSTALL_LIBRARY" OFF) @@ -157,14 +175,17 @@ option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) option(LIBCXX_ABI_FORCE_ITANIUM "Ignore auto-detection and force use of the Itanium ABI.") option(LIBCXX_ABI_FORCE_MICROSOFT "Ignore auto-detection and force use of the Microsoft ABI.") +set(LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION "default" CACHE STRING + "Override the implementation to use for comparing typeinfos. By default, this + is detected automatically by the library, but this option allows overriding + which implementation is used unconditionally. -set(LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION "" CACHE STRING "The implementation of typeinfo comparison to use.") -set(TYPEINFO_COMPARISON_VALUES ";1;2") -set_property(CACHE LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION PROPERTY STRINGS ${TYPEINFO_COMPARISON_VALUES}) -list(FIND TYPEINFO_COMPARISON_VALUES "${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" IS_VALID_DEFAULT) -if (${IS_VALID_DEFAULT} EQUAL -1) + See the documentation in for details on what each + value means.") +set(TYPEINFO_COMPARISON_VALUES "default;1;2;3") +if (NOT ("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" IN_LIST TYPEINFO_COMPARISON_VALUES)) message(FATAL_ERROR "Value '${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}' is not a valid value for - LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION") + LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION") endif() option(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT "Enable per TU ABI insulation by default. To be used by vendors." OFF) @@ -225,17 +246,17 @@ option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) option(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS - "Build libc++ with definitions for operator new/delete. This option can - be used to disable the definitions when libc++abi is expected to provide - them" ON) - + "Build libc++ with definitions for operator new/delete. These are normally + defined in libc++abi, but this option can be used to define them in libc++ + instead. If you define them in libc++, make sure they are NOT defined in + libc++abi. Doing otherwise is an ODR violation." OFF) # Build libc++abi with libunwind. We need this option to determine whether to # link with libunwind or libgcc_s while running the test cases. option(LIBCXXABI_USE_LLVM_UNWINDER "Build and use the LLVM unwinder." OFF) # Target options -------------------------------------------------------------- option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++." ${LLVM_BUILD_32_BITS}) -set(LIBCXX_TARGET_TRIPLE "" CACHE STRING "Use alternate target triple.") +set(LIBCXX_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING "Use alternate target triple.") set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") @@ -271,23 +292,6 @@ option(LIBCXX_GENERATE_COVERAGE "Enable generating code coverage." OFF) set(LIBCXX_COVERAGE_LIBRARY "" CACHE STRING "The Profile-rt library used to build with code coverage") -# Don't allow a user to accidentally overwrite the system libc++ installation on Darwin. -# If the user specifies -DCMAKE_INSTALL_PREFIX=/usr the install rules for libc++ -# will not be generated and a warning will be issued. -option(LIBCXX_OVERRIDE_DARWIN_INSTALL "Enable overwriting darwins libc++ installation." OFF) -mark_as_advanced(LIBCXX_OVERRIDE_DARWIN_INSTALL) # Don't show this option by default. - -if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT LIBCXX_OVERRIDE_DARWIN_INSTALL) - if ("${CMAKE_INSTALL_PREFIX}" STREQUAL "/usr") - message(WARNING "Disabling libc++ install rules because installation would " - "overwrite the systems installation. Configure with " - "-DLIBCXX_OVERRIDE_DARWIN_INSTALL=ON to suppress this behaviour.") - mark_as_advanced(CLEAR LIBCXX_OVERRIDE_DARWIN_INSTALL) # Show the override option. - set(LIBCXX_INSTALL_HEADERS OFF) - set(LIBCXX_INSTALL_LIBRARY OFF) - endif() -endif() - set(LIBCXX_CONFIGURE_IDE_DEFAULT OFF) if (XCODE OR MSVC_IDE) set(LIBCXX_CONFIGURE_IDE_DEFAULT ON) @@ -394,11 +398,6 @@ if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SC LIBCXX_ENABLE_ABI_LINKER_SCRIPT") endif() -if (LIBCXX_HAS_MUSL_LIBC AND NOT LIBCXX_INSTALL_SUPPORT_HEADERS) - message(FATAL_ERROR "LIBCXX_INSTALL_SUPPORT_HEADERS can not be turned off" - "when building for Musl with LIBCXX_HAS_MUSL_LIBC.") -endif() - if (LIBCXX_ABI_FORCE_ITANIUM AND LIBCXX_ABI_FORCE_MICROSOFT) message(FATAL_ERROR "Only one of LIBCXX_ABI_FORCE_ITANIUM and LIBCXX_ABI_FORCE_MICROSOFT can be specified.") endif () @@ -407,37 +406,46 @@ endif () # Configure System #=============================================================================== -set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER}) -set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) -set(LIBCXX_BINARY_INCLUDE_DIR "${LIBCXX_BINARY_DIR}/include/c++build") - -string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" CLANG_VERSION - ${PACKAGE_VERSION}) - +# TODO: Projects that depend on libc++ should use LIBCXX_GENERATED_INCLUDE_DIR +# instead of hard-coding include/c++/v1. if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) - set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) - set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++) + set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LLVM_BINARY_DIR}/include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1") + set(LIBCXX_INSTALL_LIBRARY_DIR lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE} CACHE PATH + "Path where built libc++ libraries should be installed.") + set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1" CACHE PATH + "Path where target-specific libc++ headers should be installed.") if(LIBCXX_LIBDIR_SUBDIR) string(APPEND LIBCXX_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) string(APPEND LIBCXX_INSTALL_LIBRARY_DIR /${LIBCXX_LIBDIR_SUBDIR}) endif() elseif(LLVM_LIBRARY_OUTPUT_INTDIR) set(LIBCXX_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR}) - set(LIBCXX_HEADER_DIR ${LLVM_BINARY_DIR}) - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${LLVM_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") + set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++ libraries should be installed.") + set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH + "Path where target-specific libc++ headers should be installed.") else() set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) - set(LIBCXX_HEADER_DIR ${CMAKE_BINARY_DIR}) - set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX}) + set(LIBCXX_GENERATED_INCLUDE_DIR "${CMAKE_BINARY_DIR}/include/c++/v1") + set(LIBCXX_GENERATED_INCLUDE_TARGET_DIR "${LIBCXX_GENERATED_INCLUDE_DIR}") + set(LIBCXX_INSTALL_LIBRARY_DIR lib${LIBCXX_LIBDIR_SUFFIX} CACHE PATH + "Path where built libc++ libraries should be installed.") + set(LIBCXX_INSTALL_INCLUDE_DIR "include/c++/v1" CACHE PATH + "Path where target-agnostic libc++ headers should be installed.") + set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${LIBCXX_INSTALL_INCLUDE_DIR}" CACHE PATH + "Path where target-specific libc++ headers should be installed.") endif() file(MAKE_DIRECTORY "${LIBCXX_BINARY_INCLUDE_DIR}") -set(LIBCXX_INSTALL_PREFIX "" CACHE STRING "Define libc++ destination prefix.") -set(LIBCXX_INSTALL_HEADER_PREFIX "" CACHE STRING "Define libc++ header destination prefix.") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) @@ -462,25 +470,21 @@ include(HandleLibcxxFlags) add_target_flags_if(LIBCXX_BUILD_32_BITS "-m32") if(LIBCXX_TARGET_TRIPLE) - add_target_flags("--target=${LIBCXX_TARGET_TRIPLE}") + add_target_flags_if_supported("--target=${LIBCXX_TARGET_TRIPLE}") elseif(CMAKE_CXX_COMPILER_TARGET) set(LIBCXX_TARGET_TRIPLE "${CMAKE_CXX_COMPILER_TARGET}") endif() if(LIBCXX_SYSROOT) - add_target_flags("--sysroot=${LIBCXX_SYSROOT}") + add_target_flags_if_supported("--sysroot=${LIBCXX_SYSROOT}") elseif(CMAKE_SYSROOT) set(LIBCXX_SYSROOT "${CMAKE_SYSROOT}") endif() if(LIBCXX_GCC_TOOLCHAIN) - add_target_flags("--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") + add_target_flags_if_supported("--gcc-toolchain=${LIBCXX_GCC_TOOLCHAIN}") elseif(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) set(LIBCXX_GCC_TOOLCHAIN "${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") endif() -if(LIBCXX_TARGET_TRIPLE) - set(TARGET_TRIPLE "${LIBCXX_TARGET_TRIPLE}") -endif() - # Configure compiler. include(config-ix) @@ -508,7 +512,7 @@ if (NOT LIBCXX_STANDALONE_BUILD) remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG -lc++abi) endif() -remove_flags(-stdlib=libc++ -stdlib=libstdc++) +remove_flags(--stdlib=libc++ -stdlib=libc++ --stdlib=libstdc++ -stdlib=libstdc++) # FIXME: Remove all debug flags and flags that change which Windows # default libraries are linked. Currently we only support linking the @@ -523,13 +527,22 @@ remove_flags(-Wno-pedantic -pedantic-errors -pedantic) # Required flags ============================================================== function(cxx_add_basic_build_flags target) - # Require C++14 for all targets. C++14 is needed to ensure constant - # initialization for certain globals (ex global memory resources). + # Require C++20 for all targets. C++17 is needed to use aligned allocation + # in the dylib. C++20 is needed to use char8_t. set_target_properties(${target} PROPERTIES - CXX_STANDARD 14 - CXX_STANDARD_REQUIRED YES + CXX_STANDARD 20 + CXX_STANDARD_REQUIRED NO CXX_EXTENSIONS NO) + # When building the dylib, don't warn for unavailable aligned allocation + # functions based on the deployment target -- they are always available + # because they are provided by the dylib itself with the excepton of z/OS. + if (ZOS) + target_add_compile_flags_if_supported(${target} PRIVATE -fno-aligned-allocation) + else() + target_add_compile_flags_if_supported(${target} PRIVATE -faligned-allocation) + endif() + # On all systems the system c++ standard library headers need to be excluded. # MSVC only has -X, which disables all default includes; including the crt. # Thus, we do nothing and hope we don't accidentally include any of the C++ @@ -575,13 +588,21 @@ endfunction() # Warning flags =============================================================== function(cxx_add_warning_flags target) target_compile_definitions(${target} PUBLIC -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) - target_add_compile_flags_if_supported(${target} PRIVATE -Wall -Wextra -W -Wwrite-strings + if (MSVC) + # -W4 is the cl.exe/clang-cl equivalent of -Wall. (In cl.exe and clang-cl, + # -Wall is equivalent to -Weverything in GCC style compiler drivers.) + target_add_compile_flags_if_supported(${target} PRIVATE -W4) + else() + target_add_compile_flags_if_supported(${target} PRIVATE -Wall) + endif() + target_add_compile_flags_if_supported(${target} PRIVATE -Wextra -W -Wwrite-strings -Wno-unused-parameter -Wno-long-long - -Werror=return-type -Wextra-semi) + -Werror=return-type -Wextra-semi -Wundef) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") target_add_compile_flags_if_supported(${target} PRIVATE -Wno-user-defined-literals -Wno-covered-switch-default + -Wno-suggest-override -Wno-ignored-attributes # FIXME: Caused by _LIBCPP_NODEBUG_TYPE not being supported on older clangs ) if (LIBCXX_TARGETING_CLANG_CL) @@ -606,7 +627,8 @@ function(cxx_add_warning_flags target) target_add_compile_flags_if_supported(${target} PRIVATE -Wno-literal-suffix -Wno-c++14-compat - -Wno-noexcept-type) + -Wno-noexcept-type + -Wno-suggest-override) endif() if (LIBCXX_ENABLE_WERROR) target_add_compile_flags_if_supported(${target} PRIVATE -Werror) @@ -730,9 +752,19 @@ endif() # Link system libraries ======================================================= function(cxx_link_system_libraries target) - target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") - target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") - target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") + +# In order to remove just libc++ from the link step +# we need to use -nostdlib++ whenever it is supported. +# Unfortunately this cannot be used universally because for example g++ supports +# only -nodefaultlibs in which case all libraries will be removed and +# all libraries but c++ have to be added in manually. + if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG) + target_add_link_flags_if_supported(${target} PRIVATE "-nostdlib++") + else() + target_add_link_flags_if_supported(${target} PRIVATE "-nodefaultlibs") + target_add_compile_flags_if_supported(${target} PRIVATE "/Zl") + target_add_link_flags_if_supported(${target} PRIVATE "/nodefaultlib") + endif() if (LIBCXX_HAS_SYSTEM_LIB) target_link_libraries(${target} PRIVATE System) @@ -842,10 +874,9 @@ config_define_if_not(LIBCXX_ENABLE_STDOUT _LIBCPP_HAS_NO_STDOUT) config_define_if_not(LIBCXX_ENABLE_THREADS _LIBCPP_HAS_NO_THREADS) config_define_if_not(LIBCXX_ENABLE_MONOTONIC_CLOCK _LIBCPP_HAS_NO_MONOTONIC_CLOCK) config_define_if_not(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) -if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "") +if (NOT LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION STREQUAL "default") config_define("${LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION}" _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION) endif() - config_define_if(LIBCXX_HAS_PTHREAD_API _LIBCPP_HAS_THREAD_API_PTHREAD) config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL) config_define_if(LIBCXX_HAS_WIN32_THREAD_API _LIBCPP_HAS_THREAD_API_WIN32) @@ -853,6 +884,14 @@ config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME) config_define_if(LIBCXX_ENABLE_PARALLEL_ALGORITHMS _LIBCPP_HAS_PARALLEL_ALGORITHMS) +config_define_if_not(LIBCXX_ENABLE_FILESYSTEM _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY) +config_define_if_not(LIBCXX_ENABLE_RANDOM_DEVICE _LIBCPP_HAS_NO_RANDOM_DEVICE) +config_define_if_not(LIBCXX_ENABLE_LOCALIZATION _LIBCPP_HAS_NO_LOCALIZATION) +config_define_if_not(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) +# Incomplete features get their own specific disabling flags. This makes it +# easier to grep for target specific flags once the feature is complete. +config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_FORMAT) +config_define_if_not(LIBCXX_ENABLE_INCOMPLETE_FEATURES _LIBCPP_HAS_NO_INCOMPLETE_RANGES) if (LIBCXX_ABI_DEFINES) set(abi_defines) @@ -874,6 +913,12 @@ if (DEFINED WIN32 AND LIBCXX_ENABLE_STATIC AND NOT LIBCXX_ENABLE_SHARED) config_define(ON _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS) endif() +if (WIN32 AND LIBCXX_ENABLE_STATIC_ABI_LIBRARY) + # If linking libcxxabi statically into libcxx, skip the dllimport attributes + # on symbols we refer to from libcxxabi. + add_definitions(-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS) +endif() + # Setup all common build flags ================================================= function(cxx_add_common_build_flags target) cxx_add_basic_build_flags(${target}) @@ -890,6 +935,7 @@ endfunction() #=============================================================================== add_subdirectory(include) add_subdirectory(src) +add_subdirectory(utils) set(LIBCXX_TEST_DEPS "") diff --git a/gnu/llvm/libcxx/appveyor-reqs-install.cmd b/gnu/llvm/libcxx/appveyor-reqs-install.cmd new file mode 100644 index 00000000000..e3bd018dd37 --- /dev/null +++ b/gnu/llvm/libcxx/appveyor-reqs-install.cmd @@ -0,0 +1,53 @@ +@echo on + +if NOT EXIST C:\projects\deps ( + mkdir C:\projects\deps +) +cd C:\projects\deps + +::########################################################################### +:: Setup Compiler +::########################################################################### +if NOT EXIST llvm-installer.exe ( + appveyor DownloadFile https://prereleases.llvm.org/win-snapshots/LLVM-9.0.0-r357435-win32.exe -FileName llvm-installer.exe +) +if "%CLANG_VERSION%"=="ToT" ( + START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM" +) +if DEFINED CLANG_VERSION @set PATH="C:\Program Files\LLVM\bin";%PATH% +if DEFINED CLANG_VERSION clang-cl -v + +if DEFINED MINGW_PATH rename "C:\Program Files\Git\usr\bin\sh.exe" "sh-ignored.exe" +if DEFINED MINGW_PATH @set "PATH=%PATH:C:\Program Files (x86)\Git\bin=%" +if DEFINED MINGW_PATH @set "PATH=%PATH%;%MINGW_PATH%" +if DEFINED MINGW_PATH g++ -v + +::########################################################################### +:: Install a recent CMake +::########################################################################### +if NOT EXIST cmake ( + appveyor DownloadFile https://cmake.org/files/v3.7/cmake-3.7.2-win64-x64.zip -FileName cmake.zip + 7z x cmake.zip -oC:\projects\deps > nul + move C:\projects\deps\cmake-* C:\projects\deps\cmake + rm cmake.zip +) +@set PATH=C:\projects\deps\cmake\bin;%PATH% +cmake --version + +::########################################################################### +:: Install Ninja +::########################################################################### +if NOT EXIST ninja ( + appveyor DownloadFile https://github.com/ninja-build/ninja/releases/download/v1.6.0/ninja-win.zip -FileName ninja.zip + 7z x ninja.zip -oC:\projects\deps\ninja > nul + rm ninja.zip +) +@set PATH=C:\projects\deps\ninja;%PATH% +ninja --version + +::########################################################################### +:: Setup the cached copy of LLVM +::########################################################################### +git clone --depth=1 http://llvm.org/git/llvm.git + +@echo off diff --git a/gnu/llvm/libcxx/appveyor.yml b/gnu/llvm/libcxx/appveyor.yml new file mode 100644 index 00000000000..ae7c7ad7cf6 --- /dev/null +++ b/gnu/llvm/libcxx/appveyor.yml @@ -0,0 +1,71 @@ +version: '{build}' + +shallow_clone: true + +build: + verbosity: detailed + +configuration: + - Debug + +environment: + matrix: + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 + CMAKE_OPTIONS: -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe + CLANG_VERSION: ToT + MSVC_SETUP_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat + MSVC_SETUP_ARG: x86 + GENERATOR: Ninja + MAKE_PROGRAM: ninja + APPVEYOR_SAVE_CACHE_ON_ERROR: true +# TODO: Maybe re-enable this configuration? Do we want to support MSVC 2015's runtime? +# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 +# MINGW_PATH: C:\mingw-w64\i686-6.3.0-posix-dwarf-rt_v5-rev1\mingw32\bin +# GENERATOR: MinGW Makefiles +# MAKE_PROGRAM: mingw32-make +# APPVEYOR_SAVE_CACHE_ON_ERROR: true + +install: + ############################################################################ + # All external dependencies are installed in C:\projects\deps + ############################################################################ + - call "%APPVEYOR_BUILD_FOLDER%\\appveyor-reqs-install.cmd" + +before_build: + - if DEFINED MSVC_SETUP_PATH call "%MSVC_SETUP_PATH%" %MSVC_SETUP_ARG% + - cd %APPVEYOR_BUILD_FOLDER% + +build_script: + - md C:\projects\build-libcxx + - cd C:\projects\build-libcxx + - echo %configuration% + + ############################################################################# + # Configuration Step + ############################################################################# + - cmake -G "%GENERATOR%" %CMAKE_OPTIONS% + "-DCMAKE_BUILD_TYPE=%configuration%" + "-DLLVM_PATH=C:\projects\deps\llvm" -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF + -DLLVM_LIT_ARGS="-sv --show-xfail --show-unsupported" + %APPVEYOR_BUILD_FOLDER% + + ############################################################################# + # Build Step + ############################################################################# + - "%MAKE_PROGRAM%" + +test_script: + - "%MAKE_PROGRAM% check-cxx" + +on_failure: + - appveyor PushArtifact CMakeFiles/CMakeOutput.log + - appveyor PushArtifact CMakeFiles/CMakeError.log + +artifacts: + - path: '_build/CMakeFiles/*.log' + name: logs + +cache: + - C:\projects\deps\ninja + - C:\projects\deps\cmake + - C:\projects\deps\llvm-installer.exe diff --git a/gnu/llvm/libcxx/benchmarks/CMakeLists.txt b/gnu/llvm/libcxx/benchmarks/CMakeLists.txt index 8480ede23a4..c4b8247da63 100644 --- a/gnu/llvm/libcxx/benchmarks/CMakeLists.txt +++ b/gnu/llvm/libcxx/benchmarks/CMakeLists.txt @@ -5,20 +5,25 @@ include(CheckCXXCompilerFlag) # Build Google Benchmark for libc++ #============================================================================== +set(CMAKE_FOLDER "${CMAKE_FOLDER}/Benchmarks") + set(BENCHMARK_LIBCXX_COMPILE_FLAGS -Wno-unused-command-line-argument -nostdinc++ - -isystem ${LIBCXX_SOURCE_DIR}/include + -isystem "${LIBCXX_GENERATED_INCLUDE_DIR}" -L${LIBCXX_LIBRARY_DIR} -Wl,-rpath,${LIBCXX_LIBRARY_DIR} ${SANITIZER_FLAGS} ) +if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE) + list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS + -isystem "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}") +endif() if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH) list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS -L${LIBCXX_CXX_ABI_LIBRARY_PATH} -Wl,-rpath,${LIBCXX_CXX_ABI_LIBRARY_PATH}) endif() -list(APPEND BENCHMARK_LIBCXX_COMPILE_FLAGS -include "${LIBCXX_BINARY_DIR}/__config_site") split_list(BENCHMARK_LIBCXX_COMPILE_FLAGS) ExternalProject_Add(google-benchmark-libcxx @@ -70,18 +75,9 @@ set(BENCHMARK_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(BENCHMARK_LIBCXX_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-libcxx) set(BENCHMARK_NATIVE_INSTALL ${CMAKE_CURRENT_BINARY_DIR}/benchmark-native) -check_flag_supported("-std=c++17") -mangle_name("LIBCXX_SUPPORTS_STD_EQ_c++17_FLAG" BENCHMARK_SUPPORTS_STD_CXX17_FLAG) -if (${BENCHMARK_SUPPORTS_STD_CXX17_FLAG}) - set(BENCHMARK_DIALECT_FLAG "-std=c++17") -else() - # If the compiler doesn't support -std=c++17, attempt to fall back to -std=c++1z while still - # requiring C++17 language features. - set(BENCHMARK_DIALECT_FLAG "-std=c++1z") -endif() set(BENCHMARK_TEST_COMPILE_FLAGS - ${BENCHMARK_DIALECT_FLAG} -O2 + -O2 -fsized-deallocation -I${BENCHMARK_LIBCXX_INSTALL}/include -I${LIBCXX_SOURCE_DIR}/test/support @@ -90,6 +86,7 @@ set(BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS ${BENCHMARK_TEST_COMPILE_FLAGS} ${SANITIZER_FLAGS} -Wno-user-defined-literals + -Wno-suggest-override ) set(BENCHMARK_TEST_LIBCXX_LINK_FLAGS @@ -147,7 +144,10 @@ function(add_benchmark_test name source_file) OUTPUT_NAME "${name}.libcxx.out" RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" COMPILE_FLAGS "${BENCHMARK_TEST_LIBCXX_COMPILE_FLAGS}" - LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}") + LINK_FLAGS "${BENCHMARK_TEST_LIBCXX_LINK_FLAGS}" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES + CXX_EXTENSIONS NO) cxx_link_system_libraries(${libcxx_target}) if (LIBCXX_BENCHMARK_NATIVE_STDLIB) if (LIBCXX_BENCHMARK_NATIVE_STDLIB STREQUAL "libstdc++" AND NOT DEFINED LIBSTDCXX_FILESYSTEM_LIB @@ -174,7 +174,10 @@ function(add_benchmark_test name source_file) RUNTIME_OUTPUT_DIRECTORY "${BENCHMARK_OUTPUT_DIR}" INCLUDE_DIRECTORIES "" COMPILE_FLAGS "${BENCHMARK_TEST_NATIVE_COMPILE_FLAGS}" - LINK_FLAGS "${BENCHMARK_TEST_NATIVE_LINK_FLAGS}") + LINK_FLAGS "${BENCHMARK_TEST_NATIVE_LINK_FLAGS}" + CXX_STANDARD 17 + CXX_STANDARD_REQUIRED YES + CXX_EXTENSIONS NO) endif() endfunction() diff --git a/gnu/llvm/libcxx/benchmarks/VariantBenchmarks.h b/gnu/llvm/libcxx/benchmarks/VariantBenchmarks.h new file mode 100644 index 00000000000..2feaeab51b9 --- /dev/null +++ b/gnu/llvm/libcxx/benchmarks/VariantBenchmarks.h @@ -0,0 +1,58 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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 BENCHMARK_VARIANT_BENCHMARKS_H +#define BENCHMARK_VARIANT_BENCHMARKS_H + +#include +#include +#include +#include +#include + +#include "benchmark/benchmark.h" + +#include "GenerateInput.h" + +namespace VariantBenchmarks { + +template +struct S { + static constexpr size_t v = I; +}; + +template +static auto genVariants(std::index_sequence) { + using V = std::variant...>; + using F = V (*)(); + static constexpr F fs[] = {[] { return V(std::in_place_index); }...}; + + std::array result = {}; + for (auto& v : result) { + v = fs[getRandomInteger(0ul, sizeof...(Is) - 1)](); + } + + return result; +} + +template +static void BM_Visit(benchmark::State& state) { + auto args = genVariants(std::make_index_sequence{}); + for (auto _ : state) { + benchmark::DoNotOptimize(std::apply( + [](auto... vs) { + return std::visit([](auto... is) { return (is.v + ... + 0); }, vs...); + }, + args)); + } +} + +} // end namespace VariantBenchmarks + +#endif // BENCHMARK_VARIANT_BENCHMARKS_H diff --git a/gnu/llvm/libcxx/benchmarks/filesystem.bench.cpp b/gnu/llvm/libcxx/benchmarks/filesystem.bench.cpp index 64314ac5ab0..95aecd50473 100644 --- a/gnu/llvm/libcxx/benchmarks/filesystem.bench.cpp +++ b/gnu/llvm/libcxx/benchmarks/filesystem.bench.cpp @@ -62,7 +62,7 @@ void BM_PathConstructIter(benchmark::State &st, GenInputs gen) { } template void BM_PathConstructInputIter(benchmark::State &st, GenInputs gen) { - BM_PathConstructIter(st, gen); + BM_PathConstructIter(st, gen); } template void BM_PathConstructForwardIter(benchmark::State &st, GenInputs gen) { diff --git a/gnu/llvm/libcxx/benchmarks/map.bench.cpp b/gnu/llvm/libcxx/benchmarks/map.bench.cpp new file mode 100644 index 00000000000..dd1884f6503 --- /dev/null +++ b/gnu/llvm/libcxx/benchmarks/map.bench.cpp @@ -0,0 +1,1037 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +#include +#include +#include +#include +#include + +#include "CartesianBenchmarks.h" +#include "benchmark/benchmark.h" +#include "test_macros.h" + +// When VALIDATE is defined the benchmark will run to validate the benchmarks. +// The time taken by several operations depend on whether or not an element +// exists. To avoid errors in the benchmark these operations have a validation +// mode to test the benchmark. Since they are not meant to be benchmarked the +// number of sizes tested is limited to 1. +//#define VALIDATE + +namespace { + +enum class Mode { Hit, Miss }; + +struct AllModes : EnumValuesAsTuple { + static constexpr const char* Names[] = {"ExistingElement", "NewElement"}; +}; + +// The positions of the hints to pick: +// - Begin picks the first item. The item cannot be put before this element. +// - Thrid picks the third item. This is just an element with a valid entry +// before and after it. +// - Correct contains the correct hint. +// - End contains a hint to the end of the map. +enum class Hint { Begin, Third, Correct, End }; +struct AllHints : EnumValuesAsTuple { + static constexpr const char* Names[] = {"Begin", "Third", "Correct", "End"}; +}; + +enum class Order { Sorted, Random }; +struct AllOrders : EnumValuesAsTuple { + static constexpr const char* Names[] = {"Sorted", "Random"}; +}; + +struct TestSets { + std::vector Keys; + std::vector > Maps; + std::vector< + std::vector::const_iterator> > + Hints; +}; + +enum class Shuffle { None, Keys, Hints }; + +TestSets makeTestingSets(size_t MapSize, Mode mode, Shuffle shuffle, + size_t max_maps) { + /* + * The shuffle does not retain the random number generator to use the same + * set of random numbers for every iteration. + */ + TestSets R; + + int MapCount = std::min(max_maps, 1000000 / MapSize); + + for (uint64_t I = 0; I < MapSize; ++I) { + R.Keys.push_back(mode == Mode::Hit ? 2 * I + 2 : 2 * I + 1); + } + if (shuffle == Shuffle::Keys) + std::shuffle(R.Keys.begin(), R.Keys.end(), std::mt19937()); + + for (int M = 0; M < MapCount; ++M) { + auto& map = R.Maps.emplace_back(); + auto& hints = R.Hints.emplace_back(); + for (uint64_t I = 0; I < MapSize; ++I) { + hints.push_back(map.insert(std::make_pair(2 * I + 2, 0)).first); + } + if (shuffle == Shuffle::Hints) + std::shuffle(hints.begin(), hints.end(), std::mt19937()); + } + + return R; +} + +struct Base { + size_t MapSize; + Base(size_t T) : MapSize(T) {} + + std::string baseName() const { return "_MapSize=" + std::to_string(MapSize); } +}; + +//*******************************************************************| +// Member functions | +//*******************************************************************| + +struct ConstructorDefault { + void run(benchmark::State& State) const { + for (auto _ : State) { + benchmark::DoNotOptimize(std::map()); + } + } + + std::string name() const { return "BM_ConstructorDefault"; } +}; + +struct ConstructorIterator : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { +#ifndef VALIDATE + benchmark::DoNotOptimize( + std::map(Map.begin(), Map.end())); +#else + std::map M{Map.begin(), Map.end()}; + if (M != Map) + State.SkipWithError("Map copy not identical"); +#endif + } + } + + std::string name() const { return "BM_ConstructorIterator" + baseName(); } +}; + +struct ConstructorCopy : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { +#ifndef VALIDATE + std::map M(Map); + benchmark::DoNotOptimize(M); +#else + std::map M(Map); + if (M != Map) + State.SkipWithError("Map copy not identical"); +#endif + } + } + + std::string name() const { return "BM_ConstructorCopy" + baseName(); } +}; + +struct ConstructorMove : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + std::map M(std::move(Map)); + benchmark::DoNotOptimize(M); + } + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + std::string name() const { return "BM_ConstructorMove" + baseName(); } +}; + +//*******************************************************************| +// Capacity | +//*******************************************************************| + +struct Empty : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1); + auto& Map = Data.Maps.front(); + for (auto _ : State) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.empty()); +#else + if (Map.empty()) + State.SkipWithError("Map contains an invalid number of elements."); +#endif + } + } + + std::string name() const { return "BM_Empty" + baseName(); } +}; + +struct Size : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1); + auto& Map = Data.Maps.front(); + for (auto _ : State) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.size()); +#else + if (Map.size() != MapSize) + State.SkipWithError("Map contains an invalid number of elements."); +#endif + } + } + + std::string name() const { return "BM_Size" + baseName(); } +}; + +//*******************************************************************| +// Modifiers | +//*******************************************************************| + +struct Clear : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + Map.clear(); + benchmark::DoNotOptimize(Map); + } + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + std::string name() const { return "BM_Clear" + baseName(); } +}; + +template +struct Insert : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.insert(std::make_pair(K, 1))); +#else + bool Inserted = Map.insert(std::make_pair(K, 1)).second; + if (Mode() == ::Mode::Hit) { + if (Inserted) + State.SkipWithError("Inserted a duplicate element"); + } else { + if (!Inserted) + State.SkipWithError("Failed to insert e new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys + : Shuffle::None, + 1000); + State.ResumeTiming(); + } + } + + std::string name() const { + return "BM_Insert" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct InsertHint : Base { + using Base::Base; + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto H = Data.Hints[I].begin(); + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.insert(*H, std::make_pair(K, 1))); +#else + auto Inserted = Map.insert(*H, std::make_pair(K, 1)); + if (Mode() == ::Mode::Hit) { + if (Inserted != *H) + State.SkipWithError("Inserted a duplicate element"); + } else { + if (++Inserted != *H) + State.SkipWithError("Failed to insert a new element"); + } +#endif + ++H; + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto Third = *(Data.Hints[I].begin() + 2); + for (auto K : Data.Keys) { + auto Itor = hint == ::Hint::Begin + ? Map.begin() + : hint == ::Hint::Third ? Third : Map.end(); +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.insert(Itor, std::make_pair(K, 1))); +#else + size_t Size = Map.size(); + Map.insert(Itor, std::make_pair(K, 1)); + if (Mode() == ::Mode::Hit) { + if (Size != Map.size()) + State.SkipWithError("Inserted a duplicate element"); + } else { + if (Size + 1 != Map.size()) + State.SkipWithError("Failed to insert a new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + void run(benchmark::State& State) const { + static constexpr auto h = Hint(); + run(State); + } + + std::string name() const { + return "BM_InsertHint" + baseName() + Mode::name() + Hint::name(); + } +}; + +template +struct InsertAssign : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.insert_or_assign(K, 1)); +#else + bool Inserted = Map.insert_or_assign(K, 1).second; + if (Mode() == ::Mode::Hit) { + if (Inserted) + State.SkipWithError("Inserted a duplicate element"); + } else { + if (!Inserted) + State.SkipWithError("Failed to insert e new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys + : Shuffle::None, + 1000); + State.ResumeTiming(); + } + } + + std::string name() const { + return "BM_InsertAssign" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct InsertAssignHint : Base { + using Base::Base; + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto H = Data.Hints[I].begin(); + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.insert_or_assign(*H, K, 1)); +#else + auto Inserted = Map.insert_or_assign(*H, K, 1); + if (Mode() == ::Mode::Hit) { + if (Inserted != *H) + State.SkipWithError("Inserted a duplicate element"); + } else { + if (++Inserted != *H) + State.SkipWithError("Failed to insert a new element"); + } +#endif + ++H; + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto Third = *(Data.Hints[I].begin() + 2); + for (auto K : Data.Keys) { + auto Itor = hint == ::Hint::Begin + ? Map.begin() + : hint == ::Hint::Third ? Third : Map.end(); +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.insert_or_assign(Itor, K, 1)); +#else + size_t Size = Map.size(); + Map.insert_or_assign(Itor, K, 1); + if (Mode() == ::Mode::Hit) { + if (Size != Map.size()) + State.SkipWithError("Inserted a duplicate element"); + } else { + if (Size + 1 != Map.size()) + State.SkipWithError("Failed to insert a new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + void run(benchmark::State& State) const { + static constexpr auto h = Hint(); + run(State); + } + + std::string name() const { + return "BM_InsertAssignHint" + baseName() + Mode::name() + Hint::name(); + } +}; + +template +struct Emplace : Base { + using Base::Base; + + void run(benchmark::State& State) const { + + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.emplace(K, 1)); +#else + bool Inserted = Map.emplace(K, 1).second; + if (Mode() == ::Mode::Hit) { + if (Inserted) + State.SkipWithError("Emplaced a duplicate element"); + } else { + if (!Inserted) + State.SkipWithError("Failed to emplace a new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys + : Shuffle::None, + 1000); + State.ResumeTiming(); + } + } + + std::string name() const { + return "BM_Emplace" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct EmplaceHint : Base { + using Base::Base; + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto H = Data.Hints[I].begin(); + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.emplace_hint(*H, K, 1)); +#else + auto Inserted = Map.emplace_hint(*H, K, 1); + if (Mode() == ::Mode::Hit) { + if (Inserted != *H) + State.SkipWithError("Emplaced a duplicate element"); + } else { + if (++Inserted != *H) + State.SkipWithError("Failed to emplace a new element"); + } +#endif + ++H; + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto Third = *(Data.Hints[I].begin() + 2); + for (auto K : Data.Keys) { + auto Itor = hint == ::Hint::Begin + ? Map.begin() + : hint == ::Hint::Third ? Third : Map.end(); +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.emplace_hint(Itor, K, 1)); +#else + size_t Size = Map.size(); + Map.emplace_hint(Itor, K, 1); + if (Mode() == ::Mode::Hit) { + if (Size != Map.size()) + State.SkipWithError("Emplaced a duplicate element"); + } else { + if (Size + 1 != Map.size()) + State.SkipWithError("Failed to emplace a new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + void run(benchmark::State& State) const { + static constexpr auto h = Hint(); + run(State); + } + + std::string name() const { + return "BM_EmplaceHint" + baseName() + Mode::name() + Hint::name(); + } +}; + +template +struct TryEmplace : Base { + using Base::Base; + + void run(benchmark::State& State) const { + + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.try_emplace(K, 1)); +#else + bool Inserted = Map.try_emplace(K, 1).second; + if (Mode() == ::Mode::Hit) { + if (Inserted) + State.SkipWithError("Emplaced a duplicate element"); + } else { + if (!Inserted) + State.SkipWithError("Failed to emplace a new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys + : Shuffle::None, + 1000); + State.ResumeTiming(); + } + } + + std::string name() const { + return "BM_TryEmplace" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct TryEmplaceHint : Base { + using Base::Base; + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto H = Data.Hints[I].begin(); + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.try_emplace(*H, K, 1)); +#else + auto Inserted = Map.try_emplace(*H, K, 1); + if (Mode() == ::Mode::Hit) { + if (Inserted != *H) + State.SkipWithError("Emplaced a duplicate element"); + } else { + if (++Inserted != *H) + State.SkipWithError("Failed to emplace a new element"); + } +#endif + ++H; + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + template < ::Hint hint> + typename std::enable_if::type + run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + auto Third = *(Data.Hints[I].begin() + 2); + for (auto K : Data.Keys) { + auto Itor = hint == ::Hint::Begin + ? Map.begin() + : hint == ::Hint::Third ? Third : Map.end(); +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.try_emplace(Itor, K, 1)); +#else + size_t Size = Map.size(); + Map.try_emplace(Itor, K, 1); + if (Mode() == ::Mode::Hit) { + if (Size != Map.size()) + State.SkipWithError("Emplaced a duplicate element"); + } else { + if (Size + 1 != Map.size()) + State.SkipWithError("Failed to emplace a new element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + void run(benchmark::State& State) const { + static constexpr auto h = Hint(); + run(State); + } + + std::string name() const { + return "BM_TryEmplaceHint" + baseName() + Mode::name() + Hint::name(); + } +}; + +template +struct Erase : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.erase(K)); +#else + size_t I = Map.erase(K); + if (Mode() == ::Mode::Hit) { + if (I == 0) + State.SkipWithError("Did not find the existing element"); + } else { + if (I == 1) + State.SkipWithError("Did find the non-existing element"); + } +#endif + } + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys + : Shuffle::None, + 1000); + State.ResumeTiming(); + } + } + + std::string name() const { + return "BM_Erase" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct EraseIterator : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode::Hit, + Order::value == ::Order::Random ? Shuffle::Hints : Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (size_t I = 0; I < Data.Maps.size(); ++I) { + auto& Map = Data.Maps[I]; + for (auto H : Data.Hints[I]) { + benchmark::DoNotOptimize(Map.erase(H)); + } +#ifdef VALIDATE + if (!Map.empty()) + State.SkipWithError("Did not erase the entire map"); +#endif + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode::Hit, + Order::value == ::Order::Random ? Shuffle::Hints + : Shuffle::None, + 1000); + State.ResumeTiming(); + } + } + + std::string name() const { + return "BM_EraseIterator" + baseName() + Order::name(); + } +}; + +struct EraseRange : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1000); + while (State.KeepRunningBatch(MapSize * Data.Maps.size())) { + for (auto& Map : Data.Maps) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.erase(Map.begin(), Map.end())); +#else + Map.erase(Map.begin(), Map.end()); + if (!Map.empty()) + State.SkipWithError("Did not erase the entire map"); +#endif + } + + State.PauseTiming(); + Data = makeTestingSets(MapSize, Mode::Hit, Shuffle::None, 1000); + State.ResumeTiming(); + } + } + + std::string name() const { return "BM_EraseRange" + baseName(); } +}; + +//*******************************************************************| +// Lookup | +//*******************************************************************| + +template +struct Count : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.count(K)); +#else + size_t I = Map.count(K); + if (Mode() == ::Mode::Hit) { + if (I == 0) + State.SkipWithError("Did not find the existing element"); + } else { + if (I == 1) + State.SkipWithError("Did find the non-existing element"); + } +#endif + } + } + } + + std::string name() const { + return "BM_Count" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct Find : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.find(K)); +#else + auto Itor = Map.find(K); + if (Mode() == ::Mode::Hit) { + if (Itor == Map.end()) + State.SkipWithError("Did not find the existing element"); + } else { + if (Itor != Map.end()) + State.SkipWithError("Did find the non-existing element"); + } +#endif + } + } + } + + std::string name() const { + return "BM_Find" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct EqualRange : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.equal_range(K)); +#else + auto Range = Map.equal_range(K); + if (Mode() == ::Mode::Hit) { + // Adjust validation for the last element. + auto Key = K; + if (Range.second == Map.end() && K == 2 * MapSize) { + --Range.second; + Key -= 2; + } + if (Range.first == Map.end() || Range.first->first != K || + Range.second == Map.end() || Range.second->first - 2 != Key) + State.SkipWithError("Did not find the existing element"); + } else { + if (Range.first == Map.end() || Range.first->first - 1 != K || + Range.second == Map.end() || Range.second->first - 1 != K) + State.SkipWithError("Did find the non-existing element"); + } +#endif + } + } + } + + std::string name() const { + return "BM_EqualRange" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct LowerBound : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.lower_bound(K)); +#else + auto Itor = Map.lower_bound(K); + if (Mode() == ::Mode::Hit) { + if (Itor == Map.end() || Itor->first != K) + State.SkipWithError("Did not find the existing element"); + } else { + if (Itor == Map.end() || Itor->first - 1 != K) + State.SkipWithError("Did find the non-existing element"); + } +#endif + } + } + } + + std::string name() const { + return "BM_LowerBound" + baseName() + Mode::name() + Order::name(); + } +}; + +template +struct UpperBound : Base { + using Base::Base; + + void run(benchmark::State& State) const { + auto Data = makeTestingSets( + MapSize, Mode(), + Order::value == ::Order::Random ? Shuffle::Keys : Shuffle::None, 1); + auto& Map = Data.Maps.front(); + while (State.KeepRunningBatch(MapSize)) { + for (auto K : Data.Keys) { +#ifndef VALIDATE + benchmark::DoNotOptimize(Map.upper_bound(K)); +#else + std::map::iterator Itor = Map.upper_bound(K); + if (Mode() == ::Mode::Hit) { + // Adjust validation for the last element. + auto Key = K; + if (Itor == Map.end() && K == 2 * MapSize) { + --Itor; + Key -= 2; + } + if (Itor == Map.end() || Itor->first - 2 != Key) + State.SkipWithError("Did not find the existing element"); + } else { + if (Itor == Map.end() || Itor->first - 1 != K) + State.SkipWithError("Did find the non-existing element"); + } +#endif + } + } + } + + std::string name() const { + return "BM_UpperBound" + baseName() + Mode::name() + Order::name(); + } +}; + +} // namespace + +int main(int argc, char** argv) { + benchmark::Initialize(&argc, argv); + if (benchmark::ReportUnrecognizedArguments(argc, argv)) + return 1; + +#ifdef VALIDATE + const std::vector MapSize{10}; +#else + const std::vector MapSize{10, 100, 1000, 10000, 100000, 1000000}; +#endif + + // Member functions + makeCartesianProductBenchmark(); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + + // Capacity + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + + // Modifiers + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + + // Lookup + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + makeCartesianProductBenchmark(MapSize); + + benchmark::RunSpecifiedBenchmarks(); +} diff --git a/gnu/llvm/libcxx/benchmarks/to_chars.bench.cpp b/gnu/llvm/libcxx/benchmarks/to_chars.bench.cpp new file mode 100644 index 00000000000..1a3dc64497b --- /dev/null +++ b/gnu/llvm/libcxx/benchmarks/to_chars.bench.cpp @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// 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 +// +//===----------------------------------------------------------------------===// + +#include +#include +#include + +#include "benchmark/benchmark.h" +#include "test_macros.h" + +static const std::array input = [] { + std::mt19937 generator; + std::uniform_int_distribution distribution(0, std::numeric_limits::max()); + std::array result; + std::generate_n(result.begin(), result.size(), [&] { return distribution(generator); }); + return result; +}(); + +static void BM_to_chars_good(benchmark::State& state) { + char buffer[128]; + int base = state.range(0); + while (state.KeepRunningBatch(input.size())) + for (auto value : input) + benchmark::DoNotOptimize(std::to_chars(buffer, &buffer[128], value, base)); +} +BENCHMARK(BM_to_chars_good)->DenseRange(2, 36, 1); + +static void BM_to_chars_bad(benchmark::State& state) { + char buffer[128]; + int base = state.range(0); + struct sample { + unsigned size; + unsigned value; + }; + std::array data; + // Assume the failure occurs, on average, halfway during the conversion. + std::transform(input.begin(), input.end(), data.begin(), [&](unsigned value) { + std::to_chars_result result = std::to_chars(buffer, &buffer[128], value, base); + return sample{unsigned((result.ptr - buffer) / 2), value}; + }); + + while (state.KeepRunningBatch(data.size())) + for (auto element : data) + benchmark::DoNotOptimize(std::to_chars(buffer, &buffer[element.size], element.value, base)); +} +BENCHMARK(BM_to_chars_bad)->DenseRange(2, 36, 1); + +int main(int argc, char** argv) { + benchmark::Initialize(&argc, argv); + if (benchmark::ReportUnrecognizedArguments(argc, argv)) + return 1; + + benchmark::RunSpecifiedBenchmarks(); +} diff --git a/gnu/llvm/libcxx/benchmarks/variant_visit_1.bench.cpp b/gnu/llvm/libcxx/benchmarks/variant_visit_1.bench.cpp new file mode 100644 index 00000000000..7d736f8abb1 --- /dev/null +++ b/gnu/llvm/libcxx/benchmarks/variant_visit_1.bench.cpp @@ -0,0 +1,27 @@ +#include "benchmark/benchmark.h" + +#include "VariantBenchmarks.h" + +using namespace VariantBenchmarks; + +BENCHMARK_TEMPLATE(BM_Visit, 1, 1); +BENCHMARK_TEMPLATE(BM_Visit, 1, 2); +BENCHMARK_TEMPLATE(BM_Visit, 1, 3); +BENCHMARK_TEMPLATE(BM_Visit, 1, 4); +BENCHMARK_TEMPLATE(BM_Visit, 1, 5); +BENCHMARK_TEMPLATE(BM_Visit, 1, 6); +BENCHMARK_TEMPLATE(BM_Visit, 1, 7); +BENCHMARK_TEMPLATE(BM_Visit, 1, 8); +BENCHMARK_TEMPLATE(BM_Visit, 1, 9); +BENCHMARK_TEMPLATE(BM_Visit, 1, 10); +BENCHMARK_TEMPLATE(BM_Visit, 1, 20); +BENCHMARK_TEMPLATE(BM_Visit, 1, 30); +BENCHMARK_TEMPLATE(BM_Visit, 1, 40); +BENCHMARK_TEMPLATE(BM_Visit, 1, 50); +BENCHMARK_TEMPLATE(BM_Visit, 1, 60); +BENCHMARK_TEMPLATE(BM_Visit, 1, 70); +BENCHMARK_TEMPLATE(BM_Visit, 1, 80); +BENCHMARK_TEMPLATE(BM_Visit, 1, 90); +BENCHMARK_TEMPLATE(BM_Visit, 1, 100); + +BENCHMARK_MAIN(); diff --git a/gnu/llvm/libcxx/benchmarks/variant_visit_2.bench.cpp b/gnu/llvm/libcxx/benchmarks/variant_visit_2.bench.cpp new file mode 100644 index 00000000000..ed26cd44c3a --- /dev/null +++ b/gnu/llvm/libcxx/benchmarks/variant_visit_2.bench.cpp @@ -0,0 +1,22 @@ +#include "benchmark/benchmark.h" + +#include "VariantBenchmarks.h" + +using namespace VariantBenchmarks; + +BENCHMARK_TEMPLATE(BM_Visit, 2, 1); +BENCHMARK_TEMPLATE(BM_Visit, 2, 2); +BENCHMARK_TEMPLATE(BM_Visit, 2, 3); +BENCHMARK_TEMPLATE(BM_Visit, 2, 4); +BENCHMARK_TEMPLATE(BM_Visit, 2, 5); +BENCHMARK_TEMPLATE(BM_Visit, 2, 6); +BENCHMARK_TEMPLATE(BM_Visit, 2, 7); +BENCHMARK_TEMPLATE(BM_Visit, 2, 8); +BENCHMARK_TEMPLATE(BM_Visit, 2, 9); +BENCHMARK_TEMPLATE(BM_Visit, 2, 10); +BENCHMARK_TEMPLATE(BM_Visit, 2, 20); +BENCHMARK_TEMPLATE(BM_Visit, 2, 30); +BENCHMARK_TEMPLATE(BM_Visit, 2, 40); +BENCHMARK_TEMPLATE(BM_Visit, 2, 50); + +BENCHMARK_MAIN(); diff --git a/gnu/llvm/libcxx/benchmarks/variant_visit_3.bench.cpp b/gnu/llvm/libcxx/benchmarks/variant_visit_3.bench.cpp new file mode 100644 index 00000000000..b20d50391f2 --- /dev/null +++ b/gnu/llvm/libcxx/benchmarks/variant_visit_3.bench.cpp @@ -0,0 +1,20 @@ +#include "benchmark/benchmark.h" + +#include "VariantBenchmarks.h" + +using namespace VariantBenchmarks; + +BENCHMARK_TEMPLATE(BM_Visit, 3, 1); +BENCHMARK_TEMPLATE(BM_Visit, 3, 2); +BENCHMARK_TEMPLATE(BM_Visit, 3, 3); +BENCHMARK_TEMPLATE(BM_Visit, 3, 4); +BENCHMARK_TEMPLATE(BM_Visit, 3, 5); +BENCHMARK_TEMPLATE(BM_Visit, 3, 6); +BENCHMARK_TEMPLATE(BM_Visit, 3, 7); +BENCHMARK_TEMPLATE(BM_Visit, 3, 8); +BENCHMARK_TEMPLATE(BM_Visit, 3, 9); +BENCHMARK_TEMPLATE(BM_Visit, 3, 10); +BENCHMARK_TEMPLATE(BM_Visit, 3, 15); +BENCHMARK_TEMPLATE(BM_Visit, 3, 20); + +BENCHMARK_MAIN(); diff --git a/gnu/llvm/libcxx/cmake/Modules/DefineLinkerScript.cmake b/gnu/llvm/libcxx/cmake/Modules/DefineLinkerScript.cmake index 11a6ca57dfc..be7f026af7e 100644 --- a/gnu/llvm/libcxx/cmake/Modules/DefineLinkerScript.cmake +++ b/gnu/llvm/libcxx/cmake/Modules/DefineLinkerScript.cmake @@ -34,13 +34,14 @@ function(define_linker_script target) if ("${lib}" STREQUAL "cxx-headers") continue() endif() - if (TARGET "${lib}" OR - (${lib} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI) OR - (${lib} MATCHES "unwind(_static|_shared)?" AND HAVE_LIBUNWIND)) - list(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}$") - else() - list(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}${lib}") - endif() + # If ${lib} is not a target, we use a dummy target which we know will + # have an OUTPUT_NAME property so that CMake doesn't fail when evaluating + # the non-selected branch of the `IF`. It doesn't matter what it evaluates + # to because it's not selected, but it must not cause an error. + # See https://gitlab.kitware.com/cmake/cmake/-/issues/21045. + set(output_name_tgt "$,${lib},${target}>") + set(libname "$,$,${lib}>") + list(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}${libname}") endforeach() endif() string(REPLACE ";" " " link_libraries "${link_libraries}") diff --git a/gnu/llvm/libcxx/cmake/Modules/HandleLibCXXABI.cmake b/gnu/llvm/libcxx/cmake/Modules/HandleLibCXXABI.cmake index c5aa26739e3..5a8a4a270a1 100644 --- a/gnu/llvm/libcxx/cmake/Modules/HandleLibCXXABI.cmake +++ b/gnu/llvm/libcxx/cmake/Modules/HandleLibCXXABI.cmake @@ -52,18 +52,18 @@ macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs) COMMENT "Copying C++ ABI header ${fpath}...") list(APPEND abilib_headers "${dst}") - if (LIBCXX_HEADER_DIR) - set(dst "${LIBCXX_HEADER_DIR}/include/c++/v1/${dstdir}/${fpath}") - add_custom_command(OUTPUT ${dst} - DEPENDS ${src} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying C++ ABI header ${fpath}...") - list(APPEND abilib_headers "${dst}") - endif() + # TODO: libc++ shouldn't be responsible for copying the libc++abi + # headers into the right location. + set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${dstdir}/${fpath}") + add_custom_command(OUTPUT ${dst} + DEPENDS ${src} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} + COMMENT "Copying C++ ABI header ${fpath}...") + list(APPEND abilib_headers "${dst}") if (LIBCXX_INSTALL_HEADERS) install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}" - DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dstdir} + DESTINATION include/c++/v1/${dstdir} COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) @@ -121,6 +121,8 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS) set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1") endif() + # libcxxrt does not provide aligned new and delete operators + set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON) setup_abi_lib( "-DLIBCXXRT" "cxxrt" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" diff --git a/gnu/llvm/libcxx/cmake/Modules/HandleLibcxxFlags.cmake b/gnu/llvm/libcxx/cmake/Modules/HandleLibcxxFlags.cmake index a5b4df6600e..859cfc4a515 100644 --- a/gnu/llvm/libcxx/cmake/Modules/HandleLibcxxFlags.cmake +++ b/gnu/llvm/libcxx/cmake/Modules/HandleLibcxxFlags.cmake @@ -121,6 +121,17 @@ macro(add_target_flags_if condition) endif() endmacro() +# Add all the flags supported by the compiler to all of +# 'CMAKE_CXX_FLAGS', 'CMAKE_C_FLAGS', 'LIBCXX_COMPILE_FLAGS' +# and 'LIBCXX_LINK_FLAGS'. +macro(add_target_flags_if_supported) + foreach(flag ${ARGN}) + mangle_name("${flag}" flagname) + check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") + add_target_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + endforeach() +endmacro() + # Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and # 'LIBCXX_LINK_FLAGS'. macro(add_flags) diff --git a/gnu/llvm/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake b/gnu/llvm/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake index 457ad417604..ad2820b324d 100644 --- a/gnu/llvm/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake +++ b/gnu/llvm/libcxx/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -25,7 +25,12 @@ else() endif() message(STATUS "Configuring for standalone build.") -set(LIBCXX_STANDALONE_BUILD 1) + +# By default, we target the host, but this can be overridden at CMake invocation time. +include(GetHostTriple) +get_host_triple(LLVM_INFERRED_HOST_TRIPLE) +set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING "Host on which LLVM binaries will run") +set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING "Target triple used by default.") # Add LLVM Functions -------------------------------------------------------- if (WIN32) @@ -49,11 +54,6 @@ if (NOT DEFINED LLVM_ENABLE_SPHINX) set(LLVM_ENABLE_SPHINX OFF) endif() -# In a standalone build, we don't have llvm to automatically generate the -# llvm-lit script for us. So we need to provide an explicit directory that -# the configurator should write the script into. -set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin") - if (LLVM_INCLUDE_TESTS) # Required LIT Configuration ------------------------------------------------ # Define the default arguments to use with 'lit', and an option for the user diff --git a/gnu/llvm/libcxx/cmake/caches/AArch64.cmake b/gnu/llvm/libcxx/cmake/caches/AArch64.cmake new file mode 100644 index 00000000000..33356a7ee02 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/AArch64.cmake @@ -0,0 +1,2 @@ +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") +set(LIBCXX_TARGET_TRIPLE "aarch64-linux-gnu" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Apple.cmake b/gnu/llvm/libcxx/cmake/caches/Apple.cmake index 622a3af84f2..c884eb561d0 100644 --- a/gnu/llvm/libcxx/cmake/caches/Apple.cmake +++ b/gnu/llvm/libcxx/cmake/caches/Apple.cmake @@ -5,14 +5,16 @@ set(LIBCXX_USE_COMPILER_RT ON CACHE BOOL "") set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "") set(LIBCXX_ABI_VERSION "1" CACHE STRING "") set(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY OFF CACHE BOOL "") -set(LIBCXX_ENABLE_STATIC OFF CACHE BOOL "") +set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "") set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "") -set(LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION "1" CACHE STRING "") set(LIBCXX_CXX_ABI libcxxabi CACHE STRING "") -set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "") set(LIBCXX_HIDE_FROM_ABI_PER_TU_BY_DEFAULT ON CACHE BOOL "") +set(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT OFF CACHE BOOL "") +set(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS ON CACHE BOOL "") +set(LIBCXX_ENABLE_INCOMPLETE_FEATURES OFF CACHE BOOL "") + +set(LIBCXX_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "") +set(LIBCXXABI_HERMETIC_STATIC_LIBRARY ON CACHE BOOL "") -set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "") -set(LIBCXXABI_ENABLE_PIC OFF CACHE BOOL "") set(LIBCXXABI_ENABLE_ASSERTIONS OFF CACHE BOOL "") set(LIBCXXABI_ENABLE_FORGIVING_DYNAMIC_CAST ON CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Armv7Arm.cmake b/gnu/llvm/libcxx/cmake/caches/Armv7Arm.cmake new file mode 100644 index 00000000000..8b2b54eba13 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Armv7Arm.cmake @@ -0,0 +1,4 @@ +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") +set(LIBCXX_TARGET_TRIPLE "armv7-linux-gnueabihf" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-marm" CACHE STRING "") +set(CMAKE_C_FLAGS "-marm" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Armv7Thumb-noexceptions.cmake b/gnu/llvm/libcxx/cmake/caches/Armv7Thumb-noexceptions.cmake new file mode 100644 index 00000000000..67ec43b93f2 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Armv7Thumb-noexceptions.cmake @@ -0,0 +1,6 @@ +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") +set(LIBCXX_TARGET_TRIPLE "armv7-linux-gnueabihf" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-mthumb" CACHE STRING "") +set(CMAKE_C_FLAGS "-mthumb" CACHE STRING "") +set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") +set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Armv8Arm.cmake b/gnu/llvm/libcxx/cmake/caches/Armv8Arm.cmake new file mode 100644 index 00000000000..55dfa908b3d --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Armv8Arm.cmake @@ -0,0 +1,4 @@ +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") +set(LIBCXX_TARGET_TRIPLE "armv8-linux-gnueabihf" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-marm" CACHE STRING "") +set(CMAKE_C_FLAGS "-marm" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Armv8Thumb-noexceptions.cmake b/gnu/llvm/libcxx/cmake/caches/Armv8Thumb-noexceptions.cmake new file mode 100644 index 00000000000..fb1d10efadd --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Armv8Thumb-noexceptions.cmake @@ -0,0 +1,6 @@ +set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "") +set(LIBCXX_TARGET_TRIPLE "armv8-linux-gnueabihf" CACHE STRING "") +set(CMAKE_CXX_FLAGS "-mthumb" CACHE STRING "") +set(CMAKE_C_FLAGS "-mthumb" CACHE STRING "") +set(LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "") +set(LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/FreeBSD.cmake b/gnu/llvm/libcxx/cmake/caches/FreeBSD.cmake new file mode 100644 index 00000000000..9e66e379864 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/FreeBSD.cmake @@ -0,0 +1,9 @@ +set(CMAKE_BUILD_TYPE Release CACHE STRING "") +set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "") + +set(LIBCXX_ENABLE_ASSERTIONS OFF CACHE BOOL "") +set(LIBCXX_ABI_VERSION "1" CACHE STRING "") +set(LIBCXX_ENABLE_STATIC ON CACHE BOOL "") +set(LIBCXX_ENABLE_SHARED ON CACHE BOOL "") +set(LIBCXX_CXX_ABI libcxxrt CACHE STRING "") +set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-assertions.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-assertions.cmake new file mode 100644 index 00000000000..e8ef72ad16e --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-assertions.cmake @@ -0,0 +1 @@ +set(LIBCXX_ENABLE_ASSERTIONS ON CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-cxx20.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-cxx20.cmake new file mode 100644 index 00000000000..3c44fdaf0e4 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-cxx20.cmake @@ -0,0 +1,2 @@ +set(LIBCXX_TEST_PARAMS "std=c++20" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-cxx2b.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-cxx2b.cmake new file mode 100644 index 00000000000..be767dd2a5e --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-cxx2b.cmake @@ -0,0 +1,2 @@ +set(LIBCXX_TEST_PARAMS "std=c++2b" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-debug-iterators.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-debug-iterators.cmake new file mode 100644 index 00000000000..2e9cbf77acd --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-debug-iterators.cmake @@ -0,0 +1,2 @@ +set(LIBCXX_TEST_PARAMS "debug_level=1" "additional_features=LIBCXX-DEBUG-FIXME" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-modules.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-modules.cmake new file mode 100644 index 00000000000..29b4d4be127 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-modules.cmake @@ -0,0 +1,2 @@ +set(LIBCXX_TEST_PARAMS "enable_modules=True" CACHE STRING "") +set(LIBCXXABI_TEST_PARAMS "${LIBCXX_TEST_PARAMS}" CACHE STRING "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-no-debug.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-no-debug.cmake new file mode 100644 index 00000000000..a62760fa78f --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-no-debug.cmake @@ -0,0 +1 @@ +set(LIBCXX_ENABLE_DEBUG_MODE_SUPPORT OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-no-filesystem.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-no-filesystem.cmake new file mode 100644 index 00000000000..4000f3a3e8e --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-no-filesystem.cmake @@ -0,0 +1 @@ +set(LIBCXX_ENABLE_FILESYSTEM OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-no-localization.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-no-localization.cmake new file mode 100644 index 00000000000..79d6b44c713 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-no-localization.cmake @@ -0,0 +1 @@ +set(LIBCXX_ENABLE_LOCALIZATION OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-no-random_device.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-no-random_device.cmake new file mode 100644 index 00000000000..e9b4cc60cc8 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-no-random_device.cmake @@ -0,0 +1 @@ +set(LIBCXX_ENABLE_RANDOM_DEVICE OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/caches/Generic-static.cmake b/gnu/llvm/libcxx/cmake/caches/Generic-static.cmake new file mode 100644 index 00000000000..ed2bf857146 --- /dev/null +++ b/gnu/llvm/libcxx/cmake/caches/Generic-static.cmake @@ -0,0 +1,3 @@ +set(LIBCXX_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "") +set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "") diff --git a/gnu/llvm/libcxx/cmake/config-ix.cmake b/gnu/llvm/libcxx/cmake/config-ix.cmake index 894f637f814..a2f1ff9f1a3 100644 --- a/gnu/llvm/libcxx/cmake/config-ix.cmake +++ b/gnu/llvm/libcxx/cmake/config-ix.cmake @@ -24,16 +24,26 @@ if (NOT LIBCXX_USE_COMPILER_RT) endif() endif() -# libc++ is built with -nodefaultlibs, so we want all our checks to also -# use this option, otherwise we may end up with an inconsistency between +# libc++ is using -nostdlib++ at the link step when available, +# otherwise -nodefaultlibs is used. We want all our checks to also +# use one of these options, otherwise we may end up with an inconsistency between # the flags we think we require during configuration (if the checks are -# performed without -nodefaultlibs) and the flags that are actually -# required during compilation (which has the -nodefaultlibs). libc is +# performed without one of those options) and the flags that are actually +# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is # required for the link to go through. We remove sanitizers from the # configuration checks to avoid spurious link errors. -check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) -if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) - set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + +check_c_compiler_flag(-nostdlib++ LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG) +if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++") +else() + check_c_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) + if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + endif() +endif() + +if (LIBCXX_SUPPORTS_NOSTDLIBXX_FLAG OR LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG) if (LIBCXX_HAS_C_LIB) list(APPEND CMAKE_REQUIRED_LIBRARIES c) endif () diff --git a/gnu/llvm/libcxx/docs/AddingNewCIJobs.rst b/gnu/llvm/libcxx/docs/AddingNewCIJobs.rst new file mode 100644 index 00000000000..bd94a9d7092 --- /dev/null +++ b/gnu/llvm/libcxx/docs/AddingNewCIJobs.rst @@ -0,0 +1,68 @@ +.. _AddingNewCIJobs: + +================== +Adding New CI Jobs +================== + +.. contents:: + :local: + +Adding The Job +============== + +libc++ uses Buildkite for running its CI. Setting up new CI jobs is easy, and +these jobs can run either on our existing infrastructure, or on your own. + +If you need to run the job on your own machines, please follow the +`Buildkite guide `_ to setup your +own agents. Make sure you tag your agents in a way that you'll be able +to recognize them when defining your job below. Finally, in order for the +agent to register itself to Buildkite, it will need a BuildKite Agent token. +Please contact a maintainer to get your token. + +Then, simply add a job to the Buildkite pipeline by editing ``libcxx/utils/ci/buildkite-pipeline.yml``. +Take a look at how the surrounding jobs are defined and do something similar. +An example of a job definition is: + +.. code-block:: yaml + + - label: "C++11" + command: "libcxx/utils/ci/run-buildbot generic-cxx11" + artifact_paths: + - "**/test-results.xml" + agents: + queue: "libcxx-builders" + os: "linux" + retry: + automatic: + - exit_status: -1 # Agent was lost + limit: 2 + +If you create your own agents, put them in the ``libcxx-builders`` queue and +use agent tags to allow targetting your agents from the Buildkite pipeline +config appropriately. + +We try to keep the pipeline definition file as simple as possible, and to +keep any script used for CI inside ``libcxx/utils/ci``. This ensures that +it's possible to reproduce CI issues locally with ease, understanding of +course that some setups may require access to special hardware that is not +available. + +Testing Your New Job +==================== + +Testing your new job is easy -- once your agent is set up (if any), just open +a code review and the libc++ CI pipeline will run, including any changes you +might have made to the pipeline definition itself. + +Service Level Agreement +======================= + +To keep the libc++ CI useful for everyone, we aim for a quick turnaround time +for all CI jobs. This allows the overall pipeline to finish in a reasonable +amount of time, which is important because it directly affects our development +velocity. We also try to make sure that jobs run on reliable infrastructure in +order to avoid flaky failures, which reduce the value of CI for everyone. + +We may be reluctant to add and support CI jobs that take a long time to finish +or that are too flaky. diff --git a/gnu/llvm/libcxx/docs/BuildingLibcxx.rst b/gnu/llvm/libcxx/docs/BuildingLibcxx.rst index c85c3d7fbcb..a29a05b8f7f 100644 --- a/gnu/llvm/libcxx/docs/BuildingLibcxx.rst +++ b/gnu/llvm/libcxx/docs/BuildingLibcxx.rst @@ -9,116 +9,158 @@ Building libc++ .. _build instructions: -Getting Started -=============== +The instructions on this page are aimed at vendors who ship libc++ as part of an +operating system distribution, a toolchain or similar shipping vehicules. If you +are a user merely trying to use libc++ in your program, you most likely want to +refer to your vendor's documentation, or to the general documentation for using +libc++ :ref:`here `. -On Mac OS 10.7 (Lion) and later, the easiest way to get this library is to install -Xcode 4.2 or later. However if you want to install tip-of-trunk from here -(getting the bleeding edge), read on. +.. warning:: + If your operating system already provides libc++, it is important to be careful + not to replace it. Replacing your system's libc++ installation could render it + non-functional. Use the CMake option ``CMAKE_INSTALL_PREFIX`` to select a safe + place to install libc++. -The following instructions describe how to checkout, build, test and -(optionally) install libc++ and libc++abi. -If your system already provides a libc++ installation it is important to be -careful not to replace it. Remember Use the CMake option -``CMAKE_INSTALL_PREFIX`` to select a safe place to install libc++. +The default build +================= -.. warning:: - * Replacing your systems libc++ installation could render the system non-functional. - * macOS will not boot without a valid copy of ``libc++.1.dylib`` in ``/usr/lib``. +By default, libc++ and libc++abi are built as sub-projects of the LLVM project. +This can be achieved with the usual CMake invocation: .. code-block:: bash $ git clone https://github.com/llvm/llvm-project.git $ cd llvm-project - $ mkdir build && cd build - $ cmake -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" \ - ../llvm - $ make # Build - $ make check-cxx # Test - $ make install-cxx install-cxxabi # Install - -For more information about configuring libc++ see :ref:`CMake Options`. You may -also want to read the `LLVM getting started -`_ documentation. - -Shared libraries for libc++ and libc++ abi should now be present in -``build/lib``. See :ref:`using an alternate libc++ installation ` for information on how to use this libc++. - -The instructions are for building libc++ on -FreeBSD, Linux, or Mac using `libc++abi`_ as the C++ ABI library. -On Linux, it is also possible to use :ref:`libsupc++ ` or libcxxrt. - -It is possible to build libc++ standalone (i.e. without building other LLVM -projects). A standalone build would look like this: + $ mkdir build + $ cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS="libcxx;libcxxabi" # Configure + $ ninja -C build cxx cxxabi # Build + $ ninja -C build check-cxx check-cxxabi # Test + $ ninja -C build install-cxx install-cxxabi # Install + +.. note:: + See :ref:`CMake Options` below for more configuration options. + +After building the ``install-cxx`` and ``install-cxxabi`` targets, shared libraries +for libc++ and libc++abi should now be present in ``/lib``, and +headers in ``/include/c++/v1``. See :ref:`using an alternate +libc++ installation ` for information on how to use this libc++ over +the default one. + +In the default configuration, libc++ and libc++abi will be built using the compiler available +by default on your system. It is also possible to bootstrap Clang and build libc++ with it. + + +Bootstrapping build +=================== + +It is also possible to build Clang and then build libc++ and libc++abi using that +just-built compiler. This is the correct way to build libc++ when putting together +a toolchain, or when the system compiler is not adequate to build libc++ (too old, +unsupported, etc.). This type of build is also commonly called a "Runtimes build": .. code-block:: bash - $ git clone https://github.com/llvm/llvm-project.git llvm-project - $ cd llvm-project - $ mkdir build && cd build - $ cmake -DCMAKE_C_COMPILER=clang \ - -DCMAKE_CXX_COMPILER=clang++ \ - -DLIBCXX_CXX_ABI=libcxxabi \ - -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/separate/libcxxabi/include \ - ../libcxx - $ make - $ make check-cxx # optional + $ mkdir build + $ cmake -G Ninja -S llvm -B build -DLLVM_ENABLE_PROJECTS="clang" \ # Configure + -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" \ + -DLLVM_RUNTIME_TARGETS="" + $ ninja -C build runtimes # Build + $ ninja -C build check-runtimes # Test + $ ninja -C build install-runtimes # Install -Experimental Support for Windows --------------------------------- +Support for Windows +=================== -The Windows support requires building with clang-cl as cl does not support one -required extension: `#include_next`. Furthermore, VS 2015 or newer (19.00) is -required. In the case of clang-cl, we need to specify the "MS Compatibility -Version" as it defaults to 2014 (18.00). +libcxx supports being built with clang-cl, but not with MSVC's cl.exe, as +cl doesn't support the ``#include_next`` extension. Furthermore, VS 2017 or +newer (19.14) is required. + +libcxx also supports being built with clang targeting MinGW environments. CMake + Visual Studio -~~~~~~~~~~~~~~~~~~~~~ +--------------------- Building with Visual Studio currently does not permit running tests. However, it is the simplest way to build. .. code-block:: batch - > cmake -G "Visual Studio 14 2015" ^ - -T "LLVM-vs2014" ^ - -DLIBCXX_ENABLE_SHARED=YES ^ - -DLIBCXX_ENABLE_STATIC=NO ^ - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ - \path\to\libcxx - > cmake --build . + > cmake -G "Visual Studio 16 2019" -S libcxx -B build ^ + -T "ClangCL" ^ + -DLIBCXX_ENABLE_SHARED=YES ^ + -DLIBCXX_ENABLE_STATIC=NO ^ + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO + > cmake --build build -CMake + ninja -~~~~~~~~~~~~~ +CMake + ninja (MSVC) +-------------------- Building with ninja is required for development to enable tests. -Unfortunately, doing so requires additional configuration as we cannot -just specify a toolset. +A couple of tests require Bash to be available, and a couple dozens +of tests require other posix tools (cp, grep and similar - LLVM's tests +require the same). Without those tools the vast majority of tests +can still be ran successfully. + +If Git for Windows is available, that can be used to provide the bash +shell by adding the right bin directory to the path, e.g. +``set PATH=%PATH%;C:\Program Files\Git\usr\bin``. + +Alternatively, one can also choose to run the whole build in a MSYS2 +shell. That can be set up e.g. by starting a Visual Studio Tools Command +Prompt (for getting the environment variables pointing to the headers and +import libraries), and making sure that clang-cl is available in the +path. From there, launch an MSYS2 shell via e.g. +``C:\msys64\msys2_shell.cmd -full-path -mingw64`` (preserving the earlier +environment, allowing the MSVC headers/libraries and clang-cl to be found). + +In either case, then run: .. code-block:: batch - > cmake -G Ninja ^ - -DCMAKE_MAKE_PROGRAM=/path/to/ninja ^ - -DCMAKE_SYSTEM_NAME=Windows ^ + > cmake -G Ninja -S libcxx -B build ^ -DCMAKE_C_COMPILER=clang-cl ^ - -DCMAKE_C_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^ - -DCMAKE_CXX_COMPILER=clang-cl ^ - -DCMAKE_CXX_FLAGS="-fms-compatibility-version=19.00 --target=i686--windows" ^ - -DLLVM_PATH=/path/to/llvm/tree ^ - -DLIBCXX_ENABLE_SHARED=YES ^ - -DLIBCXX_ENABLE_STATIC=NO ^ - -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO ^ - \path\to\libcxx - > /path/to/ninja cxx - > /path/to/ninja check-cxx - -Note that the paths specified with backward slashes must use the `\\` as the -directory separator as clang-cl may otherwise parse the path as an argument. + -DCMAKE_CXX_COMPILER=clang-cl ^ + -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=NO + > ninja -C build cxx + > ninja -C build check-cxx + +If you are running in an MSYS2 shell and you have installed the +MSYS2-provided clang package (which defaults to a non-MSVC target), you +should add e.g. ``-DLIBCXX_TARGET_TRIPLE=x86_64-windows-msvc`` (replacing +``x86_64`` with the architecture you're targeting) to the ``cmake`` command +line above. This will instruct ``check-cxx`` to use the right target triple +when invoking ``clang++``. + +Also note that if not building in Release mode, a failed assert in the tests +pops up a blocking dialog box, making it hard to run a larger number of tests. + +CMake + ninja (MinGW) +--------------------- + +libcxx can also be built in MinGW environments, e.g. with the MinGW +compilers in MSYS2. This requires clang to be available (installed with +e.g. the ``mingw-w64-x86_64-clang`` package), together with CMake and ninja. + +.. code-block:: bash + + > cmake -G Ninja -S libcxx -B build \ + -DCMAKE_C_COMPILER=clang \ + -DCMAKE_CXX_COMPILER=clang++ \ + -DLIBCXX_HAS_WIN32_THREAD_API=ON \ + -DLIBCXX_CXX_ABI=libstdc++ \ + -DLIBCXX_TARGET_INFO="libcxx.test.target_info.MingwLocalTI" + > ninja -C build cxx + > cp /mingw64/bin/{libstdc++-6,libgcc_s_seh-1,libwinpthread-1}.dll lib + > ninja -C build check-cxx + +As this build configuration ends up depending on a couple other DLLs that +aren't available in path while running tests, copy them into the same +directory as the tested libc++ DLL. + +(Building a libc++ that depends on libstdc++ isn't necessarily a config one +would want to deploy, but it simplifies the config for testing purposes.) .. _`libc++abi`: http://libcxxabi.llvm.org/ @@ -193,12 +235,6 @@ libc++ specific options Extra suffix to append to the directory where libraries are to be installed. This option overrides `LLVM_LIBDIR_SUFFIX`. -.. option:: LIBCXX_INSTALL_PREFIX:STRING - - **Default**: ``""`` - - Define libc++ destination prefix. - .. option:: LIBCXX_HERMETIC_STATIC_LIBRARY:BOOL **Default**: ``OFF`` @@ -210,10 +246,41 @@ libc++ specific options .. option:: LIBCXX_ENABLE_FILESYSTEM:BOOL - **Default**: ``ON`` except on Windows. + **Default**: ``ON`` except on Windows when using MSVC. This option can be used to enable or disable the filesystem components on - platforms that may not support them. For example on Windows. + platforms that may not support them. For example on Windows when using MSVC. + +.. option:: LIBCXX_ENABLE_INCOMPLETE_FEATURES:BOOL + + **Default**: ``ON`` + + Whether to enable support for incomplete library features. Incomplete features + are new library features under development. These features don't guarantee + ABI stability nor the quality of completed library features. Vendors + shipping the library may want to disable this option. + +.. option:: LIBCXX_INSTALL_LIBRARY_DIR:PATH + + **Default**: ``lib${LIBCXX_LIBDIR_SUFFIX}`` + + Path where built libc++ libraries should be installed. If a relative path, + relative to ``CMAKE_INSTALL_PREFIX``. + +.. option:: LIBCXX_INSTALL_INCLUDE_DIR:PATH + + **Default**: ``include/c++/v1`` + + Path where target-agnostic libc++ headers should be installed. If a relative + path, relative to ``CMAKE_INSTALL_PREFIX``. + +.. option:: LIBCXX_INSTALL_INCLUDE_TARGET_DIR:PATH + + **Default**: ``include/c++/v1`` or + ``include/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1`` + + Path where target-specific libc++ headers should be installed. If a relative + path, relative to ``CMAKE_INSTALL_PREFIX``. .. _libc++experimental options: @@ -292,7 +359,7 @@ libc++ Feature Options .. option:: LIBCXX_INCLUDE_TESTS:BOOL - **Default**: ``ON`` (or value of ``LLVM_INCLUDE_DIR``) + **Default**: ``ON`` (or value of ``LLVM_INCLUDE_TESTS``) Build the libc++ tests. @@ -378,26 +445,6 @@ The following options allow building libc++ for a different ABI version. See ``include/__config`` for the list of ABI macros. -.. option:: LIBCXX_TYPEINFO_COMPARISON_IMPLEMENTATION - - **Default**: ``None``, which lets the library figure out which implementation - to use based on the object format. - - This setting defines what implementation to use for comparing typeinfo objects. - There are two main implementations, which differ on whether we make the assumption - that type info names for a type have been fully merged are unique across the entire - program. This may not be the case for libraries built with ``-Bsymbolic`` or due to - compiler or linker bugs (Ex. llvm.org/PR37398). - - - When the value is set to ``1``, we assume that typeinfos are unique across the - whole program, and typeinfo comparisons compare only the pointer value. - - When the value is set to ``2``, we do not assume that typeinfos are unique across - the whole program. We first compare the pointers, and then use ``strcmp`` on the - typeinfo names as a fallback. - - .. _LLVM-specific variables: LLVM-specific options @@ -424,8 +471,12 @@ LLVM-specific options Using Alternate ABI libraries ============================= +In order to implement various features like exceptions, RTTI, ``dynamic_cast`` and +more, libc++ requires what we refer to as an ABI library. Typically, that library +implements the `Itanium C++ ABI `_. -.. _libsupcxx: +By default, libc++ uses libc++abi as an ABI library. However, it is possible to use +other ABI libraries too. Using libsupc++ on Linux ------------------------ @@ -455,17 +506,17 @@ You can also figure this out by running End of search list. Note that the first two entries happen to be what we are looking for. This -may not be correct on other platforms. +may not be correct on all platforms. We can now run CMake: .. code-block:: bash - $ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \ - -DLIBCXX_CXX_ABI=libstdc++ \ - -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/" \ - -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr \ - + $ cmake -G Ninja -S llvm -B build \ + -DLLVM_ENABLE_PROJECTS="libcxx" \ + -DLIBCXX_CXX_ABI=libstdc++ \ + -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/usr/include/c++/4.7/;/usr/include/c++/4.7/x86_64-linux-gnu/" + $ ninja -C build install-cxx You can also substitute ``-DLIBCXX_CXX_ABI=libsupc++`` @@ -476,16 +527,6 @@ GCC ships libsupc++ separately but only as a static library. If a program also needs to link against libstdc++, it will provide its own copy of libsupc++ and this can lead to subtle problems. -.. code-block:: bash - - $ make cxx - $ make install - -You can now run clang with -stdlib=libc++. - - -.. _libcxxrt_ref: - Using libcxxrt on Linux ------------------------ @@ -497,14 +538,11 @@ We can now run CMake like: .. code-block:: bash - $ CC=clang CXX=clang++ cmake -G "Unix Makefiles" \ - -DLIBCXX_CXX_ABI=libcxxrt \ - -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/usr \ - - $ make cxx - $ make install + $ cmake -G Ninja -S llvm -B build \ + -DLLVM_ENABLE_PROJECTS="libcxx" \ + -DLIBCXX_CXX_ABI=libcxxrt \ + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxrt-sources/src + $ ninja -C build install-cxx Unfortunately you can't simply run clang with "-stdlib=libc++" at this point, as clang is set up to link for libc++ linked to libsupc++. To get around this @@ -522,32 +560,4 @@ situations will give the same result: $ clang++ -stdlib=libc++ helloworld.cpp -lcxxrt -.. _`libcxxrt`: https://github.com/pathscale/libcxxrt/ - - -Using a local ABI library installation ---------------------------------------- - -.. warning:: - This is not recommended in almost all cases. - -These instructions should only be used when you can't install your ABI library. - -Normally you must link libc++ against a ABI shared library that the -linker can find. If you want to build and test libc++ against an ABI -library not in the linker's path you need to set -``-DLIBCXX_CXX_ABI_LIBRARY_PATH=/path/to/abi/lib`` when configuring CMake. - -An example build using libc++abi would look like: - -.. code-block:: bash - - $ CC=clang CXX=clang++ cmake \ - -DLIBCXX_CXX_ABI=libc++abi \ - -DLIBCXX_CXX_ABI_INCLUDE_PATHS="/path/to/libcxxabi/include" \ - -DLIBCXX_CXX_ABI_LIBRARY_PATH="/path/to/libcxxabi-build/lib" \ - path/to/libcxx - $ make - -When testing libc++ LIT will automatically link against the proper ABI -library. +.. _`libcxxrt`: https://github.com/libcxxrt/libcxxrt diff --git a/gnu/llvm/libcxx/docs/Contributing.rst b/gnu/llvm/libcxx/docs/Contributing.rst new file mode 100644 index 00000000000..9d52445c368 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Contributing.rst @@ -0,0 +1,68 @@ +.. _ContributingToLibcxx: + +====================== +Contributing to libc++ +====================== + +This file contains notes about various tasks and processes specific to contributing +to libc++. If this is your first time contributing, please also read `this document +`__ on general rules for contributing to LLVM. + +For libc++, please make sure you follow `these instructions `_ +for submitting a code review from the command-line using ``arc``, since we have some +automation (e.g. CI) that depends on the review being submitted that way. + +Looking for pre-existing reviews +================================ + +Before you start working on any feature, please take a look at the open reviews +to avoid duplicating someone else's work. You can do that by going to the website +where code reviews are held, `Differential `__, +and clicking on ``Libc++ Open Reviews`` in the sidebar to the left. If you see +that your feature is already being worked on, please consider chiming in instead +of duplicating work! + +Pre-commit check list +===================== + +Before committing or creating a review, please go through this check-list to make +sure you don't forget anything: + +- Do you have tests for every public class and/or function you're adding or modifying? +- Did you update the synopsis of the relevant headers? +- Did you update the relevant files to track implementation status (in ``docs/Status/``)? +- Did you mark all functions and type declarations with the :ref:`proper visibility macro `? +- If you added a header: + + - Did you add it to ``include/module.modulemap``? + - Did you add it to ``include/CMakeLists.txt``? + - If it's a public header, did you add a test under ``test/libcxx`` that the new header defines ``_LIBCPP_VERSION``? See ``test/libcxx/algorithms/version.pass.cpp`` for an example. NOTE: This should be automated. + - If it's a public header, did you update ``utils/generate_header_inclusion_tests.py``? + +- Did you add the relevant feature test macro(s) for your feature? Did you update the ``generate_feature_test_macro_components.py`` script with it? +- Did you run the ``libcxx-generate-files`` target and verify its output? + +Post-release check list +======================= + +After branching for an LLVM release: + +1. Update ``_LIBCPP_VERSION`` in ``include/__config`` +2. Update the ``include/__libcpp_version`` file +3. Update the version number in ``docs/conf.py`` + +Exporting new symbols from the library +====================================== + +When exporting new symbols from libc++, you must update the ABI lists located in ``lib/abi``. +To test whether the lists are up-to-date, please run the target ``check-cxx-abilist``. +To regenerate the lists, use the target ``generate-cxx-abilist``. +The ABI lists must be updated for all supported platforms; currently Linux and +Apple. If you don't have access to one of these platforms, you can download an +updated list from the failed build at +`Buildkite `__. +Look for the failed build and select the ``artifacts`` tab. There, download the +abilist for the platform, e.g.: + +* C++20 for the Linux platform. +* MacOS C++20 for the Apple platform. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/ABIVersioning.rst b/gnu/llvm/libcxx/docs/DesignDocs/ABIVersioning.rst index 5960dd18610..3b82f3cc60a 100644 --- a/gnu/llvm/libcxx/docs/DesignDocs/ABIVersioning.rst +++ b/gnu/llvm/libcxx/docs/DesignDocs/ABIVersioning.rst @@ -3,15 +3,22 @@ Libc++ ABI stability ==================== -Libc++ aims to preserve stable ABI to avoid subtle bugs when code built to the old ABI -is linked with the code build to the new ABI. At the same time, libc++ allows ABI-breaking -improvements and bugfixes for the scenarios when ABI change is not a issue. +Libc++ aims to preserve a stable ABI to avoid subtle bugs when code built under the old ABI +is linked with code built under the new ABI. At the same time, libc++ wants to make +ABI-breaking improvements and bugfixes in scenarios where the user doesn't mind ABI breaks. -To support both cases, libc++ allows specifying the ABI version at the -build time. The version is defined with a cmake option -LIBCXX_ABI_VERSION. Another option LIBCXX_ABI_UNSTABLE can be used to -include all present ABI breaking features. These options translate -into C++ macro definitions _LIBCPP_ABI_VERSION, _LIBCPP_ABI_UNSTABLE. +To support both cases, libc++ allows specifying an ABI version at +build time. The version is defined with CMake option ``LIBCXX_ABI_VERSION``. +Currently supported values are ``1`` (the stable default) +and ``2`` (the unstable "next" version). At some point "ABI version 2" will be +frozen and new ABI-breaking changes will start being applied to version ``3``; +but this has not happened yet. -Any ABI-changing feature is placed under it's own macro, _LIBCPP_ABI_XXX, which is enabled -based on the value of _LIBCPP_ABI_VERSION. _LIBCPP_ABI_UNSTABLE, if set, enables all features at once. +To always use the most cutting-edge, most unstable ABI (which is currently ``2`` +but at some point will become ``3``), set the CMake option ``LIBCXX_ABI_UNSTABLE``. + +Internally, each ABI-changing feature is placed under its own C++ macro, +``_LIBCPP_ABI_XXX``. These macros' definitions are controlled by the C++ macro +``_LIBCPP_ABI_VERSION``, which is controlled by the ``LIBCXX_ABI_VERSION`` set +at build time. Libc++ does not intend users to interact with these C++ macros +directly. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/AtomicDesign.rst b/gnu/llvm/libcxx/docs/DesignDocs/AtomicDesign.rst new file mode 100644 index 00000000000..4b28ab2a821 --- /dev/null +++ b/gnu/llvm/libcxx/docs/DesignDocs/AtomicDesign.rst @@ -0,0 +1,797 @@ + +==================== +```` Design +==================== + +There were originally 3 designs under consideration. They differ in where most +of the implementation work is done. The functionality exposed to the customer +should be identical (and conforming) for all three designs. + + +Design A: Minimal work for the library +====================================== +The compiler supplies all of the intrinsics as described below. This list of +intrinsics roughly parallels the requirements of the C and C++ atomics proposals. +The C and C++ library implementations simply drop through to these intrinsics. +Anything the platform does not support in hardware, the compiler +arranges for a (compiler-rt) library call to be made which will do the job with +a mutex, and in this case ignoring the memory ordering parameter (effectively +implementing ``memory_order_seq_cst``). + +Ultimate efficiency is preferred over run time error checking. Undefined +behavior is acceptable when the inputs do not conform as defined below. + +.. code-block:: cpp + + // In every intrinsic signature below, type* atomic_obj may be a pointer to a + // volatile-qualified type. Memory ordering values map to the following meanings: + // memory_order_relaxed == 0 + // memory_order_consume == 1 + // memory_order_acquire == 2 + // memory_order_release == 3 + // memory_order_acq_rel == 4 + // memory_order_seq_cst == 5 + + // type must be trivially copyable + // type represents a "type argument" + bool __atomic_is_lock_free(type); + + // type must be trivially copyable + // Behavior is defined for mem_ord = 0, 1, 2, 5 + type __atomic_load(const type* atomic_obj, int mem_ord); + + // type must be trivially copyable + // Behavior is defined for mem_ord = 0, 3, 5 + void __atomic_store(type* atomic_obj, type desired, int mem_ord); + + // type must be trivially copyable + // Behavior is defined for mem_ord = [0 ... 5] + type __atomic_exchange(type* atomic_obj, type desired, int mem_ord); + + // type must be trivially copyable + // Behavior is defined for mem_success = [0 ... 5], + // mem_failure <= mem_success + // mem_failure != 3 + // mem_failure != 4 + bool __atomic_compare_exchange_strong(type* atomic_obj, + type* expected, type desired, + int mem_success, int mem_failure); + + // type must be trivially copyable + // Behavior is defined for mem_success = [0 ... 5], + // mem_failure <= mem_success + // mem_failure != 3 + // mem_failure != 4 + bool __atomic_compare_exchange_weak(type* atomic_obj, + type* expected, type desired, + int mem_success, int mem_failure); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + // Behavior is defined for mem_ord = [0 ... 5] + type __atomic_fetch_add(type* atomic_obj, type operand, int mem_ord); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + // Behavior is defined for mem_ord = [0 ... 5] + type __atomic_fetch_sub(type* atomic_obj, type operand, int mem_ord); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + // Behavior is defined for mem_ord = [0 ... 5] + type __atomic_fetch_and(type* atomic_obj, type operand, int mem_ord); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + // Behavior is defined for mem_ord = [0 ... 5] + type __atomic_fetch_or(type* atomic_obj, type operand, int mem_ord); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + // Behavior is defined for mem_ord = [0 ... 5] + type __atomic_fetch_xor(type* atomic_obj, type operand, int mem_ord); + + // Behavior is defined for mem_ord = [0 ... 5] + void* __atomic_fetch_add(void** atomic_obj, ptrdiff_t operand, int mem_ord); + void* __atomic_fetch_sub(void** atomic_obj, ptrdiff_t operand, int mem_ord); + + // Behavior is defined for mem_ord = [0 ... 5] + void __atomic_thread_fence(int mem_ord); + void __atomic_signal_fence(int mem_ord); + +If desired the intrinsics taking a single ``mem_ord`` parameter can default +this argument to 5. + +If desired the intrinsics taking two ordering parameters can default ``mem_success`` +to 5, and ``mem_failure`` to ``translate_memory_order(mem_success)`` where +``translate_memory_order(mem_success)`` is defined as: + +.. code-block:: cpp + + int translate_memory_order(int o) { + switch (o) { + case 4: + return 2; + case 3: + return 0; + } + return o; + } + +Below are representative C++ implementations of all of the operations. Their +purpose is to document the desired semantics of each operation, assuming +``memory_order_seq_cst``. This is essentially the code that will be called +if the front end calls out to compiler-rt. + +.. code-block:: cpp + + template + T __atomic_load(T const volatile* obj) { + unique_lock _(some_mutex); + return *obj; + } + + template + void __atomic_store(T volatile* obj, T desr) { + unique_lock _(some_mutex); + *obj = desr; + } + + template + T __atomic_exchange(T volatile* obj, T desr) { + unique_lock _(some_mutex); + T r = *obj; + *obj = desr; + return r; + } + + template + bool __atomic_compare_exchange_strong(T volatile* obj, T* exp, T desr) { + unique_lock _(some_mutex); + if (std::memcmp(const_cast(obj), exp, sizeof(T)) == 0) // if (*obj == *exp) + { + std::memcpy(const_cast(obj), &desr, sizeof(T)); // *obj = desr; + return true; + } + std::memcpy(exp, const_cast(obj), sizeof(T)); // *exp = *obj; + return false; + } + + // May spuriously return false (even if *obj == *exp) + template + bool __atomic_compare_exchange_weak(T volatile* obj, T* exp, T desr) { + unique_lock _(some_mutex); + if (std::memcmp(const_cast(obj), exp, sizeof(T)) == 0) // if (*obj == *exp) + { + std::memcpy(const_cast(obj), &desr, sizeof(T)); // *obj = desr; + return true; + } + std::memcpy(exp, const_cast(obj), sizeof(T)); // *exp = *obj; + return false; + } + + template + T __atomic_fetch_add(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj += operand; + return r; + } + + template + T __atomic_fetch_sub(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj -= operand; + return r; + } + + template + T __atomic_fetch_and(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj &= operand; + return r; + } + + template + T __atomic_fetch_or(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj |= operand; + return r; + } + + template + T __atomic_fetch_xor(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj ^= operand; + return r; + } + + void* __atomic_fetch_add(void* volatile* obj, ptrdiff_t operand) { + unique_lock _(some_mutex); + void* r = *obj; + (char*&)(*obj) += operand; + return r; + } + + void* __atomic_fetch_sub(void* volatile* obj, ptrdiff_t operand) { + unique_lock _(some_mutex); + void* r = *obj; + (char*&)(*obj) -= operand; + return r; + } + + void __atomic_thread_fence() { + unique_lock _(some_mutex); + } + + void __atomic_signal_fence() { + unique_lock _(some_mutex); + } + + +Design B: Something in between +============================== +This is a variation of design A which puts the burden on the library to arrange +for the correct manipulation of the run time memory ordering arguments, and only +calls the compiler for well-defined memory orderings. I think of this design as +the worst of A and C, instead of the best of A and C. But I offer it as an +option in the spirit of completeness. + +.. code-block:: cpp + + // type must be trivially copyable + bool __atomic_is_lock_free(const type* atomic_obj); + + // type must be trivially copyable + type __atomic_load_relaxed(const volatile type* atomic_obj); + type __atomic_load_consume(const volatile type* atomic_obj); + type __atomic_load_acquire(const volatile type* atomic_obj); + type __atomic_load_seq_cst(const volatile type* atomic_obj); + + // type must be trivially copyable + type __atomic_store_relaxed(volatile type* atomic_obj, type desired); + type __atomic_store_release(volatile type* atomic_obj, type desired); + type __atomic_store_seq_cst(volatile type* atomic_obj, type desired); + + // type must be trivially copyable + type __atomic_exchange_relaxed(volatile type* atomic_obj, type desired); + type __atomic_exchange_consume(volatile type* atomic_obj, type desired); + type __atomic_exchange_acquire(volatile type* atomic_obj, type desired); + type __atomic_exchange_release(volatile type* atomic_obj, type desired); + type __atomic_exchange_acq_rel(volatile type* atomic_obj, type desired); + type __atomic_exchange_seq_cst(volatile type* atomic_obj, type desired); + + // type must be trivially copyable + bool __atomic_compare_exchange_strong_relaxed_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_consume_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_consume_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_acquire_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_acquire_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_acquire_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_release_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_release_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_release_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_acq_rel_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_acq_rel_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_acq_rel_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_seq_cst_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_seq_cst_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_seq_cst_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_strong_seq_cst_seq_cst(volatile type* atomic_obj, + type* expected, + type desired); + + // type must be trivially copyable + bool __atomic_compare_exchange_weak_relaxed_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_consume_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_consume_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_acquire_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_acquire_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_acquire_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_release_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_release_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_release_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_acq_rel_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_acq_rel_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_acq_rel_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_seq_cst_relaxed(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_seq_cst_consume(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_seq_cst_acquire(volatile type* atomic_obj, + type* expected, + type desired); + bool __atomic_compare_exchange_weak_seq_cst_seq_cst(volatile type* atomic_obj, + type* expected, + type desired); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + type __atomic_fetch_add_relaxed(volatile type* atomic_obj, type operand); + type __atomic_fetch_add_consume(volatile type* atomic_obj, type operand); + type __atomic_fetch_add_acquire(volatile type* atomic_obj, type operand); + type __atomic_fetch_add_release(volatile type* atomic_obj, type operand); + type __atomic_fetch_add_acq_rel(volatile type* atomic_obj, type operand); + type __atomic_fetch_add_seq_cst(volatile type* atomic_obj, type operand); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + type __atomic_fetch_sub_relaxed(volatile type* atomic_obj, type operand); + type __atomic_fetch_sub_consume(volatile type* atomic_obj, type operand); + type __atomic_fetch_sub_acquire(volatile type* atomic_obj, type operand); + type __atomic_fetch_sub_release(volatile type* atomic_obj, type operand); + type __atomic_fetch_sub_acq_rel(volatile type* atomic_obj, type operand); + type __atomic_fetch_sub_seq_cst(volatile type* atomic_obj, type operand); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + type __atomic_fetch_and_relaxed(volatile type* atomic_obj, type operand); + type __atomic_fetch_and_consume(volatile type* atomic_obj, type operand); + type __atomic_fetch_and_acquire(volatile type* atomic_obj, type operand); + type __atomic_fetch_and_release(volatile type* atomic_obj, type operand); + type __atomic_fetch_and_acq_rel(volatile type* atomic_obj, type operand); + type __atomic_fetch_and_seq_cst(volatile type* atomic_obj, type operand); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + type __atomic_fetch_or_relaxed(volatile type* atomic_obj, type operand); + type __atomic_fetch_or_consume(volatile type* atomic_obj, type operand); + type __atomic_fetch_or_acquire(volatile type* atomic_obj, type operand); + type __atomic_fetch_or_release(volatile type* atomic_obj, type operand); + type __atomic_fetch_or_acq_rel(volatile type* atomic_obj, type operand); + type __atomic_fetch_or_seq_cst(volatile type* atomic_obj, type operand); + + // type is one of: char, signed char, unsigned char, short, unsigned short, int, + // unsigned int, long, unsigned long, long long, unsigned long long, + // char16_t, char32_t, wchar_t + type __atomic_fetch_xor_relaxed(volatile type* atomic_obj, type operand); + type __atomic_fetch_xor_consume(volatile type* atomic_obj, type operand); + type __atomic_fetch_xor_acquire(volatile type* atomic_obj, type operand); + type __atomic_fetch_xor_release(volatile type* atomic_obj, type operand); + type __atomic_fetch_xor_acq_rel(volatile type* atomic_obj, type operand); + type __atomic_fetch_xor_seq_cst(volatile type* atomic_obj, type operand); + + void* __atomic_fetch_add_relaxed(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_add_consume(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_add_acquire(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_add_release(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_add_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_add_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand); + + void* __atomic_fetch_sub_relaxed(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_sub_consume(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_sub_acquire(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_sub_release(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_sub_acq_rel(void* volatile* atomic_obj, ptrdiff_t operand); + void* __atomic_fetch_sub_seq_cst(void* volatile* atomic_obj, ptrdiff_t operand); + + void __atomic_thread_fence_relaxed(); + void __atomic_thread_fence_consume(); + void __atomic_thread_fence_acquire(); + void __atomic_thread_fence_release(); + void __atomic_thread_fence_acq_rel(); + void __atomic_thread_fence_seq_cst(); + + void __atomic_signal_fence_relaxed(); + void __atomic_signal_fence_consume(); + void __atomic_signal_fence_acquire(); + void __atomic_signal_fence_release(); + void __atomic_signal_fence_acq_rel(); + void __atomic_signal_fence_seq_cst(); + +Design C: Minimal work for the front end +======================================== +The ```` header is one of the most closely coupled headers to the compiler. +Ideally when you invoke any function from ````, it should result in highly +optimized assembly being inserted directly into your application -- assembly that +is not otherwise representable by higher level C or C++ expressions. The design of +the libc++ ```` header started with this goal in mind. A secondary, but +still very important goal is that the compiler should have to do minimal work to +facilitate the implementation of ````. Without this second goal, then +practically speaking, the libc++ ```` header would be doomed to be a +barely supported, second class citizen on almost every platform. + +Goals: + +- Optimal code generation for atomic operations +- Minimal effort for the compiler to achieve goal 1 on any given platform +- Conformance to the C++0X draft standard + +The purpose of this document is to inform compiler writers what they need to do +to enable a high performance libc++ ```` with minimal effort. + +The minimal work that must be done for a conforming ```` +---------------------------------------------------------------- +The only "atomic" operations that must actually be lock free in +```` are represented by the following compiler intrinsics: + +.. code-block:: cpp + + __atomic_flag__ __atomic_exchange_seq_cst(__atomic_flag__ volatile* obj, __atomic_flag__ desr) { + unique_lock _(some_mutex); + __atomic_flag__ result = *obj; + *obj = desr; + return result; + } + + void __atomic_store_seq_cst(__atomic_flag__ volatile* obj, __atomic_flag__ desr) { + unique_lock _(some_mutex); + *obj = desr; + } + +Where: + +- If ``__has_feature(__atomic_flag)`` evaluates to 1 in the preprocessor then + the compiler must define ``__atomic_flag__`` (e.g. as a typedef to ``int``). +- If ``__has_feature(__atomic_flag)`` evaluates to 0 in the preprocessor then + the library defines ``__atomic_flag__`` as a typedef to ``bool``. +- To communicate that the above intrinsics are available, the compiler must + arrange for ``__has_feature`` to return 1 when fed the intrinsic name + appended with an '_' and the mangled type name of ``__atomic_flag__``. + +For example if ``__atomic_flag__`` is ``unsigned int``: + +.. code-block:: cpp + + // __has_feature(__atomic_flag) == 1 + // __has_feature(__atomic_exchange_seq_cst_j) == 1 + // __has_feature(__atomic_store_seq_cst_j) == 1 + + typedef unsigned int __atomic_flag__; + + unsigned int __atomic_exchange_seq_cst(unsigned int volatile*, unsigned int) { + // ... + } + + void __atomic_store_seq_cst(unsigned int volatile*, unsigned int) { + // ... + } + +That's it! Compiler writers do the above and you've got a fully conforming +(though sub-par performance) ```` header! + + +Recommended work for a higher performance ```` +------------------------------------------------------ +It would be good if the above intrinsics worked with all integral types plus +``void*``. Because this may not be possible to do in a lock-free manner for +all integral types on all platforms, a compiler must communicate each type that +an intrinsic works with. For example, if ``__atomic_exchange_seq_cst`` works +for all types except for ``long long`` and ``unsigned long long`` then: + +.. code-block:: cpp + + __has_feature(__atomic_exchange_seq_cst_b) == 1 // bool + __has_feature(__atomic_exchange_seq_cst_c) == 1 // char + __has_feature(__atomic_exchange_seq_cst_a) == 1 // signed char + __has_feature(__atomic_exchange_seq_cst_h) == 1 // unsigned char + __has_feature(__atomic_exchange_seq_cst_Ds) == 1 // char16_t + __has_feature(__atomic_exchange_seq_cst_Di) == 1 // char32_t + __has_feature(__atomic_exchange_seq_cst_w) == 1 // wchar_t + __has_feature(__atomic_exchange_seq_cst_s) == 1 // short + __has_feature(__atomic_exchange_seq_cst_t) == 1 // unsigned short + __has_feature(__atomic_exchange_seq_cst_i) == 1 // int + __has_feature(__atomic_exchange_seq_cst_j) == 1 // unsigned int + __has_feature(__atomic_exchange_seq_cst_l) == 1 // long + __has_feature(__atomic_exchange_seq_cst_m) == 1 // unsigned long + __has_feature(__atomic_exchange_seq_cst_Pv) == 1 // void* + +Note that only the ``__has_feature`` flag is decorated with the argument +type. The name of the compiler intrinsic is not decorated, but instead works +like a C++ overloaded function. + +Additionally, there are other intrinsics besides ``__atomic_exchange_seq_cst`` +and ``__atomic_store_seq_cst``. They are optional. But if the compiler can +generate faster code than provided by the library, then clients will benefit +from the compiler writer's expertise and knowledge of the targeted platform. + +Below is the complete list of *sequentially consistent* intrinsics, and +their library implementations. Template syntax is used to indicate the desired +overloading for integral and ``void*`` types. The template does not represent a +requirement that the intrinsic operate on **any** type! + +.. code-block:: cpp + + // T is one of: + // bool, char, signed char, unsigned char, short, unsigned short, + // int, unsigned int, long, unsigned long, + // long long, unsigned long long, char16_t, char32_t, wchar_t, void* + + template + T __atomic_load_seq_cst(T const volatile* obj) { + unique_lock _(some_mutex); + return *obj; + } + + template + void __atomic_store_seq_cst(T volatile* obj, T desr) { + unique_lock _(some_mutex); + *obj = desr; + } + + template + T __atomic_exchange_seq_cst(T volatile* obj, T desr) { + unique_lock _(some_mutex); + T r = *obj; + *obj = desr; + return r; + } + + template + bool __atomic_compare_exchange_strong_seq_cst_seq_cst(T volatile* obj, T* exp, T desr) { + unique_lock _(some_mutex); + if (std::memcmp(const_cast(obj), exp, sizeof(T)) == 0) { + std::memcpy(const_cast(obj), &desr, sizeof(T)); + return true; + } + std::memcpy(exp, const_cast(obj), sizeof(T)); + return false; + } + + template + bool __atomic_compare_exchange_weak_seq_cst_seq_cst(T volatile* obj, T* exp, T desr) { + unique_lock _(some_mutex); + if (std::memcmp(const_cast(obj), exp, sizeof(T)) == 0) + { + std::memcpy(const_cast(obj), &desr, sizeof(T)); + return true; + } + std::memcpy(exp, const_cast(obj), sizeof(T)); + return false; + } + + // T is one of: + // char, signed char, unsigned char, short, unsigned short, + // int, unsigned int, long, unsigned long, + // long long, unsigned long long, char16_t, char32_t, wchar_t + + template + T __atomic_fetch_add_seq_cst(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj += operand; + return r; + } + + template + T __atomic_fetch_sub_seq_cst(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj -= operand; + return r; + } + + template + T __atomic_fetch_and_seq_cst(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj &= operand; + return r; + } + + template + T __atomic_fetch_or_seq_cst(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj |= operand; + return r; + } + + template + T __atomic_fetch_xor_seq_cst(T volatile* obj, T operand) { + unique_lock _(some_mutex); + T r = *obj; + *obj ^= operand; + return r; + } + + void* __atomic_fetch_add_seq_cst(void* volatile* obj, ptrdiff_t operand) { + unique_lock _(some_mutex); + void* r = *obj; + (char*&)(*obj) += operand; + return r; + } + + void* __atomic_fetch_sub_seq_cst(void* volatile* obj, ptrdiff_t operand) { + unique_lock _(some_mutex); + void* r = *obj; + (char*&)(*obj) -= operand; + return r; + } + + void __atomic_thread_fence_seq_cst() { + unique_lock _(some_mutex); + } + + void __atomic_signal_fence_seq_cst() { + unique_lock _(some_mutex); + } + +One should consult the (currently draft) `C++ Standard `_ +for the details of the definitions for these operations. For example, +``__atomic_compare_exchange_weak_seq_cst_seq_cst`` is allowed to fail +spuriously while ``__atomic_compare_exchange_strong_seq_cst_seq_cst`` is not. + +If on your platform the lock-free definition of ``__atomic_compare_exchange_weak_seq_cst_seq_cst`` +would be the same as ``__atomic_compare_exchange_strong_seq_cst_seq_cst``, you may omit the +``__atomic_compare_exchange_weak_seq_cst_seq_cst`` intrinsic without a performance cost. The +library will prefer your implementation of ``__atomic_compare_exchange_strong_seq_cst_seq_cst`` +over its own definition for implementing ``__atomic_compare_exchange_weak_seq_cst_seq_cst``. +That is, the library will arrange for ``__atomic_compare_exchange_weak_seq_cst_seq_cst`` to call +``__atomic_compare_exchange_strong_seq_cst_seq_cst`` if you supply an intrinsic for the strong +version but not the weak. + +Taking advantage of weaker memory synchronization +------------------------------------------------- +So far, all of the intrinsics presented require a **sequentially consistent** memory ordering. +That is, no loads or stores can move across the operation (just as if the library had locked +that internal mutex). But ```` supports weaker memory ordering operations. In all, +there are six memory orderings (listed here from strongest to weakest): + +.. code-block:: cpp + + memory_order_seq_cst + memory_order_acq_rel + memory_order_release + memory_order_acquire + memory_order_consume + memory_order_relaxed + +(See the `C++ Standard `_ for the detailed definitions of each of these orderings). + +On some platforms, the compiler vendor can offer some or even all of the above +intrinsics at one or more weaker levels of memory synchronization. This might +lead for example to not issuing an ``mfence`` instruction on the x86. + +If the compiler does not offer any given operation, at any given memory ordering +level, the library will automatically attempt to call the next highest memory +ordering operation. This continues up to ``seq_cst``, and if that doesn't +exist, then the library takes over and does the job with a ``mutex``. This +is a compile-time search and selection operation. At run time, the application +will only see the few inlined assembly instructions for the selected intrinsic. + +Each intrinsic is appended with the 7-letter name of the memory ordering it +addresses. For example a ``load`` with ``relaxed`` ordering is defined by: + +.. code-block:: cpp + + T __atomic_load_relaxed(const volatile T* obj); + +And announced with: + +.. code-block:: cpp + + __has_feature(__atomic_load_relaxed_b) == 1 // bool + __has_feature(__atomic_load_relaxed_c) == 1 // char + __has_feature(__atomic_load_relaxed_a) == 1 // signed char + ... + +The ``__atomic_compare_exchange_strong(weak)`` intrinsics are parameterized +on two memory orderings. The first ordering applies when the operation returns +``true`` and the second ordering applies when the operation returns ``false``. + +Not every memory ordering is appropriate for every operation. ``exchange`` +and the ``fetch_XXX`` operations support all 6. But ``load`` only supports +``relaxed``, ``consume``, ``acquire`` and ``seq_cst``. ``store`` only supports +``relaxed``, ``release``, and ``seq_cst``. The ``compare_exchange`` operations +support the following 16 combinations out of the possible 36: + +.. code-block:: cpp + + relaxed_relaxed + consume_relaxed + consume_consume + acquire_relaxed + acquire_consume + acquire_acquire + release_relaxed + release_consume + release_acquire + acq_rel_relaxed + acq_rel_consume + acq_rel_acquire + seq_cst_relaxed + seq_cst_consume + seq_cst_acquire + seq_cst_seq_cst + +Again, the compiler supplies intrinsics only for the strongest orderings where +it can make a difference. The library takes care of calling the weakest +supplied intrinsic that is as strong or stronger than the customer asked for. + +Note about ABI +============== +With any design, the (back end) compiler writer should note that the decision to +implement lock-free operations on any given type (or not) is an ABI-binding decision. +One can not change from treating a type as not lock free, to lock free (or vice-versa) +without breaking your ABI. + +For example: + +**TU1.cpp**: + +.. code-block:: cpp + + extern atomic A; + int foo() { return A.compare_exchange_strong(w, x); } + + +**TU2.cpp**: + +.. code-block:: cpp + + extern atomic A; + void bar() { return A.compare_exchange_strong(y, z); } + +If only **one** of these calls to ``compare_exchange_strong`` is implemented with +mutex-locked code, then that mutex-locked code will not be executed mutually +exclusively of the one implemented in a lock-free manner. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/DebugMode.rst b/gnu/llvm/libcxx/docs/DesignDocs/DebugMode.rst index e4d4e5b2d90..abcd5e5c8c6 100644 --- a/gnu/llvm/libcxx/docs/DesignDocs/DebugMode.rst +++ b/gnu/llvm/libcxx/docs/DesignDocs/DebugMode.rst @@ -7,34 +7,59 @@ Debug Mode .. _using-debug-mode: -Using Debug Mode -================ +Using the debug mode +==================== -Libc++ provides a debug mode that enables assertions meant to detect incorrect -usage of the standard library. By default these assertions are disabled but +Libc++ provides a debug mode that enables special debugging checks meant to detect +incorrect usage of the standard library. These checks are disabled by default, but they can be enabled using the ``_LIBCPP_DEBUG`` macro. -**_LIBCPP_DEBUG** Macro ------------------------ +Note that using the debug mode discussed in this document requires that the library +has been compiled with support for the debug mode (see ``LIBCXX_ENABLE_DEBUG_MODE_SUPPORT``). -**_LIBCPP_DEBUG**: - This macro is used to enable assertions and iterator debugging checks within - libc++. By default it is undefined. +Also note that while the debug mode has no effect on libc++'s ABI, it does have broad ODR +implications. Users should compile their whole program at the same debugging level. - **Values**: ``0``, ``1`` +The various levels of checking provided by the debug mode follow. - Defining ``_LIBCPP_DEBUG`` to ``0`` or greater enables most of libc++'s - assertions. Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging" - which provides additional assertions about the validity of iterators used by - the program. +No debugging checks (``_LIBCPP_DEBUG`` not defined) +--------------------------------------------------- +When ``_LIBCPP_DEBUG`` is not defined, there are no debugging checks performed by +the library. This is the default. - Note that this option has no effect on libc++'s ABI; but it does have broad - ODR implications. Users should compile their whole program at the same - debugging level. +Basic checks (``_LIBCPP_DEBUG == 0``) +------------------------------------- +When ``_LIBCPP_DEBUG`` is defined to ``0`` (to be understood as level ``0``), some +debugging checks are enabled. The non-exhaustive list of things is: -Handling Assertion Failures ---------------------------- +- Many algorithms, such as ``binary_search``, ``merge``, ``next_permutation``, and ``sort``, + wrap the user-provided comparator to assert that `!comp(y, x)` whenever + `comp(x, y)`. This can cause the user-provided comparator to be evaluated + up to twice as many times as it would be without ``_LIBCPP_DEBUG``, and + causes the library to violate some of the Standard's complexity clauses. + +- FIXME: Update this list + +Iterator debugging checks (``_LIBCPP_DEBUG == 1``) +-------------------------------------------------- +Defining ``_LIBCPP_DEBUG`` to ``1`` enables "iterator debugging", which provides +additional assertions about the validity of iterators used by the program. +The following containers and classes support iterator debugging: + +- ``std::string`` +- ``std::vector`` (``T != bool``) +- ``std::list`` +- ``std::unordered_map`` +- ``std::unordered_multimap`` +- ``std::unordered_set`` +- ``std::unordered_multiset`` + +The remaining containers do not currently support iterator debugging. +Patches welcome. + +Handling Assertion Failures +=========================== When a debug assertion fails the assertion handler is called via the ``std::__libcpp_debug_function`` function pointer. It is possible to override this function pointer using a different handler function. Libc++ provides a @@ -55,37 +80,3 @@ assertion handler as follows. str.insert(bad_it, '!'); // causes debug assertion // control flow doesn't return } - -Debug Mode Checks -================= - -Libc++'s debug mode offers two levels of checking. The first enables various -precondition checks throughout libc++. The second additionally enables -"iterator debugging" which checks the validity of iterators used by the program. - -Basic Checks -============ - -These checks are enabled when ``_LIBCPP_DEBUG`` is defined to either 0 or 1. - -The following checks are enabled by ``_LIBCPP_DEBUG``: - - * FIXME: Update this list - -Iterator Debugging Checks -========================= - -These checks are enabled when ``_LIBCPP_DEBUG`` is defined to 1. - -The following containers and STL classes support iterator debugging: - - * ``std::string`` - * ``std::vector`` (``T != bool``) - * ``std::list`` - * ``std::unordered_map`` - * ``std::unordered_multimap`` - * ``std::unordered_set`` - * ``std::unordered_multiset`` - -The remaining containers do not currently support iterator debugging. -Patches welcome. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/FeatureTestMacros.rst b/gnu/llvm/libcxx/docs/DesignDocs/FeatureTestMacros.rst index 2fbba6547bb..2c6f983ee6d 100644 --- a/gnu/llvm/libcxx/docs/DesignDocs/FeatureTestMacros.rst +++ b/gnu/llvm/libcxx/docs/DesignDocs/FeatureTestMacros.rst @@ -8,7 +8,7 @@ Feature Test Macros Overview ======== -Libc++ implements the C++ feature test macros as specified in the C++2a standard, +Libc++ implements the C++ feature test macros as specified in the C++20 standard, and before that in non-normative guiding documents (`See cppreference `_) @@ -39,7 +39,5 @@ The `generate_feature_test_macro_components.py` script is used to track and update feature test macros in libc++. Whenever a feature test macro is added or changed, the table should be updated -and the script should be re-ran. The script will clobber the existing test files -and the documentation and it will generate a new `` header as a -temporary file. The generated `` header should be merged with the -existing one. +and the script should be re-ran. The script will clobber the existing test files, +the documentation and the `` header. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/FileTimeType.rst b/gnu/llvm/libcxx/docs/DesignDocs/FileTimeType.rst index f1e9edd8735..a54d2bf2720 100644 --- a/gnu/llvm/libcxx/docs/DesignDocs/FileTimeType.rst +++ b/gnu/llvm/libcxx/docs/DesignDocs/FileTimeType.rst @@ -18,7 +18,7 @@ type, which is a specialization of ``chrono::time_point`` for the trivial-clock is an implementation-defined type that satisfies the Cpp17TrivialClock requirements ([time.clock.req]) and that is capable of representing and measuring file time values. Implementations should ensure - that the resolution and range of file_­time_­type reflect the operating + that the resolution and range of file_time_type reflect the operating system dependent resolution and range of file time values. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/NoexceptPolicy.rst b/gnu/llvm/libcxx/docs/DesignDocs/NoexceptPolicy.rst new file mode 100644 index 00000000000..8dc5e14e486 --- /dev/null +++ b/gnu/llvm/libcxx/docs/DesignDocs/NoexceptPolicy.rst @@ -0,0 +1,13 @@ +==================== +``noexcept`` Policy +==================== + +Extended applications of ``noexcept`` +------------------------------------------ + +As of version 13 libc++ may mark functions that do not throw (i.e., +"Throws: Nothing") as ``noexcept``. This has two primary consequences: +first, functions might not report precondition violations by throwing. +Second, user-provided functions, such as custom predicates or custom +traits, which throw might not be propagated up to the caller (unless +specified otherwise by the Standard). diff --git a/gnu/llvm/libcxx/docs/DesignDocs/UniquePtrTrivialAbi.rst b/gnu/llvm/libcxx/docs/DesignDocs/UniquePtrTrivialAbi.rst new file mode 100644 index 00000000000..a0f260a44e8 --- /dev/null +++ b/gnu/llvm/libcxx/docs/DesignDocs/UniquePtrTrivialAbi.rst @@ -0,0 +1,149 @@ +============================================= +Enable std::unique_ptr [[clang::trivial_abi]] +============================================= + +Background +========== + +Consider the follow snippets + + +.. code-block:: cpp + + void raw_func(Foo* raw_arg) { ... } + void smart_func(std::unique_ptr smart_arg) { ... } + + Foo* raw_ptr_retval() { ... } + std::unique_ptr smart_ptr_retval() { ... } + + + +The argument ``raw_arg`` could be passed in a register but ``smart_arg`` could not, due to current +implementation. + +Specifically, in the ``smart_arg`` case, the caller secretly constructs a temporary ``std::unique_ptr`` +in its stack-frame, and then passes a pointer to it to the callee in a hidden parameter. +Similarly, the return value from ``smart_ptr_retval`` is secretly allocated in the caller and +passed as a secret reference to the callee. + + +Goal +=================== + +``std::unique_ptr`` is passed directly in a register. + +Design +====== + +* Annotate the two definitions of ``std::unique_ptr`` with ``clang::trivial_abi`` attribute. +* Put the attribuate behind a flag because this change has potential compilation and runtime breakages. + + +This comes with some side effects: + +* ``std::unique_ptr`` parameters will now be destroyed by callees, rather than callers. + It is worth noting that destruction by callee is not unique to the use of trivial_abi attribute. + In most Microsoft's ABIs, arguments are always destroyed by the callee. + + Consequently, this may change the destruction order for function parameters to an order that is non-conforming to the standard. + For example: + + + .. code-block:: cpp + + struct A { ~A(); }; + struct B { ~B(); }; + struct C { C(A, unique_ptr, A) {} }; + C c{{}, make_unique, {}}; + + + In a conforming implementation, the destruction order for C::C's parameters is required to be ``~A(), ~B(), ~A()`` but with this mode enabled, we'll instead see ``~B(), ~A(), ~A()``. + +* Reduced code-size. + + +Performance impact +------------------ + +Google has measured performance improvements of up to 1.6% on some large server macrobenchmarks, and a small reduction in binary sizes. + +This also affects null pointer optimization + +Clang's optimizer can now figure out when a `std::unique_ptr` is known to contain *non*-null. +(Actually, this has been a *missed* optimization all along.) + + +.. code-block:: cpp + + struct Foo { + ~Foo(); + }; + std::unique_ptr make_foo(); + void do_nothing(const Foo&) + + void bar() { + auto x = make_foo(); + do_nothing(*x); + } + + +With this change, ``~Foo()`` will be called even if ``make_foo`` returns ``unique_ptr(nullptr)``. +The compiler can now assume that ``x.get()`` cannot be null by the end of ``bar()``, because +the deference of ``x`` would be UB if it were ``nullptr``. (This dereference would not have caused +a segfault, because no load is generated for dereferencing a pointer to a reference. This can be detected with ``-fsanitize=null``). + + +Potential breakages +------------------- + +The following breakages were discovered by enabling this change and fixing the resulting issues in a large code base. + +- Compilation failures + + - Function definitions now require complete type ``T`` for parameters with type ``std::unique_ptr``. The following code will no longer compile. + + .. code-block:: cpp + + class Foo; + void func(std::unique_ptr arg) { /* never use `arg` directly */ } + + - Fix: Remove forward-declaration of ``Foo`` and include its proper header. + +- Runtime Failures + + - Lifetime of ``std::unique_ptr<>`` arguments end earlier (at the end of the callee's body, rather than at the end of the full expression containing the call). + + .. code-block:: cpp + + util::Status run_worker(std::unique_ptr); + void func() { + std::unique_ptr smart_foo = ...; + Foo* owned_foo = smart_foo.get(); + // Currently, the following would "work" because the argument to run_worker() is deleted at the end of func() + // With the new calling convention, it will be deleted at the end of run_worker(), + // making this an access to freed memory. + owned_foo->Bar(run_worker(std::move(smart_foo))); + ^ + // <<`` ends earlier. + + Spot the bug: + + .. code-block:: cpp + + std::unique_ptr create_and_subscribe(Bar* subscriber) { + auto foo = std::make_unique(); + subscriber->sub([&foo] { foo->do_thing();} ); + return foo; + } + + One could point out this is an obvious stack-use-after return bug. + With the current calling convention, running this code with ASAN enabled, however, would not yield any "issue". + So is this a bug in ASAN? (Spoiler: No) + + This currently would "work" only because the storage for ``foo`` is in the caller's stackframe. + In other words, ``&foo`` in callee and ``&foo`` in the caller are the same address. + +ASAN can be used to detect both of these. diff --git a/gnu/llvm/libcxx/docs/DesignDocs/VisibilityMacros.rst b/gnu/llvm/libcxx/docs/DesignDocs/VisibilityMacros.rst index d0d4f0adb22..e5aa50097dd 100644 --- a/gnu/llvm/libcxx/docs/DesignDocs/VisibilityMacros.rst +++ b/gnu/llvm/libcxx/docs/DesignDocs/VisibilityMacros.rst @@ -5,6 +5,8 @@ Symbol Visibility Macros .. contents:: :local: +.. _visibility-macros: + Overview ======== @@ -44,6 +46,10 @@ Visibility Macros Mark a function as not being part of the ABI of any final linked image that uses it. +**_LIBCPP_INLINE_VISIBILITY** + Historical predecessor of ``_LIBCPP_HIDE_FROM_ABI`` -- please use + ``_LIBCPP_HIDE_FROM_ABI`` instead. + **_LIBCPP_HIDE_FROM_ABI_AFTER_V1** Mark a function as being hidden from the ABI (per `_LIBCPP_HIDE_FROM_ABI`) when libc++ is built with an ABI version after ABI v1. This macro is used to @@ -131,12 +137,6 @@ Visibility Macros specified on the primary template and to export the member functions produced by the explicit instantiation in the dylib. - **GCC Behavior**: GCC ignores visibility attributes applied the type in - extern template declarations and applying an attribute results in a warning. - However since `_LIBCPP_TEMPLATE_VIS` is the same as - `__attribute__((visibility("default"))` the visibility is already correct. - The macro has an empty definition with GCC. - **Windows Behavior**: `extern template` and `dllexport` are fundamentally incompatible *on a class template* on Windows; the former suppresses instantiation, while the latter forces it. Specifying both on the same diff --git a/gnu/llvm/libcxx/docs/FeatureTestMacroTable.rst b/gnu/llvm/libcxx/docs/FeatureTestMacroTable.rst index a6867fb30a3..c2690e72eea 100644 --- a/gnu/llvm/libcxx/docs/FeatureTestMacroTable.rst +++ b/gnu/llvm/libcxx/docs/FeatureTestMacroTable.rst @@ -22,191 +22,286 @@ Status :widths: auto ================================================= ================= - Macro Name Value + Macro Name Value ================================================= ================= - **C++ 14** + **C++ 14** ------------------------------------------------------------------- - ``__cpp_lib_chrono_udls`` ``201304L`` + ``__cpp_lib_chrono_udls`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_complex_udls`` ``201309L`` + ``__cpp_lib_complex_udls`` ``201309L`` ------------------------------------------------- ----------------- - ``__cpp_lib_exchange_function`` ``201304L`` + ``__cpp_lib_exchange_function`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_generic_associative_lookup`` ``201304L`` + ``__cpp_lib_generic_associative_lookup`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_integer_sequence`` ``201304L`` + ``__cpp_lib_integer_sequence`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_integral_constant_callable`` ``201304L`` + ``__cpp_lib_integral_constant_callable`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_is_final`` ``201402L`` + ``__cpp_lib_is_final`` ``201402L`` ------------------------------------------------- ----------------- - ``__cpp_lib_is_null_pointer`` ``201309L`` + ``__cpp_lib_is_null_pointer`` ``201309L`` ------------------------------------------------- ----------------- - ``__cpp_lib_make_reverse_iterator`` ``201402L`` + ``__cpp_lib_make_reverse_iterator`` ``201402L`` ------------------------------------------------- ----------------- - ``__cpp_lib_make_unique`` ``201304L`` + ``__cpp_lib_make_unique`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_null_iterators`` ``201304L`` + ``__cpp_lib_null_iterators`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_quoted_string_io`` ``201304L`` + ``__cpp_lib_quoted_string_io`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_result_of_sfinae`` ``201210L`` + ``__cpp_lib_result_of_sfinae`` ``201210L`` ------------------------------------------------- ----------------- - ``__cpp_lib_robust_nonmodifying_seq_ops`` ``201304L`` + ``__cpp_lib_robust_nonmodifying_seq_ops`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_shared_timed_mutex`` ``201402L`` + ``__cpp_lib_shared_timed_mutex`` ``201402L`` ------------------------------------------------- ----------------- - ``__cpp_lib_string_udls`` ``201304L`` + ``__cpp_lib_string_udls`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_transformation_trait_aliases`` ``201304L`` + ``__cpp_lib_transformation_trait_aliases`` ``201304L`` ------------------------------------------------- ----------------- - ``__cpp_lib_transparent_operators`` ``201210L`` + ``__cpp_lib_transparent_operators`` ``201210L`` ------------------------------------------------- ----------------- - ``__cpp_lib_tuple_element_t`` ``201402L`` + ``__cpp_lib_tuple_element_t`` ``201402L`` ------------------------------------------------- ----------------- - ``__cpp_lib_tuples_by_type`` ``201304L`` + ``__cpp_lib_tuples_by_type`` ``201304L`` ------------------------------------------------- ----------------- - **C++ 17** + **C++ 17** ------------------------------------------------------------------- - ``__cpp_lib_addressof_constexpr`` ``201603L`` + ``__cpp_lib_addressof_constexpr`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_allocator_traits_is_always_equal`` ``201411L`` + ``__cpp_lib_allocator_traits_is_always_equal`` ``201411L`` ------------------------------------------------- ----------------- - ``__cpp_lib_any`` ``201606L`` + ``__cpp_lib_any`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_apply`` ``201603L`` + ``__cpp_lib_apply`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_array_constexpr`` ``201603L`` + ``__cpp_lib_array_constexpr`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_as_const`` ``201510L`` + ``__cpp_lib_as_const`` ``201510L`` ------------------------------------------------- ----------------- - ``__cpp_lib_atomic_is_always_lock_free`` ``201603L`` + ``__cpp_lib_atomic_is_always_lock_free`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_bool_constant`` ``201505L`` + ``__cpp_lib_bool_constant`` ``201505L`` ------------------------------------------------- ----------------- - ``__cpp_lib_boyer_moore_searcher`` *unimplemented* + ``__cpp_lib_boyer_moore_searcher`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_byte`` ``201603L`` + ``__cpp_lib_byte`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_chrono`` ``201611L`` + ``__cpp_lib_chrono`` ``201611L`` ------------------------------------------------- ----------------- - ``__cpp_lib_clamp`` ``201603L`` + ``__cpp_lib_clamp`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_enable_shared_from_this`` ``201603L`` + ``__cpp_lib_enable_shared_from_this`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_execution`` *unimplemented* + ``__cpp_lib_execution`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_filesystem`` ``201703L`` + ``__cpp_lib_filesystem`` ``201703L`` ------------------------------------------------- ----------------- - ``__cpp_lib_gcd_lcm`` ``201606L`` + ``__cpp_lib_gcd_lcm`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_hardware_interference_size`` *unimplemented* + ``__cpp_lib_hardware_interference_size`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_has_unique_object_representations`` ``201606L`` + ``__cpp_lib_has_unique_object_representations`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_hypot`` ``201603L`` + ``__cpp_lib_hypot`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_incomplete_container_elements`` ``201505L`` + ``__cpp_lib_incomplete_container_elements`` ``201505L`` ------------------------------------------------- ----------------- - ``__cpp_lib_invoke`` ``201411L`` + ``__cpp_lib_invoke`` ``201411L`` ------------------------------------------------- ----------------- - ``__cpp_lib_is_aggregate`` ``201703L`` + ``__cpp_lib_is_aggregate`` ``201703L`` ------------------------------------------------- ----------------- - ``__cpp_lib_is_invocable`` ``201703L`` + ``__cpp_lib_is_invocable`` ``201703L`` ------------------------------------------------- ----------------- - ``__cpp_lib_is_swappable`` ``201603L`` + ``__cpp_lib_is_swappable`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_launder`` ``201606L`` + ``__cpp_lib_launder`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_logical_traits`` ``201510L`` + ``__cpp_lib_logical_traits`` ``201510L`` ------------------------------------------------- ----------------- - ``__cpp_lib_make_from_tuple`` ``201606L`` + ``__cpp_lib_make_from_tuple`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_map_try_emplace`` ``201411L`` + ``__cpp_lib_map_try_emplace`` ``201411L`` ------------------------------------------------- ----------------- - ``__cpp_lib_math_special_functions`` *unimplemented* + ``__cpp_lib_math_special_functions`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_memory_resource`` *unimplemented* + ``__cpp_lib_memory_resource`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_node_extract`` ``201606L`` + ``__cpp_lib_node_extract`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_nonmember_container_access`` ``201411L`` + ``__cpp_lib_nonmember_container_access`` ``201411L`` ------------------------------------------------- ----------------- - ``__cpp_lib_not_fn`` ``201603L`` + ``__cpp_lib_not_fn`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_optional`` ``201606L`` + ``__cpp_lib_optional`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_parallel_algorithm`` *unimplemented* + ``__cpp_lib_parallel_algorithm`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_raw_memory_algorithms`` ``201606L`` + ``__cpp_lib_raw_memory_algorithms`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_sample`` ``201603L`` + ``__cpp_lib_sample`` ``201603L`` ------------------------------------------------- ----------------- - ``__cpp_lib_scoped_lock`` ``201703L`` + ``__cpp_lib_scoped_lock`` ``201703L`` ------------------------------------------------- ----------------- - ``__cpp_lib_shared_mutex`` ``201505L`` + ``__cpp_lib_shared_mutex`` ``201505L`` ------------------------------------------------- ----------------- - ``__cpp_lib_shared_ptr_arrays`` *unimplemented* + ``__cpp_lib_shared_ptr_arrays`` ``201611L`` ------------------------------------------------- ----------------- - ``__cpp_lib_shared_ptr_weak_type`` ``201606L`` + ``__cpp_lib_shared_ptr_weak_type`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_string_view`` ``201606L`` + ``__cpp_lib_string_view`` ``201606L`` ------------------------------------------------- ----------------- - ``__cpp_lib_to_chars`` *unimplemented* + ``__cpp_lib_to_chars`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_transparent_operators`` ``201510L`` + ``__cpp_lib_transparent_operators`` ``201510L`` ------------------------------------------------- ----------------- - ``__cpp_lib_type_trait_variable_templates`` ``201510L`` + ``__cpp_lib_type_trait_variable_templates`` ``201510L`` ------------------------------------------------- ----------------- - ``__cpp_lib_uncaught_exceptions`` ``201411L`` + ``__cpp_lib_uncaught_exceptions`` ``201411L`` ------------------------------------------------- ----------------- - ``__cpp_lib_unordered_map_try_emplace`` ``201411L`` + ``__cpp_lib_unordered_map_try_emplace`` ``201411L`` ------------------------------------------------- ----------------- - ``__cpp_lib_variant`` ``201606L`` + ``__cpp_lib_variant`` ``202102L`` ------------------------------------------------- ----------------- - ``__cpp_lib_void_t`` ``201411L`` + ``__cpp_lib_void_t`` ``201411L`` ------------------------------------------------- ----------------- - **C++ 2a** + **C++ 20** ------------------------------------------------------------------- - ``__cpp_lib_array_constexpr`` ``201811L`` + ``__cpp_lib_array_constexpr`` ``201811L`` ------------------------------------------------- ----------------- - ``__cpp_lib_atomic_ref`` *unimplemented* + ``__cpp_lib_assume_aligned`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_bind_front`` *unimplemented* + ``__cpp_lib_atomic_flag_test`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_bit_cast`` *unimplemented* + ``__cpp_lib_atomic_float`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_char8_t`` ``201811L`` + ``__cpp_lib_atomic_lock_free_type_aliases`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_concepts`` *unimplemented* + ``__cpp_lib_atomic_ref`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_constexpr_misc`` *unimplemented* + ``__cpp_lib_atomic_shared_ptr`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_constexpr_swap_algorithms`` *unimplemented* + ``__cpp_lib_atomic_value_initialization`` ``201911L`` ------------------------------------------------- ----------------- - ``__cpp_lib_destroying_delete`` ``201806L`` + ``__cpp_lib_atomic_wait`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_endian`` ``201907L`` + ``__cpp_lib_barrier`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_erase_if`` ``202002L`` + ``__cpp_lib_bind_front`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_generic_unordered_lookup`` *unimplemented* + ``__cpp_lib_bit_cast`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_interpolate`` ``201902L`` + ``__cpp_lib_bitops`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_is_constant_evaluated`` ``201811L`` + ``__cpp_lib_bounded_array_traits`` ``201902L`` ------------------------------------------------- ----------------- - ``__cpp_lib_list_remove_return_type`` ``201806L`` + ``__cpp_lib_char8_t`` ``201811L`` ------------------------------------------------- ----------------- - ``__cpp_lib_math_constants`` ``201907L`` + ``__cpp_lib_concepts`` ``202002L`` ------------------------------------------------- ----------------- - ``__cpp_lib_ranges`` *unimplemented* + ``__cpp_lib_constexpr_algorithms`` ``201806L`` ------------------------------------------------- ----------------- - ``__cpp_lib_span`` ``202002L`` + ``__cpp_lib_constexpr_complex`` *unimplemented* ------------------------------------------------- ----------------- - ``__cpp_lib_three_way_comparison`` *unimplemented* + ``__cpp_lib_constexpr_dynamic_alloc`` ``201907L`` ------------------------------------------------- ----------------- - ``__cpp_lib_to_array`` ``201907L`` + ``__cpp_lib_constexpr_functional`` ``201907L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_iterator`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_memory`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_numeric`` ``201911L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_string`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_string_view`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_tuple`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_utility`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_constexpr_vector`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_coroutine`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_destroying_delete`` ``201806L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_endian`` ``201907L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_erase_if`` ``202002L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_execution`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_format`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_generic_unordered_lookup`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_int_pow2`` ``202002L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_integer_comparison_functions`` ``202002L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_interpolate`` ``201902L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_is_constant_evaluated`` ``201811L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_is_layout_compatible`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_is_nothrow_convertible`` ``201806L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_is_pointer_interconvertible`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_jthread`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_latch`` ``201907L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_list_remove_return_type`` ``201806L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_math_constants`` ``201907L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_polymorphic_allocator`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_ranges`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_remove_cvref`` ``201711L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_semaphore`` ``201907L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_shift`` ``201806L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_smart_ptr_for_overwrite`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_source_location`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_span`` ``202002L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_ssize`` ``201902L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_starts_ends_with`` ``201711L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_string_view`` ``201803L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_syncbuf`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_three_way_comparison`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_to_address`` ``201711L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_to_array`` ``201907L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_unwrap_ref`` ``201811L`` + ------------------------------------------------- ----------------- + **C++ 2b** + ------------------------------------------------------------------- + ``__cpp_lib_is_scoped_enum`` ``202011L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_stacktrace`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_stdatomic_h`` *unimplemented* + ------------------------------------------------- ----------------- + ``__cpp_lib_string_contains`` ``202011L`` + ------------------------------------------------- ----------------- + ``__cpp_lib_to_underlying`` ``202102L`` ================================================= ================= - diff --git a/gnu/llvm/libcxx/docs/Helpers/Styles.rst b/gnu/llvm/libcxx/docs/Helpers/Styles.rst new file mode 100644 index 00000000000..9bba3bf69db --- /dev/null +++ b/gnu/llvm/libcxx/docs/Helpers/Styles.rst @@ -0,0 +1,31 @@ +.. raw:: html + + + +.. role:: nothingtodo +.. role:: inprogress +.. role:: partial +.. role:: complete + + +.. |Nothing To Do| replace:: :nothingtodo:`Nothing To Do` +.. |In Progress| replace:: :inprogress:`In Progress` +.. |Partial| replace:: :partial:`Partial` +.. |Complete| replace:: :complete:`Complete` + +.. |sect| unicode:: U+00A7 +.. |hellip| unicode:: U+2026 diff --git a/gnu/llvm/libcxx/docs/README.txt b/gnu/llvm/libcxx/docs/README.txt index 06d94f5b5fc..ff7e71f1023 100644 --- a/gnu/llvm/libcxx/docs/README.txt +++ b/gnu/llvm/libcxx/docs/README.txt @@ -11,3 +11,7 @@ To build the documents into html configure libc++ with the following cmake optio After configuring libc++ with these options the make rule `docs-libcxx-html` should be available. + +The documentation in this directory is published at https://libcxx.llvm.org. It is kept up-to-date +by a build bot: https://lab.llvm.org/buildbot/#/builders/publish-sphinx-docs. If you notice that the +documentation is not updating anymore, please contact one of the maintainers. diff --git a/gnu/llvm/libcxx/docs/ReleaseNotes.rst b/gnu/llvm/libcxx/docs/ReleaseNotes.rst index 001957570c9..85b7016485f 100644 --- a/gnu/llvm/libcxx/docs/ReleaseNotes.rst +++ b/gnu/llvm/libcxx/docs/ReleaseNotes.rst @@ -1,6 +1,6 @@ -=========================== -Libc++ 11.0.0 Release Notes -=========================== +========================================= +Libc++ 13.0.0 (In-Progress) Release Notes +========================================= .. contents:: :local: @@ -8,11 +8,17 @@ Libc++ 11.0.0 Release Notes Written by the `Libc++ Team `_ +.. warning:: + + These are in-progress notes for the upcoming libc++ 13 release. + Release notes for previous releases can be found on + `the Download Page `_. + Introduction ============ This document contains the release notes for the libc++ C++ Standard Library, -part of the LLVM Compiler Infrastructure, release 11.0.0. Here we describe the +part of the LLVM Compiler Infrastructure, release 13.0.0. Here we describe the status of libc++ in some detail, including major improvements from the previous release and new feature work. For the general LLVM release notes, see `the LLVM documentation `_. All LLVM releases may @@ -21,10 +27,77 @@ be downloaded from the `LLVM releases web site `_. For more information about libc++, please see the `Libc++ Web Site `_ or the `LLVM Web Site `_. -What's New in Libc++ 11.0.0? +Note that if you are reading this file from a Git checkout or the +main Libc++ web page, this document applies to the *next* release, not +the current one. To see the release notes for a specific release, please +see the `releases page `_. + +What's New in Libc++ 13.0.0? ============================ +- Support for older compilers has been removed. Several additional platforms + are now officially supported. :ref:`platform_and_compiler_support` contains + the complete overview of platforms and compilers supported by libc++. +- The large headers ````, ````, and ```` have + been split in more granular headers. This reduces the size of included code + when using libc++. This may lead to missing includes after upgrading to + libc++13. + New Features ------------ -- ```` +- ``std::filesystem`` is now feature complete for the Windows platform using + MinGW. MSVC isn't supported since it lacks 128-bit integer support. +- The implementation of the C++20 concepts library has been completed. +- Several C++20 ``constexpr`` papers have been completed: + + - `P0879R0 `_ ``constexpr`` for ``std::swap()`` + and swap related functions + - `P1032R1 `_ Misc ``constexpr`` bits + - `P0883 `_ Fixing Atomic Initialization + +- More C++20 features have been implemented. :doc:`Status/Cxx20` has the full + overview of libc++'s C++20 implementation status. +- More C++2b features have been implemented. :doc:`Status/Cxx2b` has the + full overview of libc++'s C++2b implementation status. +- The CMake option ``LIBCXX_ENABLE_INCOMPLETE_FEATURES`` has been added. This + option allows libc++ vendors to disable headers that aren't production + quality yet. Currently, turning the option off disables the headers + ```` and ````. +- The documentation conversion from html to restructured text has been + completed. + +API Changes +----------- + +- There has been several changes in the tuple constructors provided by libc++. + Those changes were made as part of an effort to regularize libc++'s tuple + implementation, which contained several subtle bugs due to these extensions. + If you notice a build breakage when initializing a tuple, make sure you + properly initialize all the tuple elements - this is probably the culprit. + + In particular, the extension allowing tuples to be constructed from fewer + elements than the number of elements in the tuple (in which case the remaining + elements would be default-constructed) has been removed. See https://godbolt.org/z/sqozjd. + + Also, the extension allowing a tuple to be constructed from an array has been + removed. See https://godbolt.org/z/5esqbW. + +- The ``std::pointer_safety`` utility and related functions are not available + in C++03 anymore. Furthermore, in other standard modes, it has changed from + a struct to a scoped enumeration, which is an ABI break. Finally, the + ``std::get_pointer_safety`` function was previously in the dylib, but it + is now defined as inline in the headers. + + While this is technically both an API and an ABI break, we do not expect + ``std::pointer_safety`` to have been used at all in real code, since we + never implemented the underlying support for garbage collection. + +- The `LIBCXXABI_ENABLE_PIC` CMake option was removed. If you are building your + own libc++abi from source and were using `LIBCXXABI_ENABLE_PIC`, please use + `CMAKE_POSITION_INDEPENDENT_CODE=ON` instead. + +- When the header is included, it will no longer include transitively. + +- The ``std::result_of`` and ``std::is_literal_type`` type traits have been removed in + C++20 mode. diff --git a/gnu/llvm/libcxx/docs/Status/Cxx14.rst b/gnu/llvm/libcxx/docs/Status/Cxx14.rst new file mode 100644 index 00000000000..fc3aeeec36a --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx14.rst @@ -0,0 +1,52 @@ +.. _cxx14-status: + +================================ +libc++ C++14 Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, initially known as "C++1y". + +The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol). + +In August 2014, this draft was approved by ISO as C++14. + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + + +.. _paper-status-cxx14: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx14Papers.csv + :header-rows: 1 + :widths: auto + + +.. _issues-status-cxx14: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx14Issues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 25-Mar-2014 diff --git a/gnu/llvm/libcxx/docs/Status/Cxx14Issues.csv b/gnu/llvm/libcxx/docs/Status/Cxx14Issues.csv new file mode 100644 index 00000000000..02da3e71be1 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx14Issues.csv @@ -0,0 +1,157 @@ +"Issue #","Issue Name","Meeting","Status" +"`1214 `__","Insufficient/inconsistent key immutability requirements for associative containers","Kona","|Complete|" +"`2009 `__","Reporting out-of-bound values on numeric string conversions","Kona","|Complete|" +"`2010 `__","``is_*``\ traits for binding operations can't be meaningfully specialized","Kona","|Complete|" +"`2015 `__","Incorrect pre-conditions for some type traits","Kona","|Complete|" +"`2021 `__","Further incorrect usages of result_of","Kona","|Complete|" +"`2028 `__","messages_base::catalog overspecified","Kona","|Complete|" +"`2033 `__","Preconditions of reserve, shrink_to_fit, and resize functions","Kona","|Complete|" +"`2039 `__","Issues with std::reverse and std::copy_if","Kona","|Complete|" +"`2044 `__","No definition of ""Stable"" for copy algorithms","Kona","|Complete|" +"`2045 `__","forward_list::merge and forward_list::splice_after with unequal allocators","Kona","|Complete|" +"`2047 `__","Incorrect ""mixed"" move-assignment semantics of unique_ptr","Kona","|Complete|" +"`2050 `__","Unordered associative containers do not use allocator_traits to define member types","Kona","|Complete|" +"`2053 `__","Errors in regex bitmask types","Kona","|Complete|" +"`2061 `__","make_move_iterator and arrays","Kona","|Complete|" +"`2064 `__","More noexcept issues in basic_string","Kona","|Complete|" +"`2065 `__","Minimal allocator interface","Kona","|Complete|" +"`2067 `__","packaged_task should have deleted copy c'tor with const parameter","Kona","|Complete|" +"`2069 `__","Inconsistent exception spec for basic_string move constructor","Kona","|Complete|" +"`2096 `__","Incorrect constraints of future::get in regard to MoveAssignable","Kona","|Complete|" +"`2102 `__","Why is std::launch an implementation-defined type?","Kona","|Complete|" +"","","","" +"`2071 `__","std::valarray move-assignment","Portland","|Complete|" +"`2074 `__","Off by one error in std::reverse_copy","Portland","|Complete|" +"`2081 `__","Allocator requirements should include CopyConstructible","Portland","|Complete|" +"`2083 `__","const-qualification on weak_ptr::owner_before","Portland","|Complete|" +"`2086 `__","Overly generic type support for math functions","Portland","|Complete|" +"`2099 `__","Unnecessary constraints of va_start() usage","Portland","|Complete|" +"`2103 `__","std::allocator_traits>::propagate_on_container_move_assignment","Portland","|Complete|" +"`2105 `__","Inconsistent requirements on ``const_iterator``'s value_type","Portland","|Complete|" +"`2110 `__","remove can't swap but note says it might","Portland","|Complete|" +"`2123 `__","merge() allocator requirements for lists versus forward lists","Portland","|Complete|" +"`2005 `__","unordered_map::insert(T&&) protection should apply to map too","Portland","|Complete|" +"`2011 `__","Unexpected output required of strings","Portland","|Complete|" +"`2048 `__","Unnecessary mem_fn overloads","Portland","|Complete|" +"`2049 `__","``is_destructible``\ is underspecified","Portland","|Complete|" +"`2056 `__","future_errc enums start with value 0 (invalid value for broken_promise)","Portland","|Complete|" +"`2058 `__","valarray and begin/end","Portland","|Complete|" +"","","","" +"`2091 `__","Misplaced effect in m.try_lock_for()","Bristol","|Complete|" +"`2092 `__","Vague Wording for condition_variable_any","Bristol","|Complete|" +"`2093 `__","Throws clause of condition_variable::wait with predicate","Bristol","|Complete|" +"`2094 `__","duration conversion overflow shouldn't participate in overload resolution","Bristol","|Complete|" +"`2122 `__","merge() stability for lists versus forward lists","Bristol","|Complete|" +"`2128 `__","Absence of global functions cbegin/cend","Bristol","|Complete|" +"`2145 `__","error_category default constructor","Bristol","|Complete|" +"`2147 `__","Unclear hint type in Allocator's allocate function","Bristol","|Complete|" +"`2148 `__","Hashing enums should be supported directly by std::hash","Bristol","|Complete|" +"`2149 `__","Concerns about 20.8/5","Bristol","|Complete|" +"`2162 `__","allocator_traits::max_size missing noexcept","Bristol","|Complete|" +"`2163 `__","nth_element requires inconsistent post-conditions","Bristol","|Complete|" +"`2169 `__","Missing reset() requirements in unique_ptr specialization","Bristol","|Complete|" +"`2172 `__","Does ``atomic_compare_exchange_*``\ accept v == nullptr arguments?","Bristol","|Complete|" +"`2080 `__","Specify when once_flag becomes invalid","Bristol","|Complete|" +"`2098 `__","promise throws clauses","Bristol","|Complete|" +"`2109 `__","Incorrect requirements for hash specializations","Bristol","|Complete|" +"`2130 `__","missing ordering constraints for fences","Bristol","|Complete|" +"`2138 `__","atomic_flag::clear ordering constraints","Bristol","|Complete|" +"`2140 `__","notify_all_at_thread_exit synchronization","Bristol","|Complete|" +"`2144 `__","Missing noexcept specification in type_index","Bristol","|Complete|" +"`2174 `__","wstring_convert::converted() should be noexcept","Bristol","|Complete|" +"`2175 `__","string_convert and wbuffer_convert validity","Bristol","|Complete|" +"`2176 `__","Special members for wstring_convert and wbuffer_convert","Bristol","|Complete|" +"`2177 `__","Requirements on Copy/MoveInsertable","Bristol","|Complete|" +"`2185 `__","Missing throws clause for future/shared_future::wait_for/wait_until","Bristol","|Complete|" +"`2187 `__","vector is missing emplace and emplace_back member functions","Bristol","|Complete|" +"`2190 `__","ordering of condition variable operations, reflects Posix discussion","Bristol","|Complete|" +"`2196 `__","Specification of ``is_*[copy/move]_[constructible/assignable]``\ unclear for non-referencable types","Bristol","|Complete|" +"`2197 `__","Specification of ``is_[un]signed``\ unclear for non-arithmetic types","Bristol","|Complete|" +"`2200 `__","Data race avoidance for all containers, not only for sequences","Bristol","|Complete|" +"`2203 `__","scoped_allocator_adaptor uses wrong argument types for piecewise construction","Bristol","|Complete|" +"`2207 `__","basic_string::at should not have a Requires clause","Bristol","|Complete|" +"`2209 `__","assign() overspecified for sequence containers","Bristol","|Complete|" +"`2210 `__","Missing allocator-extended constructor for allocator-aware containers","Bristol","|Complete|" +"`2211 `__","Replace ambiguous use of ""Allocator"" in container requirements","Bristol","|Complete|" +"`2222 `__","Inconsistency in description of forward_list::splice_after single-element overload","Bristol","|Complete|" +"`2225 `__","Unrealistic header inclusion checks required","Bristol","|Complete|" +"`2229 `__","Standard code conversion facets underspecified","Bristol","|Complete|" +"`2231 `__","DR 704 removes complexity guarantee for clear()","Bristol","|Complete|" +"`2235 `__","Undefined behavior without proper requirements on basic_string constructors","Bristol","|Complete|" +"","","","" +"`2141 `__","common_type trait produces reference types","Chicago","|Complete|" +"`2246 `__","unique_ptr assignment effects w.r.t. deleter","Chicago","|Complete|" +"`2247 `__","Type traits and std::nullptr_t","Chicago","|Complete|" +"`2085 `__","Wrong description of effect 1 of basic_istream::ignore","Chicago","|Complete|" +"`2087 `__","iostream_category() and noexcept","Chicago","|Complete|" +"`2143 `__","ios_base::xalloc should be thread-safe","Chicago","|Complete|" +"`2150 `__","Unclear specification of find_end","Chicago","|Complete|" +"`2180 `__","Exceptions from std::seed_seq operations","Chicago","|Complete|" +"`2194 `__","Impossible container requirements for adaptor types","Chicago","|Complete|" +"`2013 `__","Do library implementers have the freedom to add constexpr?","Chicago","|Complete|" +"`2018 `__","regex_traits::isctype Returns clause is wrong","Chicago","|Complete|" +"`2078 `__","Throw specification of async() incomplete","Chicago","|Complete|" +"`2097 `__","packaged_task constructors should be constrained","Chicago","|Complete|" +"`2100 `__","Timed waiting functions cannot timeout if launch::async policy used","Chicago","|Complete|" +"`2120 `__","What should async do if neither 'async' nor 'deferred' is set in policy?","Chicago","|Complete|" +"`2159 `__","atomic_flag initialization","Chicago","|Complete|" +"`2275 `__","Why is forward_as_tuple not constexpr?","Chicago","|Complete|" +"`2284 `__","Inconsistency in allocator_traits::max_size","Chicago","|Complete|" +"`2298 `__","``is_nothrow_constructible``\ is always false because of create<>","Chicago","|Complete|" +"`2300 `__","Redundant sections for map and multimap members should be removed","Chicago","|Complete|" +"NB comment: GB9","Remove gets from C++14","Chicago","|Complete|" +"","","","" +"`2135 `__","Unclear requirement for exceptions thrown in condition_variable::wait()","Issaquah","|Complete|" +"`2291 `__","std::hash is vulnerable to collision DoS attack","Issaquah","|Complete|" +"`2142 `__","packaged_task::operator() synchronization too broad?","Issaquah","|Complete|" +"`2240 `__","Probable misuse of term ""function scope"" in [thread.condition]","Issaquah","|Complete|" +"`2252 `__","Strong guarantee on vector::push_back() still broken with C++11?","Issaquah","|Complete|" +"`2257 `__","Simplify container requirements with the new algorithms","Issaquah","|Complete|" +"`2268 `__","Setting a default argument in the declaration of a member function assign of std::basic_string","Issaquah","|Complete|" +"`2271 `__","regex_traits::lookup_classname specification unclear","Issaquah","|Complete|" +"`2272 `__","quoted should use char_traits::eq for character comparison","Issaquah","|Complete|" +"`2278 `__","User-defined literals for Standard Library types","Issaquah","|Complete|" +"`2280 `__","begin / end for arrays should be constexpr and noexcept","Issaquah","|Complete|" +"`2285 `__","make_reverse_iterator","Issaquah","|Complete|" +"`2299 `__","Effects of inaccessible ``key_compare::is_transparent``\ type are not clear","Issaquah","|Complete|" +"`1450 `__","Contradiction in regex_constants","Issaquah","|Complete|" +"`2003 `__","String exception inconsistency in erase.","Issaquah","|Complete|" +"`2112 `__","User-defined classes that cannot be derived from","Issaquah","|Complete|" +"`2132 `__","std::function ambiguity","Issaquah","|Complete|" +"`2182 `__","``Container::[const_]reference`` types are misleadingly specified","Issaquah","|Complete|" +"`2188 `__","Reverse iterator does not fully support targets that overload operator&","Issaquah","|Complete|" +"`2193 `__","Default constructors for standard library containers are explicit","Issaquah","|Complete|" +"`2205 `__","Problematic postconditions of regex_match and regex_search","Issaquah","|Complete|" +"`2213 `__","Return value of std::regex_replace","Issaquah","|Complete|" +"`2258 `__","a.erase(q1, q2) unable to directly return q2","Issaquah","|Complete|" +"`2263 `__","Comparing iterators and allocator pointers with different const-character","Issaquah","|Complete|" +"`2293 `__","Wrong facet used by num_put::do_put","Issaquah","|Complete|" +"`2301 `__","Why is std::tie not constexpr?","Issaquah","|Complete|" +"`2304 `__","Complexity of count in unordered associative containers","Issaquah","|Complete|" +"`2306 `__","match_results::reference should be value_type&, not const value_type&","Issaquah","|Complete|" +"`2308 `__","Clarify container destructor requirements w.r.t. std::array","Issaquah","|Complete|" +"`2313 `__","tuple_size should always derive from integral_constant","Issaquah","|Complete|" +"`2314 `__","apply() should return decltype(auto) and use decay_t before tuple_size","Issaquah","|Complete|" +"`2315 `__","weak_ptr should be movable","Issaquah","|Complete|" +"`2316 `__","weak_ptr::lock() should be atomic","Issaquah","|Complete|" +"`2317 `__","The type property queries should be UnaryTypeTraits returning size_t","Issaquah","|Complete|" +"`2320 `__","select_on_container_copy_construction() takes allocators, not containers","Issaquah","|Complete|" +"`2322 `__","Associative(initializer_list, stuff) constructors are underspecified","Issaquah","|Complete|" +"`2323 `__","vector::resize(n, t)'s specification should be simplified","Issaquah","|Complete|" +"`2324 `__","Insert iterator constructors should use addressof()","Issaquah","|Complete|" +"`2329 `__","regex_match()/regex_search() with match_results should forbid temporary strings","Issaquah","|Complete|" +"`2330 `__","regex(""meow"", regex::icase) is technically forbidden but should be permitted","Issaquah","|Complete|" +"`2332 `__","regex_iterator/regex_token_iterator should forbid temporary regexes","Issaquah","|Complete|" +"`2339 `__","Wording issue in nth_element","Issaquah","|Complete|" +"`2341 `__","Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir)","Issaquah","|Complete|" +"`2344 `__","quoted()'s interaction with padding is unclear","Issaquah","|Complete|" +"`2346 `__","integral_constant's member functions should be marked noexcept","Issaquah","|Complete|" +"`2350 `__","min, max, and minmax should be constexpr","Issaquah","|Complete|" +"`2356 `__","Stability of erasure in unordered associative containers","Issaquah","|Complete|" +"`2357 `__","Remaining ""Assignable"" requirement","Issaquah","|Complete|" +"`2359 `__","How does regex_constants::nosubs affect basic_regex::mark_count()?","Issaquah","|Complete|" +"`2360 `__","``reverse_iterator::operator*()``\ is unimplementable","Issaquah","|Complete|" +"`2104 `__","unique_lock move-assignment should not be noexcept","Issaquah","|Complete|" +"`2186 `__","Incomplete action on async/launch::deferred","Issaquah","|Complete|" +"`2075 `__","Progress guarantees, lock-free property, and scheduling assumptions","Issaquah","|Complete|" +"`2288 `__","Inconsistent requirements for shared mutexes","Issaquah","|Complete|" diff --git a/gnu/llvm/libcxx/docs/Status/Cxx14Papers.csv b/gnu/llvm/libcxx/docs/Status/Cxx14Papers.csv new file mode 100644 index 00000000000..0e5ba7f991f --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx14Papers.csv @@ -0,0 +1,32 @@ +"Paper #","Group","Paper Name","Meeting","Status","First released version" +"`3346 `__","LWG","Terminology for Container Element Requirements - Rev 1","Kona","|Complete|","3.4" +"","","","","","" +"`3421 `__","LWG","Making Operator Functors greater<>","Portland","|Complete|","3.4" +"`3462 `__","LWG","std::result_of and SFINAE","Portland","|Complete|","3.4" +"`3469 `__","LWG","Constexpr Library Additions: chrono, v3","Portland","|Complete|","3.4" +"`3470 `__","LWG","Constexpr Library Additions: containers, v2","Portland","|Complete|","3.4" +"`3471 `__","LWG","Constexpr Library Additions: utilities, v3","Portland","|Complete|","3.4" +"`3302 `__","LWG","Constexpr Library Additions: complex, v2","Portland","|Complete|","3.4" +"","","","","","" +"`3545 `__","LWG","An Incremental Improvement to integral_constant","Bristol","|Complete|","3.4" +"`3644 `__","LWG","Null Forward Iterators","Bristol","|Complete|","3.4" +"`3668 `__","LWG","std::exchange()","Bristol","|Complete|","3.4" +"`3658 `__","LWG","Compile-time integer sequences","Bristol","|Complete|","3.4" +"`3670 `__","LWG","Addressing Tuples by Type","Bristol","|Complete|","3.4" +"`3671 `__","LWG","Making non-modifying sequence operations more robust","Bristol","|Complete|","3.4" +"`3656 `__","LWG","make_unique","Bristol","|Complete|","3.4" +"`3654 `__","LWG","Quoted Strings","Bristol","|Complete|","3.4" +"`3642 `__","LWG","User-defined Literals","Bristol","|Complete|","3.4" +"`3655 `__","LWG","TransformationTraits Redux (excluding part 4)","Bristol","|Complete|","3.4" +"`3657 `__","LWG","Adding heterogeneous comparison lookup to associative containers","Bristol","|Complete|","3.4" +"`3672 `__","LWG","A proposal to add a utility class to represent optional objects","Bristol","*Removed from Draft Standard*","n/a" +"`3669 `__","LWG","Fixing constexpr member functions without const","Bristol","|Complete|","3.4" +"`3662 `__","LWG","C++ Dynamic Arrays (dynarray)","Bristol","*Removed from Draft Standard*","n/a" +"`3659 `__","SG1","Shared Locking in C++","Bristol","|Complete|","3.4" +"","","","","","" +"`3779 `__","LWG","User-defined Literals for std::complex","Chicago","|Complete|","3.4" +"`3789 `__","LWG","Constexpr Library Additions: functional","Chicago","|Complete|","3.4" +"","","","","","" +"`3924 `__","LWG","Discouraging rand() in C++14","Issaquah","|Complete|","3.5" +"`3887 `__","LWG","Consistent Metafunction Aliases","Issaquah","|Complete|","3.5" +"`3891 `__","SG1","A proposal to rename shared_mutex to shared_timed_mutex","Issaquah","|Complete|","3.5" diff --git a/gnu/llvm/libcxx/docs/Status/Cxx17.rst b/gnu/llvm/libcxx/docs/Status/Cxx17.rst new file mode 100644 index 00000000000..9076b9cf4b3 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx17.rst @@ -0,0 +1,57 @@ +.. _cxx17-status: + +================================ +libc++ C++17 Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In November 2014, the C++ standard committee created a draft for the next version of the C++ standard, initially known as "C++1z". +In February 2017, the C++ standard committee approved this draft, and sent it to ISO for approval as C++17. + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +.. attention:: Features in unreleased drafts of the standard are subject to change. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + +.. note:: "Nothing to do" means that no library changes were needed to implement this change. + +.. _paper-status-cxx17: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx17Papers.csv + :header-rows: 1 + :widths: auto + +.. note:: + + .. [#note-P0433] P0433: So far, only the ````, sequence containers, container adaptors and ```` portions of P0433 have been implemented. + .. [#note-P0607] P0607: The parts of P0607 that are not done are the ```` bits. + + +.. _issues-status-cxx17: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx17Issues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 17-Nov-2020 diff --git a/gnu/llvm/libcxx/docs/Status/Cxx17Issues.csv b/gnu/llvm/libcxx/docs/Status/Cxx17Issues.csv new file mode 100644 index 00000000000..090e12ffd9a --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx17Issues.csv @@ -0,0 +1,318 @@ +"Issue #","Issue Name","Meeting","Status","First released version" +"`2016 `__","Allocators must be no-throw swappable","Urbana","|Complete|","" +"`2118 `__","``unique_ptr``\ for array does not support cv qualification conversion of actual argument","Urbana","|Complete|","" +"`2170 `__","Aggregates cannot be ``DefaultConstructible``\ ","Urbana","|Complete|","" +"`2308 `__","Clarify container destructor requirements w.r.t. ``std::array``\ ","Urbana","|Complete|","" +"`2340 `__","Replacement allocation functions declared as inline","Urbana","|Complete|","" +"`2354 `__","Unnecessary copying when inserting into maps with braced-init syntax","Urbana","|Complete|","" +"`2377 `__","``std::align``\ requirements overly strict","Urbana","|Complete|","" +"`2396 `__","``underlying_type``\ doesn't say what to do for an incomplete enumeration type","Urbana","|Complete|","" +"`2399 `__","``shared_ptr``\ 's constructor from ``unique_ptr``\ should be constrained","Urbana","|Complete|","" +"`2400 `__","``shared_ptr``\ 's ``get_deleter()``\ should use ``addressof()``\ ","Urbana","|Complete|","" +"`2401 `__","``std::function``\ needs more noexcept","Urbana","|Complete|","" +"`2404 `__","``mismatch()``\ 's complexity needs to be updated","Urbana","|Complete|","" +"`2408 `__","SFINAE-friendly ``common_type``\ / ``iterator_traits``\ is missing in C++14","Urbana","|Complete|","" +"","","","","" +"`2106 `__","``move_iterator``\ wrapping iterators returning prvalues","Urbana","|Complete|","" +"`2129 `__","User specializations of ``std::initializer_list``\ ","Urbana","|Complete|","" +"`2212 `__","``tuple_size``\ for ``const pair``\ request header","Urbana","|Complete|","" +"`2217 `__","``operator==(sub_match, string)``\ slices on embedded '\0's","Urbana","|Complete|","" +"`2230 `__","""see below"" for ``initializer_list``\ constructors of unordered containers","Urbana","|Complete|","" +"`2233 `__","``bad_function_call::what()``\ unhelpful","Urbana","|Complete|","" +"`2266 `__","``vector``\ and ``deque``\ have incorrect insert requirements","Urbana","|Complete|","" +"`2325 `__","``minmax_element()``\ 's behavior differing from ``max_element()``\ 's should be noted","Urbana","|Complete|","" +"`2361 `__","Apply 2299 resolution throughout library","Urbana","|Complete|","" +"`2365 `__","Missing noexcept in ``shared_ptr::shared_ptr(nullptr_t)``\ ","Urbana","|Complete|","" +"`2376 `__","``bad_weak_ptr::what()``\ overspecified","Urbana","|Complete|","" +"`2387 `__","More nested types that must be accessible and unambiguous","Urbana","|Complete|","" +"","","","","" +"`2059 `__","C++0x ambiguity problem with map::erase","Lenexa","|Complete|","" +"`2063 `__","Contradictory requirements for string move assignment","Lenexa","|Complete|","" +"`2076 `__","Bad CopyConstructible requirement in set constructors","Lenexa","|Complete|","" +"`2160 `__","Unintended destruction ordering-specification of resize","Lenexa","|Complete|","" +"`2168 `__","Inconsistent specification of uniform_real_distribution constructor","Lenexa","|Complete|","" +"`2239 `__","min/max/minmax requirements","Lenexa","|Complete|","" +"`2364 `__","deque and vector pop_back don't specify iterator invalidation requirements","Lenexa","|Complete|","" +"`2369 `__","constexpr max(initializer_list) vs max_element","Lenexa","|Complete|","" +"`2378 `__","Behaviour of standard exception types","Lenexa","|Complete|","" +"`2403 `__","stof() should call strtof() and wcstof()","Lenexa","|Complete|","" +"`2406 `__","negative_binomial_distribution should reject p == 1","Lenexa","|Complete|","" +"`2407 `__","packaged_task(allocator_arg_t, const Allocator&, F&&) should neither be constrained nor explicit","Lenexa","|Complete|","" +"`2411 `__","shared_ptr is only contextually convertible to bool","Lenexa","|Complete|","" +"`2415 `__","Inconsistency between unique_ptr and shared_ptr","Lenexa","|Complete|","" +"`2420 `__","function does not discard the return value of the target object","Lenexa","|Complete|","" +"`2425 `__","``operator delete(void*, size_t)``\ doesn't invalidate pointers sufficiently","Lenexa","|Complete|","" +"`2427 `__","Container adaptors as sequence containers, redux","Lenexa","|Complete|","" +"`2428 `__","""External declaration"" used without being defined","Lenexa","|Complete|","" +"`2433 `__","``uninitialized_copy()``\ /etc. should tolerate overloaded operator&","Lenexa","|Complete|","" +"`2434 `__","``shared_ptr::use_count()``\ is efficient","Lenexa","|Complete|","" +"`2437 `__","``iterator_traits::reference``\ can and can't be void","Lenexa","|Complete|","" +"`2438 `__","``std::iterator``\ inheritance shouldn't be mandated","Lenexa","|Complete|","" +"`2439 `__","``unique_copy()``\ sometimes can't fall back to reading its output","Lenexa","|Complete|","" +"`2440 `__","``seed_seq::size()``\ should be noexcept","Lenexa","|Complete|","" +"`2442 `__","``call_once()``\ shouldn't DECAY_COPY()","Lenexa","|Complete|","" +"`2448 `__","Non-normative Container destructor specification","Lenexa","|Complete|","" +"`2454 `__","Add ``raw_storage_iterator::base()``\ member","Lenexa","|Complete|","" +"`2455 `__","Allocator default construction should be allowed to throw","Lenexa","|Complete|","" +"`2458 `__","N3778 and new library deallocation signatures","Lenexa","|Complete|","" +"`2459 `__","``std::polar``\ should require a non-negative rho","Lenexa","|Complete|","" +"`2464 `__","``try_emplace``\ and ``insert_or_assign``\ misspecified","Lenexa","|Complete|","" +"`2467 `__","``is_always_equal``\ has slightly inconsistent default","Lenexa","|Complete|","" +"`2470 `__","Allocator's destroy function should be allowed to fail to instantiate","Lenexa","|Complete|","" +"`2482 `__","[c.strings] Table 73 mentions nonexistent functions","Lenexa","|Complete|","" +"`2488 `__","Placeholders should be allowed and encouraged to be constexpr","Lenexa","|Complete|","" +"","","","","" +"`1169 `__","``num_get``\ not fully compatible with ``strto*``\ ","Kona","|Complete|","" +"`2072 `__","Unclear wording about capacity of temporary buffers","Kona","|Complete|","" +"`2101 `__","Some transformation types can produce impossible types","Kona","|Complete|","" +"`2111 `__","Which ``unexpected``\ /``terminate``\ handler is called from the exception handling runtime?","Kona","|Complete|","" +"`2119 `__","Missing ``hash``\ specializations for extended integer types","Kona","|Complete|","" +"`2127 `__","Move-construction with ``raw_storage_iterator``\ ","Kona","|Complete|","" +"`2133 `__","Attitude to overloaded comma for iterators","Kona","|Complete|","" +"`2156 `__","Unordered containers' ``reserve(n)``\ reserves for ``n-1``\ elements","Kona","|Complete|","" +"`2218 `__","Unclear how containers use ``allocator_traits::construct()``\ ","Kona","|Complete|","" +"`2219 `__","``*INVOKE*``\ -ing a pointer to member with a ``reference_wrapper``\ as the object expression","Kona","|Complete|","" +"`2224 `__","Ambiguous status of access to non-live objects","Kona","|Complete|","" +"`2234 `__","``assert()``\ should allow usage in constant expressions","Kona","|Complete|","" +"`2244 `__","Issue on ``basic_istream::seekg``\ ","Kona","|Complete|","" +"`2250 `__","Follow-up On Library Issue 2207","Kona","|Complete|","" +"`2259 `__","Issues in 17.6.5.5 rules for member functions","Kona","|Complete|","" +"`2273 `__","``regex_match``\ ambiguity","Kona","|Complete|","" +"`2336 `__","``is_trivially_constructible``\ /``is_trivially_assignable``\ traits are always false","Kona","|Complete|","" +"`2353 `__","``std::next``\ is over-constrained","Kona","|Complete|","" +"`2367 `__","``pair``\ and ``tuple``\ are not correctly implemented for ``is_constructible``\ with no args","Kona","|Complete|","" +"`2380 `__","May ````\ provide ``long ::abs(long)``\ and ``long long ::abs(long long)``\ ?","Kona","|Complete|","" +"`2384 `__","Allocator's ``deallocate``\ function needs better specification","Kona","|Complete|","" +"`2385 `__","``function::assign``\ allocator argument doesn't make sense","Kona","|Complete|","" +"`2435 `__","``reference_wrapper::operator()``\ 's Remark should be deleted","Kona","|Complete|","" +"`2447 `__","Allocators and ``volatile``\ -qualified value types","Kona","|Complete|","" +"`2462 `__","``std::ios_base::failure``\ is overspecified","Kona","|Complete|","" +"`2466 `__","``allocator_traits::max_size()``\ default behavior is incorrect","Kona","|Complete|","" +"`2469 `__","Wrong specification of Requires clause of ``operator[]``\ for ``map``\ and ``unordered_map``\ ","Kona","|Complete|","" +"`2473 `__","``basic_filebuf``\ 's relation to C ``FILE``\ semantics","Kona","|Complete|","" +"`2476 `__","``scoped_allocator_adaptor``\ is not assignable","Kona","|Complete|","" +"`2477 `__","Inconsistency of wordings in ``std::vector::erase()``\ and ``std::deque::erase()``\ ","Kona","|Complete|","" +"`2483 `__","``throw_with_nested()``\ should use ``is_final``\ ","Kona","|Complete|","" +"`2484 `__","``rethrow_if_nested()``\ is doubly unimplementable","Kona","|Complete|","" +"`2485 `__","``get()``\ should be overloaded for ``const tuple&&``\ ","Kona","|Complete|","" +"`2486 `__","``mem_fn()``\ should be required to use perfect forwarding","Kona","|Complete|","" +"`2487 `__","``bind()``\ should be ``const``\ -overloaded, not *cv*-overloaded","Kona","|Complete|","" +"`2489 `__","``mem_fn()``\ should be ``noexcept``\ ","Kona","|Complete|","" +"`2492 `__","Clarify requirements for ``comp``\ ","Kona","|Complete|","" +"`2495 `__","There is no such thing as an Exception Safety element","Kona","|Complete|","" +"","","","","" +"`2192 `__","Validity and return type of ``std::abs(0u)``\ is unclear","Jacksonville","|Complete|","" +"`2276 `__","Missing requirement on ``std::promise::set_exception``\ ","Jacksonville","|Complete|","" +"`2296 `__","``std::addressof``\ should be ``constexpr``\ ","Jacksonville","|Complete|","" +"`2450 `__","``(greater|less|greater_equal|less_equal)``\ do not yield a total order for pointers","Jacksonville","|Complete|","" +"`2520 `__","N4089 broke initializing ``unique_ptr``\ from a ``nullptr``\ ","Jacksonville","|Complete|","" +"`2522 `__","[fund.ts.v2] Contradiction in ``set_default_resource``\ specification","Jacksonville","|Complete|","" +"`2523 `__","``std::promise``\ synopsis shows two ``set_value_at_thread_exit()``\ 's for no apparent reason","Jacksonville","|Complete|","" +"`2537 `__","Constructors for ``priority_queue``\ taking allocators should call ``make_heap``\ ","Jacksonville","|Complete|","" +"`2539 `__","[fund.ts.v2] ``invocation_trait``\ definition definition doesn't work for surrogate call functions","Jacksonville","","" +"`2545 `__","Simplify wording for ``bind``\ without explicitly specified return type","Jacksonville","|Complete|","" +"`2557 `__","Logical operator traits are broken in the zero-argument case","Jacksonville","|Complete|","" +"`2558 `__","[fund.ts.v2] Logical operator traits are broken in the zero-argument case","Jacksonville","|Complete|","" +"`2559 `__","Error in LWG 2234's resolution","Jacksonville","|Complete|","" +"`2560 `__","``is_constructible``\ underspecified when applied to a function type","Jacksonville","Broken in 3.6; See r261653.","" +"`2565 `__","``std::function``\ 's move constructor should guarantee nothrow for ``reference_wrapper``\ s and function pointers","Jacksonville","|Complete|","" +"`2566 `__","Requirements on the first template parameter of container adaptors","Jacksonville","|Complete|","" +"`2571 `__","|sect|\ [map.modifiers]/2 imposes nonsensical requirement on ``insert(InputIterator, InputIterator)``\ ","Jacksonville","|Complete|","" +"`2572 `__","The remarks for ``shared_ptr::operator*``\ should apply to *cv*-qualified ``void``\ as well","Jacksonville","|Complete|","" +"`2574 `__","[fund.ts.v2] ``std::experimental::function::operator=(F&&)``\ should be constrained","Jacksonville","|Complete|","" +"`2575 `__","[fund.ts.v2] ``experimental::function::assign``\ should be removed","Jacksonville","","" +"`2576 `__","``istream_iterator``\ and ``ostream_iterator``\ should use ``std::addressof``\ ","Jacksonville","|Complete|","" +"`2577 `__","``{shared,unique}_lock``\ should use ``std::addressof``\ ","Jacksonville","|Complete|","" +"`2579 `__","Inconsistency wrt Allocators in ``basic_string``\ assignment vs. ``basic_string::assign``\ ","Jacksonville","|Complete|","" +"`2581 `__","Specialization of ````\ variable templates should be prohibited","Jacksonville","|Complete|","" +"`2582 `__","|sect|\ [res.on.functions]/2's prohibition against incomplete types shouldn't apply to type traits","Jacksonville","|Complete|","" +"`2583 `__","There is no way to supply an allocator for ``basic_string(str, pos)``\ ","Jacksonville","|Complete|","" +"`2585 `__","``forward_list::resize(size_type, const value_type&)``\ effects incorrect","Jacksonville","|Complete|","" +"`2586 `__","Wrong value category used in ``scoped_allocator_adaptor::construct()``\ ","Jacksonville","|Complete|","" +"`2590 `__","Aggregate initialization for ``std::array``\ ","Jacksonville","|Complete|","" +"","","","","" +"`2181 `__","Exceptions from seed sequence operations","Oulu","|Complete|","" +"`2309 `__","mutex::lock() should not throw device_or_resource_busy","Oulu","|Complete|","" +"`2310 `__","Public exposition only member in std::array","Oulu","|Complete|","" +"`2312 `__","tuple's constructor constraints need to be phrased more precisely","Oulu","|Complete|","" +"`2328 `__","Rvalue stream extraction should use perfect forwarding","Oulu","|Complete|","" +"`2393 `__","std::function's Callable definition is broken","Oulu","|Complete|","" +"`2422 `__","``std::numeric_limits::is_modulo``\ description: ""most machines"" errata","Oulu","|Complete|","" +"`2426 `__","Issue about compare_exchange","Oulu","","" +"`2436 `__","Comparators for associative containers should always be CopyConstructible","Oulu","|Complete|","" +"`2441 `__","Exact-width atomic typedefs should be provided","Oulu","|Complete|","" +"`2451 `__","[fund.ts.v2] optional should 'forward' T's implicit conversions","Oulu","|Nothing To Do|","" +"`2509 `__","[fund.ts.v2] any_cast doesn't work with rvalue reference targets and cannot move with a value target","Oulu","|Complete|","" +"`2516 `__","[fund.ts.v2] Public ""exposition only"" members in observer_ptr","Oulu","","" +"`2542 `__","Missing const requirements for associative containers","Oulu","","" +"`2549 `__","Tuple EXPLICIT constructor templates that take tuple parameters end up taking references to temporaries and will create dangling references","Oulu","|Complete|","" +"`2550 `__","Wording of unordered container's clear() method complexity","Oulu","|Complete|","" +"`2551 `__","[fund.ts.v2] ""Exception safety"" cleanup in library fundamentals required","Oulu","|Complete|","" +"`2555 `__","[fund.ts.v2] No handling for over-aligned types in optional","Oulu","|Complete|","" +"`2573 `__","[fund.ts.v2] std::hash does not work for arrays","Oulu","","" +"`2596 `__","vector::data() should use addressof","Oulu","|Complete|","" +"`2667 `__","path::root_directory() description is confusing","Oulu","|Complete|","" +"`2669 `__","recursive_directory_iterator effects refers to non-existent functions","Oulu","|Complete|","" +"`2670 `__","system_complete refers to undefined variable 'base'","Oulu","|Complete|","" +"`2671 `__","Errors in Copy","Oulu","|Complete|","" +"`2673 `__","status() effects cannot be implemented as specified","Oulu","|Complete|","" +"`2674 `__","Bidirectional iterator requirement on path::iterator is very expensive","Oulu","|Complete|","" +"`2683 `__","filesystem::copy() says ""no effects""","Oulu","|Complete|","" +"`2684 `__","priority_queue lacking comparator typedef","Oulu","|Complete|","" +"`2685 `__","shared_ptr deleters must not throw on move construction","Oulu","|Complete|","" +"`2687 `__","{inclusive,exclusive}_scan misspecified","Oulu","","" +"`2688 `__","clamp misses preconditions and has extraneous condition on result","Oulu","|Complete|","" +"`2689 `__","Parallel versions of std::copy and std::move shouldn't be in order","Oulu","","" +"`2698 `__","Effect of assign() on iterators/pointers/references","Oulu","|Complete|","" +"`2704 `__","recursive_directory_iterator's members should require '``*this`` is dereferenceable'","Oulu","|Complete|","" +"`2706 `__","Error reporting for recursive_directory_iterator::pop() is under-specified","Oulu","|Complete|","" +"`2707 `__","path construction and assignment should have ""string_type&&"" overloads","Oulu","|Complete|","" +"`2709 `__","offsetof is unnecessarily imprecise","Oulu","","" +"`2710 `__","""Effects: Equivalent to ..."" doesn't count ""Synchronization:"" as determined semantics","Oulu","|Complete|","" +"`2711 `__","path is convertible from approximately everything under the sun","Oulu","|Complete|","" +"`2716 `__","Specification of shuffle and sample disallows lvalue URNGs","Oulu","|Complete|","" +"`2718 `__","Parallelism bug in [algorithms.parallel.exec] p2","Oulu","","" +"`2719 `__","permissions function should not be noexcept due to narrow contract","Oulu","|Complete|","" +"`2720 `__","permissions function incorrectly specified for symlinks","Oulu","|Complete|","" +"`2721 `__","remove_all has incorrect post conditions","Oulu","|Complete|","" +"`2723 `__","Do directory_iterator and recursive_directory_iterator become the end iterator upon error?","Oulu","|Complete|","" +"`2724 `__","The protected virtual member functions of memory_resource should be private","Oulu","","" +"`2725 `__","filesystem::exists(const path&, error_code&) error reporting","Oulu","|Complete|","" +"`2726 `__","``[recursive_]directory_iterator::increment(error_code&)`` is underspecified","Oulu","|Complete|","" +"`2727 `__","Parallel algorithms with constexpr specifier","Oulu","","" +"`2728 `__","status(p).permissions() and symlink_status(p).permissions() are not specified","Oulu","|Complete|","" +"","","","","" +"`2062 `__","Effect contradictions w/o no-throw guarantee of std::function swaps","Issaquah","|Complete|","" +"`2166 `__","Heap property underspecified?","Issaquah","","" +"`2221 `__","No formatted output operator for nullptr","Issaquah","|Complete|","" +"`2223 `__","shrink_to_fit effect on iterator validity","Issaquah","|Complete|","" +"`2261 `__","Are containers required to use their 'pointer' type internally?","Issaquah","","" +"`2394 `__","locale::name specification unclear - what is implementation-defined?","Issaquah","|Complete|","" +"`2460 `__","LWG issue 2408 and value categories","Issaquah","|Complete|","" +"`2468 `__","Self-move-assignment of library types","Issaquah","","" +"`2475 `__","Allow overwriting of std::basic_string terminator with charT() to allow cleaner interoperation with legacy APIs","Issaquah","|Complete|","" +"`2503 `__","multiline option should be added to syntax_option_type","Issaquah","|Complete|","" +"`2510 `__","Tag types should not be DefaultConstructible","Issaquah","|Complete|","" +"`2514 `__","Type traits must not be final","Issaquah","|Complete|","" +"`2518 `__","[fund.ts.v2] Non-member swap for propagate_const should call member swap","Issaquah","|Complete|","" +"`2519 `__","Iterator operator-= has gratuitous undefined behaviour","Issaquah","|Complete|","" +"`2521 `__","[fund.ts.v2] weak_ptr's converting move constructor should be modified as well for array support","Issaquah","","" +"`2525 `__","[fund.ts.v2] get_memory_resource should be const and noexcept","Issaquah","","" +"`2527 `__","[fund.ts.v2] ALLOCATOR_OF for function::operator= has incorrect default","Issaquah","","" +"`2531 `__","future::get should explicitly state that the shared state is released","Issaquah","","" +"`2534 `__","Constrain rvalue stream operators","Issaquah","|Complete|","" +"`2536 `__","What should do?","Issaquah","|Complete|","" +"`2540 `__","unordered_multimap::insert hint iterator","Issaquah","|Complete|","" +"`2543 `__","LWG 2148 (hash support for enum types) seems under-specified","Issaquah","|Complete|","" +"`2544 `__","``istreambuf_iterator(basic_streambuf* s)``\ effects unclear when s is 0","Issaquah","|Complete|","" +"`2556 `__","Wide contract for future::share()","Issaquah","|Complete|","" +"`2562 `__","Consistent total ordering of pointers by comparison functors","Issaquah","","" +"`2567 `__","Specification of logical operator traits uses BaseCharacteristic, which is defined only for UnaryTypeTraits and BinaryTypeTraits","Issaquah","|Complete|","" +"`2568 `__","[fund.ts.v2] Specification of logical operator traits uses BaseCharacteristic, which is defined only for UnaryTypeTraits and BinaryTypeTraits","Issaquah","","" +"`2569 `__","conjunction and disjunction requirements are too strict","Issaquah","|Complete|","" +"`2570 `__","[fund.ts.v2] conjunction and disjunction requirements are too strict","Issaquah","","" +"`2578 `__","Iterator requirements should reference iterator traits","Issaquah","|Complete|","" +"`2584 `__"," ECMAScript IdentityEscape is ambiguous","Issaquah","","" +"`2587 `__","""Convertible to bool"" requirement in conjunction and disjunction","Issaquah","Resolved by 2567","" +"`2588 `__","[fund.ts.v2] ""Convertible to bool"" requirement in conjunction and disjunction","Issaquah","","" +"`2589 `__","match_results can't satisfy the requirements of a container","Issaquah","|Complete|","" +"`2591 `__","std::function's member template target() should not lead to undefined behaviour","Issaquah","|Complete|","" +"`2598 `__","addressof works on temporaries","Issaquah","|Complete|","" +"`2664 `__","operator/ (and other append) semantics not useful if argument has root","Issaquah","|Complete|","" +"`2665 `__","remove_filename() post condition is incorrect","Issaquah","|Complete|","" +"`2672 `__","Should ``is_empty``\ use error_code in its specification?","Issaquah","|Complete|","" +"`2678 `__","std::filesystem enum classes overspecified","Issaquah","|Complete|","" +"`2679 `__","Inconsistent Use of Effects and Equivalent To","Issaquah","|Complete|","" +"`2680 `__","Add ""Equivalent to"" to filesystem","Issaquah","|Complete|","" +"`2681 `__","filesystem::copy() cannot copy symlinks","Issaquah","|Complete|","" +"`2682 `__","filesystem::copy() won't create a symlink to a directory","Issaquah","|Complete|","" +"`2686 `__","Why is std::hash specialized for error_code, but not error_condition?","Issaquah","|Complete|","" +"`2694 `__","Application of LWG 436 accidentally deleted definition of ""facet""","Issaquah","|Complete|","" +"`2696 `__","Interaction between make_shared and enable_shared_from_this is underspecified","Issaquah","|Nothing To Do|","" +"`2699 `__","Missing restriction in [numeric.requirements]","Issaquah","|Complete|","" +"`2712 `__","copy_file(from, to, ...) has a number of unspecified error conditions","Issaquah","|Complete|","" +"`2722 `__","equivalent incorrectly specifies throws clause","Issaquah","|Complete|","" +"`2729 `__","Missing SFINAE on std::pair::operator=","Issaquah","|Complete|","" +"`2732 `__","Questionable specification of path::operator/= and path::append","Issaquah","|Complete|","" +"`2733 `__","[fund.ts.v2] gcd / lcm and bool","Issaquah","|Complete|","" +"`2735 `__","std::abs(short), std::abs(signed char) and others should return int instead of double in order to be compatible with C++98 and C","Issaquah","|Complete|","" +"`2736 `__","nullopt_t insufficiently constrained","Issaquah","|Complete|","" +"`2738 `__","``is_constructible``\ with void types","Issaquah","|Complete|","" +"`2739 `__","Issue with time_point non-member subtraction with an unsigned duration","Issaquah","|Complete|","" +"`2740 `__","constexpr optional::operator->","Issaquah","|Complete|","" +"`2742 `__","Inconsistent string interface taking string_view","Issaquah","|Complete|","" +"`2744 `__","any's in_place constructors","Issaquah","|Complete|","" +"`2745 `__","[fund.ts.v2] Implementability of LWG 2451","Issaquah","|Complete|","" +"`2747 `__","Possibly redundant std::move in [alg.foreach]","Issaquah","|Complete|","" +"`2748 `__","swappable traits for optionals","Issaquah","|Complete|","" +"`2749 `__","swappable traits for variants","Issaquah","|Complete|","" +"`2750 `__","[fund.ts.v2] LWG 2451 conversion constructor constraint","Issaquah","|Nothing To Do|","" +"`2752 `__","""Throws:"" clauses of async and packaged_task are unimplementable","Issaquah","","" +"`2755 `__","[string.view.io] uses non-existent basic_string_view::to_string function","Issaquah","|Complete|","" +"`2756 `__","C++ WP optional should 'forward' T's implicit conversions","Issaquah","|Complete|","" +"`2758 `__","std::string{}.assign(""ABCDE"", 0, 1) is ambiguous","Issaquah","|Complete|","" +"`2759 `__","gcd / lcm and bool for the WP","Issaquah","|Complete|","" +"`2760 `__","non-const basic_string::data should not invalidate iterators","Issaquah","|Complete|","" +"`2765 `__","Did LWG 1123 go too far?","Issaquah","|Complete|","" +"`2767 `__","not_fn call_wrapper can form invalid types","Issaquah","|Complete|","" +"`2769 `__","Redundant const in the return type of any_cast(const any&)","Issaquah","|Complete|","" +"`2771 `__","Broken Effects of some basic_string::compare functions in terms of basic_string_view","Issaquah","|Complete|","" +"`2773 `__","Making std::ignore constexpr","Issaquah","|Complete|","" +"`2777 `__","basic_string_view::copy should use char_traits::copy","Issaquah","|Complete|","" +"`2778 `__","basic_string_view is missing constexpr","Issaquah","|Complete|","" +"","","","","" +"`2260 `__","Missing requirement for Allocator::pointer","Kona","|Complete|","" +"`2676 `__","Provide filesystem::path overloads for File-based streams","Kona","|Complete|","" +"`2768 `__","any_cast and move semantics","Kona","|Complete|","" +"`2769 `__","Redundant const in the return type of any_cast(const any&)","Kona","|Complete|","" +"`2781 `__","Contradictory requirements for std::function and std::reference_wrapper","Kona","|Complete|","" +"`2782 `__","scoped_allocator_adaptor constructors must be constrained","Kona","|Complete|","" +"`2784 `__","Resolution to LWG 2484 is missing ""otherwise, no effects"" and is hard to parse","Kona","|Complete|","" +"`2785 `__","quoted should work with basic_string_view","Kona","|Complete|","" +"`2786 `__","Annex C should mention shared_ptr changes for array support","Kona","|Complete|","" +"`2787 `__","|sect|\ [file_status.cons] doesn't match class definition","Kona","|Complete|","" +"`2788 `__","basic_string range mutators unintentionally require a default constructible allocator","Kona","|Complete|","" +"`2789 `__","Equivalence of contained objects","Kona","|Complete|","" +"`2790 `__","Missing specification of istreambuf_iterator::operator->","Kona","|Complete|","" +"`2794 `__","Missing requirements for allocator pointers","Kona","|Nothing To Do|","" +"`2795 `__","|sect|\ [global.functions] provides incorrect example of ADL use","Kona","|Complete|","" +"`2796 `__","tuple should be a literal type","Kona","|Complete|","" +"`2801 `__","Default-constructibility of unique_ptr","Kona","|Complete|","" +"`2802 `__","shared_ptr constructor requirements for a deleter","Kona","|Complete|","" +"`2804 `__","Unconditional constexpr default constructor for istream_iterator","Kona","|Complete|","" +"`2806 `__","Base class of bad_optional_access","Kona","|Complete|","" +"`2807 `__","std::invoke should use ``std::is_nothrow_callable``\ ","Kona","|Complete|","" +"`2812 `__","Range access is available with ","Kona","|Complete|","" +"`2824 `__","list::sort should say that the order of elements is unspecified if an exception is thrown","Kona","|Complete|","" +"`2826 `__","string_view iterators use old wording","Kona","|Complete|","" +"`2834 `__","Resolution LWG 2223 is missing wording about end iterators","Kona","|Complete|","" +"`2835 `__","LWG 2536 seems to misspecify ","Kona","|Complete|","" +"`2837 `__","gcd and lcm should support a wider range of input values","Kona","|Complete|","" +"`2838 `__","is_literal_type specification needs a little cleanup","Kona","|Complete|","" +"`2842 `__","in_place_t check for optional::optional(U&&) should decay U","Kona","|Complete|","" +"`2850 `__","std::function move constructor does unnecessary work","Kona","|Complete|","" +"`2853 `__","Possible inconsistency in specification of erase in [vector.modifiers]","Kona","|Complete|","" +"`2855 `__","std::throw_with_nested(""string_literal"")","Kona","|Complete|","" +"`2857 `__","{variant,optional,any}::emplace should return the constructed value","Kona","|Complete|","" +"`2861 `__","basic_string should require that charT match traits::char_type","Kona","|Complete|","" +"`2866 `__","Incorrect derived classes constraints","Kona","|Nothing To Do|","" +"`2868 `__","Missing specification of bad_any_cast::what()","Kona","|Complete|","" +"`2872 `__","Add definition for direct-non-list-initialization","Kona","|Complete|","" +"`2873 `__","Add noexcept to several shared_ptr related functions","Kona","|Complete|","" +"`2874 `__","Constructor ``shared_ptr::shared_ptr(Y*)``\ should be constrained","Kona","|Complete|","13.0" +"`2875 `__","shared_ptr::shared_ptr(Y\*, D, [|hellip|\ ]) constructors should be constrained","Kona","|Complete|","" +"`2876 `__","``shared_ptr::shared_ptr(const weak_ptr&)``\ constructor should be constrained","Kona","","" +"`2878 `__","Missing DefaultConstructible requirement for istream_iterator default constructor","Kona","|Complete|","" +"`2890 `__","The definition of 'object state' applies only to class types","Kona","|Complete|","" +"`2900 `__","The copy and move constructors of optional are not constexpr","Kona","|Complete|","" +"`2903 `__","The form of initialization for the emplace-constructors is not specified","Kona","|Complete|","" +"`2904 `__","Make variant move-assignment more exception safe","Kona","|Complete|","" +"`2905 `__","is_constructible_v, P, D const &> should be false when D is not copy constructible","Kona","|Complete|","" +"`2908 `__","The less-than operator for shared pointers could do more","Kona","|Complete|","" +"`2911 `__","An is_aggregate type trait is needed","Kona","|Complete|","" +"`2921 `__","packaged_task and type-erased allocators","Kona","|Complete|","" +"`2934 `__","optional doesn't compare with T","Kona","|Complete|","" +"","","","","" +"`2901 `__","Variants cannot properly support allocators","Toronto","|Complete|","" +"`2955 `__","``to_chars / from_chars``\ depend on ``std::string``\ ","Toronto","Resolved by `P0682R1 `__","" +"`2956 `__","``filesystem::canonical()``\ still defined in terms of ``absolute(p, base)``\ ","Toronto","|Complete|","" diff --git a/gnu/llvm/libcxx/docs/Status/Cxx17Papers.csv b/gnu/llvm/libcxx/docs/Status/Cxx17Papers.csv new file mode 100644 index 00000000000..a015529feed --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx17Papers.csv @@ -0,0 +1,113 @@ +"Paper #","Group","Paper Name","Meeting","Status","First released version" +"`N3911 `__","LWG","TransformationTrait Alias ``void_t``\ .","Urbana","|Complete|","3.6" +"`N4089 `__","LWG","Safe conversions in ``unique_ptr``\ .","Urbana","|In Progress|","3.9" +"`N4169 `__","LWG","A proposal to add invoke function template","Urbana","|Complete|","3.7" +"`N4190 `__","LWG","Removing auto_ptr, random_shuffle(), And Old Stuff.","Urbana","|In Progress|","" +"`N4258 `__","LWG","Cleaning-up noexcept in the Library.","Urbana","|In Progress|","3.7" +"`N4259 `__","CWG","Wording for std::uncaught_exceptions","Urbana","|Complete|","3.7" +"`N4277 `__","LWG","TriviallyCopyable ``reference_wrapper``\ .","Urbana","|Complete|","3.2" +"`N4279 `__","LWG","Improved insertion interface for unique-key maps.","Urbana","|Complete|","3.7" +"`N4280 `__","LWG","Non-member size() and more","Urbana","|Complete|","3.6" +"`N4284 `__","LWG","Contiguous Iterators.","Urbana","|Complete|","3.6" +"`N4285 `__","CWG","Cleanup for exception-specification and throw-expression.","Urbana","|Complete|","4.0" +"","","","","","" +"`N4387 `__","LWG","improving pair and tuple","Lenexa","|Complete|","4.0" +"`N4389 `__","LWG","bool_constant","Lenexa","|Complete|","3.7" +"`N4508 `__","LWG","shared_mutex for C++17","Lenexa","|Complete|","3.7" +"`N4366 `__","LWG","LWG 2228 missing SFINAE rule","Lenexa","|Complete|","3.1" +"`N4510 `__","LWG","Minimal incomplete type support for standard containers, revision 4","Lenexa","|Complete|","3.6" +"","","","","","" +"`P0004R1 `__","LWG","Remove Deprecated iostreams aliases.","Kona","|Complete|","3.8" +"`P0006R0 `__","LWG","Adopt Type Traits Variable Templates for C++17.","Kona","|Complete|","3.8" +"`P0092R1 `__","LWG","Polishing ","Kona","|Complete|","3.8" +"`P0007R1 `__","LWG","Constant View: A proposal for a ``std::as_const``\ helper function template.","Kona","|Complete|","3.8" +"`P0156R0 `__","LWG","Variadic lock_guard(rev 3).","Kona","*Reverted in Kona*","3.9" +"`P0074R0 `__","LWG","Making ``std::owner_less``\ more flexible","Kona","|Complete|","3.8" +"`P0013R1 `__","LWG","Logical type traits rev 2","Kona","|Complete|","3.8" +"","","","","","" +"`P0024R2 `__","LWG","The Parallelism TS Should be Standardized","Jacksonville","","" +"`P0226R1 `__","LWG","Mathematical Special Functions for C++17","Jacksonville","","" +"`P0220R1 `__","LWG","Adopt Library Fundamentals V1 TS Components for C++17","Jacksonville","|In Progress|","" +"`P0218R1 `__","LWG","Adopt the File System TS for C++17","Jacksonville","|Complete|","7.0" +"`P0033R1 `__","LWG","Re-enabling shared_from_this","Jacksonville","|Complete|","3.9" +"`P0005R4 `__","LWG","Adopt not_fn from Library Fundamentals 2 for C++17","Jacksonville","|Complete|","3.9" +"`P0152R1 `__","LWG","constexpr ``atomic::is_always_lock_free``\ ","Jacksonville","|Complete|","3.9" +"`P0185R1 `__","LWG","Adding [nothrow-]swappable traits","Jacksonville","|Complete|","3.9" +"`P0253R1 `__","LWG","Fixing a design mistake in the searchers interface","Jacksonville","|Complete|","3.9" +"`P0025R0 `__","LWG","An algorithm to ""clamp"" a value between a pair of boundary values","Jacksonville","|Complete|","3.9" +"`P0154R1 `__","LWG","constexpr std::hardware_{constructive,destructive}_interference_size","Jacksonville","","" +"`P0030R1 `__","LWG","Proposal to Introduce a 3-Argument Overload to std::hypot","Jacksonville","|Complete|","3.9" +"`P0031R0 `__","LWG","A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access","Jacksonville","|Complete|","4.0" +"`P0272R1 `__","LWG","Give ``std::string``\ a non-const ``.data()``\ member function","Jacksonville","|Complete|","3.9" +"`P0077R2 `__","LWG","``is_callable``\ , the missing INVOKE related trait","Jacksonville","|Complete|","3.9" +"","","","","","" +"`p0032r3 `__","LWG","Homogeneous interface for variant, any and optional","Oulu","|Complete|","4.0" +"`p0040r3 `__","LWG","Extending memory management tools","Oulu","|Complete|","4.0" +"`p0063r3 `__","LWG","C++17 should refer to C11 instead of C99","Oulu","|Complete|","7.0" +"`p0067r3 `__","LWG","Elementary string conversions","Oulu","Now `P0067R5 `__","n/a" +"`p0083r3 `__","LWG","Splicing Maps and Sets","Oulu","|Complete|","8.0" +"`p0084r2 `__","LWG","Emplace Return Type","Oulu","|Complete|","4.0" +"`p0088r3 `__","LWG","Variant: a type-safe union for C++17","Oulu","|Complete|","4.0" +"`p0137r1 `__","CWG","Core Issue 1776: Replacement of class objects containing reference members","Oulu","|Complete|","6.0" +"`p0163r0 `__","LWG","shared_ptr::weak_type","Oulu","|Complete|","3.9" +"`p0174r2 `__","LWG","Deprecating Vestigial Library Parts in C++17","Oulu","|Partial|","" +"`p0175r1 `__","LWG","Synopses for the C library","Oulu","","" +"`p0180r2 `__","LWG","Reserve a New Library Namespace for Future Standardization","Oulu","|Nothing To Do|","n/a" +"`p0181r1 `__","LWG","Ordered by Default","Oulu","*Removed in Kona*","n/a" +"`p0209r2 `__","LWG","make_from_tuple: apply for construction","Oulu","|Complete|","3.9" +"`p0219r1 `__","LWG","Relative Paths for Filesystem","Oulu","|Complete|","7.0" +"`p0254r2 `__","LWG","Integrating std::string_view and std::string","Oulu","|Complete|","4.0" +"`p0258r2 `__","LWG","has_unique_object_representations","Oulu","|Complete|","6.0" +"`p0295r0 `__","LWG","Adopt Selected Library Fundamentals V2 Components for C++17","Oulu","|Complete|","4.0" +"`p0302r1 `__","LWG","Removing Allocator Support in std::function","Oulu","|Complete|","4.0" +"`p0307r2 `__","LWG","Making Optional Greater Equal Again","Oulu","|Complete|","4.0" +"`p0336r1 `__","LWG","Better Names for Parallel Execution Policies in C++17","Oulu","","" +"`p0337r0 `__","LWG","Delete ``operator=``\ for polymorphic_allocator","Oulu","|Complete|","3.9" +"`p0346r1 `__","LWG","A Nomenclature Tweak","Oulu","|Complete|","3.9" +"`p0358r1 `__","LWG","Fixes for not_fn","Oulu","|Complete|","3.9" +"`p0371r1 `__","LWG","Temporarily discourage memory_order_consume","Oulu","|Nothing To Do|","n/a" +"`p0392r0 `__","LWG","Adapting string_view by filesystem paths","Oulu","|Complete|","4.0" +"`p0393r3 `__","LWG","Making Variant Greater Equal","Oulu","|Complete|","4.0" +"`P0394r4 `__","LWG","Hotel Parallelifornia: terminate() for Parallel Algorithms Exception Handling","Oulu","","" +"","","","","","" +"`P0003R5 `__","LWG","Removing Deprecated Exception Specifications from C++17","Issaquah","|Complete|","5.0" +"`P0067R5 `__","LWG","Elementary string conversions, revision 5","Issaquah","|Partial|","" +"`P0403R1 `__","LWG","Literal suffixes for ``basic_string_view``\ ","Issaquah","|Complete|","4.0" +"`P0414R2 `__","LWG","Merging shared_ptr changes from Library Fundamentals to C++17","Issaquah","|Complete|","11.0" +"`P0418R2 `__","LWG","Fail or succeed: there is no atomic lattice","Issaquah","","" +"`P0426R1 `__","LWG","Constexpr for ``std::char_traits``\ ","Issaquah","|Complete|","4.0" +"`P0435R1 `__","LWG","Resolving LWG Issues re ``common_type``\ ","Issaquah","|Complete|","4.0" +"`P0502R0 `__","LWG","Throwing out of a parallel algorithm terminates - but how?","Issaquah","","" +"`P0503R0 `__","LWG","Correcting library usage of ""literal type""","Issaquah","|Complete|","4.0" +"`P0504R0 `__","LWG","Revisiting in-place tag types for any/optional/variant","Issaquah","|Complete|","4.0" +"`P0505R0 `__","LWG","Wording for GB 50 - constexpr for chrono","Issaquah","|Complete|","4.0" +"`P0508R0 `__","LWG","Wording for GB 58 - structured bindings for node_handles","Issaquah","","" +"`P0509R1 `__","LWG","Updating ""Restrictions on exception handling""","Issaquah","|Nothing To Do|","n/a" +"`P0510R0 `__","LWG","Disallowing references, incomplete types, arrays, and empty variants","Issaquah","|Complete|","4.0" +"`P0513R0 `__","LWG","Poisoning the Hash","Issaquah","|Complete|","5.0" +"`P0516R0 `__","LWG","Clarify That shared_future's Copy Operations have Wide Contracts","Issaquah","|Complete|","4.0" +"`P0517R0 `__","LWG","Make future_error Constructible","Issaquah","|Complete|","4.0" +"`P0521R0 `__","LWG","Proposed Resolution for CA 14 (shared_ptr use_count/unique)","Issaquah","|Nothing To Do|","n/a" +"","","","","","" +"`P0156R2 `__","LWG","Variadic Lock guard(rev 5)","Kona","|Complete|","5.0" +"`P0270R3 `__","CWG","Removing C dependencies from signal handler wording","Kona","","" +"`P0298R3 `__","CWG","A byte type definition","Kona","|Complete|","5.0" +"`P0317R1 `__","LWG","Directory Entry Caching for Filesystem","Kona","|Complete|","7.0" +"`P0430R2 `__","LWG","File system library on non-POSIX-like operating systems","Kona","|Complete|","7.0" +"`P0433R2 `__","LWG","Toward a resolution of US7 and US14: Integrating template deduction for class templates into the standard library","Kona","|In Progress| [#note-P0433]_","7.0" +"`P0452R1 `__","LWG","Unifying Parallel Algorithms","Kona","","" +"`P0467R2 `__","LWG","Iterator Concerns for Parallel Algorithms","Kona","","" +"`P0492R2 `__","LWG","Proposed Resolution of C++17 National Body Comments for Filesystems","Kona","|Complete|","7.0" +"`P0518R1 `__","LWG","Allowing copies as arguments to function objects given to parallel algorithms in response to CH11","Kona","","" +"`P0523R1 `__","LWG","Wording for CH 10: Complexity of parallel algorithms","Kona","","" +"`P0548R1 `__","LWG","common_type and duration","Kona","|Complete|","5.0" +"`P0558R1 `__","LWG","Resolving atomic named base class inconsistencies","Kona","","" +"`P0574R1 `__","LWG","Algorithm Complexity Constraints and Parallel Overloads","Kona","","" +"`P0599R1 `__","LWG","noexcept for hash functions","Kona","|Complete|","5.0" +"`P0604R0 `__","LWG","Resolving GB 55, US 84, US 85, US 86","Kona","|Complete|","" +"`P0607R0 `__","LWG","Inline Variables for the Standard Library","Kona","|In Progress| [#note-P0607]_","6.0" +"`P0618R0 `__","LWG","Deprecating ","Kona","","" +"`P0623R0 `__","LWG","Final C++17 Parallel Algorithms Fixes","Kona","","" +"","","","","","" +"`P0682R1 `__","LWG","Repairing elementary string conversions","Toronto","","" +"`P0739R0 `__","LWG","Some improvements to class template argument deduction integration into the standard library","Toronto","|Complete|","5.0" diff --git a/gnu/llvm/libcxx/docs/Status/Cxx20.rst b/gnu/llvm/libcxx/docs/Status/Cxx20.rst new file mode 100644 index 00000000000..69e607cb7e5 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx20.rst @@ -0,0 +1,59 @@ +.. _cxx20-status: + +================================ +libc++ C++20 Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In July 2017, the C++ standard committee created a draft for the next version of the C++ standard, initially known as "C++2a". +In September 2020, the C++ standard committee approved this draft, and sent it to ISO for approval as C++20. + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +.. attention:: Features in unreleased drafts of the standard are subject to change. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + +.. note:: "Nothing to do" means that no library changes were needed to implement this change. + +.. _paper-status-cxx20: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx20Papers.csv + :header-rows: 1 + :widths: auto + +.. note:: + + .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class], |sect|\ [mem.poly.allocator.class], and |sect|\ [container.node.overview]. + .. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 `__. + .. [#note-P0619] P0619: Only sections D.8, D.9, D.10 and D.13 are implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone. + .. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet. + + +.. _issues-status-cxx20: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx20Issues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 24-May-2021 diff --git a/gnu/llvm/libcxx/docs/Status/Cxx20Issues.csv b/gnu/llvm/libcxx/docs/Status/Cxx20Issues.csv new file mode 100644 index 00000000000..2437cc24707 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx20Issues.csv @@ -0,0 +1,300 @@ +"Issue #","Issue Name","Meeting","Status","First released version" +"`2070 `__","``allocate_shared``\ should use ``allocator_traits::construct``\ ","Toronto","Resolved by `P0674R1 `__","" +"`2444 `__","Inconsistent complexity for ``std::sort_heap``\ ","Toronto","","" +"`2593 `__","Moved-from state of Allocators","Toronto","","" +"`2597 `__","``std::log``\ misspecified for complex numbers","Toronto","","" +"`2783 `__","``stack::emplace()``\ and ``queue::emplace()``\ should return ``decltype(auto)``\ ","Toronto","|Complete|","" +"`2932 `__","Constraints on parallel algorithm implementations are underspecified","Toronto","","" +"`2937 `__","Is ``equivalent(""existing_thing"", ""not_existing_thing"")``\ an error","Toronto","|Complete|","" +"`2940 `__","``result_of``\ specification also needs a little cleanup","Toronto","","" +"`2942 `__","LWG 2873's resolution missed ``weak_ptr::owner_before``\ ","Toronto","|Complete|","" +"`2954 `__","Specialization of the convenience variable templates should be prohibited","Toronto","|Complete|","" +"`2961 `__","Bad postcondition for ``set_default_resource``\ ","Toronto","","" +"`2966 `__","Incomplete resolution of US 74","Toronto","|Nothing To Do|","" +"`2974 `__","Diagnose out of bounds ``tuple_element/variant_alternative``\ ","Toronto","|Complete|","" +"","","","","" +"`2779 `__","[networking.ts] Relax requirements on buffer sequence iterators","Albuquerque","","" +"`2870 `__","Default value of parameter theta of polar should be dependent","Albuquerque","|Complete|","" +"`2935 `__","What should create_directories do when p already exists but is not a directory?","Albuquerque","|Nothing To Do|","" +"`2941 `__","[thread.req.timing] wording should apply to both member and namespace-level functions","Albuquerque","|Nothing To Do|","" +"`2944 `__","LWG 2905 accidentally removed requirement that construction of the deleter doesn't throw an exception","Albuquerque","|Nothing To Do|","" +"`2945 `__","Order of template parameters in optional comparisons","Albuquerque","|Complete|","" +"`2948 `__","unique_ptr does not define operator<< for stream output","Albuquerque","|Complete|","" +"`2950 `__","std::byte operations are misspecified","Albuquerque","|Complete|","" +"`2952 `__","iterator_traits should work for pointers to cv T","Albuquerque","|Complete|","" +"`2953 `__","LWG 2853 should apply to deque::erase too","Albuquerque","|Complete|","" +"`2958 `__","Moves improperly defined as deleted","Albuquerque","*We already do this*","" +"`2964 `__","Apparently redundant requirement for dynamic_pointer_cast","Albuquerque","","" +"`2965 `__","Non-existing path::native_string() in filesystem_error::what() specification","Albuquerque","|Nothing To Do|","" +"`2972 `__","What is ``is_trivially_destructible_v``\ ?","Albuquerque","|Complete|","" +"`2976 `__","Dangling uses_allocator specialization for packaged_task","Albuquerque","|Complete|","" +"`2977 `__","unordered_meow::merge() has incorrect Throws: clause","Albuquerque","|Nothing To Do|","" +"`2978 `__","Hash support for pmr::string and friends","Albuquerque","","" +"`2979 `__","aligned_union should require complete object types","Albuquerque","|Complete|","" +"`2980 `__","Cannot compare_exchange empty pointers","Albuquerque","","" +"`2981 `__","Remove redundant deduction guides from standard library","Albuquerque","","" +"`2982 `__","Making size_type consistent in associative container deduction guides","Albuquerque","","" +"`2988 `__","Clause 32 cleanup missed one typename","Albuquerque","","" +"`2993 `__","reference_wrapper conversion from T&&","Albuquerque","|Complete|","13.0" +"`2998 `__","Requirements on function objects passed to {``forward_``,}list-specific algorithms","Albuquerque","|Nothing To Do|","" +"`3001 `__","weak_ptr::element_type needs remove_extent_t","Albuquerque","","" +"`3024 `__","variant's copies must be deleted instead of disabled via SFINAE","Albuquerque","|Complete|","" +"","","","","" +"`2164 `__","What are the semantics of ``vector.emplace(vector.begin(), vector.back())``\ ?","Jacksonville","|Complete|","" +"`2243 `__","``istream::putback``\ problem","Jacksonville","|Complete|","" +"`2816 `__","``resize_file``\ has impossible postcondition","Jacksonville","|Nothing To Do|","" +"`2843 `__","Unclear behavior of ``std::pmr::memory_resource::do_allocate()``\ ","Jacksonville","|Complete|","" +"`2849 `__","Why does ``!is_regular_file(from)``\ cause ``copy_file``\ to report a ""file already exists"" error?","Jacksonville","|Nothing To Do|","" +"`2851 `__","``std::filesystem``\ enum classes are now underspecified","Jacksonville","|Nothing To Do|","" +"`2946 `__","LWG 2758's resolution missed further corrections","Jacksonville","|Complete|","" +"`2969 `__","``polymorphic_allocator::construct()``\ shouldn't pass ``resource()``\ ","Jacksonville","|Complete|","" +"`2975 `__","Missing case for ``pair``\ construction in scoped and polymorphic allocators","Jacksonville","","" +"`2989 `__","``path``\ 's stream insertion operator lets you insert everything under the sun","Jacksonville","|Complete|","" +"`3000 `__","``monotonic_memory_resource::do_is_equal``\ uses ``dynamic_cast``\ unnecessarily","Jacksonville","","" +"`3002 `__","[networking.ts] ``basic_socket_acceptor::is_open()``\ isn't ``noexcept``\ ","Jacksonville","","" +"`3004 `__","|sect|\ [string.capacity] and |sect|\ [vector.capacity] should specify time complexity for ``capacity()``\ ","Jacksonville","|Nothing To Do|","" +"`3005 `__","Destruction order of arrays by ``make_shared/allocate_shared``\ only recommended?","Jacksonville","","" +"`3007 `__","``allocate_shared``\ should rebind allocator to *cv*-unqualified ``value_type``\ for construction","Jacksonville","","" +"`3009 `__","Including ````\ doesn't provide ``std::size/empty/data``\ ","Jacksonville","|Complete|","" +"`3010 `__","[networking.ts] ``uses_executor``\ says ""if a type ``T::executor_type``\ exists""","Jacksonville","","" +"`3013 `__","``(recursive_)directory_iterator``\ construction and traversal should not be ``noexcept``\ ","Jacksonville","|Complete|","" +"`3014 `__","More ``noexcept``\ issues with filesystem operations","Jacksonville","|Complete|","" +"`3015 `__","``copy_options::*unspecified*``\ underspecified","Jacksonville","|Nothing To Do|","" +"`3017 `__","``list splice``\ functions should use ``addressof``\ ","Jacksonville","|Complete|","" +"`3020 `__","[networking.ts] Remove spurious nested ``value_type``\ buffer sequence requirement","Jacksonville","","" +"`3026 `__","``filesystem::weakly_canonical``\ still defined in terms of ``canonical(p, base)``\ ","Jacksonville","|Complete|","" +"`3030 `__","Who shall meet the requirements of ``try_lock``\ ?","Jacksonville","|Nothing To Do|","" +"`3034 `__","P0767R1 breaks previously-standard-layout types","Jacksonville","|Complete|","" +"`3035 `__","``std::allocator``\ 's constructors should be ``constexpr``\ ","Jacksonville","|Complete|","" +"`3039 `__","Unnecessary ``decay``\ in ``thread``\ and ``packaged_task``\ ","Jacksonville","|Complete|","" +"`3041 `__","Unnecessary ``decay``\ in ``reference_wrapper``\ ","Jacksonville","|Complete|","" +"`3042 `__","``is_literal_type_v``\ should be inline","Jacksonville","|Complete|","" +"`3043 `__","Bogus postcondition for ``filesystem_error``\ constructor","Jacksonville","|Complete|","" +"`3045 `__","``atomic<*floating-point*>``\ doesn't have ``value_type``\ or ``difference_type``\ ","Jacksonville","","" +"`3048 `__","``transform_reduce(exec, first1, last1, first2, init)``\ discards execution policy","Jacksonville","","" +"`3051 `__","Floating point classifications were inadvertently changed in P0175","Jacksonville","|Nothing To Do|","" +"`3075 `__","``basic_string``\ needs deduction guides from ``basic_string_view``\ ","Jacksonville","|Complete|","" +"","","","","" +"`2139 `__","What is a user-defined type?","Rapperswil","","" +"`2970 `__","Return type of std::visit misspecified","Rapperswil","","" +"`3058 `__","Parallel adjacent_difference shouldn't require creating temporaries","Rapperswil","","" +"`3062 `__","Unnecessary decay_t in is_execution_policy_v should be remove_cvref_t","Rapperswil","","" +"`3067 `__","recursive_directory_iterator::pop must invalidate","Rapperswil","|Nothing To Do|","" +"`3071 `__","[networking.ts] read_until still refers to ""input sequence""","Rapperswil","|Nothing To Do|","" +"`3074 `__","Non-member functions for valarray should only deduce from the valarray","Rapperswil","","" +"`3076 `__","basic_string CTAD ambiguity","Rapperswil","|Complete|","" +"`3079 `__","LWG 2935 forgot to fix the existing_p overloads of create_directory","Rapperswil","|Nothing To Do|","" +"`3080 `__","Floating point from_chars pattern specification breaks round-tripping","Rapperswil","","" +"`3083 `__","What should ios::iword(-1) do?","Rapperswil","|Nothing To Do|","" +"`3094 `__","[time.duration.io]p4 makes surprising claims about encoding","Rapperswil","","" +"`3100 `__","Unnecessary and confusing ""empty span"" wording","Rapperswil","|Nothing To Do|","" +"`3102 `__","Clarify span iterator and ``const_iterator`` behavior","Rapperswil","|Complete|","" +"`3104 `__","Fixing duration division","Rapperswil","|Complete|","" +"","","","","" +"`2183 `__","Muddled allocator requirements for ``match_results``\ constructors","San Diego","|Complete|","" +"`2184 `__","Muddled allocator requirements for ``match_results``\ assignments","San Diego","|Complete|","" +"`2412 `__","``promise::set_value()``\ and ``promise::get_future()``\ should not race","San Diego","","" +"`2499 `__","``operator>>(basic_istream&, CharT*)``\ makes it hard to avoid buffer overflows","San Diego","Resolved by P0487R1","" +"`2682 `__","``filesystem::copy()``\ won't create a symlink to a directory","San Diego","|Nothing To Do|","" +"`2697 `__","[concurr.ts] Behavior of ``future/shared_future``\ unwrapping constructor when given an invalid ``future``\ ","San Diego","","" +"`2797 `__","Trait precondition violations","San Diego","Resolved by 1285R0","" +"`2936 `__","Path comparison is defined in terms of the generic format","San Diego","|Complete|","" +"`2943 `__","Problematic specification of the wide version of ``basic_filebuf::open``\ ","San Diego","|Nothing To Do|","" +"`2960 `__","[fund.ts.v3] ``nonesuch``\ is insufficiently useless","San Diego","|Complete|","" +"`2995 `__","``basic_stringbuf``\ default constructor forbids it from using SSO capacity","San Diego","","" +"`2996 `__","Missing rvalue overloads for ``shared_ptr``\ operations","San Diego","","" +"`3008 `__","``make_shared``\ (sub)object destruction semantics are not specified","San Diego","","" +"`3022 `__","``is_convertible``\ may lead to ODR","San Diego","Resolved by 1285R0","" +"`3025 `__","Map-like container deduction guides should use ``pair``\ , not ``pair``\ ","San Diego","|Complete|","" +"`3031 `__","Algorithms and predicates with non-const reference arguments","San Diego","","" +"`3037 `__","``polymorphic_allocator``\ and incomplete types","San Diego","","" +"`3038 `__","``polymorphic_allocator::allocate``\ should not allow integer overflow to create vulnerabilities","San Diego","","" +"`3054 `__","``uninitialized_copy``\ appears to not be able to meet its exception-safety guarantee","San Diego","","" +"`3065 `__","LWG 2989 missed that all ``path``\ 's other operators should be hidden friends as well","San Diego","|Complete|","" +"`3096 `__","``path::lexically_relative``\ is confused by trailing slashes","San Diego","|Complete|","" +"`3116 `__","``*OUTERMOST_ALLOC_TRAITS*``\ needs ``remove_reference_t``\ ","San Diego","","" +"`3122 `__","``__cpp_lib_chrono_udls``\ was accidentally dropped","San Diego","|Complete|","" +"`3127 `__","``basic_osyncstream::rdbuf``\ needs a ````const_cast````\ ","San Diego","","" +"`3128 `__","``strstream::rdbuf``\ needs a ````const_cast````\ ","San Diego","|Nothing To Do|","" +"`3129 `__","``regex_token_iterator``\ constructor uses wrong pointer arithmetic","San Diego","","" +"`3130 `__","|sect|\ [input.output] needs many ``addressof``\ ","San Diego","","" +"`3131 `__","``addressof``\ all the things","San Diego","","" +"`3132 `__","Library needs to ban macros named ``expects``\ or ``ensures``\ ","San Diego","|Nothing To Do|","" +"`3134 `__","[fund.ts.v3] LFTSv3 contains extraneous [meta] variable templates that should have been deleted by P09961","San Diego","Resolved by P1210R0","" +"`3137 `__","Header for ``__cpp_lib_to_chars``\ ","San Diego","|Complete|","" +"`3145 `__","``file_clock``\ breaks ABI for C++17 implementations","San Diego","|Complete|","" +"`3147 `__","Definitions of ""likely"" and ""unlikely"" are likely to cause problems","San Diego","","" +"`3148 `__","````\ should be freestanding","San Diego","","" +"`3153 `__","``Common``\ and ``common_type``\ have too little in common","San Diego","","" +"`3154 `__","``Common``\ and ``CommonReference``\ have a common defect","San Diego","","" +"","","","","" +"`3012 `__","``atomic``\ is unimplementable for non-``is_trivially_copy_constructible T``\ ","Kona","","" +"`3040 `__","``basic_string_view::starts_with``\ *Effects* are incorrect","Kona","|Complete|","" +"`3077 `__","``(push|emplace)_back``\ should invalidate the ``end``\ iterator","Kona","|Nothing To Do|","" +"`3087 `__","One final ``&x``\ in |sect|\ [list.ops]","Kona","|Nothing To Do|","" +"`3101 `__","``span``\ 's ``Container``\ constructors need another constraint","Kona","|Complete|","" +"`3112 `__","``system_error``\ and ``filesystem_error``\ constructors taking a ``string``\ may not be able to meet their postconditions","Kona","","" +"`3119 `__","Program-definedness of closure types","Kona","|Nothing To Do|","" +"`3133 `__","Modernizing numeric type requirements","Kona","","" +"`3144 `__","``span``\ does not have a ````const_pointer````\ typedef","Kona","|Complete|","" +"`3173 `__","Enable CTAD for *``ref-view``*\ ","Kona","","" +"`3179 `__","``subrange``\ should always model ``Range``\ ","Kona","","" +"`3180 `__","Inconsistently named return type for ``ranges::minmax_element``\ ","Kona","","" +"`3182 `__","Specification of ``Same``\ could be clearer","Kona","","" +"","","","","" +"`2899 `__","``is_(nothrow_)move_constructible``\ and ``tuple``\ , ``optional``\ and ``unique_ptr``\ ","Cologne","","" +"`3055 `__","``path::operator+=(*single-character*)``\ misspecified","Cologne","|Complete|","7.0" +"`3158 `__","``tuple(allocator_arg_t, const Alloc&)``\ should be conditionally explicit","Cologne","","" +"`3169 `__","``ranges``\ permutation generators discard useful information","Cologne","","" +"`3183 `__","Normative permission to specialize Ranges variable templates","Cologne","","" +"`3184 `__","Inconsistencies in ``bind_front``\ wording","Cologne","|Complete|","13.0" +"`3185 `__","Uses-allocator construction functions missing ``constexpr``\ and ``noexcept``\ ","Cologne","","" +"`3186 `__","``ranges``\ removal, partition, and ``partial_sort_copy``\ algorithms discard useful information","Cologne","","" +"`3187 `__","`P0591R4 `__ reverted DR 2586 fixes to ``scoped_allocator_adaptor::construct()``\ ","Cologne","","" +"`3191 `__","``std::ranges::shuffle``\ synopsis does not match algorithm definition","Cologne","","" +"`3196 `__","``std::optional``\ is ill-formed is ``T``\ is an array","Cologne","|Complete|","" +"`3198 `__","Bad constraint on ``std::span::span()``\ ","Cologne","|Complete|","" +"`3199 `__","``istream >> bitset<0>``\ fails","Cologne","","" +"`3202 `__","P0318R1 was supposed to be revised","Cologne","|Complete|","" +"`3206 `__","``year_month_day``\ conversion to ``sys_days``\ uses not-existing member function","Cologne","|Complete|","" +"`3208 `__","``Boolean``\ 's expression requirements are ordered inconsistently","Cologne","|Nothing To Do|","" +"`3209 `__","Expression in ``year::ok()``\ returns clause is ill-formed","Cologne","|Complete|","" +"","","","","" +"`3231 `__","``year_month_day_last::day``\ specification does not cover ``!ok()``\ values","Belfast","|Nothing To Do|","" +"`3225 `__","``zoned_time``\ converting constructor shall not be ``noexcept``\ ","Belfast","","" +"`3190 `__","``std::allocator::allocate``\ sometimes returns too little storage","Belfast","","" +"`3218 `__","Modifier for ``%d``\ parse flag does not match POSIX and ``format``\ specification","Belfast","","" +"`3224 `__","``zoned_time``\ constructor from ``TimeZonePtr``\ does not specify initialization of ``tp_``\ ","Belfast","","" +"`3230 `__","Format specifier ``%y/%Y``\ is missing locale alternative versions","Belfast","","" +"`3232 `__","Inconsistency in ``zoned_time``\ deduction guides","Belfast","","" +"`3222 `__","P0574R1 introduced preconditions on non-existent parameters","Belfast","","" +"`3221 `__","Result of ``year_month``\ arithmetic with ``months``\ is ambiguous","Belfast","|Complete|","8.0" +"`3235 `__","``parse``\ manipulator without abbreviation is not callable","Belfast","","" +"`3246 `__","What are the constraints on the template parameter of ``basic_format_arg``\ ?","Belfast","","" +"`3253 `__","``basic_syncbuf::basic_syncbuf()``\ should not be explicit","Belfast","","" +"`3245 `__","Unnecessary restriction on ``'%p'``\ parse specifier","Belfast","","" +"`3244 `__","Constraints for ``Source``\ in |sect|\ [fs.path.req] insufficiently constrainty","Belfast","","" +"`3241 `__","``chrono-spec``\ grammar ambiguity in |sect|\ [time.format]","Belfast","","" +"`3257 `__","Missing feature testing macro update from P0858","Belfast","","" +"`3256 `__","Feature testing macro for ``constexpr``\ algorithms","Belfast","|Complete|","13.0" +"`3273 `__","Specify ``weekday_indexed``\ to range of ``[0, 7]``\ ","Belfast","","" +"`3070 `__","``path::lexically_relative``\ causes surprising results if a filename can also be a *root-name*","Belfast","","" +"`3266 `__","``to_chars(bool)``\ should be deleted","Belfast","","" +"`3272 `__","``%I%p``\ should parse/format ``duration``\ since midnight","Belfast","","" +"`3259 `__","The definition of *constexpr iterators* should be adjusted","Belfast","","" +"`3103 `__","Errors in taking subview of ``span``\ should be ill-formed where possible","Belfast","","" +"`3274 `__","Missing feature test macro for ````\ ","Belfast","","" +"`3276 `__","Class ``split_view::outer_iterator::value_type``\ should inherit from ``view_interface``\ ","Belfast","","" +"`3277 `__","Pre-increment on prvalues is not a requirement of ``weakly_incrementable``\ ","Belfast","","" +"`3149 `__","``DefaultConstructible``\ should require default initialization","Belfast","|Complete|","13.0" +"","","","","" +"`1203 `__","More useful rvalue stream insertion","Prague","|Complete|","12.0" +"`2859 `__","Definition of *reachable* in [ptr.launder] misses pointer arithmetic from pointer-interconvertible object","Prague","","" +"`3018 `__","``shared_ptr``\ of function type","Prague","","" +"`3050 `__","Conversion specification problem in ``chrono::duration``\ constructor","Prague","","" +"`3141 `__","``CopyConstructible``\ doesn't preserve source values","Prague","|Nothing to do|","" +"`3150 `__","``UniformRandomBitGenerator``\ should validate ``min``\ and ``max``\ ","Prague","|Complete|","13.0" +"`3175 `__","The ``CommonReference``\ requirement of concept ``SwappableWith``\ is not satisfied in the example","Prague","|Complete|","13.0" +"`3194 `__","``ConvertibleTo``\ prose does not match code","Prague","|Complete|","13.0" +"`3200 `__","``midpoint``\ should not constrain ``T``\ is complete","Prague","|Nothing To Do|","" +"`3201 `__","``lerp``\ should be marked as ``noexcept``\ ","Prague","|Complete|","" +"`3226 `__","``zoned_time``\ constructor from ``string_view``\ should accept ``zoned_time``\ ","Prague","","" +"`3233 `__","Broken requirements for ``shared_ptr``\ converting constructors","Prague","","" +"`3237 `__","LWG 3038 and 3190 have inconsistent PRs","Prague","","" +"`3238 `__","Insufficiently-defined behavior of ``std::function``\ deduction guides","Prague","","" +"`3242 `__","``std::format``\ : missing rules for ``arg-id``\ in ``width``\ and ``precision``\ ","Prague","","" +"`3243 `__","``std::format``\ and negative zeroes","Prague","","" +"`3247 `__","``ranges::iter_move``\ should perform ADL-only lookup of ``iter_move``\ ","Prague","","" +"`3248 `__","``std::format``\ ``#b``\ , ``#B``\ , ``#o``\ , ``#x``\ , and ``#X``\ presentation types misformat negative numbers","Prague","","" +"`3250 `__","``std::format``\ : ``#``\ (alternate form) for NaN and inf","Prague","","" +"`3251 `__","Are ``std::format``\ alignment specifiers applied to string arguments?","Prague","","" +"`3252 `__","Parse locale's aware modifiers for commands are not consistent with POSIX spec","Prague","","" +"`3254 `__","Strike ``stop_token``\ 's ``operator!=``\ ","Prague","","" +"`3255 `__","``span``\ 's ``array``\ constructor is too strict","Prague","|Complete|","" +"`3260 `__","``year_month*``\ arithmetic rejects durations convertible to years","Prague","","" +"`3262 `__","Formatting of negative durations is not specified","Prague","","" +"`3264 `__","``sized_range``\ and ``ranges::size``\ redundantly use ``disable_sized_range``\ ","Prague","","" +"`3269 `__","Parse manipulators do not specify the result of the extraction from stream","Prague","","" +"`3270 `__","Parsing and formatting ``%j``\ with ``duration``\ s","Prague","","" +"`3280 `__","View converting constructors can cause constraint recursion and are unneeded","Prague","","" +"`3281 `__","Conversion from ``*pair-like*``\ types to ``subrange``\ is a silent semantic promotion","Prague","","" +"`3282 `__","``subrange``\ converting constructor should disallow derived to base conversions","Prague","","" +"`3284 `__","``random_access_iterator``\ semantic constraints accidentally promote difference type using unary negate","Prague","","" +"`3285 `__","The type of a customization point object shall satisfy ``semiregular``\ ","Prague","","" +"`3286 `__","``ranges::size``\ is not required to be valid after a call to ``ranges::begin``\ on an input range","Prague","","" +"`3291 `__","``iota_view::iterator``\ has the wrong ``iterator_category``\ ","Prague","","" +"`3292 `__","``iota_view``\ is under-constrained","Prague","","" +"`3294 `__","``zoned_time``\ deduction guides misinterprets ``string``\ /``char*``\ ","Prague","","" +"`3296 `__","Inconsistent default argument for ``basic_regex<>::assign``\ ","Prague","|Complete|","" +"`3299 `__","Pointers don't need customized iterator behavior","Prague","","" +"`3300 `__","Non-array ``ssize``\ overload is underconstrained","Prague","","" +"`3301 `__","``transform_view::iterator``\ has incorrect ``iterator_category``\ ","Prague","","" +"`3302 `__","Range adaptor objects ``keys``\ and ``values``\ are unspecified","Prague","","" +"`3303 `__","Bad ""``constexpr``\ "" marker for ``destroy/destroy_n``\ ","Prague","","" +"`3304 `__","Allocate functions of ``std::polymorphic_allocator``\ should require ``[[nodiscard]]``\ ","Prague","","" +"`3307 `__","``std::allocator().allocate(n)``\ ","Prague","","" +"`3310 `__","Replace ``SIZE_MAX``\ with ``numeric_limits::max()``\ ","Prague","","" +"`3313 `__","``join_view::iterator::operator--``\ is incorrectly constrained","Prague","","" +"`3314 `__","Is stream insertion behavior locale dependent when ``Period::type``\ is ``micro``\ ?","Prague","","" +"`3315 `__","Correct Allocator Default Behavior","Prague","","" +"`3316 `__","Correctly define epoch for ``utc_clock``\ / ``utc_timepoint``\ ","Prague","","" +"`3317 `__","Incorrect ``operator<<``\ for floating-point durations","Prague","","" +"`3318 `__","Clarify whether clocks can represent time before their epoch","Prague","","" +"`3319 `__","Properly reference specification of IANA time zone database","Prague","","" +"`3320 `__","``span::cbegin/cend``\ methods produce different results than ``std::[ranges::]cbegin/cend``\ ","Prague","|Complete|","" +"`3321 `__","``uninitialized_construct_using_allocator``\ should use ``construct_at``\ ","Prague","","" +"`3323 `__","``*has-tuple-element*``\ helper concept needs ``convertible_to``\ ","Prague","","" +"`3324 `__","Special-case ``std::strong/weak/partial_order``\ for pointers","Prague","","" +"`3325 `__","Constrain return type of transformation function for ``transform_view``\ ","Prague","","" +"`3326 `__","``enable_view``\ has false positives","Prague","|In progress|","" +"`3327 `__","Format alignment specifiers vs. text direction","Prague","|Nothing To Do|","" +"`3328 `__","Clarify that ``std::string``\ is not good for UTF-8","Prague","","" +"`3329 `__","``totally_ordered_with``\ both directly and indirectly requires ``common_reference_with``\ ","Prague","|Complete|","13.0" +"`3330 `__","Include ````\ from most library headers","Prague","","" +"`3331 `__","Define ``totally_ordered/_with``\ in terms of ``*partially-ordered-with*``\ ","Prague","|Complete|","13.0" +"`3332 `__","Issue in |sect|\ [time.format]","Prague","","" +"`3334 `__","``basic_osyncstream``\ move assignment and destruction calls ``basic_syncbuf::emit()``\ twice","Prague","","" +"`3335 `__","Resolve C++20 NB comments US 273 and GB 274","Prague","","" +"`3338 `__","Rename ``default_constructible``\ to ``default_initializable``\ ","Prague","|Complete|","13.0" +"`3340 `__","Formatting functions should throw on argument/format string mismatch in |sect|\ [format.functions]","Prague","","" +"`3346 `__","``pair``\ and ``tuple``\ copy and move constructor have backwards specification","Prague","","" +"`3347 `__","``std::pair``\ now requires ``T``\ and ``U``\ to be less-than-comparable","Prague","","" +"`3348 `__","``__cpp_lib_unwrap_ref``\ in wrong header","Prague","","" +"`3349 `__","Missing ``__cpp_lib_constexpr_complex``\ for P0415R1","Prague","","" +"`3350 `__","Simplify return type of ``lexicographical_compare_three_way``\ ","Prague","","" +"`3351 `__","``ranges::enable_safe_range``\ should not be constrained","Prague","","" +"`3352 `__","``strong_equality``\ isn't a thing","Prague","","" +"`3354 `__","``has_strong_structural_equality``\ has a meaningless definition","Prague","","" +"`3355 `__","The memory algorithms should support move-only input iterators introduced by P1207","Prague","","" +"`3356 `__","``__cpp_lib_nothrow_convertible``\ should be ``__cpp_lib_is_nothrow_convertible``\ ","Prague","","" +"`3358 `__","|sect|\ [span.cons] is mistaken that ``to_address``\ can throw","Prague","","" +"`3359 `__","````\ leap second support should allow for negative leap seconds","Prague","","" +"`3360 `__","``three_way_comparable_with``\ is inconsistent with similar concepts","Prague","","" +"`3362 `__","Strike ``stop_source``\ 's ``operator!=``\ ","Prague","","" +"`3363 `__","``drop_while_view``\ should opt-out of ``sized_range``\ ","Prague","","" +"`3364 `__","Initialize data members of ranges and their iterators","Prague","","" +"`3367 `__","Integer-class conversions should not throw","Prague","","" +"`3369 `__","``span``\ 's deduction-guide for built-in arrays doesn't work","Prague","","" +"`3371 `__","``visit_format_arg``\ and ``make_format_args``\ are not hidden friends","Prague","","" +"`3372 `__","``vformat_to``\ should not try to deduce ``Out``\ twice","Prague","","" +"`3373 `__","``{to,from}_chars_result``\ and ``format_to_n_result``\ need the ""we really mean what we say"" wording","Prague","","" +"`3374 `__","P0653 + P1006 should have made the other ``std::to_address``\ overload ``constexpr``\ ","Prague","|Complete|","12.0" +"`3375 `__","``decay``\ in ``viewable_range``\ should be ``remove_cvref``\ ","Prague","","" +"`3377 `__","``elements_view::iterator``\ befriends a specialization of itself","Prague","","" +"`3379 `__","""``safe``\ "" in several library names is misleading","Prague","|In Progress|","" +"`3380 `__","``common_type``\ and comparison categories","Prague","","" +"`3381 `__","``begin``\ and ``data``\ must agree for ``contiguous_range``\ ","Prague","","" +"`3382 `__","NTTP for ``pair``\ and ``array``\ ","Prague","","" +"`3383 `__","|sect|\ [time.zone.leap.nonmembers] ``sys_seconds``\ should be replaced with ``seconds``\ ","Prague","","" +"`3384 `__","``transform_view::*sentinel*``\ has an incorrect ``operator-``\ ","Prague","","" +"`3385 `__","``common_iterator``\ is not sufficiently constrained for non-copyable iterators","Prague","","" +"`3387 `__","|sect|\ [range.reverse.view] ``reverse_view``\ unintentionally requires ``range``\ ","Prague","","" +"`3388 `__","``view``\ iterator types have ill-formed ``<=>``\ operators","Prague","","" +"`3389 `__","A move-only iterator still does not have a ``counted_iterator``\ ","Prague","","" +"`3390 `__","``make_move_iterator()``\ cannot be used to construct a ``move_iterator``\ for a move-only iterator","Prague","","" +"`3393 `__","Missing/incorrect feature test macro for coroutines","Prague","","" +"`3395 `__","Definition for three-way comparison needs to be updated (US 152)","Prague","","" +"`3396 `__","Clarify point of reference for ``source_location::current()``\ (DE 169)","Prague","","" +"`3397 `__","``ranges::basic_istream_view::iterator``\ should not provide ``iterator_category``\ ","Prague","","" +"`3398 `__","``tuple_element_t``\ is also wrong for ``const subrange``\ ","Prague","","" +"`3446 `__","``indirectly_readable_traits``\ ambiguity for types with both ``value_type``\ and ``element_type``\ ","November virtual meeting","|Complete|","13.0" diff --git a/gnu/llvm/libcxx/docs/Status/Cxx20Papers.csv b/gnu/llvm/libcxx/docs/Status/Cxx20Papers.csv new file mode 100644 index 00000000000..7915b7929ea --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx20Papers.csv @@ -0,0 +1,202 @@ +"Paper #","Group","Paper Name","Meeting","Status","First released version" +"`P0463R1 `__","LWG","Endian just Endian","Toronto","|Complete|","7.0" +"`P0674R1 `__","LWG","Extending make_shared to Support Arrays","Toronto","","" +"","","","","","" +"`P0020R6 `__","LWG","Floating Point Atomic","Albuquerque","","" +"`P0053R7 `__","LWG","C++ Synchronized Buffered Ostream","Albuquerque","","" +"`P0202R3 `__","LWG","Add constexpr modifiers to functions in and Headers","Albuquerque","|Complete|","12.0" +"`P0415R1 `__","LWG","Constexpr for ``std::complex``\ ","Albuquerque","|In Progress|","7.0" +"`P0439R0 `__","LWG","Make ``std::memory_order``\ a scoped enumeration","Albuquerque","|Complete|","" +"`P0457R2 `__","LWG","String Prefix and Suffix Checking","Albuquerque","|Complete|","6.0" +"`P0550R2 `__","LWG","Transformation Trait ``remove_cvref``\ ","Albuquerque","|Complete|","6.0" +"`P0600R1 `__","LWG","nodiscard in the Library","Albuquerque","|In Progress| [#note-P0600]_","7.0" +"`P0616R0 `__","LWG","de-pessimize legacy algorithms with std::move","Albuquerque","|Complete|","12.0" +"`P0653R2 `__","LWG","Utility to convert a pointer to a raw pointer","Albuquerque","|Complete|","6.0" +"`P0718R2 `__","LWG","Atomic shared_ptr","Albuquerque","","" +"`P0767R1 `__","CWG","Deprecate POD","Albuquerque","|Complete|","7.0" +"`P0768R1 `__","CWG","Library Support for the Spaceship (Comparison) Operator","Albuquerque","|Complete|","" +"`P0777R1 `__","LWG","Treating Unnecessary ``decay``\ ","Albuquerque","|Complete|","7.0" +"`P0122R7 `__","LWG","","Jacksonville","|Complete|","7.0" +"`P0355R7 `__","LWG","Extending chrono to Calendars and Time Zones","Jacksonville","|In Progress|","" +"`P0551R3 `__","LWG","Thou Shalt Not Specialize ``std``\ Function Templates!","Jacksonville","|Complete|","11.0" +"`P0753R2 `__","LWG","Manipulators for C++ Synchronized Buffered Ostream","Jacksonville","","" +"`P0754R2 `__","LWG","","Jacksonville","|Complete|","7.0" +"`P0809R0 `__","LWG","Comparing Unordered Containers","Jacksonville","|Nothing To Do|","" +"`P0858R0 `__","LWG","Constexpr iterator requirements","Jacksonville","","" +"`P0905R1 `__","CWG","Symmetry for spaceship","Jacksonville","","" +"`P0966R1 `__","LWG","``string::reserve``\ Should Not Shrink","Jacksonville","|Complete| [#note-P0966]_","12.0" +"","","","","","" +"`P0019R8 `__","LWG","Atomic Ref","Rapperswil","","" +"`P0458R2 `__","LWG","Checking for Existence of an Element in Associative Containers","Rapperswil","|Complete|","13.0" +"`P0475R1 `__","LWG","LWG 2511: guaranteed copy elision for piecewise construction","Rapperswil","|Complete|","" +"`P0476R2 `__","LWG","Bit-casting object representations","Rapperswil","","" +"`P0528R3 `__","CWG","The Curious Case of Padding Bits, Featuring Atomic Compare-and-Exchange","Rapperswil","","" +"`P0542R5 `__","CWG","Support for contract based programming in C++","Rapperswil","*Removed in Cologne*","n/a" +"`P0556R3 `__","LWG","Integral power-of-2 operations","Rapperswil","|Complete|","9.0" +"`P0619R4 `__","LWG","Reviewing Deprecated Facilities of C++17 for C++20","Rapperswil","|Partial| [#note-P0619]_","" +"`P0646R1 `__","LWG","Improving the Return Value of Erase-Like Algorithms","Rapperswil","|Complete|","10.0" +"`P0722R3 `__","CWG","Efficient sized delete for variable sized classes","Rapperswil","|Complete|","9.0" +"`P0758R1 `__","LWG","Implicit conversion traits and utility functions","Rapperswil","|Complete|","" +"`P0759R1 `__","LWG","fpos Requirements","Rapperswil","|Complete|","11.0" +"`P0769R2 `__","LWG","Add shift to ","Rapperswil","|Complete|","12.0" +"`P0788R3 `__","LWG","Standard Library Specification in a Concepts and Contracts World","Rapperswil","*Removed in Cologne*","n/a" +"`P0879R0 `__","LWG","Constexpr for swap and swap related functions Also resolves LWG issue 2800.","Rapperswil","|Complete|","13.0" +"`P0887R1 `__","LWG","The identity metafunction","Rapperswil","|Complete|","8.0" +"`P0892R2 `__","CWG","explicit(bool)","Rapperswil","","" +"`P0898R3 `__","LWG","Standard Library Concepts","Rapperswil","|Complete|","13.0" +"`P0935R0 `__","LWG","Eradicating unnecessarily explicit default constructors from the standard library","Rapperswil","|Complete|","12.0" +"`P0941R2 `__","CWG","Integrating feature-test macros into the C++ WD","Rapperswil","|In Progress|","" +"`P1023R0 `__","LWG","constexpr comparison operators for std::array","Rapperswil","|Complete|","8.0" +"`P1025R1 `__","CWG","Update The Reference To The Unicode Standard","Rapperswil","","" +"`P1120R0 `__","CWG","Consistency improvements for <=> and other comparison operators","Rapperswil","","" +"","","","","","" +"`P0318R1 `__","LWG","unwrap_ref_decay and unwrap_reference","San Diego","|Complete|","8.0" +"`P0356R5 `__","LWG","Simplified partial function application","San Diego","|Complete|","13.0" +"`P0357R3 `__","LWG","reference_wrapper for incomplete types","San Diego","|Complete|","8.0" +"`P0482R6 `__","CWG","char8_t: A type for UTF-8 characters and strings","San Diego","|In Progress|","" +"`P0487R1 `__","LWG","Fixing ``operator>>(basic_istream&, CharT*)``\ (LWG 2499)","San Diego","|Complete|","8.0" +"`P0591R4 `__","LWG","Utility functions to implement uses-allocator construction","San Diego","* *","" +"`P0595R2 `__","CWG","P0595R2 std::is_constant_evaluated()","San Diego","|Complete|","9.0" +"`P0602R4 `__","LWG","variant and optional should propagate copy/move triviality","San Diego","|Complete|","8.0" +"`P0608R3 `__","LWG","A sane variant converting constructor","San Diego","|Complete|","9.0" +"`P0655R1 `__","LWG","visit: Explicit Return Type for visit","San Diego","|Complete|","12.0" +"`P0771R1 `__","LWG","std::function move constructor should be noexcept","San Diego","|Complete|","6.0" +"`P0896R4 `__","LWG","The One Ranges Proposal","San Diego","|In Progress|","" +"`P0899R1 `__","LWG","P0899R1 - LWG 3016 is not a defect","San Diego","|Nothing To Do|","" +"`P0919R3 `__","LWG","Heterogeneous lookup for unordered containers","San Diego","|Complete|","12.0" +"`P0972R0 `__","LWG"," ``zero()``\ , ``min()``\ , and ``max()``\ should be noexcept","San Diego","|Complete|","8.0" +"`P1006R1 `__","LWG","Constexpr in std::pointer_traits","San Diego","|Complete|","8.0" +"`P1007R3 `__","LWG","``std::assume_aligned``\ ","San Diego","* *","" +"`P1020R1 `__","LWG","Smart pointer creation with default initialization","San Diego","* *","" +"`P1032R1 `__","LWG","Misc constexpr bits","San Diego","|Complete|","13.0" +"`P1085R2 `__","LWG","Should Span be Regular?","San Diego","|Complete|","8.0" +"`P1123R0 `__","LWG","Editorial Guidance for merging P0019r8 and P0528r3","San Diego","* *","" +"`P1148R0 `__","LWG","Cleaning up Clause 20","San Diego","* *","" +"`P1165R1 `__","LWG","Make stateful allocator propagation more consistent for ``operator+(basic_string)``\ ","San Diego","* *","" +"`P1209R0 `__","LWG","Adopt Consistent Container Erasure from Library Fundamentals 2 for C++20","San Diego","|Complete|","8.0" +"`P1210R0 `__","LWG","Completing the Rebase of Library Fundamentals, Version 3, Working Draft","San Diego","* *","" +"`P1236R1 `__","CWG","Alternative Wording for P0907R4 Signed Integers are Two's Complement","San Diego","* *","" +"`P1248R1 `__","LWG","Remove CommonReference requirement from StrictWeakOrdering (a.k.a Fixing Relations)","San Diego","|Complete|","13.0" +"`P1285R0 `__","LWG","Improving Completeness Requirements for Type Traits","San Diego","* *","" +"`P1353R0 `__","CWG","Missing feature test macros","San Diego","* *","" +"","","","","","" +"`P0339R6 `__","LWG","polymorphic_allocator<> as a vocabulary type","Kona","","" +"`P0340R3 `__","LWG","Making std::underlying_type SFINAE-friendly","Kona","|Complete|","9.0" +"`P0738R2 `__","LWG","I Stream, You Stream, We All Stream for istream_iterator","Kona","","" +"`P0811R3 `__","LWG","Well-behaved interpolation for numbers and pointers","Kona","|Complete|","9.0" +"`P0920R2 `__","LWG","Precalculated hash values in lookup","Kona","Reverted by `P1661 `__","" +"`P1001R2 `__","LWG","Target Vectorization Policies from Parallelism V2 TS to C++20","Kona","","" +"`P1024R3 `__","LWG","Usability Enhancements for std::span","Kona","|Complete|","9.0" +"`P1164R1 `__","LWG","Make create_directory() Intuitive","Kona","|Complete|","12.0" +"`P1227R2 `__","LWG","Signed ssize() functions, unsigned size() functions","Kona","|Complete|","9.0" +"`P1252R2 `__","LWG","Ranges Design Cleanup","Kona","","" +"`P1286R2 `__","CWG","Contra CWG DR1778","Kona","","" +"`P1357R1 `__","LWG","Traits for [Un]bounded Arrays","Kona","|Complete|","9.0" +"`P1458R1 `__","LWG","Mandating the Standard Library: Clause 16 - Language support library","Kona","|Complete|","9.0" +"`P1459R1 `__","LWG","Mandating the Standard Library: Clause 18 - Diagnostics library","Kona","|Complete|","9.0" +"`P1462R1 `__","LWG","Mandating the Standard Library: Clause 20 - Strings library","Kona","|Complete|","9.0" +"`P1463R1 `__","LWG","Mandating the Standard Library: Clause 21 - Containers library","Kona","","" +"`P1464R1 `__","LWG","Mandating the Standard Library: Clause 22 - Iterators library","Kona","|Complete|","9.0" +"","","","","","" +"`P0325 `__","LWG","to_array from LFTS with updates","Cologne","|Complete|","10.0" +"`P0408 `__","LWG","Efficient Access to basic_stringbuf's Buffer","Cologne","","" +"`P0466 `__","LWG","Layout-compatibility and Pointer-interconvertibility Traits","Cologne","","" +"`P0553 `__","LWG","Bit operations","Cologne","|Complete|","9.0" +"`P0631 `__","LWG","Math Constants","Cologne","|Complete|","11.0" +"`P0645 `__","LWG","Text Formatting","Cologne","|In Progress|","" +"`P0660 `__","LWG","Stop Token and Joining Thread, Rev 10","Cologne","","" +"`P0784 `__","CWG","More constexpr containers","Cologne","|Complete|","12.0" +"`P0980 `__","LWG","Making std::string constexpr","Cologne","","" +"`P1004 `__","LWG","Making std::vector constexpr","Cologne","","" +"`P1035 `__","LWG","Input Range Adaptors","Cologne","","" +"`P1065 `__","LWG","Constexpr INVOKE","Cologne","|Complete|","12.0" +"`P1135 `__","LWG","The C++20 Synchronization Library","Cologne","|Complete|","11.0" +"`P1207 `__","LWG","Movability of Single-pass Iterators","Cologne","","" +"`P1208 `__","LWG","Adopt source_location for C++20","Cologne","","" +"`P1355 `__","LWG","Exposing a narrow contract for ceil2","Cologne","|Complete|","9.0" +"`P1361 `__","LWG","Integration of chrono with text formatting","Cologne","","" +"`P1423 `__","LWG","char8_t backward compatibility remediation","Cologne","|In Progress|","" +"`P1424 `__","LWG","'constexpr' feature macro concerns","Cologne","Superseded by `P1902 `__","" +"`P1466 `__","LWG","Miscellaneous minor fixes for chrono","Cologne","","" +"`P1474 `__","LWG","Helpful pointers for ContiguousIterator","Cologne","","" +"`P1502 `__","LWG","Standard library header units for C++20","Cologne","","" +"`P1522 `__","LWG","Iterator Difference Type and Integer Overflow","Cologne","","" +"`P1523 `__","LWG","Views and Size Types","Cologne","","" +"`P1612 `__","LWG","Relocate Endian's Specification","Cologne","|Complete|","10.0" +"`P1614 `__","LWG","The Mothership has Landed","Cologne","|In Progress|","" +"`P1638 `__","LWG","basic_istream_view::iterator should not be copyable","Cologne","","" +"`P1643 `__","LWG","Add wait/notify to atomic_ref","Cologne","","" +"`P1644 `__","LWG","Add wait/notify to atomic","Cologne","","" +"`P1650 `__","LWG","Output std::chrono::days with 'd' suffix","Cologne","","" +"`P1651 `__","LWG","bind_front should not unwrap reference_wrapper","Cologne","|Complete|","13.0" +"`P1652 `__","LWG","Printf corner cases in std::format","Cologne","","" +"`P1661 `__","LWG","Remove dedicated precalculated hash lookup interface","Cologne","|Nothing To Do|","" +"`P1754 `__","LWG","Rename concepts to standard_case for C++20, while we still can","Cologne","|In Progress|","" +"","","","","","" +"`P0883 `__","LWG","Fixing Atomic Initialization","Belfast","|Complete| [#note-P0883]_","13.0" +"`P1391 `__","LWG","Range constructor for std::string_view","Belfast","* *","" +"`P1394 `__","LWG","Range constructor for std::span","Belfast","* *","" +"`P1456 `__","LWG","Move-only views","Belfast","* *","" +"`P1622 `__","LWG","Mandating the Standard Library: Clause 32 - Thread support library","Belfast","* *","" +"`P1645 `__","LWG","constexpr for numeric algorithms","Belfast","|Complete|","12.0" +"`P1664 `__","LWG","reconstructible_range - a concept for putting ranges back together","Belfast","* *","" +"`P1686 `__","LWG","Mandating the Standard Library: Clause 27 - Time library","Belfast","* *","" +"`P1690 `__","LWG","Refinement Proposal for P0919 Heterogeneous lookup for unordered containers","Belfast","|Complete|","12.0" +"`P1716 `__","LWG","ranges compare algorithm are over-constrained","Belfast","* *","" +"`P1718 `__","LWG","Mandating the Standard Library: Clause 25 - Algorithms library","Belfast","* *","" +"`P1719 `__","LWG","Mandating the Standard Library: Clause 26 - Numerics library","Belfast","* *","" +"`P1720 `__","LWG","Mandating the Standard Library: Clause 28 - Localization library","Belfast","* *","" +"`P1721 `__","LWG","Mandating the Standard Library: Clause 29 - Input/Output library","Belfast","* *","" +"`P1722 `__","LWG","Mandating the Standard Library: Clause 30 - Regular Expression library","Belfast","* *","" +"`P1723 `__","LWG","Mandating the Standard Library: Clause 31 - Atomics library","Belfast","* *","" +"`P1855 `__","LWG","Make ````\ freestanding","Belfast","* *","" +"`P1862 `__","LWG","Ranges adaptors for non-copyable iterators","Belfast","* *","" +"`P1865 `__","LWG","Add max() to latch and barrier","Belfast","|Complete|","11.0" +"`P1869 `__","LWG","Rename 'condition_variable_any' interruptible wait methods","Belfast","* *","" +"`P1870 `__","LWG","forwarding-range is too subtle","Belfast","|In Progress|","" +"`P1871 `__","LWG","Should concepts be enabled or disabled?","Belfast","* *","" +"`P1872 `__","LWG","span should have size_type, not index_type","Belfast","|Complete|","10.0" +"`P1878 `__","LWG","Constraining Readable Types","Belfast","* *","" +"`P1892 `__","LWG","Extended locale-specific presentation specifiers for std::format","Belfast","* *","" +"`P1902 `__","LWG","Missing feature-test macros 2018-2019","Belfast","* *","" +"`P1959 `__","LWG","Remove std::weak_equality and std::strong_equality","Belfast","* *","" +"`P1960 `__","LWG","NB Comment Changes Reviewed by SG1","Belfast","* *","" +"`P1961 `__","LWG","Harmonizing the definitions of total order for pointers","Belfast","* *","" +"`P1965 `__","LWG","Blanket Wording for Specifying ""Hidden Friends""","Belfast","* *","" +"","","","","","" +"`P0586 `__","LWG","Safe integral comparisons","Prague","|Complete|","13.0" +"`P0593 `__","CWG","Implicit creation of objects for low-level object manipulation","Prague","* *","" +"`P1115 `__","LWG","Improving the Return Value of Erase-Like Algorithms II: Free erase/erase if","Prague","|Complete|","11.0" +"`P1243 `__","LWG","Rangify New Algorithms","Prague","* *","" +"`P1460 `__","LWG","Mandating the Standard Library: Clause 20 - Utilities library","Prague","* *","" +"`P1739 `__","LWG","Avoid template bloat for safe_ranges in combination with ""subrange-y"" view adaptors","Prague","* *","" +"`P1831 `__","LWG","Deprecating volatile: library","Prague","* *","" +"`P1868 `__","LWG","width: clarifying units of width and precision in std::format","Prague","* *","" +"`P1908 `__","CWG","Reserving Attribute Namespaces for Future Use","Prague","* *","" +"`P1937 `__","CWG","Fixing inconsistencies between constexpr and consteval functions","Prague","* *","" +"`P1956 `__","LWG","On the names of low-level bit manipulation functions","Prague","|Complete|","12.0" +"`P1957 `__","CWG","Converting from ``T*``\ to bool should be considered narrowing (re: US 212)","Prague","* *","" +"`P1963 `__","LWG","Fixing US 313","Prague","* *","" +"`P1964 `__","LWG","Wording for boolean-testable","Prague","|Complete|","13.0" +"`P1970 `__","LWG","Consistency for size() functions: Add ranges::ssize","Prague","* *","" +"`P1973 `__","LWG","Rename ""_default_init"" Functions, Rev1","Prague","* *","" +"`P1976 `__","LWG","Fixed-size span construction from dynamic range","Prague","|Complete|","11.0" +"`P1981 `__","LWG","Rename leap to leap_second","Prague","* *","" +"`P1982 `__","LWG","Rename link to time_zone_link","Prague","* *","" +"`P1983 `__","LWG","Wording for GB301, US296, US292, US291, and US283","Prague","* *","" +"`P1994 `__","LWG","elements_view needs its own sentinel","Prague","* *","" +"`P2002 `__","CWG","Defaulted comparison specification cleanups","Prague","* *","" +"`P2045 `__","LWG","Missing Mandates for the standard library","Prague","* *","" +"`P2085 `__","CWG","Consistent defaulted comparisons","Prague","* *","" +"`P2091 `__","LWG","Issues with range access CPOs","Prague","* *","" +"`P2101 `__","LWG","'Models' subsumes 'satisfies' (Wording for US298 and US300)","Prague","* *","" +"`P2102 `__","LWG","Make 'implicit expression variations' more explicit (Wording for US185)","Prague","* *","" +"`P2106 `__","LWG","Alternative wording for GB315 and GB316","Prague","* *","" +"`P2116 `__","LWG","Remove tuple-like protocol support from fixed-extent span","Prague","|Complete|","11.0" +"`P2231 `__","LWG","Missing constexpr in std::optional and std::variant","February 2021","|In progress|","13.0" +"`P2325 `__","LWG","Views should not be required to be default constructible","June 2021","|In progress|","" +"`P2210R2 `__","LWG",Superior String Splitting,"June 2021","","" +"`P2216R3 `__","LWG",std::format improvements,"June 2021","","" +"`P2281R1 `__","LWG",Clarifying range adaptor objects,"June 2021","","" +"`P2328R1 `__","LWG",join_view should join all views of ranges,"June 2021","","" +"`P2367R0 `__","LWG",Remove misuses of list-initialization from Clause 24,"June 2021","","" \ No newline at end of file diff --git a/gnu/llvm/libcxx/docs/Status/Cxx2b.rst b/gnu/llvm/libcxx/docs/Status/Cxx2b.rst new file mode 100644 index 00000000000..cdd1b9c2e29 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx2b.rst @@ -0,0 +1,50 @@ +.. _cxx2b-status: + +================================ +libc++ C++2b Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +In November 2020, the C++ standard committee adopted the first changes to the next version of the C++ standard, known here as "C++2b" (probably to be C++23). + +This page shows the status of libc++; the status of clang's support of the language features is `here `__. + +.. attention:: Features in unreleased drafts of the standard are subject to change. + +The groups that have contributed papers: + +- CWG - Core Language Working group +- LWG - Library working group +- SG1 - Study group #1 (Concurrency working group) + +.. note:: "Nothing to do" means that no library changes were needed to implement this change. + +.. _paper-status-cxx2b: + +Paper Status +==================================== + +.. csv-table:: + :file: Cxx2bPapers.csv + :header-rows: 1 + :widths: auto + +.. _issues-status-cxx2b: + +Library Working Group Issues Status +==================================== + +.. csv-table:: + :file: Cxx2bIssues.csv + :header-rows: 1 + :widths: auto + +Last Updated: 22-July-2021 diff --git a/gnu/llvm/libcxx/docs/Status/Cxx2bIssues.csv b/gnu/llvm/libcxx/docs/Status/Cxx2bIssues.csv new file mode 100644 index 00000000000..3e745c599aa --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx2bIssues.csv @@ -0,0 +1,99 @@ +"Issue #","Issue Name","Meeting","Status","First released version" +"`2839 `__","Self-move-assignment of library types, again","November 2020","","" +"`3117 `__","Missing ``packaged_task`` deduction guides","November 2020","","" +"`3143 `__","``monotonic_buffer_resource`` growth policy is unclear","November 2020","","" +"`3195 `__","What is the stored pointer value of an empty weak_ptr?","November 2020","","" +"`3211 `__","``std::tuple<>`` should be trivially constructible","November 2020","","" +"`3236 `__","Random access iterator requirements lack limiting relational operators domain to comparing those from the same range","November 2020","","" +"`3265 `__","``move_iterator``'s conversions are more broken after P1207","November 2020","Fixed by `LWG3435 `__","" +"`3435 `__","``three_way_comparable_with, reverse_iterator>``","November 2020","|Complete|","13.0" +"`3432 `__","Missing requirement for comparison_category","November 2020","","" +"`3447 `__","Deduction guides for ``take_view`` and ``drop_view`` have different constraints","November 2020","","" +"`3450 `__","The const overloads of ``take_while_view::begin/end`` are underconstrained","November 2020","","" +"`3464 `__","``istream::gcount()`` can overflow","November 2020","","" +"`2731 `__","Existence of ``lock_guard::mutex_type`` typedef unclear","November 2020","","" +"`2743 `__","P0083R3 ``node_handle`` private members missing ""exposition only"" comment","November 2020","","" +"`2820 `__","Clarify ```` macros","November 2020","","" +"`3120 `__","Unclear behavior of ``monotonic_buffer_resource::release()``","November 2020","","" +"`3170 `__","``is_always_equal`` added to ``std::allocator`` makes the standard library treat derived types as always equal","November 2020","","" +"`3036 `__","``polymorphic_allocator::destroy`` is extraneous","November 2020","","" +"`3171 `__","LWG2989 breaks ``directory_entry`` stream insertion","November 2020","","" +"`3306 `__","``ranges::advance`` violates its preconditions","November 2020","","" +"`3403 `__","Domain of ``ranges::ssize(E)`` doesn't ``match ranges::size(E)``","November 2020","","" +"`3404 `__","Finish removing subrange's conversions from pair-like","November 2020","","" +"`3405 `__","``common_view``'s converting constructor is bad, too","November 2020","","" +"`3406 `__","``elements_view::begin()`` and ``elements_view::end()`` have incompatible constraints","November 2020","","" +"`3419 `__","[algorithms.requirements]/15 doesn't reserve as many rights as it intends to","November 2020","","" +"`3420 `__","cpp17-iterator should check that the type looks like an iterator first","November 2020","","" +"`3421 `__","Imperfect ADL emulation for boolean-testable","November 2020","","" +"`3425 `__","``condition_variable_any`` fails to constrain its Lock parameters","November 2020","","" +"`3426 `__","``operator<=>(const unique_ptr&, nullptr_t)`` can't get no satisfaction","November 2020","","" +"`3427 `__","``operator<=>(const shared_ptr&, nullptr_t)`` definition ill-formed","November 2020","","" +"`3428 `__","``single_view``'s in place constructor should be explicit","November 2020","","" +"`3434 `__","``ios_base`` never reclaims memory for iarray and parray","November 2020","","" +"`3437 `__","``__cpp_lib_polymorphic_allocator`` is in the wrong header","November 2020","","" +"`3446 `__","``indirectly_readable_traits`` ambiguity for types with both ``value_type`` and ``element_type``","November 2020","","" +"`3448 `__","``transform_view``'s sentinel not comparable with ``iterator``","November 2020","","" +"`3449 `__","take_view and take_while_view's ``sentinel`` not comparable with their const iterator","November 2020","","" +"`3453 `__","Generic code cannot call ``ranges::advance(i, s)``","November 2020","","" +"`3455 `__","Incorrect Postconditions on ``unique_ptr`` move assignment","November 2020","|Nothing To Do|","" +"`3460 `__","Unimplementable ``noop_coroutine_handle`` guarantees","November 2020","","" +"`3461 `__","``convertible_to``'s description mishandles cv-qualified void","November 2020","","" +"`3465 `__","compare_partial_order_fallback requires ``F < E``","November 2020","","" +"`3466 `__","Specify the requirements for ``promise``/``future``/``shared_future`` consistently","November 2020","","" +"`3467 `__","``bool`` can't be an integer-like type","November 2020","","" +"`3472 `__","``counted_iterator`` is missing preconditions","November 2020","","" +"`3473 `__","Normative encouragement in non-normative note","November 2020","","" +"`3474 `__","Nesting ``join_views`` is broken because of CTAD","November 2020","","" +"`3476 `__","``thread`` and ``jthread`` constructors require that the parameters be move-constructible but never move construct the parameters","November 2020","","" +"`3477 `__","Simplify constraints for semiregular-box","November 2020","","" +"`3482 `__","``drop_view``'s const begin should additionally require sized_range","November 2020","","" +"`3483 `__","``transform_view::iterator``'s difference is overconstrained","November 2020","","" +"","","","","" +"`3391 `__","Problems with ``counted_iterator``/``move_iterator::base() const &``","February 2021","","" +"`3433 `__","``subrange::advance(n)`` has UB when ``n < 0``","February 2021","","" +"`3490 `__","``ranges::drop_while_view::begin()`` is missing a precondition","February 2021","","" +"`3492 `__","Minimal improvements to ``elements_view::iterator``","February 2021","","" +"`3494 `__","Allow ranges to be conditionally borrowed","February 2021","Superseded by `P2017R1 `__","" +"`3495 `__","``constexpr launder`` makes pointers to inactive members of unions usable","February 2021","","" +"`3500 `__","``join_view::iterator::operator->()`` is bogus","February 2021","","" +"`3502 `__","``elements_view`` should not be allowed to return dangling reference","February 2021","","" +"`3505 `__","``split_view::outer-iterator::operator++`` misspecified","February 2021","","" +"","","","","" +`2774 `__,"``std::function`` construction vs assignment","June 2021","","" +`2818 `__,"``::std::`` everywhere rule needs tweaking","June 2021","","" +`2997 `__,"LWG 491 and the specification of ``{forward_,}list::unique``","June 2021","","" +`3410 `__,"``lexicographical_compare_three_way`` is overspecified","June 2021","","" +`3430 `__,"``std::fstream`` & co. should be constructible from string_view","June 2021","","" +`3462 `__,"§[formatter.requirements]: Formatter requirements forbid use of ``fc.arg()``","June 2021","","" +`3481 `__,"``viewable_range`` mishandles lvalue move-only views","June 2021","","" +`3506 `__,"Missing allocator-extended constructors for ``priority_queue``","June 2021","","" +`3517 `__,"``join_view::iterator``'s ``iter_swap`` is underconstrained","June 2021","","" +`3518 `__,"Exception requirements on char trait operations unclear","June 2021","","" +`3519 `__,"Incomplete synopses for classes","June 2021","","" +`3520 `__,"``iter_move`` and ``iter_swap`` are inconsistent for ``transform_view::iterator``","June 2021","","" +`3521 `__,"Overly strict requirements on ``qsort`` and ``bsearch``","June 2021","","" +`3522 `__,"Missing requirement on ``InputIterator`` template parameter for ``priority_queue`` constructors","June 2021","","" +`3523 `__,"``iota_view::sentinel`` is not always ``iota_view``'s sentinel","June 2021","","" +`3526 `__,"Return types of ``uses_allocator_construction_args`` unspecified","June 2021","","" +`3527 `__,"``uses_allocator_construction_args`` handles rvalue pairs of rvalue references incorrectly","June 2021","","" +`3528 `__,"``make_from_tuple`` can perform (the equivalent of) a C-style cast","June 2021","","" +`3529 `__,"``priority_queue(first, last)`` should construct ``c`` with ``(first, last)``","June 2021","","" +`3530 `__,"``BUILTIN-PTR-MEOW`` should not opt the type out of syntactic checks","June 2021","","" +`3532 `__,"``split_view::inner-iterator::operator++(int)`` should depend on ``Base``","June 2021","","" +`3533 `__,"Make ``base() const &`` consistent across iterator wrappers that supports ``input_iterators``","June 2021","","" +`3536 `__,"Should ``chrono::from_stream()`` assign zero to duration for failure?","June 2021","","" +`3539 `__,"``format_to`` must not copy models of ``output_iterator``","June 2021","","" +`3540 `__,"§[format.arg] There should be no const in ``basic_format_arg(const T* p)``","June 2021","","" +`3541 `__,"``indirectly_readable_traits`` should be SFINAE-friendly for all types","June 2021","","" +`3542 `__,"``basic_format_arg`` mishandles ``basic_string_view`` with custom traits","June 2021","","" +`3543 `__,"Definition of when ``counted_iterators`` refer to the same sequence isn't quite right","June 2021","","" +`3544 `__,"``format-arg-store::args`` is unintentionally not exposition-only","June 2021","","" +`3546 `__,"``common_iterator``'s postfix-proxy is not quite right","June 2021","","" +`3548 `__,"``shared_ptr`` construction from ``unique_ptr`` should move (not copy) the deleter","June 2021","","" +`3549 `__,"``view_interface`` is overspecified to derive from ``view_base``","June 2021","","" +`3551 `__,"``borrowed_{iterator,subrange}_t`` are overspecified","June 2021","","" +`3552 `__,"Parallel specialized memory algorithms should require forward iterators","June 2021","","" +`3553 `__,"Useless constraint in ``split_view::outer-iterator::value_type::begin()``","June 2021","","" +`3555 `__,"``{transform,elements}_view::iterator::iterator_concept`` should consider const-qualification of the underlying range","June 2021","","" +"","","","","" diff --git a/gnu/llvm/libcxx/docs/Status/Cxx2bPapers.csv b/gnu/llvm/libcxx/docs/Status/Cxx2bPapers.csv new file mode 100644 index 00000000000..4df0bfcddbf --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Cxx2bPapers.csv @@ -0,0 +1,25 @@ +"Paper #","Group","Paper Name","Meeting","Status","First released version" +"`P0881R7 `__","LWG","A Proposal to add stacktrace library","Autumn 2020","","" +"`P0943R6 `__","LWG","Support C atomics in C++","Autumn 2020","","" +"`P1048R1 `__","LWG","A proposal for a type trait to detect scoped enumerations","Autumn 2020","|Complete|","12.0" +"`P1679R3 `__","LWG","string contains function","Autumn 2020","|Complete|","12.0" +"","","","","","" +"`P1682R3 `__","LWG","std::to_underlying for enumerations","February 2021","|Complete|","13.0" +"`P2017R1 `__","LWG","Conditionally borrowed ranges","February 2021","","" +"`P2160R1 `__","LWG","Locks lock lockables","February 2021","","" +"`P2162R2 `__","LWG","Inheriting from std::variant","February 2021","|Complete|","13.0" +"`P2212R2 `__","LWG","Relax Requirements for time_point::clock","February 2021","","" +"`P2259R1 `__","LWG","Repairing input range adaptors and counted_iterator","February 2021","","" +"","","","","","" +"`P0401R6 `__","LWG","Providing size feedback in the Allocator interface","June 2021","", +"`P0448R4 `__","LWG","A strstream replacement using span as buffer","June 2021","","" +"`P1132R8 `__","LWG","out_ptr - a scalable output pointer abstraction","June 2021","","" +"`P1328R1 `__","LWG","Making std::type_info::operator== constexpr","June 2021","","" +"`P1425R4 `__","LWG","Iterators pair constructors for stack and queue","June 2021","","" +"`P1518R2 `__","LWG","Stop overconstraining allocators in container deduction guides","June 2021","|Complete|","13.0" +"`P1659R3 `__","LWG","starts_with and ends_with","June 2021","","" +"`P1951R1 `__","LWG","Default Arguments for pair Forwarding Constructor","June 2021","","" +"`P1989R2 `__","LWG","Range constructor for std::string_view","June 2021","","" +"`P2136R3 `__","LWG","invoke_r","June 2021","","" +"`P2166R1 `__","LWG","A Proposal to Prohibit std::basic_string and std::basic_string_view construction from nullptr","June 2021","|Complete|","13.0" +"","","","","","" \ No newline at end of file diff --git a/gnu/llvm/libcxx/docs/Status/Format.rst b/gnu/llvm/libcxx/docs/Status/Format.rst new file mode 100644 index 00000000000..948b1b744ae --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Format.rst @@ -0,0 +1,53 @@ +.. format-status: + +================================ +libc++ Format Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +======== + +This document contains the status of the C++20 Format library in libc++. It is used to +track both the status of the sub-projects of the Format library and who is assigned to +these sub-projects. This is imperative to effective implementation so that work is not +duplicated and implementors are not blocked by each other. + + +If you are interested in contributing to the libc++ Format library, please send +a message to the #libcxx channel in the LLVM discord. Please *do not* start +working on any of the assigned items below. + + +Sub-Projects in the Format library +================================== + +.. csv-table:: + :file: FormatPaper.csv + :header-rows: 1 + :widths: auto + + +Misc. Items and TODOs +===================== + +(Please mark all Format-related TODO comments with the string ``TODO FMT``, so we +can find them easily.) + + * C++23 may break the ABI with `P2216 `_. + This ABI break may be backported to C++20. Therefore the library will not + be available on platforms where the ABI break is an issue. + + +Paper and Issue Status +====================== + +.. csv-table:: + :file: FormatIssues.csv + :header-rows: 1 + :widths: auto diff --git a/gnu/llvm/libcxx/docs/Status/FormatIssues.csv b/gnu/llvm/libcxx/docs/Status/FormatIssues.csv new file mode 100644 index 00000000000..7f4218d33f0 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/FormatIssues.csv @@ -0,0 +1,31 @@ +Number,Name,Assignee,Patch,Status,First released version +`P0645 `_,"Text Formatting",Mark de Wever,,|partial|, +`P1652 `_,"Printf corner cases in std::format",Mark de Wever,`D103433 `__,Review, +`P1892 `_,"Extended locale-specific presentation specifiers for std::format",Mark de Wever,`D103368 `__,Review, +`P1868 `_,"width: clarifying units of width and precision in std::format (Implements the unicode support.)",Mark de Wever,"`D103413 `__ `D103425 `__ `D103670 `__",Review, +`P2216 `_,"std::format improvements",,,, +`LWG-3242 `_,"std::format: missing rules for arg-id in width and precision",Mark de Wever,`D103368 `__,Review, +`LWG-3243 `_,"std::format and negative zeroes",,,, +`LWG-3246 `_,"What are the constraints on the template parameter of basic_format_arg?",,,, +`LWG-3248 `_,"std::format #b, #B, #o, #x, and #X presentation types misformat negative numbers",Mark de Wever,`D103433 `__,Review, +`LWG-3250 `_,"std::format: # (alternate form) for NaN and inf",,,, +`LWG-3327 `_,"Format alignment specifiers vs. text direction",,,|Nothing To Do|, +`LWG-3340 `_,"Formatting functions should throw on argument/format string mismatch in [format.functions]",,,, +`LWG-3371 `_,"visit_format_arg and make_format_args are not hidden friends",Mark de Wever,`D103357 `__,Review, +`LWG-3372 `_,"vformat_to should not try to deduce Out twice",,,, +`LWG-3373 `_,"{to,from}_chars_result and format_to_n_result need the 'we really mean what we say'",,,, +`LWG-3462 `_,"§[formatter.requirements]: Formatter requirements forbid use of fc.arg()",,,, +`LWG-3539 `_,"format_to must not copy models of output_iterator",,,, +`LWG-3540 `_,"§[format.arg] There should be no const in basic_format_arg(const T* p)",,,, +`LWG-3541 `_,"indirectly_readable_traits should be SFINAE-friendly for all types",,,, +`LWG-3542 `_,"basic_format_arg mishandles basic_string_view with custom traits",,,, +`LWG-3544 `_,"format-arg-store::args is unintentionally not exposition-only",,,, + +`P1361 `_,"Integration of chrono with text formatting",,,, +`LWG-3218 `_,"Modifier for %d parse flag does not match POSIX and format specification",,,, +`LWG-3230 `_,"Format specifier %y/%Y is missing locale alternative versions",,,, +`LWG-3241 `_,"chrono-spec grammar ambiguity in [time.format]",,,, +`LWG-3262 `_,"Formatting of negative durations is not specified",,,, +`LWG-3270 `_,"Parsing and formatting %j with durations",,,, +`LWG-3272 `_,"%I%p should parse/format duration since midnight",,,, +`LWG-3332 `_,"Issue in [time.format]",,,, diff --git a/gnu/llvm/libcxx/docs/Status/FormatPaper.csv b/gnu/llvm/libcxx/docs/Status/FormatPaper.csv new file mode 100644 index 00000000000..afdf88355c5 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/FormatPaper.csv @@ -0,0 +1,48 @@ +Section,Description,Dependencies,Assignee,Patch,Status,First released version +[charconv.to.chars],"Fix integral conformance",,Mark de Wever,`D100722 `__,|Complete|,Clang 13 +[charconv.to.chars],"Add floating-point conversion",`D100722 `__,"Mark de Wever (Code provided by Stephan T. Lavavej of Microsoft)",`D70631 `__,In progress, +[format.error],"Class format_error",,Mark de Wever,`D92214 `__,|Complete|,Clang 13 +[format.parse.ctx],"Class template basic_format_parse_context",,Mark de Wever,`D93166 `__,|Complete|,Clang 13 +[format.context],"Class template basic_format_context",,Mark de Wever,`D103357 `__,Review, +[format.args],"Class template basic_format_args",,Mark de Wever,`D103357 `__,Review, +[format.arg],"Class template basic_format_arg",,Mark de Wever,`D103357 `__,Review, +[format.arg],"Class template basic_format_arg - handle",,,,,, +[format.arg],"Class template basic_format_arg - pointers",,,,,, +[format.arg.store],"Class template format-arg-store",,Mark de Wever,`D103357 `__,Review, +[format.formatter.spec],"Formatter specializations - character types",,Mark de Wever,"`D96664 `__ `D103466 `__",Review, +[format.formatter.spec],"Formatter specializations - string types",,Mark de Wever,"`D96664 `__ `D103425 `__",Review, +[format.formatter.spec],"Formatter specializations - boolean type",,Mark de Wever,"`D96664 `__ `D103670 `__",Review, +[format.formatter.spec],"Formatter specializations - integral types",,Mark de Wever,"`D96664 `__ `D103433 `__",Review, +[format.formatter.spec],"Formatter specializations - floating-point types",`D70631 `__,Mark de Wever,`D96664 `__,Review, +[format.formatter.spec],"Formatter specializations - pointer types",,,,,, +[format.string.std],"Standard format specifiers - character types",,Mark de Wever,`D103368 `__,Review, +[format.string.std],"Standard format specifiers - string types",`D103379 `__,Mark de Wever,"`D103368 `__ `D103413 `__",Review, +[format.string.std],"Standard format specifiers - boolean type",`D103379 `__,Mark de Wever,"`D103368 `__ `D103413 `__",Review, +[format.string.std],"Standard format specifiers - integral types",,Mark de Wever,`D103368 `__,Review, +[format.string.std],"Standard format specifiers - floating-point types",,Mark de Wever,,,, +[format.string.std],"Standard format specifiers - pointer types",,Mark de Wever,,,, +[format.functions],"Format functions - format(string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format(wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format(const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format(const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(string_view fmt, format_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(wstring_view fmt, wformat_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(const locale& loc, string_view fmt, format_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat(const locale& loc, wstring_view fmt, wformat_args args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to(Out out, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to(Out out, const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, string_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, wstring_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, const locale& loc, string_view fmt, format_args_t, char> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - vformat_to(Out out, const locale& loc, wstring_view fmt,format_args_t, wchar_t> args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n(Out out, iter_difference_t n, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n(Out out, iter_difference_t n, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n_result format_to_n(Out out, iter_difference_t n, const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - format_to_n_result format_to_n(Out out, iter_difference_t n, const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(const locale& loc, string_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - formatted_size(const locale& loc, wstring_view fmt, const Args&... args);",,Mark de Wever,`D96664 `__,Review, +[format.functions],"Format functions - Implement locale support",,Mark de Wever,,In progress,, +[format.functions],"Format functions - Improve performance format_to_n",,Mark de Wever,,,, +[format.functions],"Format functions - Improve performance formatted size",,Mark de Wever,,,, diff --git a/gnu/llvm/libcxx/docs/Status/Ranges.rst b/gnu/llvm/libcxx/docs/Status/Ranges.rst new file mode 100644 index 00000000000..66b2ba375e0 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/Ranges.rst @@ -0,0 +1,51 @@ +.. ranges-status: + +================================ +libc++ Ranges Status +================================ + +.. include:: ../Helpers/Styles.rst + +.. contents:: + :local: + + +Overview +================================ + +This document contains the status of the C++20 Ranges library in libc++. It is used to +track both the status of the sub-projects of the ranges library and who is assigned to +these sub-projects. This is imperative to effective implementation so that work is not +duplicated and implementors are not blocked by each other. + +If you are interested in contributing to the libc++ Ranges library, please send a message +to the #libcxx channel in the LLVM discord. Please *do not* start working on any of the +assigned items below. + + +Sub-Projects in the One Ranges Proposal +======================================= + +.. csv-table:: + :file: RangesPaper.csv + :header-rows: 1 + :widths: auto + + +Misc. Items and TODOs +==================================== + +(Note: files with required updates will contain the TODO at the beginning of the list item +so they can be easily found via global search.) + + * TODO(XX_SPACESHIP_CONCEPTS): when spaceship support is added to various STL types, we need to update some concept tests. + +Paper and Issue Status +==================================== + +(Note: stolen from MSVC `here `_.) + +.. csv-table:: + :file: RangesIssues.csv + :header-rows: 1 + :widths: auto \ No newline at end of file diff --git a/gnu/llvm/libcxx/docs/Status/RangesIssues.csv b/gnu/llvm/libcxx/docs/Status/RangesIssues.csv new file mode 100644 index 00000000000..4cd6c3d1122 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/RangesIssues.csv @@ -0,0 +1,80 @@ +"Number","Name","Status","Assignee" +`P0896R4 `__,,, +`P1035R7 `__,Input Range Adaptors,, +`P1207R4 `__,Movability Of Single-Pass Iterators,, +`P1243R4 `__,Rangify New Algorithms,, +`P1248R1 `__,Fixing Relations,, +`P1252R2 `__,Ranges Design Cleanup,, +`P1391R4 `__,Range Constructor For string_view,, +`P1456R1 `__,Move-Only Views,, +`P1474R1 `__,Helpful Pointers For contiguous_iterator,, +`P1522R1 `__,Iterator Difference Type And Integer Overflow,, +`P1523R1 `__,Views And Size Types,, +`P1638R1 `__,basic_istream_view::iterator Should Not Be Copyable,, +`P1716R3 `__,Range Comparison Algorithms Are Over-Constrained,, +`P1739R4 `__,Avoiding Template Bloat For Ranges,, +`P1862R1 `__,Range Adaptors For Non-Copyable Iterators,, +`P1870R1 `__,safe_range,, +`P1871R1 `__,disable_sized_sentinel_for,, +`P1878R1 `__,Constraining Readable Types,, +`P1970R2 `__,ranges::ssize,, +`P1983R0 `__,Fixing Minor Ranges Issues,, +`P1994R1 `__,elements_view Needs Its Own sentinel,, +`P2091R0 `__,Fixing Issues With Range Access CPOs,, +`P2106R0 `__,Range Algorithm Result Types,, + +`P2325R3 `__,Views should not be required to be default constructible ,, +`P2328R1 `__,join_view should join all views of ranges,, +`P2210R2 `__,Superior String Splitting,, +`P2281R1 `__,Clarifying range adaptor objects,, +`P2367R0 `__,Remove misuses of list-initialization from Clause 24,, + +`LWG3169 `__, ranges permutation generators discard useful information,, +`LWG3173 `__, Enable CTAD for ref-view,, +`LWG3179 `__, subrange should always model Range,, +`LWG3180 `__, Inconsistently named return type for ranges::minmax_element,, +`LWG3183 `__, Normative permission to specialize Ranges variable templates,, +`LWG3186 `__, "ranges removal, partition, and partial_sort_copy algorithms discard useful information",, +`LWG3191 `__, std::ranges::shuffle synopsis does not match algorithm definition,, +`LWG3276 `__, Class split_view::outer_iterator::value_type should inherit from view_interface,, +`LWG3280 `__, View converting constructors can cause constraint recursion and are unneeded,, +`LWG3281 `__, Conversion from pair-like types to subrange is a silent semantic promotion,, +`LWG3282 `__, subrange converting constructor should disallow derived to base conversions,, +`LWG3286 `__, ranges::size is not required to be valid after a call to ranges::begin on an input range,, +`LWG3291 `__, iota_view::iterator has the wrong iterator_category,, +`LWG3292 `__, iota_view is under-constrained,, +`LWG3299 `__, Pointers don't need customized iterator behavior,, +`LWG3301 `__, transform_view::iterator has incorrect iterator_category,, +`LWG3302 `__, Range adaptor objects keys and values are unspecified,, +`LWG3313 `__, join_view::iterator::operator-- is incorrectly constrained,, +`LWG3323 `__, has-tuple-element helper concept needs convertible_to,, +`LWG3325 `__, Constrain return type of transformation function for transform_view,, +`LWG3335 `__, range_size_t and views::all_t,, +`LWG3355 `__, The memory algorithms should support move-only input iterators introduced by P1207,, +`LWG3363 `__, drop_while_view should opt-out of sized_range,, +`LWG3364 `__, Initialize data members of ranges and their iterators,, +`LWG3381 `__, begin and data must agree for contiguous_range,, +`LWG3384 `__, transform_view::sentinel has an incorrect operator-,, +`LWG3385 `__, common_iterator is not sufficiently constrained for non-copyable iterators,, +`LWG3387 `__, [range.reverse.view] reverse_view unintentionally requires range,, +`LWG3388 `__, view iterator types have ill-formed <=> operators,, +`LWG3389 `__, A move-only iterator still does not have a counted_iterator,, +`LWG3397 `__, ranges::basic_istream_view::iterator should not provide iterator_category,, +`LWG3398 `__, tuple_element_t is also wrong for const subrange,, +`LWG3474 `__, Nesting join_views is broken because of CTAD,, +`LWG3481 `__,"viewable_range mishandles lvalue move-only views",, +`LWG3500 `__, join_view::iterator::operator->() is bogus,, +`LWG3505 `__, split_view::outer-iterator::operator++ misspecified,, +`LWG3517 `__,"join_view::iterator's iter_swap is underconstrained",, +`LWG3520 `__,"iter_move and iter_swap are inconsistent for transform_view::iterator",, +`LWG3522 `__,"Missing requirement on InputIterator template parameter for priority_queue constructors",, +`LWG3523 `__,"iota_view::sentinel is not always iota_view's sentinel",, +`LWG3532 `__,"split_view::inner-iterator::operator++(int) should depend on Base",, +`LWG3533 `__,"Make base() const & consistent across iterator wrappers that supports input_iterators",, +`LWG3541 `__,"indirectly_readable_traits should be SFINAE-friendly for all types",, +`LWG3543 `__,"Definition of when counted_iterators refer to the same sequence isn't quite right",, +`LWG3546 `__,"common_iterator's postfix-proxy is not quite right",, +`LWG3549 `__,"view_interface is overspecified to derive from view_base",, +`LWG3551 `__,"borrowed_{iterator,subrange}_t are overspecified",, +`LWG3553 `__,"Useless constraint in split_view::outer-iterator::value_type::begin()",, +`LWG3555 `__,"{transform,elements}_view::iterator::iterator_concept should consider const-qualification of the underlying range",, diff --git a/gnu/llvm/libcxx/docs/Status/RangesPaper.csv b/gnu/llvm/libcxx/docs/Status/RangesPaper.csv new file mode 100644 index 00000000000..a7d28970669 --- /dev/null +++ b/gnu/llvm/libcxx/docs/Status/RangesPaper.csv @@ -0,0 +1,149 @@ +Section,Description,Dependencies,Assignee,Complete +[tuple.helper],Update includes.,None,Unassigned,Not started +`[range.cmp] `_,"| `ranges::equal_to `_ +| `ranges::not_equal_to `_ +| `ranges::less `_ +| `ranges::greater `_ +| `ranges::less_equal `_ +| `ranges::greater_equal `_",None,Zoe Carver,✅ +`[readable.traits] `_,"| `indirectly_readable_traits `_ +| `iter_value_t `_",None,Christopher Di Bella,✅ +`[incrementable.traits] `_,"| `incrementable_traits `_ +| `iter_difference_t `_",,Christopher Di Bella,✅ +`[iterator.traits] `_,`Updates to iterator_traits `_,"| indirectly_readable_traits +| incrementable_traits",Christopher Di Bella,✅ +`[special.mem.concepts] `_,"| *no-throw-input-iterator* +| *no-throw-sentinel-for* +| *no-throw-input-range* +| *no-throw-forward-iterator* +| *no-throw-forward-range*","| [iterator.concepts] +| [range.refinements]",Unassigned,Not started +`[specialized.algorithms] `_,"| ranges::uninitialized_default_construct +| ranges::uninitialized_default_construct_n +| ranges::uninitialized_value_construct +| ranges::uninitialized_value_construct_n +| ranges::uninitialized_copy +| ranges::uninitialized_copy_n +| ranges::uninitialized_move +| ranges::uninitialized_move_n +| ranges::uninitialized_fill +| ranges::uninitialized_fill_n +| ranges::construct_at +| ranges::destroy +| ranges::destroy_at +| ranges::destroy_n",[special.mem.concepts],Unassigned,Not started +[strings],Adds begin/end and updates const_iterator.,[iterator.concepts],Unassigned,Not started +[views.span],Same as [strings],[iterator.concepts],Unassigned,Not started +`[iterator.cust.move] `_,`ranges::iter_move `_,,Zoe Carver,✅ +`[iterator.cust.swap] `_,`ranges::iter_swap `_,iter_value_t,Zoe Carver,✅ +`[iterator.concepts] `_,"| `indirectly_readable `_ +| `indirectly_writable `_ +| `weakly_incrementable `_ +| `incrementable `_ +| `input_or_output_iterator `_ +| `sentinel_for `_ +| `sized_sentinel_for `_ +| `input_iterator `_ +| `output_iterator `_ +| `forward_iterator `_ +| `bidirectional_iterator `_ +| `random_access_iterator `_ +| `contiguous_iterator `_",,Various,✅ +`[indirectcallable.indirectinvocable] `_,"| indirectly_unary_invocable +| `indirectly_regular_unary_invocable `_ +| `indirectly_unary_predicate `_ +| `indirectly_binary_predicate `_ +| `indirectly_equivalence_relation `_ +| `indirectly_strict_weak_order `_",[readable.traits],Louis Dionne,✅ +`[projected] `_,`ranges::projected `_,[iterator.concepts],Louis Dionne,✅ +`[common.alg.req] `_: pt. 1,"| `indirectly_movable `_ +| `indirectly_movable_storable `_ +| indirectly_copyable +| indirectly_copyable_storable",[iterator.concepts],Zoe Carver,In progress +[common.alg.req]: pt. 2,indirectly_swappable,"| [iterator.concepts] +| [iterator.cust.swap]",Zoe Carver,✅ +[common.alg.req]: pt. 3,indirectly_comparable,[projected],Louis Dionne,Not started +[common.alg.req]: pt. 4,"| permutable +| mergeable +| sortable",[iterator.concepts],Unassigned,Not started +[std.iterator.tags],,[iterator.traits],Unassigned,Not started +`[range.iter.ops] `_,"| `ranges::advance `_ +| `ranges::distance `_ +| `ranges::next `_ +| `ranges::prev `_",[iterator.concepts],Christopher Di Bella,In progress +[predef.iterators],Updates to predefined iterators.,"| [iterator.concepts] +| [iterator.cust.swap] +| [iterator.cust.move]",Unassigned,Not started +[move.sentinel],,[predef.iterators],Unassigned,Not started +[common.iterator],,"| [iterator.concepts] +| [iterator.cust.swap] +| [iterator.cust.move]",Zoe Carver,✅ +[default.sentinels],std::default_sentinel_t.,No dependencies,Zoe Carver,✅ +[counted.iterator],,"| [iterator.concepts] +| [iterator.cust.swap] +| [iterator.cust.move] +| [default.sentinels]",Zoe Carver,✅ +[stream.iterators],,[default.sentinels],Unassigned,Not started +`[range.access] `_,"| `ranges::begin `_ +| `ranges::end `_ +| `range::cbegin `_ +| `ranges::cend `_ +| ranges::rbegin +| ranges::rend +| ranges::crbegin +| ranges::crend +| `ranges::size `_ +| `ranges::ssize `_ +| `ranges::empty `_ +| `ranges::data `_ +| ranges::cdata",[iterator.concepts],Christopher Di Bella and Zoe Carver,In progress +`[range.range] `_,"| `ranges::range `_ +| `ranges::borrowed_range `_ +| `ranges::enable_borrowed_range `_ +| `ranges::iterator_t `_ +| `ranges::sentinel_t `_ +| `ranges::range_difference_t `_ +| `ranges::range_size_t `_ +| `ranges::range_value_t `_ +| `ranges::range_reference_t `_ +| `ranges::range_rvalue_reference_t `_",[range.access],Christopher Di Bella,✅ +`[range.sized] `_,"| `ranges::sized_range `_ +| `ranges::disable_sized_range `_","| [range.primitives] +| [range.range]",Christopher Di Bella,✅ +`[range.view] `_,"| `ranges::enable_view `_ +| `ranges::view_base `_ +| `ranges::view `_",[range.range],Louis Dionne,✅ +`[range.refinements] `_,"| ranges::output_range +| `ranges::input_range `_ +| `ranges::forward_range: `D100275 `_ +| `ranges::bidirectional_range `_ +| `ranges::random_access_range `_ +| ranges::contiguous_range +| `ranges::common_range `_",[range.range],Christopher Di Bella,✅ +`[range.refinements]`_,`ranges::viewable_range `_,[range.range],Louis Dionne,✅ +`[range.utility.helpers] `_,"| *simple-view* +| *has-arrow* +| *not-same-as*","| [range.range] +| [iterator.concept.input]",Zoe Carver,✅ +`[view.interface] `_,"`ranges::view_interface `_","| [ranges.range] +| [range.view] +| [range.iterator.op.prev] +| [range.refinements]",Zoe Carver,✅ +`[range.subrange] `_,`ranges::subrange `_,[view.interface],Zoe Carver,✅ +`[range.dangling] `_,"| ranges::dangling +| ranges::borrowed_iterator_t +| ranges::borrowed_subrange_t","| [range.range] +| [range.subrange]",Christopher Di Bella,✅ +`[range.all] `_,`view::all `_,"[range.subrange], [range.view.ref]",Zoe Carver,✅ +`[range.view.ref] `_,`ref-view `_,[view.interface],Zoe Carver,✅ +`[range.filter] `_,filter_view,[range.all],Louis Dionne,Not started +`[range.transform] `_,`transform_view `_,[range.all],Zoe Carver,✅ +`[range.iota] `_,iota_view,[range.all],Louis Dionne,Not started +`[range.take] `_,take_view,[range.all],Zoe Carver,In Progress +`[range.join] `_,join_view,[range.all],Christopher Di Bella,Not started +`[range.empty] `_,`empty_view `_,[view.interface],Zoe Carver,✅ +`[range.single] `_,single_view,[view.interface],Zoe Carver,In Progress +`[range.split] `_,split_view,[range.all],Unassigned,Not started +`[range.counted] `_,view::counted,[range.subrange],Zoe Carver,Not started +`[range.common] `_,common_view,[range.all],Zoe Carver,✅ +`[range.reverse] `_,reverse_view,[range.all],Unassigned,Not started diff --git a/gnu/llvm/libcxx/docs/TestingLibcxx.rst b/gnu/llvm/libcxx/docs/TestingLibcxx.rst index 0c9c87d489b..ddb8a6d09b5 100644 --- a/gnu/llvm/libcxx/docs/TestingLibcxx.rst +++ b/gnu/llvm/libcxx/docs/TestingLibcxx.rst @@ -27,16 +27,22 @@ Usage After building libc++, you can run parts of the libc++ test suite by simply running ``llvm-lit`` on a specified test or directory. If you're unsure whether the required libraries have been built, you can use the -`check-cxx-deps` target. For example: +`cxx-test-depends` target. For example: .. code-block:: bash $ cd - $ make -C check-cxx-deps # If you want to make sure the targets get rebuilt + $ make -C cxx-test-depends # If you want to make sure the targets get rebuilt $ /bin/llvm-lit -sv libcxx/test/std/re # Run all of the std::regex tests $ /bin/llvm-lit -sv libcxx/test/std/depr/depr.c.headers/stdlib_h.pass.cpp # Run a single test $ /bin/llvm-lit -sv libcxx/test/std/atomics libcxx/test/std/threads # Test std::thread and std::atomic +In the default configuration, the tests are built against headers that form a +fake installation root of libc++. This installation root has to be updated when +changes are made to the headers, so you should re-run the `cxx-test-depends` +target before running the tests manually with `lit` when you make any sort of +change, including to the headers. + Sometimes you'll want to change the way LIT is running the tests. Custom options can be specified using the `--param==` flag. The most common option you'll want to change is the standard dialect (ie -std=c++XX). By default the @@ -63,8 +69,8 @@ Some other common examples include: # Specify a custom compiler. $ /bin/llvm-lit -sv libcxx/test/std --param=cxx_under_test=/opt/bin/g++ - # Enable warnings in the test suite - $ /bin/llvm-lit -sv libcxx/test --param=enable_warnings=true + # Disable warnings in the test suite + $ /bin/llvm-lit -sv libcxx/test --param=enable_warnings=False # Use UBSAN when running the tests. $ /bin/llvm-lit -sv libcxx/test --param=use_sanitizer=Undefined @@ -74,19 +80,20 @@ Using a custom site configuration By default, the libc++ test suite will use a site configuration that matches the current CMake configuration. It does so by generating a ``lit.site.cfg`` -file in the build directory from the ``libcxx/test/lit.site.cfg.in`` template, -and pointing ``llvm-lit`` (which is a wrapper around ``llvm/utils/lit/lit.py``) -to that file. So when you're running ``/bin/llvm-lit``, the generated -``lit.site.cfg`` file is always loaded instead of ``libcxx/test/lit.cfg.py``. -If you want to use a custom site configuration, simply point the CMake build -to it using ``-DLIBCXX_TEST_CONFIG=``, and that site -configuration will be used instead. That file can use CMake variables inside -itself to make configuration easier. +file in the build directory from one of the configuration file templates in +``libcxx/test/configs/``, and pointing ``llvm-lit`` (which is a wrapper around +``llvm/utils/lit/lit.py``) to that file. So when you're running +``/bin/llvm-lit``, the generated ``lit.site.cfg`` file is always loaded +instead of ``libcxx/test/lit.cfg.py``. If you want to use a custom site +configuration, simply point the CMake build to it using +``-DLIBCXX_TEST_CONFIG=``, and that site configuration +will be used instead. That file can use CMake variables inside it to make +configuration easier. .. code-block:: bash $ cmake -DLIBCXX_TEST_CONFIG= - $ make -C check-cxx-deps + $ make -C cxx-test-depends $ /bin/llvm-lit -sv libcxx/test # will use your custom config file @@ -119,7 +126,7 @@ default. .. option:: std= - **Values**: c++03, c++11, c++14, c++17, c++2a + **Values**: c++03, c++11, c++14, c++17, c++20, c++2b Change the standard version used when building the tests. @@ -146,7 +153,7 @@ default. **Default**: False Enable or disable testing against the installed version of libc++ library. - This impacts whether the ``with_system_cxx_lib`` Lit feature is defined or + This impacts whether the ``use_system_cxx_lib`` Lit feature is defined or not. The ``cxx_library_root`` and ``cxx_runtime_root`` parameters should still be used to specify the path of the library to link to and run against, respectively. @@ -186,7 +193,7 @@ few requirements to the test suite. Here's some stuff you should know: - All tests are run in a temporary directory that is unique to that test and cleaned up after the test is done. - When a test needs data files as inputs, these data files can be saved in the - repository (when reasonable) and referrenced by the test as + repository (when reasonable) and referenced by the test as ``// FILE_DEPENDENCIES: ``. Copies of these files or directories will be made available to the test in the temporary directory where it is run. diff --git a/gnu/llvm/libcxx/docs/UsingLibcxx.rst b/gnu/llvm/libcxx/docs/UsingLibcxx.rst index 4c37ada334b..863123688e6 100644 --- a/gnu/llvm/libcxx/docs/UsingLibcxx.rst +++ b/gnu/llvm/libcxx/docs/UsingLibcxx.rst @@ -1,3 +1,5 @@ +.. _using-libcxx: + ============ Using libc++ ============ @@ -5,138 +7,118 @@ Using libc++ .. contents:: :local: -Getting Started -=============== - -If you already have libc++ installed you can use it with clang. - -.. code-block:: bash - - $ clang++ -stdlib=libc++ test.cpp - $ clang++ -std=c++11 -stdlib=libc++ test.cpp +Usually, libc++ is packaged and shipped by a vendor through some delivery vehicle +(operating system distribution, SDK, toolchain, etc) and users don't need to do +anything special in order to use the library. -On macOS and FreeBSD libc++ is the default standard library -and the ``-stdlib=libc++`` is not required. +This page contains information about configuration knobs that can be used by +users when they know libc++ is used by their toolchain, and how to use libc++ +when it is not the default library used by their toolchain. -.. _alternate libcxx: - -If you want to select an alternate installation of libc++ you -can use the following options. - -.. code-block:: bash - - $ clang++ -std=c++11 -stdlib=libc++ -nostdinc++ \ - -I/include/c++/v1 \ - -L/lib \ - -Wl,-rpath,/lib \ - test.cpp -The option ``-Wl,-rpath,/lib`` adds a runtime library -search path. Meaning that the systems dynamic linker will look for libc++ in -``/lib`` whenever the program is run. Alternatively the -environment variable ``LD_LIBRARY_PATH`` (``DYLD_LIBRARY_PATH`` on macOS) can -be used to change the dynamic linkers search paths after a program is compiled. +Using a different version of the C++ Standard +============================================= -An example of using ``LD_LIBRARY_PATH``: +Libc++ implements the various versions of the C++ Standard. Changing the version of +the standard can be done by passing ``-std=c++XY`` to the compiler. Libc++ will +automatically detect what Standard is being used and will provide functionality that +matches that Standard in the library. .. code-block:: bash - $ clang++ -stdlib=libc++ -nostdinc++ \ - -I/include/c++/v1 - -L/lib \ - test.cpp -o - $ ./a.out # Searches for libc++ in the systems library paths. - $ export LD_LIBRARY_PATH=/lib - $ ./a.out # Searches for libc++ along LD_LIBRARY_PATH + $ clang++ -std=c++17 test.cpp -Using ```` -====================== - -Prior to LLVM 9.0, libc++ provides the implementation of the filesystem library -in a separate static library. Users of ```` and ```` -are required to link ``-lc++fs``. Prior to libc++ 7.0, users of -```` were required to link libc++experimental. +.. warning:: + Using ``-std=c++XY`` with a version of the Standard that has not been ratified yet + is considered unstable. Libc++ reserves the right to make breaking changes to the + library until the standard has been ratified. -Starting with LLVM 9.0, support for ```` is provided in the main -library and nothing special is required to use ````. Using libc++experimental and ```` -===================================================== +=================================================== Libc++ provides implementations of experimental technical specifications in a separate library, ``libc++experimental.a``. Users of ```` -headers may be required to link ``-lc++experimental``. +headers may be required to link ``-lc++experimental``. Note that not all +vendors ship ``libc++experimental.a``, and as a result, you may not be +able to use those experimental features. .. code-block:: bash - $ clang++ -std=c++14 -stdlib=libc++ test.cpp -lc++experimental - -Libc++experimental.a may not always be available, even when libc++ is already -installed. For information on building libc++experimental from source see -:ref:`Building Libc++ ` and -:ref:`libc++experimental CMake Options `. - -Also see the `Experimental Library Implementation Status `__ -page. + $ clang++ test.cpp -lc++experimental .. warning:: Experimental libraries are Experimental. * The contents of the ```` headers and ``libc++experimental.a`` library will not remain compatible between versions. * No guarantees of API or ABI stability are provided. - * When we implement the standardized version of an experimental feature, + * When the standardized version of an experimental feature is implemented, the experimental feature is removed two releases after the non-experimental version has shipped. The full policy is explained :ref:`here `. -Using libc++ on Linux -===================== -On Linux libc++ can typically be used with only '-stdlib=libc++'. However -some libc++ installations require the user manually link libc++abi themselves. -If you are running into linker errors when using libc++ try adding '-lc++abi' -to the link line. For example: +Using libc++ when it is not the system default +============================================== + +On systems where libc++ is provided but is not the default, Clang provides a flag +called ``-stdlib=`` that can be used to decide which standard library is used. +Using ``-stdlib=libc++`` will select libc++: .. code-block:: bash - $ clang++ -stdlib=libc++ test.cpp -lc++ -lc++abi -lm -lc -lgcc_s -lgcc + $ clang++ -stdlib=libc++ test.cpp -Alternately, you could just add libc++abi to your libraries list, which in -most situations will give the same result: +On systems where libc++ is the library in use by default such as macOS and FreeBSD, +this flag is not required. -.. code-block:: bash - $ clang++ -stdlib=libc++ test.cpp -lc++abi +.. _alternate libcxx: +Using a custom built libc++ +=========================== -Using libc++ with GCC ---------------------- +Most compilers provide a way to disable the default behavior for finding the +standard library and to override it with custom paths. With Clang, this can +be done with: -GCC does not provide a way to switch from libstdc++ to libc++. You must manually -configure the compile and link commands. +.. code-block:: bash + + $ clang++ -nostdinc++ -nostdlib++ \ + -isystem /include/c++/v1 \ + -L /lib \ + -Wl,-rpath,/lib \ + -lc++ \ + test.cpp -In particular you must tell GCC to remove the libstdc++ include directories -using ``-nostdinc++`` and to not link libstdc++.so using ``-nodefaultlibs``. +The option ``-Wl,-rpath,/lib`` adds a runtime library search path, +which causes the system's dynamic linker to look for libc++ in ``/lib`` +whenever the program is loaded. -Note that ``-nodefaultlibs`` removes all of the standard system libraries and -not just libstdc++ so they must be manually linked. For example: +GCC does not support the ``-nostdlib++`` flag, so one must use ``-nodefaultlibs`` +instead. Since that removes all the standard system libraries and not just libc++, +the system libraries must be re-added manually. For example: .. code-block:: bash - $ g++ -nostdinc++ -I/include/c++/v1 \ - test.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc + $ g++ -nostdinc++ -nodefaultlibs \ + -isystem /include/c++/v1 \ + -L /lib \ + -Wl,-rpath,/lib \ + -lc++ -lc++abi -lm -lc -lgcc_s -lgcc \ + test.cpp GDB Pretty printers for libc++ ------------------------------- +============================== -GDB does not support pretty-printing of libc++ symbols by default. Unfortunately -libc++ does not provide pretty-printers itself. However there are 3rd -party implementations available and although they are not officially -supported by libc++ they may be useful to users. +GDB does not support pretty-printing of libc++ symbols by default. However, libc++ does +provide pretty-printers itself. Those can be used as: -Known 3rd Party Implementations Include: +.. code-block:: bash -* `Koutheir's libc++ pretty-printers `_. + $ gdb -ex "source /utils/gdb/libcxx/printers.py" \ + -ex "python register_libcxx_printer_loader()" \ + Libc++ Configuration Macros @@ -151,7 +133,7 @@ thread safety annotations. **_LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS**: This macro is used to enable -Wthread-safety annotations on libc++'s - ``std::mutex`` and ``std::lock_guard``. By default these annotations are + ``std::mutex`` and ``std::lock_guard``. By default, these annotations are disabled and must be manually enabled by the user. **_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS**: @@ -165,33 +147,6 @@ thread safety annotations. headers. The intended use case is for clients who wish to use the libc++ headers without taking a dependency on the libc++ library itself. -**_LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION**: - This macro is used to re-enable an extension in `std::tuple` which allowed - it to be implicitly constructed from fewer initializers than contained - elements. Elements without an initializer are default constructed. For example: - - .. code-block:: cpp - - std::tuple foo() { - return {"hello world", 42}; // default constructs error_code - } - - - Since libc++ 4.0 this extension has been disabled by default. This macro - may be defined to re-enable it in order to support existing code that depends - on the extension. New use of this extension should be discouraged. - See `PR 27374 `_ for more information. - - Note: The "reduced-arity-initialization" extension is still offered but only - for explicit conversions. Example: - - .. code-block:: cpp - - auto foo() { - using Tup = std::tuple; - return Tup{"hello world", 42}; // explicit constructor called. OK. - } - **_LIBCPP_DISABLE_ADDITIONAL_DIAGNOSTICS**: This macro disables the additional diagnostics generated by libc++ using the `diagnose_if` attribute. These additional diagnostics include checks for: @@ -247,20 +202,56 @@ C++17 Specific Configuration Macros This macro is used to re-enable all the features removed in C++17. The effect is equivalent to manually defining each macro listed below. -**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**: - This macro is used to re-enable the `set_unexpected`, `get_unexpected`, and - `unexpected` functions, which were removed in C++17. - **_LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR**: - This macro is used to re-enable `std::auto_ptr` in C++17. + This macro is used to re-enable `auto_ptr`. -C++2a Specific Configuration Macros: +**_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS**: + This macro is used to re-enable the `binder1st`, `binder2nd`, + `pointer_to_unary_function`, `pointer_to_binary_function`, `mem_fun_t`, + `mem_fun1_t`, `mem_fun_ref_t`, `mem_fun1_ref_t`, `const_mem_fun_t`, + `const_mem_fun1_t`, `const_mem_fun_ref_t`, and `const_mem_fun1_ref_t` + class templates, and the `bind1st`, `bind2nd`, `mem_fun`, `mem_fun_ref`, + and `ptr_fun` functions. + +**_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE**: + This macro is used to re-enable the `random_shuffle` algorithm. + +**_LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS**: + This macro is used to re-enable `set_unexpected`, `get_unexpected`, and + `unexpected`. + +C++20 Specific Configuration Macros: ------------------------------------ **_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17**: This macro can be used to disable diagnostics emitted from functions marked ``[[nodiscard]]`` in dialects after C++17. See :ref:`Extended Applications of [[nodiscard]] ` for more information. +**_LIBCPP_ENABLE_CXX20_REMOVED_FEATURES**: + This macro is used to re-enable all the features removed in C++20. The effect + is equivalent to manually defining each macro listed below. + +**_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS**: + This macro is used to re-enable redundant members of `allocator`, + including `pointer`, `reference`, `rebind`, `address`, `max_size`, + `construct`, `destroy`, and the two-argument overload of `allocate`. + +**_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS**: + This macro is used to re-enable the `argument_type`, `result_type`, + `first_argument_type`, and `second_argument_type` members of class + templates such as `plus`, `logical_not`, `hash`, and `owner_less`. + +**_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS**: + This macro is used to re-enable `not1`, `not2`, `unary_negate`, + and `binary_negate`. + +**_LIBCPP_ENABLE_CXX20_REMOVED_RAW_STORAGE_ITERATOR**: + This macro is used to re-enable `raw_storage_iterator`. + +**_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS**: + This macro is used to re-enable `is_literal_type`, `is_literal_type_v`, + `result_of` and `result_of_t`. + Libc++ Extensions ================= @@ -287,15 +278,15 @@ applications of ``[[nodiscard]]`` takes two forms: 1. Backporting ``[[nodiscard]]`` to entities declared as such by the standard in newer dialects, but not in the present one. -2. Extended applications of ``[[nodiscard]]``, at the libraries discretion, +2. Extended applications of ``[[nodiscard]]``, at the library's discretion, applied to entities never declared as such by the standard. Users may also opt-out of additional applications ``[[nodiscard]]`` using additional macros. Applications of the first form, which backport ``[[nodiscard]]`` from a newer -dialect may be disabled using macros specific to the dialect it was added. For -example ``_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17``. +dialect, may be disabled using macros specific to the dialect in which it was +added. For example, ``_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17``. Applications of the second form, which are pure extensions, may be disabled by defining ``_LIBCPP_DISABLE_NODISCARD_EXT``. @@ -346,3 +337,10 @@ which no dialect declares as such (See the second form described above). * ``unique`` * ``upper_bound`` * ``lock_guard``'s constructors +* ``as_const`` +* ``forward`` +* ``move`` +* ``move_if_noexcept`` +* ``identity::operator()`` +* ``to_integer`` +* ``to_underlying`` diff --git a/gnu/llvm/libcxx/docs/conf.py b/gnu/llvm/libcxx/docs/conf.py index 00000eec027..f3c904c8efc 100644 --- a/gnu/llvm/libcxx/docs/conf.py +++ b/gnu/llvm/libcxx/docs/conf.py @@ -11,6 +11,7 @@ # serve to show the default. import sys, os +from datetime import date # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -40,16 +41,16 @@ master_doc = 'index' # General information about the project. project = u'libc++' -copyright = u'2011-2018, LLVM Project' +copyright = u'2011-%d, LLVM Project' % date.today().year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '11.0' +version = '13.0' # The full version, including alpha/beta/rc tags. -release = '11.0' +release = '13.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -63,7 +64,7 @@ today_fmt = '%Y-%m-%d' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ['_build', 'Helpers'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None diff --git a/gnu/llvm/libcxx/docs/index.rst b/gnu/llvm/libcxx/docs/index.rst index c60a72d4972..c52e42b146b 100644 --- a/gnu/llvm/libcxx/docs/index.rst +++ b/gnu/llvm/libcxx/docs/index.rst @@ -29,24 +29,33 @@ above. Getting Started with libc++ ---------------------------- +=========================== .. toctree:: - :maxdepth: 2 + :maxdepth: 1 ReleaseNotes UsingLibcxx BuildingLibcxx TestingLibcxx + Contributing + Status/Cxx14 + Status/Cxx17 + Status/Cxx20 + Status/Cxx2b + Status/Ranges + Status/Format .. toctree:: :hidden: + AddingNewCIJobs FeatureTestMacroTable + Current Status --------------- +============== After its initial introduction, many people have asked "why start a new library instead of contributing to an existing library?" (like Apache's @@ -82,61 +91,61 @@ reasons, but some of the major ones are: Further, both projects are apparently abandoned: STLport 5.2.1 was released in Oct'08, and STDCXX 4.2.1 in May'08. -Platform and Compiler Support ------------------------------ - -For using the libc++ headers -############################ -The libc++ headers are known to work on the following platforms, using GCC and -Clang. Note that functionality provided by ```` is only functional with -Clang and GCC. - -============ ==================== ============ -OS Arch Compilers -============ ==================== ============ -macOS 10.9+ i386, x86_64 Clang, GCC -FreeBSD 10+ i386, x86_64, ARM Clang, GCC -Linux i386, x86_64 Clang, GCC -============ ==================== ============ - -The following minimum compiler versions are required: - -* Clang 4.0 and above -* GCC 5.0 and above. - -The C++03 dialect is only supported with Clang. +.. _platform_and_compiler_support: -For building the libc++ library -############################### -Building the libc++ library (static or shared) requires some features from -the operating system. As such, it has its own set of (slightly different) -system requirements. - -============ ==================== ============ ======================== -OS Arch Compilers ABI Library -============ ==================== ============ ======================== -macOS 10.12+ i386, x86_64 Clang, GCC libc++abi -FreeBSD 10+ i386, x86_64, ARM Clang, GCC libcxxrt, libc++abi -Linux i386, x86_64 Clang, GCC libc++abi -============ ==================== ============ ======================== - -The following minimum compiler versions are required: +Platform and Compiler Support +============================= -* Clang 4.0 and above -* GCC 5.0 and above. +Libc++ aims to support common compilers that implement the C++11 Standard. In order to strike a +good balance between stability for users and maintenance cost, testing coverage and development +velocity, libc++ drops support for older compilers as newer ones are released. + +============ =============== ========================== ===================== +Compiler Versions Restrictions Support policy +============ =============== ========================== ===================== +Clang 11, 12 latest two stable releases per `LLVM's release page `_ +AppleClang 12 latest stable release per `Xcode's release page `_ +GCC 11 In C++11 or later only latest stable release per `GCC's release page `_ +============ =============== ========================== ===================== + +Libc++ also supports common platforms and architectures: + +=============== ========================= ============================ +Target platform Target architecture Notes +=============== ========================= ============================ +macOS 10.9+ i386, x86_64, arm64 Building the shared library itself requires targetting macOS 10.11+ +FreeBSD 10+ i386, x86_64, arm +Linux i386, x86_64, arm, arm64 +Windows x86_64 +=============== ========================= ============================ + +Generally speaking, libc++ should work on any platform that provides a fairly complete +C Standard Library. It is also possible to turn off parts of the library for use on +systems that provide incomplete support. + +However, libc++ aims to provide a high-quality implementation of the C++ Standard +Library, especially when it comes to correctness. As such, we aim to have test coverage +for all the platforms and compilers that we claim to support. If a platform or compiler +is not listed here, it is not officially supported. It may happen to work, and +in practice the library is known to work on some platforms not listed here, but +we don't make any guarantees. If you would like your compiler and/or platform +to be formally supported and listed here, +please work with the libc++ team to set up testing for your configuration. C++ Dialect Support ---------------------- +=================== * C++11 - Complete -* `C++14 - Complete `__ -* `C++17 - In Progress `__ -* `Post C++14 Technical Specifications - In Progress `__ +* :ref:`C++14 - Complete ` +* :ref:`C++17 - In Progress ` +* :ref:`C++20 - In Progress ` +* :ref:`C++2b - In Progress ` * :ref:`C++ Feature Test Macro Status ` + Notes and Known Issues ----------------------- +====================== This list contains known issues with libc++ @@ -148,36 +157,34 @@ A full list of currently open libc++ bugs can be `found here`__. .. __: https://bugs.llvm.org/buglist.cgi?component=All%20Bugs&product=libc%2B%2B&query_format=advanced&resolution=---&order=changeddate%20DESC%2Cassigned_to%20DESC%2Cbug_status%2Cpriority%2Cbug_id&list_id=74184 + Design Documents ----------------- +================ .. toctree:: :maxdepth: 1 - DesignDocs/AvailabilityMarkup - DesignDocs/DebugMode - DesignDocs/CapturingConfigInfo DesignDocs/ABIVersioning + DesignDocs/AtomicDesign + DesignDocs/CapturingConfigInfo + DesignDocs/DebugMode DesignDocs/ExperimentalFeatures - DesignDocs/VisibilityMacros - DesignDocs/ThreadingSupportAPI - DesignDocs/FileTimeType - DesignDocs/FeatureTestMacros DesignDocs/ExtendedCXX03Support + DesignDocs/FeatureTestMacros + DesignDocs/FileTimeType + DesignDocs/NoexceptPolicy + DesignDocs/ThreadingSupportAPI + DesignDocs/UniquePtrTrivialAbi + DesignDocs/VisibilityMacros -* ` design `_ -* ` design `_ -* `Notes by Marshall Clow`__ - -.. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/ Build Bots and Test Coverage ----------------------------- +============================ + +* `Buildkite CI pipeline `_ +* `LLVM Buildbot Builders `_ +* :ref:`Adding New CI Jobs ` -* `LLVM Buildbot Builders `_ -* `Apple Jenkins Builders `_ -* `Windows Appveyor Builders `_ -* `Code Coverage Results `_ Getting Involved ================ @@ -203,7 +210,6 @@ Send discussions and questions to the `libcxx-dev mailing list `_. - Quick Links =========== * `LLVM Homepage `_ @@ -211,4 +217,4 @@ Quick Links * `LLVM Bugzilla `_ * `libcxx-commits Mailing List`_ * `libcxx-dev Mailing List`_ -* `Browse libc++ Sources `_ +* `Browse libc++ Sources `_ diff --git a/gnu/llvm/libcxx/include/CMakeLists.txt b/gnu/llvm/libcxx/include/CMakeLists.txt index be8141c9816..5fba7607756 100644 --- a/gnu/llvm/libcxx/include/CMakeLists.txt +++ b/gnu/llvm/libcxx/include/CMakeLists.txt @@ -1,26 +1,249 @@ set(files + __algorithm/adjacent_find.h + __algorithm/all_of.h + __algorithm/any_of.h + __algorithm/binary_search.h + __algorithm/clamp.h + __algorithm/comp_ref_type.h + __algorithm/comp.h + __algorithm/copy_backward.h + __algorithm/copy_if.h + __algorithm/copy_n.h + __algorithm/copy.h + __algorithm/count_if.h + __algorithm/count.h + __algorithm/equal_range.h + __algorithm/equal.h + __algorithm/fill_n.h + __algorithm/fill.h + __algorithm/find_end.h + __algorithm/find_first_of.h + __algorithm/find_if_not.h + __algorithm/find_if.h + __algorithm/find.h + __algorithm/for_each_n.h + __algorithm/for_each.h + __algorithm/generate_n.h + __algorithm/generate.h + __algorithm/half_positive.h + __algorithm/includes.h + __algorithm/inplace_merge.h + __algorithm/is_heap_until.h + __algorithm/is_heap.h + __algorithm/is_partitioned.h + __algorithm/is_permutation.h + __algorithm/is_sorted_until.h + __algorithm/is_sorted.h + __algorithm/iter_swap.h + __algorithm/lexicographical_compare.h + __algorithm/lower_bound.h + __algorithm/make_heap.h + __algorithm/max_element.h + __algorithm/max.h + __algorithm/merge.h + __algorithm/min_element.h + __algorithm/min.h + __algorithm/minmax_element.h + __algorithm/minmax.h + __algorithm/mismatch.h + __algorithm/move_backward.h + __algorithm/move.h + __algorithm/next_permutation.h + __algorithm/none_of.h + __algorithm/nth_element.h + __algorithm/partial_sort_copy.h + __algorithm/partial_sort.h + __algorithm/partition_copy.h + __algorithm/partition_point.h + __algorithm/partition.h + __algorithm/pop_heap.h + __algorithm/prev_permutation.h + __algorithm/push_heap.h + __algorithm/remove_copy_if.h + __algorithm/remove_copy.h + __algorithm/remove_if.h + __algorithm/remove.h + __algorithm/replace_copy_if.h + __algorithm/replace_copy.h + __algorithm/replace_if.h + __algorithm/replace.h + __algorithm/reverse_copy.h + __algorithm/reverse.h + __algorithm/rotate_copy.h + __algorithm/rotate.h + __algorithm/sample.h + __algorithm/search_n.h + __algorithm/search.h + __algorithm/set_difference.h + __algorithm/set_intersection.h + __algorithm/set_symmetric_difference.h + __algorithm/set_union.h + __algorithm/shift_left.h + __algorithm/shift_right.h + __algorithm/shuffle.h + __algorithm/sift_down.h + __algorithm/sort_heap.h + __algorithm/sort.h + __algorithm/stable_partition.h + __algorithm/stable_sort.h + __algorithm/swap_ranges.h + __algorithm/transform.h + __algorithm/unique_copy.h + __algorithm/unique.h + __algorithm/unwrap_iter.h + __algorithm/upper_bound.h + __availability __bit_reference + __bits __bsd_locale_defaults.h __bsd_locale_fallbacks.h - __errc + __config __debug - __functional_03 + __errc + __format/format_error.h + __format/format_parse_context.h + __function_like.h __functional_base - __functional_base_03 + __functional/binary_function.h + __functional/binary_negate.h + __functional/bind_front.h + __functional/bind.h + __functional/binder1st.h + __functional/binder2nd.h + __functional/default_searcher.h + __functional/function.h + __functional/hash.h + __functional/identity.h + __functional/invoke.h + __functional/is_transparent.h + __functional/mem_fn.h + __functional/mem_fun_ref.h + __functional/not_fn.h + __functional/operations.h + __functional/perfect_forward.h + __functional/pointer_to_binary_function.h + __functional/pointer_to_unary_function.h + __functional/ranges_operations.h + __functional/reference_wrapper.h + __functional/unary_function.h + __functional/unary_negate.h + __functional/unwrap_ref.h + __functional/weak_result_type.h __hash_table + __iterator/access.h + __iterator/advance.h + __iterator/back_insert_iterator.h + __iterator/common_iterator.h + __iterator/concepts.h + __iterator/counted_iterator.h + __iterator/data.h + __iterator/default_sentinel.h + __iterator/distance.h + __iterator/empty.h + __iterator/erase_if_container.h + __iterator/front_insert_iterator.h + __iterator/incrementable_traits.h + __iterator/insert_iterator.h + __iterator/istream_iterator.h + __iterator/istreambuf_iterator.h + __iterator/iter_move.h + __iterator/iter_swap.h + __iterator/iterator_traits.h + __iterator/iterator.h + __iterator/move_iterator.h + __iterator/next.h + __iterator/ostream_iterator.h + __iterator/ostreambuf_iterator.h + __iterator/prev.h + __iterator/projected.h + __iterator/readable_traits.h + __iterator/reverse_access.h + __iterator/reverse_iterator.h + __iterator/size.h + __iterator/wrap_iter.h __libcpp_version __locale + __memory/addressof.h + __memory/allocation_guard.h + __memory/allocator_arg_t.h + __memory/allocator_traits.h + __memory/allocator.h + __memory/auto_ptr.h + __memory/compressed_pair.h + __memory/construct_at.h + __memory/pointer_safety.h + __memory/pointer_traits.h + __memory/raw_storage_iterator.h + __memory/shared_ptr.h + __memory/temporary_buffer.h + __memory/uninitialized_algorithms.h + __memory/unique_ptr.h + __memory/uses_allocator.h __mutex_base __node_handle __nullptr + __random/uniform_int_distribution.h + __ranges/access.h + __ranges/all.h + __ranges/common_view.h + __ranges/concepts.h + __ranges/copyable_box.h + __ranges/dangling.h + __ranges/data.h + __ranges/drop_view.h + __ranges/empty_view.h + __ranges/empty.h + __ranges/enable_borrowed_range.h + __ranges/enable_view.h + __ranges/non_propagating_cache.h + __ranges/ref_view.h + __ranges/size.h + __ranges/subrange.h + __ranges/transform_view.h + __ranges/view_interface.h __split_buffer - __sso_allocator __std_stream __string + __support/android/locale_bionic.h + __support/fuchsia/xlocale.h + __support/ibm/gettod_zos.h + __support/ibm/limits.h + __support/ibm/locale_mgmt_aix.h + __support/ibm/locale_mgmt_zos.h + __support/ibm/nanosleep.h + __support/ibm/support.h + __support/ibm/xlocale.h + __support/musl/xlocale.h + __support/newlib/xlocale.h + __support/nuttx/xlocale.h + __support/openbsd/xlocale.h + __support/solaris/floatingpoint.h + __support/solaris/wchar.h + __support/solaris/xlocale.h + __support/win32/limits_msvc_win32.h + __support/win32/locale_win32.h + __support/xlocale/__nop_locale_mgmt.h + __support/xlocale/__posix_l_fallback.h + __support/xlocale/__strtonum_fallback.h __threading_support __tree __tuple __undef_macros + __utility/__decay_copy.h + __utility/as_const.h + __utility/cmp.h + __utility/declval.h + __utility/exchange.h + __utility/forward.h + __utility/in_place.h + __utility/integer_sequence.h + __utility/move.h + __utility/pair.h + __utility/piecewise_construct.h + __utility/rel_ops.h + __utility/swap.h + __utility/to_underlying.h + __variant/monostate.h algorithm any array @@ -93,6 +316,7 @@ set(files fenv.h filesystem float.h + format forward_list fstream functional @@ -123,6 +347,8 @@ set(files ostream queue random + ranges + ranges ratio regex scoped_allocator @@ -141,8 +367,8 @@ set(files stdlib.h streambuf string - string.h string_view + string.h strstream system_error tgmath.h @@ -162,121 +388,55 @@ set(files wctype.h ) -if(LIBCXX_INSTALL_SUPPORT_HEADERS) - set(files - ${files} - support/android/locale_bionic.h - support/fuchsia/xlocale.h - support/ibm/limits.h - support/ibm/locale_mgmt_aix.h - support/ibm/support.h - support/ibm/xlocale.h - support/musl/xlocale.h - support/newlib/xlocale.h - support/solaris/floatingpoint.h - support/solaris/wchar.h - support/solaris/xlocale.h - support/win32/limits_msvc_win32.h - support/win32/locale_win32.h - support/xlocale/__nop_locale_mgmt.h - support/xlocale/__posix_l_fallback.h - support/xlocale/__strtonum_fallback.h - ) -endif() - -configure_file("__config_site.in" - "${LIBCXX_BINARY_DIR}/__config_site" - @ONLY) +configure_file("__config_site.in" "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site" @ONLY) -# Generate a custom __config header. The new header is created -# by prepending __config_site to the current __config header. -add_custom_command(OUTPUT ${LIBCXX_BINARY_DIR}/__generated_config - COMMAND ${Python3_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/cat_files.py - ${LIBCXX_BINARY_DIR}/__config_site - ${LIBCXX_SOURCE_DIR}/include/__config - -o ${LIBCXX_BINARY_DIR}/__generated_config - DEPENDS ${LIBCXX_SOURCE_DIR}/include/__config - ${LIBCXX_BINARY_DIR}/__config_site -) -# Add a target that executes the generation commands. -add_custom_target(cxx-generated-config ALL - DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config) - -# In some build configurations (like bootstrapping clang), we need to be able to -# install the libcxx headers before the CMake configuration for libcxx runs. Making -# the name of this target configurable allows LLVM/runtimes/CMakeLists.txt to -# add this subdirectory to the LLVM build to put libcxx's headers in place -# before libcxx's build configuration is run. -if (NOT CXX_HEADER_TARGET) - set(CXX_HEADER_TARGET cxx-headers) -endif() -if(LIBCXX_HEADER_DIR) - set(output_dir ${LIBCXX_HEADER_DIR}/include/c++/v1) - - set(out_files) - foreach(f ${files}) - set(src ${CMAKE_CURRENT_SOURCE_DIR}/${f}) - set(dst ${output_dir}/${f}) - add_custom_command(OUTPUT ${dst} - DEPENDS ${src} - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying CXX header ${f}") - list(APPEND out_files ${dst}) - endforeach() - - # Copy the generated header as __config into build directory. - set(src ${LIBCXX_BINARY_DIR}/__generated_config) - set(dst ${output_dir}/__config) +set(_all_includes "${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site") +foreach(f ${files}) + set(src "${CMAKE_CURRENT_SOURCE_DIR}/${f}") + set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${f}") add_custom_command(OUTPUT ${dst} - DEPENDS ${src} cxx-generated-config - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} - COMMENT "Copying CXX __config") - list(APPEND out_files ${dst}) - add_custom_target(generate-cxx-headers DEPENDS ${out_files}) + DEPENDS ${src} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst} + COMMENT "Copying CXX header ${f}") + list(APPEND _all_includes "${dst}") +endforeach() - add_library(${CXX_HEADER_TARGET} INTERFACE) - add_dependencies(${CXX_HEADER_TARGET} generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET}) - # TODO: Use target_include_directories once we figure out why that breaks the runtimes build - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - target_compile_options(${CXX_HEADER_TARGET} INTERFACE /I "${output_dir}") - else() - target_compile_options(${CXX_HEADER_TARGET} INTERFACE -I "${output_dir}") - endif() +add_custom_target(generate-cxx-headers ALL DEPENDS ${_all_includes}) - # Make sure the generated __config_site header is included when we build the library. - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") - target_compile_options(${CXX_HEADER_TARGET} INTERFACE /FI "${LIBCXX_BINARY_DIR}/__config_site") - else() - target_compile_options(${CXX_HEADER_TARGET} INTERFACE -include "${LIBCXX_BINARY_DIR}/__config_site") - endif() +add_library(cxx-headers INTERFACE) +add_dependencies(cxx-headers generate-cxx-headers ${LIBCXX_CXX_ABI_HEADER_TARGET}) +# TODO: Use target_include_directories once we figure out why that breaks the runtimes build +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" OR "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + target_compile_options(cxx-headers INTERFACE /I${LIBCXX_GENERATED_INCLUDE_DIR} + INTERFACE /I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}) else() - add_library(${CXX_HEADER_TARGET} INTERFACE) + target_compile_options(cxx-headers INTERFACE -I${LIBCXX_GENERATED_INCLUDE_DIR} + INTERFACE -I${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}) endif() if (LIBCXX_INSTALL_HEADERS) foreach(file ${files}) get_filename_component(dir ${file} DIRECTORY) install(FILES ${file} - DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dir} - COMPONENT ${CXX_HEADER_TARGET} + DESTINATION ${LIBCXX_INSTALL_INCLUDE_DIR}/${dir} + COMPONENT cxx-headers PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) endforeach() - # Install the generated header as __config. - install(FILES ${LIBCXX_BINARY_DIR}/__generated_config - DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1 + # Install the generated __config_site. + install(FILES ${LIBCXX_GENERATED_INCLUDE_TARGET_DIR}/__config_site + DESTINATION ${LIBCXX_INSTALL_INCLUDE_TARGET_DIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - RENAME __config - COMPONENT ${CXX_HEADER_TARGET}) + COMPONENT cxx-headers) if (NOT CMAKE_CONFIGURATION_TYPES) - add_custom_target(install-${CXX_HEADER_TARGET} - DEPENDS ${CXX_HEADER_TARGET} cxx-generated-config + add_custom_target(install-cxx-headers + DEPENDS cxx-headers COMMAND "${CMAKE_COMMAND}" - -DCMAKE_INSTALL_COMPONENT=${CXX_HEADER_TARGET} + -DCMAKE_INSTALL_COMPONENT=cxx-headers -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") # Stripping is a no-op for headers - add_custom_target(install-${CXX_HEADER_TARGET}-stripped DEPENDS install-${CXX_HEADER_TARGET}) + add_custom_target(install-cxx-headers-stripped DEPENDS install-cxx-headers) endif() endif() diff --git a/gnu/llvm/libcxx/include/__algorithm/adjacent_find.h b/gnu/llvm/libcxx/include/__algorithm/adjacent_find.h new file mode 100644 index 00000000000..0a2aa055c10 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/adjacent_find.h @@ -0,0 +1,51 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_ADJACENT_FIND_H +#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { + if (__first != __last) { + _ForwardIterator __i = __first; + while (++__i != __last) { + if (__pred(*__first, *__i)) + return __first; + __first = __i; + } + } + return __last; +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { + typedef typename iterator_traits<_ForwardIterator>::value_type __v; + return _VSTD::adjacent_find(__first, __last, __equal_to<__v>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H diff --git a/gnu/llvm/libcxx/include/__algorithm/all_of.h b/gnu/llvm/libcxx/include/__algorithm/all_of.h new file mode 100644 index 00000000000..7d6ed508596 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/all_of.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_ALL_OF_H +#define _LIBCPP___ALGORITHM_ALL_OF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { + for (; __first != __last; ++__first) + if (!__pred(*__first)) + return false; + return true; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_ALL_OF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/any_of.h b/gnu/llvm/libcxx/include/__algorithm/any_of.h new file mode 100644 index 00000000000..d5a6c094a67 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/any_of.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_ANY_OF_H +#define _LIBCPP___ALGORITHM_ANY_OF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { + for (; __first != __last; ++__first) + if (__pred(*__first)) + return true; + return false; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_ANY_OF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/binary_search.h b/gnu/llvm/libcxx/include/__algorithm/binary_search.h new file mode 100644 index 00000000000..766f5da1629 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/binary_search.h @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_BINARY_SEARCH_H +#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/lower_bound.h> +#include <__algorithm/comp_ref_type.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +__binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + __first = _VSTD::__lower_bound<_Compare>(__first, __last, __value_, __comp); + return __first != __last && !__comp(__value_, *__first); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__binary_search<_Comp_ref>(__first, __last, __value_, __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) +{ + return _VSTD::binary_search(__first, __last, __value_, + __less::value_type, _Tp>()); +} + + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H diff --git a/gnu/llvm/libcxx/include/__algorithm/clamp.h b/gnu/llvm/libcxx/include/__algorithm/clamp.h new file mode 100644 index 00000000000..f8eba03cf89 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/clamp.h @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_CLAMP_H +#define _LIBCPP___ALGORITHM_CLAMP_H + +#include <__config> +#include <__debug> +#include <__algorithm/comp.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 +// clamp +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +const _Tp& +clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) +{ + _LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp"); + return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v; + +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +const _Tp& +clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) +{ + return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>()); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_CLAMP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/comp.h b/gnu/llvm/libcxx/include/__algorithm/comp.h new file mode 100644 index 00000000000..2039cf7b395 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/comp.h @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COMP_H +#define _LIBCPP___ALGORITHM_COMP_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// I'd like to replace these with _VSTD::equal_to, but can't because: +// * That only works with C++14 and later, and +// * We haven't included here. +template +struct __equal_to +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T1& __x, const _T2& __y) const {return __x == __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T1& __y) const {return __x == __y;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 bool operator()(const _T2& __x, const _T2& __y) const {return __x == __y;} +}; + +template +struct __equal_to<_T1, _T1> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} +}; + +template +struct __equal_to +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} +}; + +template +struct __equal_to<_T1, const _T1> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x == __y;} +}; + +template +struct __less +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;} +}; + +template +struct __less<_T1, _T1> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} +}; + +template +struct __less +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} +}; + +template +struct __less<_T1, const _T1> +{ + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COMP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/comp_ref_type.h b/gnu/llvm/libcxx/include/__algorithm/comp_ref_type.h new file mode 100644 index 00000000000..b3bca82c095 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/comp_ref_type.h @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COMP_REF_TYPE_H +#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifdef _LIBCPP_DEBUG + +template +struct __debug_less +{ + _Compare &__comp_; + _LIBCPP_CONSTEXPR_AFTER_CXX17 + __debug_less(_Compare& __c) : __comp_(__c) {} + + template + _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 + _LIBCPP_CONSTEXPR_AFTER_CXX17 + bool operator()(_Tp& __x, _Up& __y) + { + bool __r = __comp_(__x, __y); + if (__r) + __do_compare_assert(0, __y, __x); + return __r; + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + inline _LIBCPP_INLINE_VISIBILITY + decltype((void)declval<_Compare&>()( + declval<_LHS &>(), declval<_RHS &>())) + __do_compare_assert(int, _LHS & __l, _RHS & __r) { + _LIBCPP_ASSERT(!__comp_(__l, __r), + "Comparator does not induce a strict weak ordering"); + } + + template + _LIBCPP_CONSTEXPR_AFTER_CXX17 + inline _LIBCPP_INLINE_VISIBILITY + void __do_compare_assert(long, _LHS &, _RHS &) {} +}; + +#endif // _LIBCPP_DEBUG + +template +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 +}; + + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/copy.h b/gnu/llvm/libcxx/include/__algorithm/copy.h new file mode 100644 index 00000000000..9db7434c043 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/copy.h @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COPY_H +#define _LIBCPP___ALGORITHM_COPY_H + +#include <__config> +#include <__algorithm/unwrap_iter.h> +#include <__iterator/iterator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// copy + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +__copy_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + for (; __first != __last; ++__first, (void) ++__result) + *__result = *__first; + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_OutputIterator +__copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + return _VSTD::__copy_constexpr(__first, __last, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if +< + is_same::type, _Up>::value && + is_trivially_copy_assignable<_Up>::value, + _Up* +>::type +__copy(_Tp* __first, _Tp* __last, _Up* __result) +{ + const size_t __n = static_cast(__last - __first); + if (__n > 0) + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + return __result + __n; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + if (__libcpp_is_constant_evaluated()) { + return _VSTD::__copy_constexpr(__first, __last, __result); + } else { + return _VSTD::__rewrap_iter(__result, + _VSTD::__copy(_VSTD::__unwrap_iter(__first), + _VSTD::__unwrap_iter(__last), + _VSTD::__unwrap_iter(__result))); + } +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/copy_backward.h b/gnu/llvm/libcxx/include/__algorithm/copy_backward.h new file mode 100644 index 00000000000..03a9c5f2d00 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/copy_backward.h @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COPY_BACKWARD_H +#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H + +#include <__config> +#include <__algorithm/unwrap_iter.h> +#include <__iterator/iterator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +__copy_backward_constexpr(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) +{ + while (__first != __last) + *--__result = *--__last; + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_OutputIterator +__copy_backward(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) +{ + return _VSTD::__copy_backward_constexpr(__first, __last, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if +< + is_same::type, _Up>::value && + is_trivially_copy_assignable<_Up>::value, + _Up* +>::type +__copy_backward(_Tp* __first, _Tp* __last, _Up* __result) +{ + const size_t __n = static_cast(__last - __first); + if (__n > 0) + { + __result -= __n; + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_BidirectionalIterator2 +copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, + _BidirectionalIterator2 __result) +{ + if (__libcpp_is_constant_evaluated()) { + return _VSTD::__copy_backward_constexpr(__first, __last, __result); + } else { + return _VSTD::__rewrap_iter(__result, + _VSTD::__copy_backward(_VSTD::__unwrap_iter(__first), + _VSTD::__unwrap_iter(__last), + _VSTD::__unwrap_iter(__result))); + } +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H diff --git a/gnu/llvm/libcxx/include/__algorithm/copy_if.h b/gnu/llvm/libcxx/include/__algorithm/copy_if.h new file mode 100644 index 00000000000..153304c7a76 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/copy_if.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COPY_IF_H +#define _LIBCPP___ALGORITHM_COPY_IF_H + +#include <__config> +#include <__algorithm/unwrap_iter.h> +#include <__iterator/iterator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +copy_if(_InputIterator __first, _InputIterator __last, + _OutputIterator __result, _Predicate __pred) +{ + for (; __first != __last; ++__first) + { + if (__pred(*__first)) + { + *__result = *__first; + ++__result; + } + } + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COPY_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/copy_n.h b/gnu/llvm/libcxx/include/__algorithm/copy_n.h new file mode 100644 index 00000000000..bbfeb8686fb --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/copy_n.h @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COPY_N_H +#define _LIBCPP___ALGORITHM_COPY_N_H + +#include <__config> +#include <__algorithm/copy.h> +#include <__algorithm/unwrap_iter.h> +#include <__iterator/iterator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +typename enable_if +< + __is_cpp17_input_iterator<_InputIterator>::value && + !__is_cpp17_random_access_iterator<_InputIterator>::value, + _OutputIterator +>::type +copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) +{ + typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; + if (__n > 0) + { + *__result = *__first; + ++__result; + for (--__n; __n > 0; --__n) + { + ++__first; + *__result = *__first; + ++__result; + } + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +typename enable_if +< + __is_cpp17_random_access_iterator<_InputIterator>::value, + _OutputIterator +>::type +copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) +{ + typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; + return _VSTD::copy(__first, __first + __n, __result); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COPY_N_H diff --git a/gnu/llvm/libcxx/include/__algorithm/count.h b/gnu/llvm/libcxx/include/__algorithm/count.h new file mode 100644 index 00000000000..7f2d1954cd6 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/count.h @@ -0,0 +1,40 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COUNT_H +#define _LIBCPP___ALGORITHM_COUNT_H + +#include <__config> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_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_) { + typename iterator_traits<_InputIterator>::difference_type __r(0); + for (; __first != __last; ++__first) + if (*__first == __value_) + ++__r; + return __r; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COUNT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/count_if.h b/gnu/llvm/libcxx/include/__algorithm/count_if.h new file mode 100644 index 00000000000..a5efffb9260 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/count_if.h @@ -0,0 +1,40 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_COUNT_IF_H +#define _LIBCPP___ALGORITHM_COUNT_IF_H + +#include <__config> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_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) { + typename iterator_traits<_InputIterator>::difference_type __r(0); + for (; __first != __last; ++__first) + if (__pred(*__first)) + ++__r; + return __r; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_COUNT_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/equal.h b/gnu/llvm/libcxx/include/__algorithm/equal.h new file mode 100644 index 00000000000..bc675598196 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/equal.h @@ -0,0 +1,90 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_EQUAL_H +#define _LIBCPP___ALGORITHM_EQUAL_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> +#include // FIXME: replace with <__iterator/distance.h> when it lands + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!__pred(*__first1, *__first2)) + return false; + return true; +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::equal(__first1, __last1, __first2, __equal_to<__v1, __v2>()); +} + +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) { + for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) + if (!__pred(*__first1, *__first2)) + return false; + return __first1 == __last1 && __first2 == __last2; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, + _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, + random_access_iterator_tag) { + if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) + return false; + return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2, + typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, __pred); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __pred) { + return _VSTD::__equal::type>( + __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(), + typename iterator_traits<_InputIterator2>::iterator_category()); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::__equal(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(), + typename iterator_traits<_InputIterator1>::iterator_category(), + typename iterator_traits<_InputIterator2>::iterator_category()); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_EQUAL_H diff --git a/gnu/llvm/libcxx/include/__algorithm/equal_range.h b/gnu/llvm/libcxx/include/__algorithm/equal_range.h new file mode 100644 index 00000000000..9694dae9500 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/equal_range.h @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_EQUAL_RANGE_H +#define _LIBCPP___ALGORITHM_EQUAL_RANGE_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/half_positive.h> +#include <__algorithm/lower_bound.h> +#include <__algorithm/upper_bound.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_ForwardIterator, _ForwardIterator> +__equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; + difference_type __len = _VSTD::distance(__first, __last); + while (__len != 0) + { + difference_type __l2 = _VSTD::__half_positive(__len); + _ForwardIterator __m = __first; + _VSTD::advance(__m, __l2); + if (__comp(*__m, __value_)) + { + __first = ++__m; + __len -= __l2 + 1; + } + else if (__comp(__value_, *__m)) + { + __last = __m; + __len = __l2; + } + else + { + _ForwardIterator __mp1 = __m; + return pair<_ForwardIterator, _ForwardIterator> + ( + _VSTD::__lower_bound<_Compare>(__first, __m, __value_, __comp), + _VSTD::__upper_bound<_Compare>(++__mp1, __last, __value_, __comp) + ); + } + } + return pair<_ForwardIterator, _ForwardIterator>(__first, __first); +} + +template +_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) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__equal_range<_Comp_ref>(__first, __last, __value_, __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +pair<_ForwardIterator, _ForwardIterator> +equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) +{ + return _VSTD::equal_range(__first, __last, __value_, + __less::value_type, _Tp>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/fill.h b/gnu/llvm/libcxx/include/__algorithm/fill.h new file mode 100644 index 00000000000..4fefe86536d --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/fill.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FILL_H +#define _LIBCPP___ALGORITHM_FILL_H + +#include <__config> +#include <__algorithm/fill_n.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, forward_iterator_tag) +{ + for (; __first != __last; ++__first) + *__first = __value_; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value_, random_access_iterator_tag) +{ + _VSTD::fill_n(__first, __last - __first, __value_); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) +{ + _VSTD::__fill(__first, __last, __value_, typename iterator_traits<_ForwardIterator>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FILL_H diff --git a/gnu/llvm/libcxx/include/__algorithm/fill_n.h b/gnu/llvm/libcxx/include/__algorithm/fill_n.h new file mode 100644 index 00000000000..34a245edb51 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/fill_n.h @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FILL_N_H +#define _LIBCPP___ALGORITHM_FILL_N_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) +{ + for (; __n > 0; ++__first, (void) --__n) + *__first = __value_; + return __first; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +fill_n(_OutputIterator __first, _Size __n, const _Tp& __value_) +{ + return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value_); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FILL_N_H diff --git a/gnu/llvm/libcxx/include/__algorithm/find.h b/gnu/llvm/libcxx/include/__algorithm/find.h new file mode 100644 index 00000000000..bc593dc5425 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/find.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FIND_H +#define _LIBCPP___ALGORITHM_FIND_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator +find(_InputIterator __first, _InputIterator __last, const _Tp& __value_) { + for (; __first != __last; ++__first) + if (*__first == __value_) + break; + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FIND_H diff --git a/gnu/llvm/libcxx/include/__algorithm/find_end.h b/gnu/llvm/libcxx/include/__algorithm/find_end.h new file mode 100644 index 00000000000..f4277f003aa --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/find_end.h @@ -0,0 +1,154 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FIND_END_OF_H +#define _LIBCPP___ALGORITHM_FIND_END_OF_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 __find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred, forward_iterator_tag, + forward_iterator_tag) { + // modeled after search algorithm + _ForwardIterator1 __r = __last1; // __last1 is the "default" answer + if (__first2 == __last2) + return __r; + while (true) { + while (true) { + if (__first1 == __last1) // if source exhausted return last correct answer + return __r; // (or __last1 if never found) + if (__pred(*__first1, *__first2)) + break; + ++__first1; + } + // *__first1 matches *__first2, now match elements after here + _ForwardIterator1 __m1 = __first1; + _ForwardIterator2 __m2 = __first2; + while (true) { + if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one + __r = __first1; + ++__first1; + break; + } + if (++__m1 == __last1) // Source exhausted, return last answer + return __r; + if (!__pred(*__m1, *__m2)) // mismatch, restart with a new __first + { + ++__first1; + break; + } // else there is a match, check next elements + } + } +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator1 __find_end( + _BidirectionalIterator1 __first1, _BidirectionalIterator1 __last1, _BidirectionalIterator2 __first2, + _BidirectionalIterator2 __last2, _BinaryPredicate __pred, bidirectional_iterator_tag, bidirectional_iterator_tag) { + // modeled after search algorithm (in reverse) + if (__first2 == __last2) + return __last1; // Everything matches an empty sequence + _BidirectionalIterator1 __l1 = __last1; + _BidirectionalIterator2 __l2 = __last2; + --__l2; + while (true) { + // Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks + while (true) { + if (__first1 == __l1) // return __last1 if no element matches *__first2 + return __last1; + if (__pred(*--__l1, *__l2)) + break; + } + // *__l1 matches *__l2, now match elements before here + _BidirectionalIterator1 __m1 = __l1; + _BidirectionalIterator2 __m2 = __l2; + while (true) { + if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) + return __m1; + if (__m1 == __first1) // Otherwise if source exhaused, pattern not found + return __last1; + if (!__pred(*--__m1, *--__m2)) // if there is a mismatch, restart with a new __l1 + { + break; + } // else there is a match, check next elements + } + } +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator1 __find_end( + _RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, + _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, random_access_iterator_tag) { + // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern + typename iterator_traits<_RandomAccessIterator2>::difference_type __len2 = __last2 - __first2; + if (__len2 == 0) + return __last1; + typename iterator_traits<_RandomAccessIterator1>::difference_type __len1 = __last1 - __first1; + if (__len1 < __len2) + return __last1; + const _RandomAccessIterator1 __s = __first1 + (__len2 - 1); // End of pattern match can't go before here + _RandomAccessIterator1 __l1 = __last1; + _RandomAccessIterator2 __l2 = __last2; + --__l2; + while (true) { + while (true) { + if (__s == __l1) + return __last1; + if (__pred(*--__l1, *__l2)) + break; + } + _RandomAccessIterator1 __m1 = __l1; + _RandomAccessIterator2 __m2 = __l2; + while (true) { + if (__m2 == __first2) + return __m1; + // no need to check range on __m1 because __s guarantees we have enough source + if (!__pred(*--__m1, *--__m2)) { + break; + } + } + } +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 +find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred) { + return _VSTD::__find_end::type>( + __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 +find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { + typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; + typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; + return _VSTD::find_end(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FIND_END_OF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/find_first_of.h b/gnu/llvm/libcxx/include/__algorithm/find_first_of.h new file mode 100644 index 00000000000..d956c8dda2f --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/find_first_of.h @@ -0,0 +1,57 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FIND_FIRST_OF_H +#define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1, + _ForwardIterator1 __last1, + _ForwardIterator2 __first2, + _ForwardIterator2 __last2, _BinaryPredicate __pred) { + for (; __first1 != __last1; ++__first1) + for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) + if (__pred(*__first1, *__j)) + return __first1; + return __last1; +} + +template +_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) { + return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 find_first_of( + _ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { + typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; + typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; + return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/find_if.h b/gnu/llvm/libcxx/include/__algorithm/find_if.h new file mode 100644 index 00000000000..456cc5b0a34 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/find_if.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FIND_IF_H +#define _LIBCPP___ALGORITHM_FIND_IF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator +find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { + for (; __first != __last; ++__first) + if (__pred(*__first)) + break; + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FIND_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/find_if_not.h b/gnu/llvm/libcxx/include/__algorithm/find_if_not.h new file mode 100644 index 00000000000..d7d25160cc7 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/find_if_not.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FIND_IF_NOT_H +#define _LIBCPP___ALGORITHM_FIND_IF_NOT_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator +find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { + for (; __first != __last; ++__first) + if (!__pred(*__first)) + break; + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/for_each.h b/gnu/llvm/libcxx/include/__algorithm/for_each.h new file mode 100644 index 00000000000..e71a36a1de4 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/for_each.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FOR_EACH_H +#define _LIBCPP___ALGORITHM_FOR_EACH_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _Function for_each(_InputIterator __first, + _InputIterator __last, + _Function __f) { + for (; __first != __last; ++__first) + __f(*__first); + return __f; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FOR_EACH_H diff --git a/gnu/llvm/libcxx/include/__algorithm/for_each_n.h b/gnu/llvm/libcxx/include/__algorithm/for_each_n.h new file mode 100644 index 00000000000..77f6c862145 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/for_each_n.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_FOR_EACH_N_H +#define _LIBCPP___ALGORITHM_FOR_EACH_N_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _InputIterator for_each_n(_InputIterator __first, + _Size __orig_n, + _Function __f) { + typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; + while (__n > 0) { + __f(*__first); + ++__first; + --__n; + } + return __first; +} + +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H diff --git a/gnu/llvm/libcxx/include/__algorithm/generate.h b/gnu/llvm/libcxx/include/__algorithm/generate.h new file mode 100644 index 00000000000..d3e1133e2bc --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/generate.h @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_GENERATE_H +#define _LIBCPP___ALGORITHM_GENERATE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) +{ + for (; __first != __last; ++__first) + *__first = __gen(); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_GENERATE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/generate_n.h b/gnu/llvm/libcxx/include/__algorithm/generate_n.h new file mode 100644 index 00000000000..c3125985861 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/generate_n.h @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_GENERATE_N_H +#define _LIBCPP___ALGORITHM_GENERATE_N_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) +{ + typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; + _IntegralSize __n = __orig_n; + for (; __n > 0; ++__first, (void) --__n) + *__first = __gen(); + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_GENERATE_N_H diff --git a/gnu/llvm/libcxx/include/__algorithm/half_positive.h b/gnu/llvm/libcxx/include/__algorithm/half_positive.h new file mode 100644 index 00000000000..b03efc495b1 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/half_positive.h @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_HALF_POSITIVE_H +#define _LIBCPP___ALGORITHM_HALF_POSITIVE_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Perform division by two quickly for positive integers (llvm.org/PR39129) + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + is_integral<_Integral>::value, + _Integral +>::type +__half_positive(_Integral __value) +{ + return static_cast<_Integral>(static_cast::type>(__value) / 2); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + !is_integral<_Tp>::value, + _Tp +>::type +__half_positive(_Tp __value) +{ + return __value / 2; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/includes.h b/gnu/llvm/libcxx/include/__algorithm/includes.h new file mode 100644 index 00000000000..ff298a51118 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/includes.h @@ -0,0 +1,67 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_INCLUDES_H +#define _LIBCPP___ALGORITHM_INCLUDES_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, + _Compare __comp) +{ + for (; __first2 != __last2; ++__first1) + { + if (__first1 == __last1 || __comp(*__first2, *__first1)) + return false; + if (!__comp(*__first1, *__first2)) + ++__first2; + } + return true; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, + _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) +{ + return _VSTD::includes(__first1, __last1, __first2, __last2, + __less::value_type, + typename iterator_traits<_InputIterator2>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_INCLUDES_H diff --git a/gnu/llvm/libcxx/include/__algorithm/inplace_merge.h b/gnu/llvm/libcxx/include/__algorithm/inplace_merge.h new file mode 100644 index 00000000000..c74633a74cf --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/inplace_merge.h @@ -0,0 +1,231 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_INPLACE_MERGE_H +#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H + +#include <__config> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/comp.h> +#include <__algorithm/lower_bound.h> +#include <__algorithm/min.h> +#include <__algorithm/move.h> +#include <__algorithm/rotate.h> +#include <__algorithm/upper_bound.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class __invert // invert the sense of a comparison +{ +private: + _Predicate __p_; +public: + _LIBCPP_INLINE_VISIBILITY __invert() {} + + _LIBCPP_INLINE_VISIBILITY + explicit __invert(_Predicate __p) : __p_(__p) {} + + template + _LIBCPP_INLINE_VISIBILITY + bool operator()(const _T1& __x) {return !__p_(__x);} + + template + _LIBCPP_INLINE_VISIBILITY + bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);} +}; + +template +void __half_inplace_merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) +{ + for (; __first1 != __last1; ++__result) + { + if (__first2 == __last2) + { + _VSTD::move(__first1, __last1, __result); + return; + } + + if (__comp(*__first2, *__first1)) + { + *__result = _VSTD::move(*__first2); + ++__first2; + } + else + { + *__result = _VSTD::move(*__first1); + ++__first1; + } + } + // __first2 through __last2 are already in the right spot. +} + +template +void +__buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, + _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1, + typename iterator_traits<_BidirectionalIterator>::difference_type __len2, + typename iterator_traits<_BidirectionalIterator>::value_type* __buff) +{ + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + __destruct_n __d(0); + unique_ptr __h2(__buff, __d); + if (__len1 <= __len2) + { + value_type* __p = __buff; + for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr(), (void) ++__i, (void) ++__p) + ::new ((void*)__p) value_type(_VSTD::move(*__i)); + _VSTD::__half_inplace_merge<_Compare>(__buff, __p, __middle, __last, __first, __comp); + } + else + { + value_type* __p = __buff; + for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr(), (void) ++__i, (void) ++__p) + ::new ((void*)__p) value_type(_VSTD::move(*__i)); + typedef reverse_iterator<_BidirectionalIterator> _RBi; + typedef reverse_iterator _Rv; + typedef __invert<_Compare> _Inverted; + _VSTD::__half_inplace_merge<_Inverted>(_Rv(__p), _Rv(__buff), + _RBi(__middle), _RBi(__first), + _RBi(__last), _Inverted(__comp)); + } +} + +template +void +__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, + _Compare __comp, typename iterator_traits<_BidirectionalIterator>::difference_type __len1, + typename iterator_traits<_BidirectionalIterator>::difference_type __len2, + typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size) +{ + typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; + while (true) + { + // if __middle == __last, we're done + if (__len2 == 0) + return; + if (__len1 <= __buff_size || __len2 <= __buff_size) + return _VSTD::__buffered_inplace_merge<_Compare> + (__first, __middle, __last, __comp, __len1, __len2, __buff); + // shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 + for (; true; ++__first, (void) --__len1) + { + if (__len1 == 0) + return; + if (__comp(*__middle, *__first)) + break; + } + // __first < __middle < __last + // *__first > *__middle + // partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that + // all elements in: + // [__first, __m1) <= [__middle, __m2) + // [__middle, __m2) < [__m1, __middle) + // [__m1, __middle) <= [__m2, __last) + // and __m1 or __m2 is in the middle of its range + _BidirectionalIterator __m1; // "median" of [__first, __middle) + _BidirectionalIterator __m2; // "median" of [__middle, __last) + difference_type __len11; // distance(__first, __m1) + difference_type __len21; // distance(__middle, __m2) + // binary search smaller range + if (__len1 < __len2) + { // __len >= 1, __len2 >= 2 + __len21 = __len2 / 2; + __m2 = __middle; + _VSTD::advance(__m2, __len21); + __m1 = _VSTD::__upper_bound<_Compare>(__first, __middle, *__m2, __comp); + __len11 = _VSTD::distance(__first, __m1); + } + else + { + if (__len1 == 1) + { // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1 + // It is known *__first > *__middle + swap(*__first, *__middle); + return; + } + // __len1 >= 2, __len2 >= 1 + __len11 = __len1 / 2; + __m1 = __first; + _VSTD::advance(__m1, __len11); + __m2 = _VSTD::__lower_bound<_Compare>(__middle, __last, *__m1, __comp); + __len21 = _VSTD::distance(__middle, __m2); + } + difference_type __len12 = __len1 - __len11; // distance(__m1, __middle) + difference_type __len22 = __len2 - __len21; // distance(__m2, __last) + // [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) + // swap middle two partitions + __middle = _VSTD::rotate(__m1, __middle, __m2); + // __len12 and __len21 now have swapped meanings + // merge smaller range with recursive call and larger with tail recursion elimination + if (__len11 + __len21 < __len12 + __len22) + { + _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); +// _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); + __first = __middle; + __middle = __m2; + __len1 = __len12; + __len2 = __len22; + } + else + { + _VSTD::__inplace_merge<_Compare>(__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); +// _VSTD::__inplace_merge<_Compare>(__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); + __last = __middle; + __middle = __m1; + __len1 = __len11; + __len2 = __len21; + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, + _Compare __comp) +{ + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; + difference_type __len1 = _VSTD::distance(__first, __middle); + difference_type __len2 = _VSTD::distance(__middle, __last); + difference_type __buf_size = _VSTD::min(__len1, __len2); + pair __buf = _VSTD::get_temporary_buffer(__buf_size); + unique_ptr __h(__buf.first); + 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); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) +{ + _VSTD::inplace_merge(__first, __middle, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_INPLACE_MERGE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/is_heap.h b/gnu/llvm/libcxx/include/__algorithm/is_heap.h new file mode 100644 index 00000000000..bc3682d471a --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/is_heap.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_IS_HEAP_H +#define _LIBCPP___ALGORITHM_IS_HEAP_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/is_heap_until.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + return _VSTD::is_heap_until(__first, __last, __comp) == __last; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + return _VSTD::is_heap(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_IS_HEAP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/is_heap_until.h b/gnu/llvm/libcxx/include/__algorithm/is_heap_until.h new file mode 100644 index 00000000000..8c52edb7d49 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/is_heap_until.h @@ -0,0 +1,65 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_IS_HEAP_UNTIL_H +#define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator +is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + difference_type __len = __last - __first; + difference_type __p = 0; + difference_type __c = 1; + _RandomAccessIterator __pp = __first; + while (__c < __len) + { + _RandomAccessIterator __cp = __first + __c; + if (__comp(*__pp, *__cp)) + return __cp; + ++__c; + ++__cp; + if (__c == __len) + return __last; + if (__comp(*__pp, *__cp)) + return __cp; + ++__p; + ++__pp; + __c = 2 * __p + 1; + } + return __last; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_RandomAccessIterator +is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + return _VSTD::is_heap_until(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H diff --git a/gnu/llvm/libcxx/include/__algorithm/is_partitioned.h b/gnu/llvm/libcxx/include/__algorithm/is_partitioned.h new file mode 100644 index 00000000000..43de6650cbd --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/is_partitioned.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_IS_PARTITIONED_H +#define _LIBCPP___ALGORITHM_IS_PARTITIONED_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) +{ + for (; __first != __last; ++__first) + if (!__pred(*__first)) + break; + if ( __first == __last ) + return true; + ++__first; + for (; __first != __last; ++__first) + if (__pred(*__first)) + return false; + return true; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H diff --git a/gnu/llvm/libcxx/include/__algorithm/is_permutation.h b/gnu/llvm/libcxx/include/__algorithm/is_permutation.h new file mode 100644 index 00000000000..0545eb76370 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/is_permutation.h @@ -0,0 +1,168 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_IS_PERMUTATION_H +#define _LIBCPP___ALGORITHM_IS_PERMUTATION_H + +#include <__algorithm/comp.h> +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__iterator/next.h> +#include // FIXME: replace with <__iterator/distance.h> when it lands + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, + _BinaryPredicate __pred) { + // shorten sequences as much as possible by lopping of any equal prefix + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!__pred(*__first1, *__first2)) + break; + if (__first1 == __last1) + return true; + + // __first1 != __last1 && *__first1 != *__first2 + typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; + _D1 __l1 = _VSTD::distance(__first1, __last1); + if (__l1 == _D1(1)) + return false; + _ForwardIterator2 __last2 = _VSTD::next(__first2, __l1); + // For each element in [f1, l1) see if there are the same number of + // equal elements in [f2, l2) + for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) { + // Have we already counted the number of *__i in [f1, l1)? + _ForwardIterator1 __match = __first1; + for (; __match != __i; ++__match) + if (__pred(*__match, *__i)) + break; + if (__match == __i) { + // Count number of *__i in [f2, l2) + _D1 __c2 = 0; + for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) + if (__pred(*__i, *__j)) + ++__c2; + if (__c2 == 0) + return false; + // Count number of *__i in [__i, l1) (we can start with 1) + _D1 __c1 = 1; + for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) + if (__pred(*__i, *__j)) + ++__c1; + if (__c1 != __c2) + return false; + } + } + return true; +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { + typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; + typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; + return _VSTD::is_permutation(__first1, __last1, __first2, __equal_to<__v1, __v2>()); +} + +#if _LIBCPP_STD_VER > 11 +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, + _ForwardIterator2 __last2, _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) { + // shorten sequences as much as possible by lopping of any equal prefix + for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) + if (!__pred(*__first1, *__first2)) + break; + if (__first1 == __last1) + return __first2 == __last2; + else if (__first2 == __last2) + return false; + + typedef typename iterator_traits<_ForwardIterator1>::difference_type _D1; + _D1 __l1 = _VSTD::distance(__first1, __last1); + + typedef typename iterator_traits<_ForwardIterator2>::difference_type _D2; + _D2 __l2 = _VSTD::distance(__first2, __last2); + if (__l1 != __l2) + return false; + + // For each element in [f1, l1) see if there are the same number of + // equal elements in [f2, l2) + for (_ForwardIterator1 __i = __first1; __i != __last1; ++__i) { + // Have we already counted the number of *__i in [f1, l1)? + _ForwardIterator1 __match = __first1; + for (; __match != __i; ++__match) + if (__pred(*__match, *__i)) + break; + if (__match == __i) { + // Count number of *__i in [f2, l2) + _D1 __c2 = 0; + for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) + if (__pred(*__i, *__j)) + ++__c2; + if (__c2 == 0) + return false; + // Count number of *__i in [__i, l1) (we can start with 1) + _D1 __c1 = 1; + for (_ForwardIterator1 __j = _VSTD::next(__i); __j != __last1; ++__j) + if (__pred(*__i, *__j)) + ++__c1; + if (__c1 != __c2) + return false; + } + } + return true; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1, + _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2, + _BinaryPredicate __pred, random_access_iterator_tag, + random_access_iterator_tag) { + if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) + return false; + return _VSTD::is_permutation<_RandomAccessIterator1, _RandomAccessIterator2, + typename add_lvalue_reference<_BinaryPredicate>::type>(__first1, __last1, __first2, + __pred); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, + _ForwardIterator2 __last2, _BinaryPredicate __pred) { + return _VSTD::__is_permutation::type>( + __first1, __last1, __first2, __last2, __pred, typename iterator_traits<_ForwardIterator1>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, + _ForwardIterator2 __last2) { + typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; + typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; + return _VSTD::__is_permutation(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>(), + typename iterator_traits<_ForwardIterator1>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_IS_PERMUTATION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/is_sorted.h b/gnu/llvm/libcxx/include/__algorithm/is_sorted.h new file mode 100644 index 00000000000..30d8da0499e --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/is_sorted.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_IS_SORTED_H +#define _LIBCPP___ALGORITHM_IS_SORTED_H + +#include <__algorithm/comp.h> +#include <__algorithm/is_sorted_until.h> +#include <__config> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +is_sorted(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + return _VSTD::is_sorted_until(__first, __last, __comp) == __last; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +is_sorted(_ForwardIterator __first, _ForwardIterator __last) +{ + return _VSTD::is_sorted(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_IS_SORTED_H diff --git a/gnu/llvm/libcxx/include/__algorithm/is_sorted_until.h b/gnu/llvm/libcxx/include/__algorithm/is_sorted_until.h new file mode 100644 index 00000000000..a914b5a566b --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/is_sorted_until.h @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_IS_SORTED_UNTIL_H +#define _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +is_sorted_until(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + if (__first != __last) + { + _ForwardIterator __i = __first; + while (++__i != __last) + { + if (__comp(*__i, *__first)) + return __i; + __first = __i; + } + } + return __last; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +is_sorted_until(_ForwardIterator __first, _ForwardIterator __last) +{ + return _VSTD::is_sorted_until(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_IS_SORTED_UNTIL_H diff --git a/gnu/llvm/libcxx/include/__algorithm/iter_swap.h b/gnu/llvm/libcxx/include/__algorithm/iter_swap.h new file mode 100644 index 00000000000..b63bce62cc0 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/iter_swap.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_ITER_SWAP_H +#define _LIBCPP___ALGORITHM_ITER_SWAP_H + +#include <__config> +#include <__utility/declval.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 void iter_swap(_ForwardIterator1 __a, + _ForwardIterator2 __b) + // _NOEXCEPT_(_NOEXCEPT_(swap(*__a, *__b))) + _NOEXCEPT_(_NOEXCEPT_(swap(*declval<_ForwardIterator1>(), *declval<_ForwardIterator2>()))) { + swap(*__a, *__b); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_ITER_SWAP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/lexicographical_compare.h b/gnu/llvm/libcxx/include/__algorithm/lexicographical_compare.h new file mode 100644 index 00000000000..6e4a90bdc03 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/lexicographical_compare.h @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H +#define _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) +{ + for (; __first2 != __last2; ++__first1, (void) ++__first2) + { + if (__first1 == __last1 || __comp(*__first1, *__first2)) + return true; + if (__comp(*__first2, *__first1)) + return false; + } + return false; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2) +{ + return _VSTD::lexicographical_compare(__first1, __last1, __first2, __last2, + __less::value_type, + typename iterator_traits<_InputIterator2>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_LEXICOGRAPHICAL_COMPARE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/lower_bound.h b/gnu/llvm/libcxx/include/__algorithm/lower_bound.h new file mode 100644 index 00000000000..1448c896332 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/lower_bound.h @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_LOWER_BOUND_H +#define _LIBCPP___ALGORITHM_LOWER_BOUND_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/half_positive.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +__lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; + difference_type __len = _VSTD::distance(__first, __last); + while (__len != 0) + { + difference_type __l2 = _VSTD::__half_positive(__len); + _ForwardIterator __m = __first; + _VSTD::advance(__m, __l2); + if (__comp(*__m, __value_)) + { + __first = ++__m; + __len -= __l2 + 1; + } + else + __len = __l2; + } + return __first; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + return _VSTD::__lower_bound<_Comp_ref>(__first, __last, __value_, __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) +{ + return _VSTD::lower_bound(__first, __last, __value_, + __less::value_type, _Tp>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_LOWER_BOUND_H diff --git a/gnu/llvm/libcxx/include/__algorithm/make_heap.h b/gnu/llvm/libcxx/include/__algorithm/make_heap.h new file mode 100644 index 00000000000..eca4013cbd1 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/make_heap.h @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MAKE_HEAP_H +#define _LIBCPP___ALGORITHM_MAKE_HEAP_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/sift_down.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 void +__make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + difference_type __n = __last - __first; + if (__n > 1) + { + // start from the first parent, there is no need to consider children + for (difference_type __start = (__n - 2) / 2; __start >= 0; --__start) + { + _VSTD::__sift_down<_Compare>(__first, __last, __comp, __n, __first + __start); + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__make_heap<_Comp_ref>(__first, __last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + _VSTD::make_heap(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MAKE_HEAP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/max.h b/gnu/llvm/libcxx/include/__algorithm/max.h new file mode 100644 index 00000000000..2fa97cad87f --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/max.h @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MAX_H +#define _LIBCPP___ALGORITHM_MAX_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/max_element.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp& +max(const _Tp& __a, const _Tp& __b, _Compare __comp) +{ + return __comp(__a, __b) ? __b : __a; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp& +max(const _Tp& __a, const _Tp& __b) +{ + return _VSTD::max(__a, __b, __less<_Tp>()); +} + +#ifndef _LIBCPP_CXX03_LANG + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp +max(initializer_list<_Tp> __t, _Compare __comp) +{ + return *_VSTD::max_element(__t.begin(), __t.end(), __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp +max(initializer_list<_Tp> __t) +{ + return *_VSTD::max_element(__t.begin(), __t.end(), __less<_Tp>()); +} + +#endif // _LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MAX_H diff --git a/gnu/llvm/libcxx/include/__algorithm/max_element.h b/gnu/llvm/libcxx/include/__algorithm/max_element.h new file mode 100644 index 00000000000..b93b67eacf5 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/max_element.h @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MAX_ELEMENT_H +#define _LIBCPP___ALGORITHM_MAX_ELEMENT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator +max_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, + "std::max_element requires a ForwardIterator"); + if (__first != __last) + { + _ForwardIterator __i = __first; + while (++__i != __last) + if (__comp(*__first, *__i)) + __first = __i; + } + return __first; +} + + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator +max_element(_ForwardIterator __first, _ForwardIterator __last) +{ + return _VSTD::max_element(__first, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MAX_ELEMENT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/merge.h b/gnu/llvm/libcxx/include/__algorithm/merge.h new file mode 100644 index 00000000000..ea53ad68f7f --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/merge.h @@ -0,0 +1,76 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MERGE_H +#define _LIBCPP___ALGORITHM_MERGE_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/copy.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +__merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + for (; __first1 != __last1; ++__result) + { + if (__first2 == __last2) + return _VSTD::copy(__first1, __last1, __result); + if (__comp(*__first2, *__first1)) + { + *__result = *__first2; + ++__first2; + } + else + { + *__result = *__first1; + ++__first1; + } + } + return _VSTD::copy(__first2, __last2, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +merge(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) +{ + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::merge(__first1, __last1, __first2, __last2, __result, __less<__v1, __v2>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MERGE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/min.h b/gnu/llvm/libcxx/include/__algorithm/min.h new file mode 100644 index 00000000000..9fea7f70a2b --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/min.h @@ -0,0 +1,70 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MIN_H +#define _LIBCPP___ALGORITHM_MIN_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/min_element.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp& +min(const _Tp& __a, const _Tp& __b, _Compare __comp) +{ + return __comp(__b, __a) ? __b : __a; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp& +min(const _Tp& __a, const _Tp& __b) +{ + return _VSTD::min(__a, __b, __less<_Tp>()); +} + +#ifndef _LIBCPP_CXX03_LANG + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp +min(initializer_list<_Tp> __t, _Compare __comp) +{ + return *_VSTD::min_element(__t.begin(), __t.end(), __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp +min(initializer_list<_Tp> __t) +{ + return *_VSTD::min_element(__t.begin(), __t.end(), __less<_Tp>()); +} + +#endif // _LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MIN_H diff --git a/gnu/llvm/libcxx/include/__algorithm/min_element.h b/gnu/llvm/libcxx/include/__algorithm/min_element.h new file mode 100644 index 00000000000..6bff140e5d9 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/min_element.h @@ -0,0 +1,57 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MIN_ELEMENT_H +#define _LIBCPP___ALGORITHM_MIN_ELEMENT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator +min_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, + "std::min_element requires a ForwardIterator"); + if (__first != __last) + { + _ForwardIterator __i = __first; + while (++__i != __last) + if (__comp(*__i, *__first)) + __first = __i; + } + return __first; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_ForwardIterator +min_element(_ForwardIterator __first, _ForwardIterator __last) +{ + return _VSTD::min_element(__first, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MIN_ELEMENT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/minmax.h b/gnu/llvm/libcxx/include/__algorithm/minmax.h new file mode 100644 index 00000000000..63753f2fecd --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/minmax.h @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MINMAX_H +#define _LIBCPP___ALGORITHM_MINMAX_H + +#include <__config> +#include <__algorithm/comp.h> +#include +#include + + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair +minmax(const _Tp& __a, const _Tp& __b, _Compare __comp) +{ + return __comp(__b, __a) ? pair(__b, __a) : + pair(__a, __b); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair +minmax(const _Tp& __a, const _Tp& __b) +{ + return _VSTD::minmax(__a, __b, __less<_Tp>()); +} + +#ifndef _LIBCPP_CXX03_LANG + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<_Tp, _Tp> +minmax(initializer_list<_Tp> __t, _Compare __comp) +{ + typedef typename initializer_list<_Tp>::const_iterator _Iter; + _Iter __first = __t.begin(); + _Iter __last = __t.end(); + pair<_Tp, _Tp> __result(*__first, *__first); + + ++__first; + if (__t.size() % 2 == 0) + { + if (__comp(*__first, __result.first)) + __result.first = *__first; + else + __result.second = *__first; + ++__first; + } + + while (__first != __last) + { + _Tp __prev = *__first++; + if (__comp(*__first, __prev)) { + if ( __comp(*__first, __result.first)) __result.first = *__first; + if (!__comp(__prev, __result.second)) __result.second = __prev; + } + else { + if ( __comp(__prev, __result.first)) __result.first = __prev; + if (!__comp(*__first, __result.second)) __result.second = *__first; + } + + __first++; + } + return __result; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<_Tp, _Tp> +minmax(initializer_list<_Tp> __t) +{ + return _VSTD::minmax(__t, __less<_Tp>()); +} + +#endif // _LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MINMAX_H diff --git a/gnu/llvm/libcxx/include/__algorithm/minmax_element.h b/gnu/llvm/libcxx/include/__algorithm/minmax_element.h new file mode 100644 index 00000000000..1eba006de9a --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/minmax_element.h @@ -0,0 +1,90 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MINMAX_ELEMENT_H +#define _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<_ForwardIterator, _ForwardIterator> +minmax_element(_ForwardIterator __first, _ForwardIterator __last, _Compare __comp) +{ + static_assert(__is_cpp17_forward_iterator<_ForwardIterator>::value, + "std::minmax_element requires a ForwardIterator"); + pair<_ForwardIterator, _ForwardIterator> __result(__first, __first); + if (__first != __last) + { + if (++__first != __last) + { + if (__comp(*__first, *__result.first)) + __result.first = __first; + else + __result.second = __first; + while (++__first != __last) + { + _ForwardIterator __i = __first; + if (++__first == __last) + { + if (__comp(*__i, *__result.first)) + __result.first = __i; + else if (!__comp(*__i, *__result.second)) + __result.second = __i; + break; + } + else + { + if (__comp(*__first, *__i)) + { + if (__comp(*__first, *__result.first)) + __result.first = __first; + if (!__comp(*__i, *__result.second)) + __result.second = __i; + } + else + { + if (__comp(*__i, *__result.first)) + __result.first = __i; + if (!__comp(*__first, *__result.second)) + __result.second = __first; + } + } + } + } + } + return __result; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +pair<_ForwardIterator, _ForwardIterator> +minmax_element(_ForwardIterator __first, _ForwardIterator __last) +{ + return _VSTD::minmax_element(__first, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MINMAX_ELEMENT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/mismatch.h b/gnu/llvm/libcxx/include/__algorithm/mismatch.h new file mode 100644 index 00000000000..fdd2bc8c09c --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/mismatch.h @@ -0,0 +1,72 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MISMATCH_H +#define _LIBCPP___ALGORITHM_MISMATCH_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { + for (; __first1 != __last1; ++__first1, (void)++__first2) + if (!__pred(*__first1, *__first2)) + break; + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::mismatch(__first1, __last1, __first2, __equal_to<__v1, __v2>()); +} + +#if _LIBCPP_STD_VER > 11 +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, + _BinaryPredicate __pred) { + for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) + if (!__pred(*__first1, *__first2)) + break; + return pair<_InputIterator1, _InputIterator2>(__first1, __first2); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_InputIterator1, _InputIterator2> + mismatch(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { + typedef typename iterator_traits<_InputIterator1>::value_type __v1; + typedef typename iterator_traits<_InputIterator2>::value_type __v2; + return _VSTD::mismatch(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MISMATCH_H diff --git a/gnu/llvm/libcxx/include/__algorithm/move.h b/gnu/llvm/libcxx/include/__algorithm/move.h new file mode 100644 index 00000000000..f5fc74854f0 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/move.h @@ -0,0 +1,83 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MOVE_H +#define _LIBCPP___ALGORITHM_MOVE_H + +#include <__config> +#include <__algorithm/unwrap_iter.h> +#include <__utility/move.h> +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// move + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +_OutputIterator +__move_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + for (; __first != __last; ++__first, (void) ++__result) + *__result = _VSTD::move(*__first); + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +_OutputIterator +__move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + return _VSTD::__move_constexpr(__first, __last, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename enable_if +< + is_same::type, _Up>::value && + is_trivially_move_assignable<_Up>::value, + _Up* +>::type +__move(_Tp* __first, _Tp* __last, _Up* __result) +{ + const size_t __n = static_cast(__last - __first); + if (__n > 0) + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + return __result + __n; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +move(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + if (__libcpp_is_constant_evaluated()) { + return _VSTD::__move_constexpr(__first, __last, __result); + } else { + return _VSTD::__rewrap_iter(__result, + _VSTD::__move(_VSTD::__unwrap_iter(__first), + _VSTD::__unwrap_iter(__last), + _VSTD::__unwrap_iter(__result))); + } +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MOVE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/move_backward.h b/gnu/llvm/libcxx/include/__algorithm/move_backward.h new file mode 100644 index 00000000000..1c93b981973 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/move_backward.h @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_MOVE_BACKWARD_H +#define _LIBCPP___ALGORITHM_MOVE_BACKWARD_H + +#include <__config> +#include <__algorithm/unwrap_iter.h> +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +_OutputIterator +__move_backward_constexpr(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + while (__first != __last) + *--__result = _VSTD::move(*--__last); + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +_OutputIterator +__move_backward(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + return _VSTD::__move_backward_constexpr(__first, __last, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename enable_if +< + is_same::type, _Up>::value && + is_trivially_move_assignable<_Up>::value, + _Up* +>::type +__move_backward(_Tp* __first, _Tp* __last, _Up* __result) +{ + const size_t __n = static_cast(__last - __first); + if (__n > 0) + { + __result -= __n; + _VSTD::memmove(__result, __first, __n * sizeof(_Up)); + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_BidirectionalIterator2 +move_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, + _BidirectionalIterator2 __result) +{ + if (__libcpp_is_constant_evaluated()) { + return _VSTD::__move_backward_constexpr(__first, __last, __result); + } else { + return _VSTD::__rewrap_iter(__result, + _VSTD::__move_backward(_VSTD::__unwrap_iter(__first), + _VSTD::__unwrap_iter(__last), + _VSTD::__unwrap_iter(__result))); + } +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_MOVE_BACKWARD_H diff --git a/gnu/llvm/libcxx/include/__algorithm/next_permutation.h b/gnu/llvm/libcxx/include/__algorithm/next_permutation.h new file mode 100644 index 00000000000..a337e5efa09 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/next_permutation.h @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_NEXT_PERMUTATION_H +#define _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/reverse.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) +{ + _BidirectionalIterator __i = __last; + if (__first == __last || __first == --__i) + return false; + while (true) + { + _BidirectionalIterator __ip1 = __i; + if (__comp(*--__i, *__ip1)) + { + _BidirectionalIterator __j = __last; + while (!__comp(*__i, *--__j)) + ; + swap(*__i, *__j); + _VSTD::reverse(__ip1, __last); + return true; + } + if (__i == __first) + { + _VSTD::reverse(__first, __last); + return false; + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__next_permutation<_Comp_ref>(__first, __last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) +{ + return _VSTD::next_permutation(__first, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_NEXT_PERMUTATION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/none_of.h b/gnu/llvm/libcxx/include/__algorithm/none_of.h new file mode 100644 index 00000000000..285691520c4 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/none_of.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_NONE_OF_H +#define _LIBCPP___ALGORITHM_NONE_OF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 bool +none_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { + for (; __first != __last; ++__first) + if (__pred(*__first)) + return false; + return true; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_NONE_OF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/nth_element.h b/gnu/llvm/libcxx/include/__algorithm/nth_element.h new file mode 100644 index 00000000000..67a03cfc37b --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/nth_element.h @@ -0,0 +1,244 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_NTH_ELEMENT_H +#define _LIBCPP___ALGORITHM_NTH_ELEMENT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/sort.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 bool +__nth_element_find_guard(_RandomAccessIterator& __i, _RandomAccessIterator& __j, + _RandomAccessIterator __m, _Compare __comp) +{ + // manually guard downward moving __j against __i + while (true) { + if (__i == --__j) { + return false; + } + if (__comp(*__j, *__m)) { + return true; // found guard for downward moving __j, now use unguarded partition + } + } +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 void +__nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) +{ + // _Compare is known to be a reference type + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + const difference_type __limit = 7; + while (true) + { + if (__nth == __last) + return; + difference_type __len = __last - __first; + switch (__len) + { + case 0: + case 1: + return; + case 2: + if (__comp(*--__last, *__first)) + swap(*__first, *__last); + return; + case 3: + { + _RandomAccessIterator __m = __first; + _VSTD::__sort3<_Compare>(__first, ++__m, --__last, __comp); + return; + } + } + if (__len <= __limit) + { + _VSTD::__selection_sort<_Compare>(__first, __last, __comp); + return; + } + // __len > __limit >= 3 + _RandomAccessIterator __m = __first + __len/2; + _RandomAccessIterator __lm1 = __last; + unsigned __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, --__lm1, __comp); + // *__m is median + // partition [__first, __m) < *__m and *__m <= [__m, __last) + // (this inhibits tossing elements equivalent to __m around unnecessarily) + _RandomAccessIterator __i = __first; + _RandomAccessIterator __j = __lm1; + // j points beyond range to be tested, *__lm1 is known to be <= *__m + // The search going up is known to be guarded but the search coming down isn't. + // Prime the downward search with a guard. + if (!__comp(*__i, *__m)) // if *__first == *__m + { + // *__first == *__m, *__first doesn't go in first part + if (_VSTD::__nth_element_find_guard<_Compare>(__i, __j, __m, __comp)) { + swap(*__i, *__j); + ++__n_swaps; + } else { + // *__first == *__m, *__m <= all other elements + // Partition instead into [__first, __i) == *__first and *__first < [__i, __last) + ++__i; // __first + 1 + __j = __last; + if (!__comp(*__first, *--__j)) { // we need a guard if *__first == *(__last-1) + while (true) { + if (__i == __j) { + return; // [__first, __last) all equivalent elements + } else if (__comp(*__first, *__i)) { + swap(*__i, *__j); + ++__n_swaps; + ++__i; + break; + } + ++__i; + } + } + // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1 + if (__i == __j) { + return; + } + while (true) { + while (!__comp(*__first, *__i)) + ++__i; + while (__comp(*__first, *--__j)) + ; + if (__i >= __j) + break; + swap(*__i, *__j); + ++__n_swaps; + ++__i; + } + // [__first, __i) == *__first and *__first < [__i, __last) + // The first part is sorted, + if (__nth < __i) { + return; + } + // __nth_element the second part + // _VSTD::__nth_element<_Compare>(__i, __nth, __last, __comp); + __first = __i; + continue; + } + } + ++__i; + // j points beyond range to be tested, *__lm1 is known to be <= *__m + // if not yet partitioned... + if (__i < __j) + { + // known that *(__i - 1) < *__m + while (true) + { + // __m still guards upward moving __i + while (__comp(*__i, *__m)) + ++__i; + // It is now known that a guard exists for downward moving __j + while (!__comp(*--__j, *__m)) + ; + if (__i >= __j) + break; + swap(*__i, *__j); + ++__n_swaps; + // It is known that __m != __j + // If __m just moved, follow it + if (__m == __i) + __m = __j; + ++__i; + } + } + // [__first, __i) < *__m and *__m <= [__i, __last) + if (__i != __m && __comp(*__m, *__i)) + { + swap(*__i, *__m); + ++__n_swaps; + } + // [__first, __i) < *__i and *__i <= [__i+1, __last) + if (__nth == __i) + return; + if (__n_swaps == 0) + { + // We were given a perfectly partitioned sequence. Coincidence? + if (__nth < __i) + { + // Check for [__first, __i) already sorted + __j = __m = __first; + while (true) { + if (++__j == __i) { + // [__first, __i) sorted + return; + } + if (__comp(*__j, *__m)) { + // not yet sorted, so sort + break; + } + __m = __j; + } + } + else + { + // Check for [__i, __last) already sorted + __j = __m = __i; + while (true) { + if (++__j == __last) { + // [__i, __last) sorted + return; + } + if (__comp(*__j, *__m)) { + // not yet sorted, so sort + break; + } + __m = __j; + } + } + } + // __nth_element on range containing __nth + if (__nth < __i) + { + // _VSTD::__nth_element<_Compare>(__first, __nth, __i, __comp); + __last = __i; + } + else + { + // _VSTD::__nth_element<_Compare>(__i+1, __nth, __last, __comp); + __first = ++__i; + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__nth_element<_Comp_ref>(__first, __nth, __last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last) +{ + _VSTD::nth_element(__first, __nth, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_NTH_ELEMENT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/partial_sort.h b/gnu/llvm/libcxx/include/__algorithm/partial_sort.h new file mode 100644 index 00000000000..4f9872c4922 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/partial_sort.h @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PARTIAL_SORT_H +#define _LIBCPP___ALGORITHM_PARTIAL_SORT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/make_heap.h> +#include <__algorithm/sift_down.h> +#include <__algorithm/sort_heap.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void +__partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, + _Compare __comp) +{ + _VSTD::__make_heap<_Compare>(__first, __middle, __comp); + typename iterator_traits<_RandomAccessIterator>::difference_type __len = __middle - __first; + for (_RandomAccessIterator __i = __middle; __i != __last; ++__i) + { + if (__comp(*__i, *__first)) + { + swap(*__i, *__first); + _VSTD::__sift_down<_Compare>(__first, __middle, __comp, __len, __first); + } + } + _VSTD::__sort_heap<_Compare>(__first, __middle, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, + _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__partial_sort<_Comp_ref>(__first, __middle, __last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) +{ + _VSTD::partial_sort(__first, __middle, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/partial_sort_copy.h b/gnu/llvm/libcxx/include/__algorithm/partial_sort_copy.h new file mode 100644 index 00000000000..31a12615fa5 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/partial_sort_copy.h @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PARTIAL_SORT_COPY_H +#define _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/make_heap.h> +#include <__algorithm/sift_down.h> +#include <__algorithm/sort_heap.h> +#include <__iterator/iterator_traits.h> +#include // swap + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator +__partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) +{ + _RandomAccessIterator __r = __result_first; + if (__r != __result_last) + { + for (; __first != __last && __r != __result_last; ++__first, (void) ++__r) + *__r = *__first; + _VSTD::__make_heap<_Compare>(__result_first, __r, __comp); + typename iterator_traits<_RandomAccessIterator>::difference_type __len = __r - __result_first; + for (; __first != __last; ++__first) + if (__comp(*__first, *__result_first)) + { + *__result_first = *__first; + _VSTD::__sift_down<_Compare>(__result_first, __r, __comp, __len, __result_first); + } + _VSTD::__sort_heap<_Compare>(__result_first, __r, __comp); + } + return __r; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_RandomAccessIterator +partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_RandomAccessIterator +partial_sort_copy(_InputIterator __first, _InputIterator __last, + _RandomAccessIterator __result_first, _RandomAccessIterator __result_last) +{ + return _VSTD::partial_sort_copy(__first, __last, __result_first, __result_last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PARTIAL_SORT_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/partition.h b/gnu/llvm/libcxx/include/__algorithm/partition.h new file mode 100644 index 00000000000..c859eaca28a --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/partition.h @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PARTITION_H +#define _LIBCPP___ALGORITHM_PARTITION_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> +#include // pair +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +__partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, forward_iterator_tag) +{ + while (true) + { + if (__first == __last) + return __first; + if (!__pred(*__first)) + break; + ++__first; + } + for (_ForwardIterator __p = __first; ++__p != __last;) + { + if (__pred(*__p)) + { + swap(*__first, *__p); + ++__first; + } + } + return __first; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _BidirectionalIterator +__partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, + bidirectional_iterator_tag) +{ + while (true) + { + while (true) + { + if (__first == __last) + return __first; + if (!__pred(*__first)) + break; + ++__first; + } + do + { + if (__first == --__last) + return __first; + } while (!__pred(*__last)); + swap(*__first, *__last); + ++__first; + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) +{ + return _VSTD::__partition::type> + (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PARTITION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/partition_copy.h b/gnu/llvm/libcxx/include/__algorithm/partition_copy.h new file mode 100644 index 00000000000..445eacdfbe9 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/partition_copy.h @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PARTITION_COPY_H +#define _LIBCPP___ALGORITHM_PARTITION_COPY_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include // pair + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 pair<_OutputIterator1, _OutputIterator2> +partition_copy(_InputIterator __first, _InputIterator __last, + _OutputIterator1 __out_true, _OutputIterator2 __out_false, + _Predicate __pred) +{ + for (; __first != __last; ++__first) + { + if (__pred(*__first)) + { + *__out_true = *__first; + ++__out_true; + } + else + { + *__out_false = *__first; + ++__out_false; + } + } + return pair<_OutputIterator1, _OutputIterator2>(__out_true, __out_false); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PARTITION_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/partition_point.h b/gnu/llvm/libcxx/include/__algorithm/partition_point.h new file mode 100644 index 00000000000..12ddacf9d75 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/partition_point.h @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PARTITION_POINT_H +#define _LIBCPP___ALGORITHM_PARTITION_POINT_H + +#include <__config> +#include <__algorithm/half_positive.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +partition_point(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) +{ + typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; + difference_type __len = _VSTD::distance(__first, __last); + while (__len != 0) + { + difference_type __l2 = _VSTD::__half_positive(__len); + _ForwardIterator __m = __first; + _VSTD::advance(__m, __l2); + if (__pred(*__m)) + { + __first = ++__m; + __len -= __l2 + 1; + } + else + __len = __l2; + } + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PARTITION_POINT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/pop_heap.h b/gnu/llvm/libcxx/include/__algorithm/pop_heap.h new file mode 100644 index 00000000000..7ebbef25e0b --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/pop_heap.h @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_POP_HEAP_H +#define _LIBCPP___ALGORITHM_POP_HEAP_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/sift_down.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +__pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len) +{ + if (__len > 1) + { + swap(*__first, *--__last); + _VSTD::__sift_down<_Compare>(__first, __last, __comp, __len - 1, __first); + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + _VSTD::pop_heap(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_POP_HEAP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/prev_permutation.h b/gnu/llvm/libcxx/include/__algorithm/prev_permutation.h new file mode 100644 index 00000000000..d6daa73ada0 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/prev_permutation.h @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PREV_PERMUTATION_H +#define _LIBCPP___ALGORITHM_PREV_PERMUTATION_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/reverse.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 bool +__prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) +{ + _BidirectionalIterator __i = __last; + if (__first == __last || __first == --__i) + return false; + while (true) + { + _BidirectionalIterator __ip1 = __i; + if (__comp(*__ip1, *--__i)) + { + _BidirectionalIterator __j = __last; + while (!__comp(*--__j, *__i)) + ; + swap(*__i, *__j); + _VSTD::reverse(__ip1, __last); + return true; + } + if (__i == __first) + { + _VSTD::reverse(__first, __last); + return false; + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__prev_permutation<_Comp_ref>(__first, __last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool +prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last) +{ + return _VSTD::prev_permutation(__first, __last, + __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PREV_PERMUTATION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/push_heap.h b/gnu/llvm/libcxx/include/__algorithm/push_heap.h new file mode 100644 index 00000000000..82a7c123d83 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/push_heap.h @@ -0,0 +1,75 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_PUSH_HEAP_H +#define _LIBCPP___ALGORITHM_PUSH_HEAP_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__iterator/iterator_traits.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 void +__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len) +{ + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + if (__len > 1) + { + __len = (__len - 2) / 2; + _RandomAccessIterator __ptr = __first + __len; + if (__comp(*__ptr, *--__last)) + { + value_type __t(_VSTD::move(*__last)); + do + { + *__last = _VSTD::move(*__ptr); + __last = __ptr; + if (__len == 0) + break; + __len = (__len - 1) / 2; + __ptr = __first + __len; + } while (__comp(*__ptr, __t)); + *__last = _VSTD::move(__t); + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__sift_up<_Comp_ref>(__first, __last, __comp, __last - __first); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + _VSTD::push_heap(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_PUSH_HEAP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/remove.h b/gnu/llvm/libcxx/include/__algorithm/remove.h new file mode 100644 index 00000000000..4717d7d9731 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/remove.h @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REMOVE_H +#define _LIBCPP___ALGORITHM_REMOVE_H + +#include <__config> +#include <__algorithm/find.h> +#include <__algorithm/find_if.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_NODISCARD_EXT _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +remove(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) +{ + __first = _VSTD::find(__first, __last, __value_); + if (__first != __last) + { + _ForwardIterator __i = __first; + while (++__i != __last) + { + if (!(*__i == __value_)) + { + *__first = _VSTD::move(*__i); + ++__first; + } + } + } + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REMOVE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/remove_copy.h b/gnu/llvm/libcxx/include/__algorithm/remove_copy.h new file mode 100644 index 00000000000..5d2b6403438 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/remove_copy.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REMOVE_COPY_H +#define _LIBCPP___ALGORITHM_REMOVE_COPY_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +remove_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, const _Tp& __value_) +{ + for (; __first != __last; ++__first) + { + if (!(*__first == __value_)) + { + *__result = *__first; + ++__result; + } + } + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/remove_copy_if.h b/gnu/llvm/libcxx/include/__algorithm/remove_copy_if.h new file mode 100644 index 00000000000..44822564a5c --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/remove_copy_if.h @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REMOVE_COPY_IF_H +#define _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +remove_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _Predicate __pred) +{ + for (; __first != __last; ++__first) + { + if (!__pred(*__first)) + { + *__result = *__first; + ++__result; + } + } + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REMOVE_COPY_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/remove_if.h b/gnu/llvm/libcxx/include/__algorithm/remove_if.h new file mode 100644 index 00000000000..e506b4c67fb --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/remove_if.h @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REMOVE_IF_H +#define _LIBCPP___ALGORITHM_REMOVE_IF_H + +#include <__config> +#include <__algorithm/find_if.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_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> + (__first, __last, __pred); + if (__first != __last) + { + _ForwardIterator __i = __first; + while (++__i != __last) + { + if (!__pred(*__i)) + { + *__first = _VSTD::move(*__i); + ++__first; + } + } + } + return __first; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REMOVE_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/replace.h b/gnu/llvm/libcxx/include/__algorithm/replace.h new file mode 100644 index 00000000000..b723ffeeace --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/replace.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REPLACE_H +#define _LIBCPP___ALGORITHM_REPLACE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +replace(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __old_value, const _Tp& __new_value) +{ + for (; __first != __last; ++__first) + if (*__first == __old_value) + *__first = __new_value; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REPLACE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/replace_copy.h b/gnu/llvm/libcxx/include/__algorithm/replace_copy.h new file mode 100644 index 00000000000..1923a57e427 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/replace_copy.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REPLACE_COPY_H +#define _LIBCPP___ALGORITHM_REPLACE_COPY_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +replace_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, + const _Tp& __old_value, const _Tp& __new_value) +{ + for (; __first != __last; ++__first, (void) ++__result) + if (*__first == __old_value) + *__result = __new_value; + else + *__result = *__first; + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/replace_copy_if.h b/gnu/llvm/libcxx/include/__algorithm/replace_copy_if.h new file mode 100644 index 00000000000..72b6f736970 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/replace_copy_if.h @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REPLACE_COPY_IF_H +#define _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +replace_copy_if(_InputIterator __first, _InputIterator __last, _OutputIterator __result, + _Predicate __pred, const _Tp& __new_value) +{ + for (; __first != __last; ++__first, (void) ++__result) + if (__pred(*__first)) + *__result = __new_value; + else + *__result = *__first; + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REPLACE_COPY_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/replace_if.h b/gnu/llvm/libcxx/include/__algorithm/replace_if.h new file mode 100644 index 00000000000..49101a5ce16 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/replace_if.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REPLACE_IF_H +#define _LIBCPP___ALGORITHM_REPLACE_IF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +replace_if(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, const _Tp& __new_value) +{ + for (; __first != __last; ++__first) + if (__pred(*__first)) + *__first = __new_value; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REPLACE_IF_H diff --git a/gnu/llvm/libcxx/include/__algorithm/reverse.h b/gnu/llvm/libcxx/include/__algorithm/reverse.h new file mode 100644 index 00000000000..e538de11472 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/reverse.h @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REVERSE_H +#define _LIBCPP___ALGORITHM_REVERSE_H + +#include <__config> +#include <__algorithm/iter_swap.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +__reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirectional_iterator_tag) +{ + while (__first != __last) + { + if (__first == --__last) + break; + _VSTD::iter_swap(__first, __last); + ++__first; + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +__reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_access_iterator_tag) +{ + if (__first != __last) + for (; __first < --__last; ++__first) + _VSTD::iter_swap(__first, __last); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +reverse(_BidirectionalIterator __first, _BidirectionalIterator __last) +{ + _VSTD::__reverse(__first, __last, typename iterator_traits<_BidirectionalIterator>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REVERSE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/reverse_copy.h b/gnu/llvm/libcxx/include/__algorithm/reverse_copy.h new file mode 100644 index 00000000000..48ce60cf881 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/reverse_copy.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_REVERSE_COPY_H +#define _LIBCPP___ALGORITHM_REVERSE_COPY_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +reverse_copy(_BidirectionalIterator __first, _BidirectionalIterator __last, _OutputIterator __result) +{ + for (; __first != __last; ++__result) + *__result = *--__last; + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_REVERSE_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/rotate.h b/gnu/llvm/libcxx/include/__algorithm/rotate.h new file mode 100644 index 00000000000..0c9ccd7bf7b --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/rotate.h @@ -0,0 +1,205 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_ROTATE_H +#define _LIBCPP___ALGORITHM_ROTATE_H + +#include <__algorithm/move.h> +#include <__algorithm/move_backward.h> +#include <__algorithm/swap_ranges.h> +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__iterator/next.h> +#include <__iterator/prev.h> +#include <__utility/swap.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator +__rotate_left(_ForwardIterator __first, _ForwardIterator __last) +{ + typedef typename iterator_traits<_ForwardIterator>::value_type value_type; + value_type __tmp = _VSTD::move(*__first); + _ForwardIterator __lm1 = _VSTD::move(_VSTD::next(__first), __last, __first); + *__lm1 = _VSTD::move(__tmp); + return __lm1; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator +__rotate_right(_BidirectionalIterator __first, _BidirectionalIterator __last) +{ + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + _BidirectionalIterator __lm1 = _VSTD::prev(__last); + value_type __tmp = _VSTD::move(*__lm1); + _BidirectionalIterator __fp1 = _VSTD::move_backward(__first, __lm1, __last); + *__first = _VSTD::move(__tmp); + return __fp1; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX14 _ForwardIterator +__rotate_forward(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) +{ + _ForwardIterator __i = __middle; + while (true) + { + swap(*__first, *__i); + ++__first; + if (++__i == __last) + break; + if (__first == __middle) + __middle = __i; + } + _ForwardIterator __r = __first; + if (__first != __middle) + { + __i = __middle; + while (true) + { + swap(*__first, *__i); + ++__first; + if (++__i == __last) + { + if (__first == __middle) + break; + __i = __middle; + } + else if (__first == __middle) + __middle = __i; + } + } + return __r; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX14 _Integral +__algo_gcd(_Integral __x, _Integral __y) +{ + do + { + _Integral __t = __x % __y; + __x = __y; + __y = __t; + } while (__y); + return __x; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX14 _RandomAccessIterator +__rotate_gcd(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + + const difference_type __m1 = __middle - __first; + const difference_type __m2 = __last - __middle; + if (__m1 == __m2) + { + _VSTD::swap_ranges(__first, __middle, __middle); + return __middle; + } + const difference_type __g = _VSTD::__algo_gcd(__m1, __m2); + for (_RandomAccessIterator __p = __first + __g; __p != __first;) + { + value_type __t(_VSTD::move(*--__p)); + _RandomAccessIterator __p1 = __p; + _RandomAccessIterator __p2 = __p1 + __m1; + do + { + *__p1 = _VSTD::move(*__p2); + __p1 = __p2; + const difference_type __d = __last - __p2; + if (__m1 < __d) + __p2 += __m1; + else + __p2 = __first + (__m1 - __d); + } while (__p2 != __p); + *__p1 = _VSTD::move(__t); + } + return __first + __m2; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 _ForwardIterator +__rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, + _VSTD::forward_iterator_tag) +{ + typedef typename iterator_traits<_ForwardIterator>::value_type value_type; + if (is_trivially_move_assignable::value) + { + if (_VSTD::next(__first) == __middle) + return _VSTD::__rotate_left(__first, __last); + } + return _VSTD::__rotate_forward(__first, __middle, __last); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 _BidirectionalIterator +__rotate(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, + bidirectional_iterator_tag) +{ + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + if (is_trivially_move_assignable::value) + { + if (_VSTD::next(__first) == __middle) + return _VSTD::__rotate_left(__first, __last); + if (_VSTD::next(__middle) == __last) + return _VSTD::__rotate_right(__first, __last); + } + return _VSTD::__rotate_forward(__first, __middle, __last); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 _RandomAccessIterator +__rotate(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, + random_access_iterator_tag) +{ + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + if (is_trivially_move_assignable::value) + { + if (_VSTD::next(__first) == __middle) + return _VSTD::__rotate_left(__first, __last); + if (_VSTD::next(__middle) == __last) + return _VSTD::__rotate_right(__first, __last); + return _VSTD::__rotate_gcd(__first, __middle, __last); + } + return _VSTD::__rotate_forward(__first, __middle, __last); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +rotate(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last) +{ + if (__first == __middle) + return __last; + if (__middle == __last) + return __first; + return _VSTD::__rotate(__first, __middle, __last, + typename iterator_traits<_ForwardIterator>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_ROTATE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/rotate_copy.h b/gnu/llvm/libcxx/include/__algorithm/rotate_copy.h new file mode 100644 index 00000000000..d5ab7d3b515 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/rotate_copy.h @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_ROTATE_COPY_H +#define _LIBCPP___ALGORITHM_ROTATE_COPY_H + +#include <__config> +#include <__algorithm/copy.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +rotate_copy(_ForwardIterator __first, _ForwardIterator __middle, _ForwardIterator __last, _OutputIterator __result) +{ + return _VSTD::copy(__first, __middle, _VSTD::copy(__middle, __last, __result)); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_ROTATE_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/sample.h b/gnu/llvm/libcxx/include/__algorithm/sample.h new file mode 100644 index 00000000000..2aac6ffa8ce --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/sample.h @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SAMPLE_H +#define _LIBCPP___ALGORITHM_SAMPLE_H + +#include <__config> +#include <__algorithm/min.h> +#include <__random/uniform_int_distribution.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __output_iter, + _Distance __n, + _UniformRandomNumberGenerator & __g, + input_iterator_tag) { + + _Distance __k = 0; + for (; __first != __last && __k < __n; ++__first, (void) ++__k) + __output_iter[__k] = *__first; + _Distance __sz = __k; + for (; __first != __last; ++__first, (void) ++__k) { + _Distance __r = uniform_int_distribution<_Distance>(0, __k)(__g); + if (__r < __sz) + __output_iter[__r] = *__first; + } + return __output_iter + _VSTD::min(__n, __k); +} + +template +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __output_iter, + _Distance __n, + _UniformRandomNumberGenerator& __g, + forward_iterator_tag) { + _Distance __unsampled_sz = _VSTD::distance(__first, __last); + for (__n = _VSTD::min(__n, __unsampled_sz); __n != 0; ++__first) { + _Distance __r = uniform_int_distribution<_Distance>(0, --__unsampled_sz)(__g); + if (__r < __n) { + *__output_iter++ = *__first; + --__n; + } + } + return __output_iter; +} + +template +_LIBCPP_INLINE_VISIBILITY +_SampleIterator __sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __output_iter, + _Distance __n, _UniformRandomNumberGenerator& __g) { + typedef typename iterator_traits<_PopulationIterator>::iterator_category + _PopCategory; + typedef typename iterator_traits<_PopulationIterator>::difference_type + _Difference; + static_assert(__is_cpp17_forward_iterator<_PopulationIterator>::value || + __is_cpp17_random_access_iterator<_SampleIterator>::value, + "SampleIterator must meet the requirements of RandomAccessIterator"); + typedef typename common_type<_Distance, _Difference>::type _CommonType; + _LIBCPP_ASSERT(__n >= 0, "N must be a positive number."); + return _VSTD::__sample( + __first, __last, __output_iter, _CommonType(__n), + __g, _PopCategory()); +} + +#if _LIBCPP_STD_VER > 14 +template +inline _LIBCPP_INLINE_VISIBILITY +_SampleIterator sample(_PopulationIterator __first, + _PopulationIterator __last, _SampleIterator __output_iter, + _Distance __n, _UniformRandomNumberGenerator&& __g) { + return _VSTD::__sample(__first, __last, __output_iter, __n, __g); +} +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SAMPLE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/search.h b/gnu/llvm/libcxx/include/__algorithm/search.h new file mode 100644 index 00000000000..008b8ebb04a --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/search.h @@ -0,0 +1,131 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SEARCH_H +#define _LIBCPP___ALGORITHM_SEARCH_H + +#include <__algorithm/comp.h> +#include <__config> +#include <__iterator/iterator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +pair<_ForwardIterator1, _ForwardIterator1> + _LIBCPP_CONSTEXPR_AFTER_CXX11 __search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, + _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred, forward_iterator_tag, forward_iterator_tag) { + if (__first2 == __last2) + return _VSTD::make_pair(__first1, __first1); // Everything matches an empty sequence + while (true) { + // Find first element in sequence 1 that matchs *__first2, with a mininum of loop checks + while (true) { + if (__first1 == __last1) // return __last1 if no element matches *__first2 + return _VSTD::make_pair(__last1, __last1); + if (__pred(*__first1, *__first2)) + break; + ++__first1; + } + // *__first1 matches *__first2, now match elements after here + _ForwardIterator1 __m1 = __first1; + _ForwardIterator2 __m2 = __first2; + while (true) { + if (++__m2 == __last2) // If pattern exhausted, __first1 is the answer (works for 1 element pattern) + return _VSTD::make_pair(__first1, __m1); + if (++__m1 == __last1) // Otherwise if source exhaused, pattern not found + return _VSTD::make_pair(__last1, __last1); + if (!__pred(*__m1, *__m2)) // if there is a mismatch, restart with a new __first1 + { + ++__first1; + break; + } // else there is a match, check next elements + } + } +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 pair<_RandomAccessIterator1, _RandomAccessIterator1> +__search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, + _RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, + random_access_iterator_tag) { + typedef typename iterator_traits<_RandomAccessIterator1>::difference_type _D1; + typedef typename iterator_traits<_RandomAccessIterator2>::difference_type _D2; + // Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern + const _D2 __len2 = __last2 - __first2; + if (__len2 == 0) + return _VSTD::make_pair(__first1, __first1); + const _D1 __len1 = __last1 - __first1; + if (__len1 < __len2) + return _VSTD::make_pair(__last1, __last1); + const _RandomAccessIterator1 __s = __last1 - (__len2 - 1); // Start of pattern match can't go beyond here + + while (true) { + while (true) { + if (__first1 == __s) + return _VSTD::make_pair(__last1, __last1); + if (__pred(*__first1, *__first2)) + break; + ++__first1; + } + + _RandomAccessIterator1 __m1 = __first1; + _RandomAccessIterator2 __m2 = __first2; + while (true) { + if (++__m2 == __last2) + return _VSTD::make_pair(__first1, __first1 + __len2); + ++__m1; // no need to check range on __m1 because __s guarantees we have enough source + if (!__pred(*__m1, *__m2)) { + ++__first1; + break; + } + } + } +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 +search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2, + _BinaryPredicate __pred) { + return _VSTD::__search::type>( + __first1, __last1, __first2, __last2, __pred, + typename iterator_traits<_ForwardIterator1>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()).first; +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator1 +search(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { + typedef typename iterator_traits<_ForwardIterator1>::value_type __v1; + typedef typename iterator_traits<_ForwardIterator2>::value_type __v2; + return _VSTD::search(__first1, __last1, __first2, __last2, __equal_to<__v1, __v2>()); +} + +#if _LIBCPP_STD_VER > 14 +template +_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 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SEARCH_H diff --git a/gnu/llvm/libcxx/include/__algorithm/search_n.h b/gnu/llvm/libcxx/include/__algorithm/search_n.h new file mode 100644 index 00000000000..1584e8e613c --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/search_n.h @@ -0,0 +1,116 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SEARCH_N_H +#define _LIBCPP___ALGORITHM_SEARCH_N_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator __search_n(_ForwardIterator __first, _ForwardIterator __last, + _Size __count, const _Tp& __value_, _BinaryPredicate __pred, + forward_iterator_tag) { + if (__count <= 0) + return __first; + while (true) { + // Find first element in sequence that matchs __value_, with a mininum of loop checks + while (true) { + if (__first == __last) // return __last if no element matches __value_ + return __last; + if (__pred(*__first, __value_)) + break; + ++__first; + } + // *__first matches __value_, now match elements after here + _ForwardIterator __m = __first; + _Size __c(0); + while (true) { + if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) + return __first; + if (++__m == __last) // Otherwise if source exhaused, pattern not found + return __last; + if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first + { + __first = __m; + ++__first; + break; + } // else there is a match, check next elements + } + } +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _RandomAccessIterator __search_n(_RandomAccessIterator __first, + _RandomAccessIterator __last, _Size __count, + const _Tp& __value_, _BinaryPredicate __pred, + random_access_iterator_tag) { + if (__count <= 0) + return __first; + _Size __len = static_cast<_Size>(__last - __first); + if (__len < __count) + return __last; + const _RandomAccessIterator __s = __last - (__count - 1); // Start of pattern match can't go beyond here + while (true) { + // Find first element in sequence that matchs __value_, with a mininum of loop checks + while (true) { + if (__first >= __s) // return __last if no element matches __value_ + return __last; + if (__pred(*__first, __value_)) + break; + ++__first; + } + // *__first matches __value_, now match elements after here + _RandomAccessIterator __m = __first; + _Size __c(0); + while (true) { + if (++__c == __count) // If pattern exhausted, __first is the answer (works for 1 element pattern) + return __first; + ++__m; // no need to check range on __m because __s guarantees we have enough source + if (!__pred(*__m, __value_)) // if there is a mismatch, restart with a new __first + { + __first = __m; + ++__first; + break; + } // else there is a match, check next elements + } + } +} + +template +_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) { + return _VSTD::__search_n::type>( + __first, __last, _VSTD::__convert_to_integral(__count), __value_, __pred, + typename iterator_traits<_ForwardIterator>::iterator_category()); +} + +template +_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const _Tp& __value_) { + typedef typename iterator_traits<_ForwardIterator>::value_type __v; + return _VSTD::search_n(__first, __last, _VSTD::__convert_to_integral(__count), __value_, __equal_to<__v, _Tp>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SEARCH_N_H diff --git a/gnu/llvm/libcxx/include/__algorithm/set_difference.h b/gnu/llvm/libcxx/include/__algorithm/set_difference.h new file mode 100644 index 00000000000..f4c985d978c --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/set_difference.h @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SET_DIFFERENCE_H +#define _LIBCPP___ALGORITHM_SET_DIFFERENCE_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/copy.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator +__set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + while (__first1 != __last1) + { + if (__first2 == __last2) + return _VSTD::copy(__first1, __last1, __result); + if (__comp(*__first1, *__first2)) + { + *__result = *__first1; + ++__result; + ++__first1; + } + else + { + if (!__comp(*__first2, *__first1)) + ++__first1; + ++__first2; + } + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) +{ + return _VSTD::set_difference(__first1, __last1, __first2, __last2, __result, + __less::value_type, + typename iterator_traits<_InputIterator2>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SET_DIFFERENCE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/set_intersection.h b/gnu/llvm/libcxx/include/__algorithm/set_intersection.h new file mode 100644 index 00000000000..9d34b66c23e --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/set_intersection.h @@ -0,0 +1,74 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SET_INTERSECTION_H +#define _LIBCPP___ALGORITHM_SET_INTERSECTION_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator +__set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + while (__first1 != __last1 && __first2 != __last2) + { + if (__comp(*__first1, *__first2)) + ++__first1; + else + { + if (!__comp(*__first2, *__first1)) + { + *__result = *__first1; + ++__result; + ++__first1; + } + ++__first2; + } + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) +{ + return _VSTD::set_intersection(__first1, __last1, __first2, __last2, __result, + __less::value_type, + typename iterator_traits<_InputIterator2>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SET_INTERSECTION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/set_symmetric_difference.h b/gnu/llvm/libcxx/include/__algorithm/set_symmetric_difference.h new file mode 100644 index 00000000000..5650b836a61 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/set_symmetric_difference.h @@ -0,0 +1,82 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H +#define _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/copy.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator +__set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + while (__first1 != __last1) + { + if (__first2 == __last2) + return _VSTD::copy(__first1, __last1, __result); + if (__comp(*__first1, *__first2)) + { + *__result = *__first1; + ++__result; + ++__first1; + } + else + { + if (__comp(*__first2, *__first1)) + { + *__result = *__first2; + ++__result; + } + else + ++__first1; + ++__first2; + } + } + return _VSTD::copy(__first2, __last2, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) +{ + return _VSTD::set_symmetric_difference(__first1, __last1, __first2, __last2, __result, + __less::value_type, + typename iterator_traits<_InputIterator2>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SET_SYMMETRIC_DIFFERENCE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/set_union.h b/gnu/llvm/libcxx/include/__algorithm/set_union.h new file mode 100644 index 00000000000..c0874e95746 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/set_union.h @@ -0,0 +1,77 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SET_UNION_H +#define _LIBCPP___ALGORITHM_SET_UNION_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/copy.h> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator +__set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + for (; __first1 != __last1; ++__result) + { + if (__first2 == __last2) + return _VSTD::copy(__first1, __last1, __result); + if (__comp(*__first2, *__first1)) + { + *__result = *__first2; + ++__first2; + } + else + { + if (!__comp(*__first1, *__first2)) + ++__first2; + *__result = *__first1; + ++__first1; + } + } + return _VSTD::copy(__first2, __last2, __result); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + return _VSTD::__set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +set_union(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result) +{ + return _VSTD::set_union(__first1, __last1, __first2, __last2, __result, + __less::value_type, + typename iterator_traits<_InputIterator2>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SET_UNION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/shift_left.h b/gnu/llvm/libcxx/include/__algorithm/shift_left.h new file mode 100644 index 00000000000..961b89cb00b --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/shift_left.h @@ -0,0 +1,61 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SHIFT_LEFT_H +#define _LIBCPP___ALGORITHM_SHIFT_LEFT_H + +#include <__config> +#include <__algorithm/move.h> +#include <__iterator/iterator_traits.h> +#include // swap + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template +inline _LIBCPP_INLINE_VISIBILITY constexpr +_ForwardIterator +shift_left(_ForwardIterator __first, _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) +{ + if (__n == 0) { + return __last; + } + + _ForwardIterator __m = __first; + if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) { + if (__n >= __last - __first) { + return __first; + } + __m += __n; + } else { + for (; __n > 0; --__n) { + if (__m == __last) { + return __first; + } + ++__m; + } + } + return _VSTD::move(__m, __last, __first); +} + +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SHIFT_LEFT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/shift_right.h b/gnu/llvm/libcxx/include/__algorithm/shift_right.h new file mode 100644 index 00000000000..5cb41950642 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/shift_right.h @@ -0,0 +1,106 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SHIFT_RIGHT_H +#define _LIBCPP___ALGORITHM_SHIFT_RIGHT_H + +#include <__config> +#include <__algorithm/move.h> +#include <__algorithm/move_backward.h> +#include <__algorithm/swap_ranges.h> +#include <__iterator/iterator_traits.h> +#include // swap + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +template +inline _LIBCPP_INLINE_VISIBILITY constexpr +_ForwardIterator +shift_right(_ForwardIterator __first, _ForwardIterator __last, + typename iterator_traits<_ForwardIterator>::difference_type __n) +{ + if (__n == 0) { + return __first; + } + + if constexpr (__is_cpp17_random_access_iterator<_ForwardIterator>::value) { + decltype(__n) __d = __last - __first; + if (__n >= __d) { + return __last; + } + _ForwardIterator __m = __first + (__d - __n); + return _VSTD::move_backward(__first, __m, __last); + } else if constexpr (__is_cpp17_bidirectional_iterator<_ForwardIterator>::value) { + _ForwardIterator __m = __last; + for (; __n > 0; --__n) { + if (__m == __first) { + return __last; + } + --__m; + } + return _VSTD::move_backward(__first, __m, __last); + } else { + _ForwardIterator __ret = __first; + for (; __n > 0; --__n) { + if (__ret == __last) { + return __last; + } + ++__ret; + } + + // We have an __n-element scratch space from __first to __ret. + // Slide an __n-element window [__trail, __lead) from left to right. + // We're essentially doing swap_ranges(__first, __ret, __trail, __lead) + // over and over; but once __lead reaches __last we needn't bother + // to save the values of elements [__trail, __last). + + auto __trail = __first; + auto __lead = __ret; + while (__trail != __ret) { + if (__lead == __last) { + _VSTD::move(__first, __trail, __ret); + return __ret; + } + ++__trail; + ++__lead; + } + + _ForwardIterator __mid = __first; + while (true) { + if (__lead == __last) { + __trail = _VSTD::move(__mid, __ret, __trail); + _VSTD::move(__first, __mid, __trail); + return __ret; + } + swap(*__mid, *__trail); + ++__mid; + ++__trail; + ++__lead; + if (__mid == __ret) { + __mid = __first; + } + } + } +} + +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SHIFT_RIGHT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/shuffle.h b/gnu/llvm/libcxx/include/__algorithm/shuffle.h new file mode 100644 index 00000000000..637fca53885 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/shuffle.h @@ -0,0 +1,127 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SHUFFLE_H +#define _LIBCPP___ALGORITHM_SHUFFLE_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__random/uniform_int_distribution.h> +#include <__utility/swap.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_RANDOM_SHUFFLE) \ + || defined(_LIBCPP_BUILDING_LIBRARY) +class _LIBCPP_TYPE_VIS __rs_default; + +_LIBCPP_FUNC_VIS __rs_default __rs_get(); + +class _LIBCPP_TYPE_VIS __rs_default +{ + static unsigned __c_; + + __rs_default(); +public: + typedef uint_fast32_t result_type; + + static const result_type _Min = 0; + static const result_type _Max = 0xFFFFFFFF; + + __rs_default(const __rs_default&); + ~__rs_default(); + + result_type operator()(); + + static _LIBCPP_CONSTEXPR result_type min() {return _Min;} + static _LIBCPP_CONSTEXPR result_type max() {return _Max;} + + friend _LIBCPP_FUNC_VIS __rs_default __rs_get(); +}; + +_LIBCPP_FUNC_VIS __rs_default __rs_get(); + +template +_LIBCPP_DEPRECATED_IN_CXX14 void +random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + typedef uniform_int_distribution _Dp; + typedef typename _Dp::param_type _Pp; + difference_type __d = __last - __first; + if (__d > 1) + { + _Dp __uid; + __rs_default __g = __rs_get(); + for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d) + { + difference_type __i = __uid(__g, _Pp(0, __d)); + if (__i != difference_type(0)) + swap(*__first, *(__first + __i)); + } + } +} + +template +_LIBCPP_DEPRECATED_IN_CXX14 void +random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, +#ifndef _LIBCPP_CXX03_LANG + _RandomNumberGenerator&& __rand) +#else + _RandomNumberGenerator& __rand) +#endif +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + difference_type __d = __last - __first; + if (__d > 1) + { + for (--__last; __first < __last; ++__first, (void) --__d) + { + difference_type __i = __rand(__d); + if (__i != difference_type(0)) + swap(*__first, *(__first + __i)); + } + } +} +#endif + +template + void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, + _UniformRandomNumberGenerator&& __g) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + typedef uniform_int_distribution _Dp; + typedef typename _Dp::param_type _Pp; + difference_type __d = __last - __first; + if (__d > 1) + { + _Dp __uid; + for (--__last, (void) --__d; __first < __last; ++__first, (void) --__d) + { + difference_type __i = __uid(__g, _Pp(0, __d)); + if (__i != difference_type(0)) + swap(*__first, *(__first + __i)); + } + } +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SHUFFLE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/sift_down.h b/gnu/llvm/libcxx/include/__algorithm/sift_down.h new file mode 100644 index 00000000000..dd4b54ed8e5 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/sift_down.h @@ -0,0 +1,84 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SIFT_DOWN_H +#define _LIBCPP___ALGORITHM_SIFT_DOWN_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__utility/move.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 void +__sift_down(_RandomAccessIterator __first, _RandomAccessIterator /*__last*/, + _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len, + _RandomAccessIterator __start) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + // left-child of __start is at 2 * __start + 1 + // right-child of __start is at 2 * __start + 2 + difference_type __child = __start - __first; + + if (__len < 2 || (__len - 2) / 2 < __child) + return; + + __child = 2 * __child + 1; + _RandomAccessIterator __child_i = __first + __child; + + if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { + // right-child exists and is greater than left-child + ++__child_i; + ++__child; + } + + // check if we are in heap-order + if (__comp(*__child_i, *__start)) + // we are, __start is larger than it's largest child + return; + + value_type __top(_VSTD::move(*__start)); + do + { + // we are not in heap-order, swap the parent with its largest child + *__start = _VSTD::move(*__child_i); + __start = __child_i; + + if ((__len - 2) / 2 < __child) + break; + + // recompute the child based off of the updated parent + __child = 2 * __child + 1; + __child_i = __first + __child; + + if ((__child + 1) < __len && __comp(*__child_i, *(__child_i + 1))) { + // right-child exists and is greater than left-child + ++__child_i; + ++__child; + } + + // check if we are in heap-order + } while (!__comp(*__child_i, __top)); + *__start = _VSTD::move(__top); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SIFT_DOWN_H diff --git a/gnu/llvm/libcxx/include/__algorithm/sort.h b/gnu/llvm/libcxx/include/__algorithm/sort.h new file mode 100644 index 00000000000..39ec21302d2 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/sort.h @@ -0,0 +1,530 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SORT_H +#define _LIBCPP___ALGORITHM_SORT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/min_element.h> +#include <__algorithm/partial_sort.h> +#include <__algorithm/unwrap_iter.h> +#include <__utility/swap.h> +#include +#include // swap + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// stable, 2-3 compares, 0-2 swaps + +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 unsigned +__sort3(_ForwardIterator __x, _ForwardIterator __y, _ForwardIterator __z, _Compare __c) +{ + unsigned __r = 0; + if (!__c(*__y, *__x)) // if x <= y + { + if (!__c(*__z, *__y)) // if y <= z + return __r; // x <= y && y <= z + // x <= y && y > z + swap(*__y, *__z); // x <= z && y < z + __r = 1; + if (__c(*__y, *__x)) // if x > y + { + swap(*__x, *__y); // x < y && y <= z + __r = 2; + } + return __r; // x <= y && y < z + } + if (__c(*__z, *__y)) // x > y, if y > z + { + swap(*__x, *__z); // x < y && y < z + __r = 1; + return __r; + } + swap(*__x, *__y); // x > y && y <= z + __r = 1; // x < y && x <= z + if (__c(*__z, *__y)) // if y > z + { + swap(*__y, *__z); // x <= y && y < z + __r = 2; + } + return __r; +} // x <= y && y <= z + +// stable, 3-6 compares, 0-5 swaps + +template +unsigned +__sort4(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, + _ForwardIterator __x4, _Compare __c) +{ + unsigned __r = _VSTD::__sort3<_Compare>(__x1, __x2, __x3, __c); + if (__c(*__x4, *__x3)) + { + swap(*__x3, *__x4); + ++__r; + if (__c(*__x3, *__x2)) + { + swap(*__x2, *__x3); + ++__r; + if (__c(*__x2, *__x1)) + { + swap(*__x1, *__x2); + ++__r; + } + } + } + return __r; +} + +// stable, 4-10 compares, 0-9 swaps + +template +_LIBCPP_HIDDEN +unsigned +__sort5(_ForwardIterator __x1, _ForwardIterator __x2, _ForwardIterator __x3, + _ForwardIterator __x4, _ForwardIterator __x5, _Compare __c) +{ + unsigned __r = _VSTD::__sort4<_Compare>(__x1, __x2, __x3, __x4, __c); + if (__c(*__x5, *__x4)) + { + swap(*__x4, *__x5); + ++__r; + if (__c(*__x4, *__x3)) + { + swap(*__x3, *__x4); + ++__r; + if (__c(*__x3, *__x2)) + { + swap(*__x2, *__x3); + ++__r; + if (__c(*__x2, *__x1)) + { + swap(*__x1, *__x2); + ++__r; + } + } + } + } + return __r; +} + +// Assumes size > 0 +template +_LIBCPP_CONSTEXPR_AFTER_CXX11 void +__selection_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) +{ + _BidirectionalIterator __lm1 = __last; + for (--__lm1; __first != __lm1; ++__first) + { + _BidirectionalIterator __i = _VSTD::min_element<_BidirectionalIterator, + typename add_lvalue_reference<_Compare>::type> + (__first, __last, __comp); + if (__i != __first) + swap(*__first, *__i); + } +} + +template +void +__insertion_sort(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + if (__first != __last) + { + _BidirectionalIterator __i = __first; + for (++__i; __i != __last; ++__i) + { + _BidirectionalIterator __j = __i; + value_type __t(_VSTD::move(*__j)); + for (_BidirectionalIterator __k = __i; __k != __first && __comp(__t, *--__k); --__j) + *__j = _VSTD::move(*__k); + *__j = _VSTD::move(__t); + } + } +} + +template +void +__insertion_sort_3(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + _RandomAccessIterator __j = __first+2; + _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); + for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) + { + if (__comp(*__i, *__j)) + { + value_type __t(_VSTD::move(*__i)); + _RandomAccessIterator __k = __j; + __j = __i; + do + { + *__j = _VSTD::move(*__k); + __j = __k; + } while (__j != __first && __comp(__t, *--__k)); + *__j = _VSTD::move(__t); + } + __j = __i; + } +} + +template +bool +__insertion_sort_incomplete(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + switch (__last - __first) + { + case 0: + case 1: + return true; + case 2: + if (__comp(*--__last, *__first)) + swap(*__first, *__last); + return true; + case 3: + _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); + return true; + case 4: + _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); + return true; + case 5: + _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); + return true; + } + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + _RandomAccessIterator __j = __first+2; + _VSTD::__sort3<_Compare>(__first, __first+1, __j, __comp); + const unsigned __limit = 8; + unsigned __count = 0; + for (_RandomAccessIterator __i = __j+1; __i != __last; ++__i) + { + if (__comp(*__i, *__j)) + { + value_type __t(_VSTD::move(*__i)); + _RandomAccessIterator __k = __j; + __j = __i; + do + { + *__j = _VSTD::move(*__k); + __j = __k; + } while (__j != __first && __comp(__t, *--__k)); + *__j = _VSTD::move(__t); + if (++__count == __limit) + return ++__i == __last; + } + __j = __i; + } + return true; +} + +template +void +__insertion_sort_move(_BidirectionalIterator __first1, _BidirectionalIterator __last1, + typename iterator_traits<_BidirectionalIterator>::value_type* __first2, _Compare __comp) +{ + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + if (__first1 != __last1) + { + __destruct_n __d(0); + unique_ptr __h(__first2, __d); + value_type* __last2 = __first2; + ::new ((void*)__last2) value_type(_VSTD::move(*__first1)); + __d.template __incr(); + for (++__last2; ++__first1 != __last1; ++__last2) + { + value_type* __j2 = __last2; + value_type* __i2 = __j2; + if (__comp(*__first1, *--__i2)) + { + ::new ((void*)__j2) value_type(_VSTD::move(*__i2)); + __d.template __incr(); + for (--__j2; __i2 != __first2 && __comp(*__first1, *--__i2); --__j2) + *__j2 = _VSTD::move(*__i2); + *__j2 = _VSTD::move(*__first1); + } + else + { + ::new ((void*)__j2) value_type(_VSTD::move(*__first1)); + __d.template __incr(); + } + } + __h.release(); + } +} + +template +void +__sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + const difference_type __limit = is_trivially_copy_constructible::value && + is_trivially_copy_assignable::value ? 30 : 6; + while (true) + { + __restart: + difference_type __len = __last - __first; + switch (__len) + { + case 0: + case 1: + return; + case 2: + if (__comp(*--__last, *__first)) + swap(*__first, *__last); + return; + case 3: + _VSTD::__sort3<_Compare>(__first, __first+1, --__last, __comp); + return; + case 4: + _VSTD::__sort4<_Compare>(__first, __first+1, __first+2, --__last, __comp); + return; + case 5: + _VSTD::__sort5<_Compare>(__first, __first+1, __first+2, __first+3, --__last, __comp); + return; + } + if (__len <= __limit) + { + _VSTD::__insertion_sort_3<_Compare>(__first, __last, __comp); + return; + } + // __len > 5 + _RandomAccessIterator __m = __first; + _RandomAccessIterator __lm1 = __last; + --__lm1; + unsigned __n_swaps; + { + difference_type __delta; + if (__len >= 1000) + { + __delta = __len/2; + __m += __delta; + __delta /= 2; + __n_swaps = _VSTD::__sort5<_Compare>(__first, __first + __delta, __m, __m+__delta, __lm1, __comp); + } + else + { + __delta = __len/2; + __m += __delta; + __n_swaps = _VSTD::__sort3<_Compare>(__first, __m, __lm1, __comp); + } + } + // *__m is median + // partition [__first, __m) < *__m and *__m <= [__m, __last) + // (this inhibits tossing elements equivalent to __m around unnecessarily) + _RandomAccessIterator __i = __first; + _RandomAccessIterator __j = __lm1; + // j points beyond range to be tested, *__m is known to be <= *__lm1 + // The search going up is known to be guarded but the search coming down isn't. + // Prime the downward search with a guard. + if (!__comp(*__i, *__m)) // if *__first == *__m + { + // *__first == *__m, *__first doesn't go in first part + // manually guard downward moving __j against __i + while (true) + { + if (__i == --__j) + { + // *__first == *__m, *__m <= all other elements + // Parition instead into [__first, __i) == *__first and *__first < [__i, __last) + ++__i; // __first + 1 + __j = __last; + if (!__comp(*__first, *--__j)) // we need a guard if *__first == *(__last-1) + { + while (true) + { + if (__i == __j) + return; // [__first, __last) all equivalent elements + if (__comp(*__first, *__i)) + { + swap(*__i, *__j); + ++__n_swaps; + ++__i; + break; + } + ++__i; + } + } + // [__first, __i) == *__first and *__first < [__j, __last) and __j == __last - 1 + if (__i == __j) + return; + while (true) + { + while (!__comp(*__first, *__i)) + ++__i; + while (__comp(*__first, *--__j)) + ; + if (__i >= __j) + break; + swap(*__i, *__j); + ++__n_swaps; + ++__i; + } + // [__first, __i) == *__first and *__first < [__i, __last) + // The first part is sorted, sort the second part + // _VSTD::__sort<_Compare>(__i, __last, __comp); + __first = __i; + goto __restart; + } + if (__comp(*__j, *__m)) + { + swap(*__i, *__j); + ++__n_swaps; + break; // found guard for downward moving __j, now use unguarded partition + } + } + } + // It is known that *__i < *__m + ++__i; + // j points beyond range to be tested, *__m is known to be <= *__lm1 + // if not yet partitioned... + if (__i < __j) + { + // known that *(__i - 1) < *__m + // known that __i <= __m + while (true) + { + // __m still guards upward moving __i + while (__comp(*__i, *__m)) + ++__i; + // It is now known that a guard exists for downward moving __j + while (!__comp(*--__j, *__m)) + ; + if (__i > __j) + break; + swap(*__i, *__j); + ++__n_swaps; + // It is known that __m != __j + // If __m just moved, follow it + if (__m == __i) + __m = __j; + ++__i; + } + } + // [__first, __i) < *__m and *__m <= [__i, __last) + if (__i != __m && __comp(*__m, *__i)) + { + swap(*__i, *__m); + ++__n_swaps; + } + // [__first, __i) < *__i and *__i <= [__i+1, __last) + // If we were given a perfect partition, see if insertion sort is quick... + if (__n_swaps == 0) + { + bool __fs = _VSTD::__insertion_sort_incomplete<_Compare>(__first, __i, __comp); + if (_VSTD::__insertion_sort_incomplete<_Compare>(__i+1, __last, __comp)) + { + if (__fs) + return; + __last = __i; + continue; + } + else + { + if (__fs) + { + __first = ++__i; + continue; + } + } + } + // sort smaller range with recursive call and larger with tail recursion elimination + if (__i - __first < __last - __i) + { + _VSTD::__sort<_Compare>(__first, __i, __comp); + // _VSTD::__sort<_Compare>(__i+1, __last, __comp); + __first = ++__i; + } + else + { + _VSTD::__sort<_Compare>(__i+1, __last, __comp); + // _VSTD::__sort<_Compare>(__first, __i, __comp); + __last = __i; + } + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +__sort(_Tp** __first, _Tp** __last, __less<_Tp*>&) +{ + __less __comp; + _VSTD::__sort<__less&, uintptr_t*>((uintptr_t*)__first, (uintptr_t*)__last, __comp); +} + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, char*>(char*, char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, signed char*>(signed char*, signed char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, short*>(short*, short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, int*>(int*, int*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned*>(unsigned*, unsigned*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long*>(long*, long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long long*>(long long*, long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, float*>(float*, float*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, double*>(double*, double*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less&, long double*>(long double*, long double*, __less&)) + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, char*>(char*, char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, wchar_t*>(wchar_t*, wchar_t*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, signed char*>(signed char*, signed char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned char*>(unsigned char*, unsigned char*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, short*>(short*, short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned short*>(unsigned short*, unsigned short*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, int*>(int*, int*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned*>(unsigned*, unsigned*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long*>(long*, long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned long*>(unsigned long*, unsigned long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long long*>(long long*, long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, unsigned long long*>(unsigned long long*, unsigned long long*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, float*>(float*, float*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, double*>(double*, double*, __less&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less&, long double*>(long double*, long double*, __less&)) + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&)) + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + if (__libcpp_is_constant_evaluated()) { + _VSTD::__partial_sort<_Comp_ref>(__first, __last, __last, _Comp_ref(__comp)); + } else { + _VSTD::__sort<_Comp_ref>(_VSTD::__unwrap_iter(__first), _VSTD::__unwrap_iter(__last), _Comp_ref(__comp)); + } +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +sort(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + _VSTD::sort(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SORT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/sort_heap.h b/gnu/llvm/libcxx/include/__algorithm/sort_heap.h new file mode 100644 index 00000000000..aa8ef762ab1 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/sort_heap.h @@ -0,0 +1,58 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SORT_HEAP_H +#define _LIBCPP___ALGORITHM_SORT_HEAP_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/pop_heap.h> +#include <__iterator/iterator_traits.h> +#include // swap + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 void +__sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + for (difference_type __n = __last - __first; __n > 1; --__last, (void) --__n) + _VSTD::__pop_heap<_Compare>(__first, __last, __comp, __n); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__sort_heap<_Comp_ref>(__first, __last, __comp); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +void +sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + _VSTD::sort_heap(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SORT_HEAP_H diff --git a/gnu/llvm/libcxx/include/__algorithm/stable_partition.h b/gnu/llvm/libcxx/include/__algorithm/stable_partition.h new file mode 100644 index 00000000000..931335f4447 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/stable_partition.h @@ -0,0 +1,305 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_STABLE_PARTITION_H +#define _LIBCPP___ALGORITHM_STABLE_PARTITION_H + +#include <__config> +#include <__algorithm/rotate.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_ForwardIterator +__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, + _Distance __len, _Pair __p, forward_iterator_tag __fit) +{ + // *__first is known to be false + // __len >= 1 + if (__len == 1) + return __first; + if (__len == 2) + { + _ForwardIterator __m = __first; + if (__pred(*++__m)) + { + swap(*__first, *__m); + return __m; + } + return __first; + } + if (__len <= __p.second) + { // The buffer is big enough to use + typedef typename iterator_traits<_ForwardIterator>::value_type value_type; + __destruct_n __d(0); + unique_ptr __h(__p.first, __d); + // Move the falses into the temporary buffer, and the trues to the front of the line + // Update __first to always point to the end of the trues + value_type* __t = __p.first; + ::new ((void*)__t) value_type(_VSTD::move(*__first)); + __d.template __incr(); + ++__t; + _ForwardIterator __i = __first; + while (++__i != __last) + { + if (__pred(*__i)) + { + *__first = _VSTD::move(*__i); + ++__first; + } + else + { + ::new ((void*)__t) value_type(_VSTD::move(*__i)); + __d.template __incr(); + ++__t; + } + } + // All trues now at start of range, all falses in buffer + // Move falses back into range, but don't mess up __first which points to first false + __i = __first; + for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i) + *__i = _VSTD::move(*__t2); + // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer + return __first; + } + // Else not enough buffer, do in place + // __len >= 3 + _ForwardIterator __m = __first; + _Distance __len2 = __len / 2; // __len2 >= 2 + _VSTD::advance(__m, __len2); + // recurse on [__first, __m), *__first know to be false + // F????????????????? + // f m l + typedef typename add_lvalue_reference<_Predicate>::type _PredRef; + _ForwardIterator __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m, __pred, __len2, __p, __fit); + // TTTFFFFF?????????? + // f ff m l + // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true + _ForwardIterator __m1 = __m; + _ForwardIterator __second_false = __last; + _Distance __len_half = __len - __len2; + while (__pred(*__m1)) + { + if (++__m1 == __last) + goto __second_half_done; + --__len_half; + } + // TTTFFFFFTTTF?????? + // f ff m m1 l + __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __fit); +__second_half_done: + // TTTFFFFFTTTTTFFFFF + // f ff m sf l + return _VSTD::rotate(__first_false, __m, __second_false); + // TTTTTTTTFFFFFFFFFF + // | +} + +template +_ForwardIterator +__stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred, + forward_iterator_tag) +{ + const unsigned __alloc_limit = 3; // might want to make this a function of trivial assignment + // Either prove all true and return __first or point to first false + while (true) + { + if (__first == __last) + return __first; + if (!__pred(*__first)) + break; + ++__first; + } + // We now have a reduced range [__first, __last) + // *__first is known to be false + typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; + typedef typename iterator_traits<_ForwardIterator>::value_type value_type; + difference_type __len = _VSTD::distance(__first, __last); + pair __p(0, 0); + unique_ptr __h; + if (__len >= __alloc_limit) + { + __p = _VSTD::get_temporary_buffer(__len); + __h.reset(__p.first); + } + return _VSTD::__stable_partition::type> + (__first, __last, __pred, __len, __p, forward_iterator_tag()); +} + +template +_BidirectionalIterator +__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, + _Distance __len, _Pair __p, bidirectional_iterator_tag __bit) +{ + // *__first is known to be false + // *__last is known to be true + // __len >= 2 + if (__len == 2) + { + swap(*__first, *__last); + return __last; + } + if (__len == 3) + { + _BidirectionalIterator __m = __first; + if (__pred(*++__m)) + { + swap(*__first, *__m); + swap(*__m, *__last); + return __last; + } + swap(*__m, *__last); + swap(*__first, *__m); + return __m; + } + if (__len <= __p.second) + { // The buffer is big enough to use + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + __destruct_n __d(0); + unique_ptr __h(__p.first, __d); + // Move the falses into the temporary buffer, and the trues to the front of the line + // Update __first to always point to the end of the trues + value_type* __t = __p.first; + ::new ((void*)__t) value_type(_VSTD::move(*__first)); + __d.template __incr(); + ++__t; + _BidirectionalIterator __i = __first; + while (++__i != __last) + { + if (__pred(*__i)) + { + *__first = _VSTD::move(*__i); + ++__first; + } + else + { + ::new ((void*)__t) value_type(_VSTD::move(*__i)); + __d.template __incr(); + ++__t; + } + } + // move *__last, known to be true + *__first = _VSTD::move(*__i); + __i = ++__first; + // All trues now at start of range, all falses in buffer + // Move falses back into range, but don't mess up __first which points to first false + for (value_type* __t2 = __p.first; __t2 < __t; ++__t2, (void) ++__i) + *__i = _VSTD::move(*__t2); + // __h destructs moved-from values out of the temp buffer, but doesn't deallocate buffer + return __first; + } + // Else not enough buffer, do in place + // __len >= 4 + _BidirectionalIterator __m = __first; + _Distance __len2 = __len / 2; // __len2 >= 2 + _VSTD::advance(__m, __len2); + // recurse on [__first, __m-1], except reduce __m-1 until *(__m-1) is true, *__first know to be false + // F????????????????T + // f m l + _BidirectionalIterator __m1 = __m; + _BidirectionalIterator __first_false = __first; + _Distance __len_half = __len2; + while (!__pred(*--__m1)) + { + if (__m1 == __first) + goto __first_half_done; + --__len_half; + } + // F???TFFF?????????T + // f m1 m l + typedef typename add_lvalue_reference<_Predicate>::type _PredRef; + __first_false = _VSTD::__stable_partition<_PredRef>(__first, __m1, __pred, __len_half, __p, __bit); +__first_half_done: + // TTTFFFFF?????????T + // f ff m l + // recurse on [__m, __last], except increase __m until *(__m) is false, *__last know to be true + __m1 = __m; + _BidirectionalIterator __second_false = __last; + ++__second_false; + __len_half = __len - __len2; + while (__pred(*__m1)) + { + if (++__m1 == __last) + goto __second_half_done; + --__len_half; + } + // TTTFFFFFTTTF?????T + // f ff m m1 l + __second_false = _VSTD::__stable_partition<_PredRef>(__m1, __last, __pred, __len_half, __p, __bit); +__second_half_done: + // TTTFFFFFTTTTTFFFFF + // f ff m sf l + return _VSTD::rotate(__first_false, __m, __second_false); + // TTTTTTTTFFFFFFFFFF + // | +} + +template +_BidirectionalIterator +__stable_partition(_BidirectionalIterator __first, _BidirectionalIterator __last, _Predicate __pred, + bidirectional_iterator_tag) +{ + typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; + typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; + const difference_type __alloc_limit = 4; // might want to make this a function of trivial assignment + // Either prove all true and return __first or point to first false + while (true) + { + if (__first == __last) + return __first; + if (!__pred(*__first)) + break; + ++__first; + } + // __first points to first false, everything prior to __first is already set. + // Either prove [__first, __last) is all false and return __first, or point __last to last true + do + { + if (__first == --__last) + return __first; + } while (!__pred(*__last)); + // We now have a reduced range [__first, __last] + // *__first is known to be false + // *__last is known to be true + // __len >= 2 + difference_type __len = _VSTD::distance(__first, __last) + 1; + pair __p(0, 0); + unique_ptr __h; + if (__len >= __alloc_limit) + { + __p = _VSTD::get_temporary_buffer(__len); + __h.reset(__p.first); + } + return _VSTD::__stable_partition::type> + (__first, __last, __pred, __len, __p, bidirectional_iterator_tag()); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +_ForwardIterator +stable_partition(_ForwardIterator __first, _ForwardIterator __last, _Predicate __pred) +{ + return _VSTD::__stable_partition::type> + (__first, __last, __pred, typename iterator_traits<_ForwardIterator>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_STABLE_PARTITION_H diff --git a/gnu/llvm/libcxx/include/__algorithm/stable_sort.h b/gnu/llvm/libcxx/include/__algorithm/stable_sort.h new file mode 100644 index 00000000000..32b239a0d72 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/stable_sort.h @@ -0,0 +1,235 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_STABLE_SORT_H +#define _LIBCPP___ALGORITHM_STABLE_SORT_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/comp_ref_type.h> +#include <__algorithm/inplace_merge.h> +#include <__algorithm/sort.h> +#include <__iterator/iterator_traits.h> +#include <__utility/swap.h> +#include +#include // swap + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +void +__merge_move_construct(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + typename iterator_traits<_InputIterator1>::value_type* __result, _Compare __comp) +{ + typedef typename iterator_traits<_InputIterator1>::value_type value_type; + __destruct_n __d(0); + unique_ptr __h(__result, __d); + for (; true; ++__result) + { + if (__first1 == __last1) + { + for (; __first2 != __last2; ++__first2, ++__result, (void)__d.template __incr()) + ::new ((void*)__result) value_type(_VSTD::move(*__first2)); + __h.release(); + return; + } + if (__first2 == __last2) + { + for (; __first1 != __last1; ++__first1, ++__result, (void)__d.template __incr()) + ::new ((void*)__result) value_type(_VSTD::move(*__first1)); + __h.release(); + return; + } + if (__comp(*__first2, *__first1)) + { + ::new ((void*)__result) value_type(_VSTD::move(*__first2)); + __d.template __incr(); + ++__first2; + } + else + { + ::new ((void*)__result) value_type(_VSTD::move(*__first1)); + __d.template __incr(); + ++__first1; + } + } +} + +template +void +__merge_move_assign(_InputIterator1 __first1, _InputIterator1 __last1, + _InputIterator2 __first2, _InputIterator2 __last2, + _OutputIterator __result, _Compare __comp) +{ + for (; __first1 != __last1; ++__result) + { + if (__first2 == __last2) + { + for (; __first1 != __last1; ++__first1, (void) ++__result) + *__result = _VSTD::move(*__first1); + return; + } + if (__comp(*__first2, *__first1)) + { + *__result = _VSTD::move(*__first2); + ++__first2; + } + else + { + *__result = _VSTD::move(*__first1); + ++__first1; + } + } + for (; __first2 != __last2; ++__first2, (void) ++__result) + *__result = _VSTD::move(*__first2); +} + +template +void +__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len, + typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size); + +template +void +__stable_sort_move(_RandomAccessIterator __first1, _RandomAccessIterator __last1, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len, + typename iterator_traits<_RandomAccessIterator>::value_type* __first2) +{ + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + switch (__len) + { + case 0: + return; + case 1: + ::new ((void*)__first2) value_type(_VSTD::move(*__first1)); + return; + case 2: + __destruct_n __d(0); + unique_ptr __h2(__first2, __d); + if (__comp(*--__last1, *__first1)) + { + ::new ((void*)__first2) value_type(_VSTD::move(*__last1)); + __d.template __incr(); + ++__first2; + ::new ((void*)__first2) value_type(_VSTD::move(*__first1)); + } + else + { + ::new ((void*)__first2) value_type(_VSTD::move(*__first1)); + __d.template __incr(); + ++__first2; + ::new ((void*)__first2) value_type(_VSTD::move(*__last1)); + } + __h2.release(); + return; + } + if (__len <= 8) + { + _VSTD::__insertion_sort_move<_Compare>(__first1, __last1, __first2, __comp); + return; + } + typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; + _RandomAccessIterator __m = __first1 + __l2; + _VSTD::__stable_sort<_Compare>(__first1, __m, __comp, __l2, __first2, __l2); + _VSTD::__stable_sort<_Compare>(__m, __last1, __comp, __len - __l2, __first2 + __l2, __len - __l2); + _VSTD::__merge_move_construct<_Compare>(__first1, __m, __m, __last1, __first2, __comp); +} + +template +struct __stable_sort_switch +{ + static const unsigned value = 128*is_trivially_copy_assignable<_Tp>::value; +}; + +template +void +__stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp, + typename iterator_traits<_RandomAccessIterator>::difference_type __len, + typename iterator_traits<_RandomAccessIterator>::value_type* __buff, ptrdiff_t __buff_size) +{ + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + switch (__len) + { + case 0: + case 1: + return; + case 2: + if (__comp(*--__last, *__first)) + swap(*__first, *__last); + return; + } + if (__len <= static_cast(__stable_sort_switch::value)) + { + _VSTD::__insertion_sort<_Compare>(__first, __last, __comp); + return; + } + typename iterator_traits<_RandomAccessIterator>::difference_type __l2 = __len / 2; + _RandomAccessIterator __m = __first + __l2; + if (__len <= __buff_size) + { + __destruct_n __d(0); + unique_ptr __h2(__buff, __d); + _VSTD::__stable_sort_move<_Compare>(__first, __m, __comp, __l2, __buff); + __d.__set(__l2, (value_type*)nullptr); + _VSTD::__stable_sort_move<_Compare>(__m, __last, __comp, __len - __l2, __buff + __l2); + __d.__set(__len, (value_type*)nullptr); + _VSTD::__merge_move_assign<_Compare>(__buff, __buff + __l2, __buff + __l2, __buff + __len, __first, __comp); +// _VSTD::__merge<_Compare>(move_iterator(__buff), +// move_iterator(__buff + __l2), +// move_iterator<_RandomAccessIterator>(__buff + __l2), +// move_iterator<_RandomAccessIterator>(__buff + __len), +// __first, __comp); + return; + } + _VSTD::__stable_sort<_Compare>(__first, __m, __comp, __l2, __buff, __buff_size); + _VSTD::__stable_sort<_Compare>(__m, __last, __comp, __len - __l2, __buff, __buff_size); + _VSTD::__inplace_merge<_Compare>(__first, __m, __last, __comp, __l2, __len - __l2, __buff, __buff_size); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) +{ + typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type; + typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; + difference_type __len = __last - __first; + pair __buf(0, 0); + unique_ptr __h; + if (__len > static_cast(__stable_sort_switch::value)) + { + __buf = _VSTD::get_temporary_buffer(__len); + __h.reset(__buf.first); + } + typedef typename __comp_ref_type<_Compare>::type _Comp_ref; + _VSTD::__stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last) +{ + _VSTD::stable_sort(__first, __last, __less::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_STABLE_SORT_H diff --git a/gnu/llvm/libcxx/include/__algorithm/swap_ranges.h b/gnu/llvm/libcxx/include/__algorithm/swap_ranges.h new file mode 100644 index 00000000000..3c72dbd24c6 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/swap_ranges.h @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_SWAP_RANGES_H +#define _LIBCPP___ALGORITHM_SWAP_RANGES_H + +#include <__config> +#include <__utility/swap.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator2 +swap_ranges(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2) { + for (; __first1 != __last1; ++__first1, (void)++__first2) + swap(*__first1, *__first2); + return __first2; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_SWAP_RANGES_H diff --git a/gnu/llvm/libcxx/include/__algorithm/transform.h b/gnu/llvm/libcxx/include/__algorithm/transform.h new file mode 100644 index 00000000000..218f0f12eac --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/transform.h @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_TRANSFORM_H +#define _LIBCPP___ALGORITHM_TRANSFORM_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op) +{ + for (; __first != __last; ++__first, (void) ++__result) + *__result = __op(*__first); + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +transform(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, + _OutputIterator __result, _BinaryOperation __binary_op) +{ + for (; __first1 != __last1; ++__first1, (void) ++__first2, ++__result) + *__result = __binary_op(*__first1, *__first2); + return __result; +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_TRANSFORM_H diff --git a/gnu/llvm/libcxx/include/__algorithm/unique.h b/gnu/llvm/libcxx/include/__algorithm/unique.h new file mode 100644 index 00000000000..fb6251a39a8 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/unique.h @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_UNIQUE_H +#define _LIBCPP___ALGORITHM_UNIQUE_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/adjacent_find.h> +#include <__iterator/iterator_traits.h> +#include <__utility/move.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// unique + +template +_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> + (__first, __last, __pred); + if (__first != __last) + { + // ... a a ? ... + // f i + _ForwardIterator __i = __first; + for (++__i; ++__i != __last;) + if (!__pred(*__first, *__i)) + *++__first = _VSTD::move(*__i); + ++__first; + } + return __first; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +unique(_ForwardIterator __first, _ForwardIterator __last) +{ + typedef typename iterator_traits<_ForwardIterator>::value_type __v; + return _VSTD::unique(__first, __last, __equal_to<__v>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_UNIQUE_H diff --git a/gnu/llvm/libcxx/include/__algorithm/unique_copy.h b/gnu/llvm/libcxx/include/__algorithm/unique_copy.h new file mode 100644 index 00000000000..974a7c4df2d --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/unique_copy.h @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_UNIQUE_COPY_H +#define _LIBCPP___ALGORITHM_UNIQUE_COPY_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__iterator/iterator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator +__unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred, + input_iterator_tag, output_iterator_tag) +{ + if (__first != __last) + { + typename iterator_traits<_InputIterator>::value_type __t(*__first); + *__result = __t; + ++__result; + while (++__first != __last) + { + if (!__pred(__t, *__first)) + { + __t = *__first; + *__result = __t; + ++__result; + } + } + } + return __result; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _OutputIterator +__unique_copy(_ForwardIterator __first, _ForwardIterator __last, _OutputIterator __result, _BinaryPredicate __pred, + forward_iterator_tag, output_iterator_tag) +{ + if (__first != __last) + { + _ForwardIterator __i = __first; + *__result = *__i; + ++__result; + while (++__first != __last) + { + if (!__pred(*__i, *__first)) + { + *__result = *__first; + ++__result; + __i = __first; + } + } + } + return __result; +} + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +__unique_copy(_InputIterator __first, _InputIterator __last, _ForwardIterator __result, _BinaryPredicate __pred, + input_iterator_tag, forward_iterator_tag) +{ + if (__first != __last) + { + *__result = *__first; + while (++__first != __last) + if (!__pred(*__result, *__first)) + *++__result = *__first; + ++__result; + } + return __result; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _BinaryPredicate __pred) +{ + return _VSTD::__unique_copy::type> + (__first, __last, __result, __pred, + typename iterator_traits<_InputIterator>::iterator_category(), + typename iterator_traits<_OutputIterator>::iterator_category()); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_OutputIterator +unique_copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) +{ + typedef typename iterator_traits<_InputIterator>::value_type __v; + return _VSTD::unique_copy(__first, __last, __result, __equal_to<__v>()); +} + + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_UNIQUE_COPY_H diff --git a/gnu/llvm/libcxx/include/__algorithm/unwrap_iter.h b/gnu/llvm/libcxx/include/__algorithm/unwrap_iter.h new file mode 100644 index 00000000000..a45d45cdd86 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/unwrap_iter.h @@ -0,0 +1,87 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_UNWRAP_ITER_H +#define _LIBCPP___ALGORITHM_UNWRAP_ITER_H + +#include <__config> +#include +#include <__memory/pointer_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +// The job of __unwrap_iter is to lower contiguous iterators (such as +// vector::iterator) into pointers, to reduce the number of template +// instantiations and to enable pointer-based optimizations e.g. in std::copy. +// For iterators that are not contiguous, it must be a no-op. +// In debug mode, we don't do this. +// +// __unwrap_iter is non-constexpr for user-defined iterators whose +// `to_address` and/or `operator->` is non-constexpr. This is okay; but we +// try to avoid doing __unwrap_iter in constant-evaluated contexts anyway. +// +// Some algorithms (e.g. std::copy, but not std::sort) need to convert an +// "unwrapped" result back into a contiguous iterator. Since contiguous iterators +// are random-access, we can do this portably using iterator arithmetic; this +// is the job of __rewrap_iter. + +template ::value> +struct __unwrap_iter_impl { + static _LIBCPP_CONSTEXPR _Iter + __apply(_Iter __i) _NOEXCEPT { + return __i; + } +}; + +#if _LIBCPP_DEBUG_LEVEL < 2 + +template +struct __unwrap_iter_impl<_Iter, true> { + static _LIBCPP_CONSTEXPR decltype(_VSTD::__to_address(declval<_Iter>())) + __apply(_Iter __i) _NOEXCEPT { + return _VSTD::__to_address(__i); + } +}; + +#endif // _LIBCPP_DEBUG_LEVEL < 2 + +template > +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +decltype(_Impl::__apply(declval<_Iter>())) +__unwrap_iter(_Iter __i) _NOEXCEPT +{ + return _Impl::__apply(__i); +} + +template +_OrigIter __rewrap_iter(_OrigIter, _OrigIter __result) +{ + return __result; +} + +template +_OrigIter __rewrap_iter(_OrigIter __first, _UnwrappedIter __result) +{ + // Precondition: __result is reachable from __first + // Precondition: _OrigIter is a contiguous iterator + return __first + (__result - _VSTD::__unwrap_iter(__first)); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_UNWRAP_ITER_H diff --git a/gnu/llvm/libcxx/include/__algorithm/upper_bound.h b/gnu/llvm/libcxx/include/__algorithm/upper_bound.h new file mode 100644 index 00000000000..7be607f8253 --- /dev/null +++ b/gnu/llvm/libcxx/include/__algorithm/upper_bound.h @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// 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___ALGORITHM_UPPER_BOUND_H +#define _LIBCPP___ALGORITHM_UPPER_BOUND_H + +#include <__config> +#include <__algorithm/comp.h> +#include <__algorithm/half_positive.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 _ForwardIterator +__upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + typedef typename iterator_traits<_ForwardIterator>::difference_type difference_type; + difference_type __len = _VSTD::distance(__first, __last); + while (__len != 0) + { + difference_type __l2 = _VSTD::__half_positive(__len); + _ForwardIterator __m = __first; + _VSTD::advance(__m, __l2); + if (__comp(__value_, *__m)) + __len = __l2; + else + { + __first = ++__m; + __len -= __l2 + 1; + } + } + return __first; +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) +{ + typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; + return _VSTD::__upper_bound<_Comp_ref>(__first, __last, __value_, __comp); +} + +template +_LIBCPP_NODISCARD_EXT inline +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +_ForwardIterator +upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_) +{ + return _VSTD::upper_bound(__first, __last, __value_, + __less<_Tp, typename iterator_traits<_ForwardIterator>::value_type>()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ALGORITHM_UPPER_BOUND_H diff --git a/gnu/llvm/libcxx/include/__availability b/gnu/llvm/libcxx/include/__availability new file mode 100644 index 00000000000..13d11950fd6 --- /dev/null +++ b/gnu/llvm/libcxx/include/__availability @@ -0,0 +1,270 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___AVAILABILITY +#define _LIBCPP___AVAILABILITY + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +# pragma GCC system_header +#endif + +// Libc++ is shipped by various vendors. In particular, it is used as a system +// library on macOS, iOS and other Apple platforms. In order for users to be +// able to compile a binary that is intended to be deployed to an older version +// of a platform, Clang provides availability attributes [1]. These attributes +// can be placed on declarations and are used to describe the life cycle of a +// symbol in the library. +// +// The main goal is to ensure a compile-time error if a symbol that hasn't been +// introduced in a previously released library is used in a program that targets +// that previously released library. Normally, this would be a load-time error +// when one tries to launch the program against the older library. +// +// For example, the filesystem library was introduced in the dylib in macOS 10.15. +// If a user compiles on a macOS 10.15 host but targets macOS 10.13 with their +// program, the compiler would normally not complain (because the required +// declarations are in the headers), but the dynamic loader would fail to find +// the symbols when actually trying to launch the program on macOS 10.13. To +// turn this into a compile-time issue instead, declarations are annotated with +// when they were introduced, and the compiler can produce a diagnostic if the +// program references something that isn't available on the deployment target. +// +// This mechanism is general in nature, and any vendor can add their markup to +// the library (see below). Whenever a new feature is added that requires support +// in the shared library, a macro should be added below to mark this feature +// as unavailable. When vendors decide to ship the feature as part of their +// shared library, they can update the markup appropriately. +// +// Furthermore, many features in the standard library have corresponding +// feature-test macros. When a feature is made unavailable on some deployment +// target, a macro should be defined to signal that it is unavailable. That +// macro can then be picked up when feature-test macros are generated (see +// generate_feature_test_macro_components.py) to make sure that feature-test +// macros don't announce a feature as being implemented if it has been marked +// as unavailable. +// +// Note that this mechanism is disabled by default in the "upstream" libc++. +// Availability annotations are only meaningful when shipping libc++ inside +// a platform (i.e. as a system library), and so vendors that want them should +// turn those annotations on at CMake configuration time. +// +// [1]: https://clang.llvm.org/docs/AttributeReference.html#availability + + +// For backwards compatibility, allow users to define _LIBCPP_DISABLE_AVAILABILITY +// for a while. +#if defined(_LIBCPP_DISABLE_AVAILABILITY) +# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) +# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS +# endif +#endif + +// Availability markup is disabled when building the library, or when the compiler +// doesn't support the proper attributes. +#if defined(_LIBCPP_BUILDING_LIBRARY) || \ + defined(_LIBCXXABI_BUILDING_LIBRARY) || \ + !__has_feature(attribute_availability_with_strict) || \ + !__has_feature(attribute_availability_in_templates) || \ + !__has_extension(pragma_clang_attribute_external_declaration) +# if !defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) +# define _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS +# endif +#endif + +#if defined(_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS) + + // This controls the availability of std::shared_mutex and std::shared_timed_mutex, + // which were added to the dylib later. +# define _LIBCPP_AVAILABILITY_SHARED_MUTEX +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex + + // These macros control the availability of std::bad_optional_access and + // other exception types. These were put in the shared library to prevent + // code bloat from every user program defining the vtable for these exception + // types. +# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS +# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS +# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST + + // This controls the availability of std::uncaught_exceptions(). +# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS + + // This controls the availability of the sized version of ::operator delete, + // which was added to the dylib later. +# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE + + // This controls the availability of the std::future_error exception. +# define _LIBCPP_AVAILABILITY_FUTURE_ERROR + + // This controls the availability of std::type_info's vtable. + // I can't imagine how using std::type_info can work at all if + // this isn't supported. +# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE + + // This controls the availability of std::locale::category members + // (e.g. std::locale::collate), which are defined in the dylib. +# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY + + // This controls the availability of atomic operations on std::shared_ptr + // (e.g. `std::atomic_store(std::shared_ptr)`), which require a shared + // lock table located in the dylib. +# define _LIBCPP_AVAILABILITY_ATOMIC_SHARED_PTR + + // These macros control the availability of all parts of that + // depend on something in the dylib. +# define _LIBCPP_AVAILABILITY_FILESYSTEM +# define _LIBCPP_AVAILABILITY_FILESYSTEM_PUSH +# define _LIBCPP_AVAILABILITY_FILESYSTEM_POP +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem + + // This controls the availability of std::to_chars. +# define _LIBCPP_AVAILABILITY_TO_CHARS + + // This controls the availability of the C++20 synchronization library, + // which requires shared library support for various operations + // (see libcxx/src/atomic.cpp). +# define _LIBCPP_AVAILABILITY_SYNC +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore + + // This controls the availability of the C++20 format library. + // The library is in development and not ABI stable yet. Currently + // P2216 is aiming to be retroactively accepted in C++20. This paper + // contains ABI breaking changes. +# define _LIBCPP_AVAILABILITY_FORMAT +// # define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format + +#elif defined(__APPLE__) + +# define _LIBCPP_AVAILABILITY_SHARED_MUTEX \ + __attribute__((availability(macosx,strict,introduced=10.12))) \ + __attribute__((availability(ios,strict,introduced=10.0))) \ + __attribute__((availability(tvos,strict,introduced=10.0))) \ + __attribute__((availability(watchos,strict,introduced=3.0))) +# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200) || \ + (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 100000) || \ + (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 100000) || \ + (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 30000) +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_mutex +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_shared_timed_mutex +# endif + +# define _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS \ + __attribute__((availability(macosx,strict,introduced=10.13))) \ + __attribute__((availability(ios,strict,introduced=11.0))) \ + __attribute__((availability(tvos,strict,introduced=11.0))) \ + __attribute__((availability(watchos,strict,introduced=4.0))) +# define _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS \ + _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS +# define _LIBCPP_AVAILABILITY_BAD_ANY_CAST \ + _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS + +# define _LIBCPP_AVAILABILITY_UNCAUGHT_EXCEPTIONS \ + __attribute__((availability(macosx,strict,introduced=10.12))) \ + __attribute__((availability(ios,strict,introduced=10.0))) \ + __attribute__((availability(tvos,strict,introduced=10.0))) \ + __attribute__((availability(watchos,strict,introduced=3.0))) + +# define _LIBCPP_AVAILABILITY_SIZED_NEW_DELETE \ + __attribute__((availability(macosx,strict,introduced=10.12))) \ + __attribute__((availability(ios,strict,introduced=10.0))) \ + __attribute__((availability(tvos,strict,introduced=10.0))) \ + __attribute__((availability(watchos,strict,introduced=3.0))) + +# define _LIBCPP_AVAILABILITY_FUTURE_ERROR \ + __attribute__((availability(ios,strict,introduced=6.0))) + +# define _LIBCPP_AVAILABILITY_TYPEINFO_VTABLE \ + __attribute__((availability(macosx,strict,introduced=10.9))) \ + __attribute__((availability(ios,strict,introduced=7.0))) + +# define _LIBCPP_AVAILABILITY_LOCALE_CATEGORY \ + __attribute__((availability(macosx,strict,introduced=10.9))) \ + __attribute__((availability(ios,strict,introduced=7.0))) + +# 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") +# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500) || \ + (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 130000) || \ + (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 130000) || \ + (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 60000) +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_filesystem +# endif + +# define _LIBCPP_AVAILABILITY_TO_CHARS \ + _LIBCPP_AVAILABILITY_FILESYSTEM + +# define _LIBCPP_AVAILABILITY_SYNC \ + __attribute__((availability(macosx,strict,introduced=11.0))) \ + __attribute__((availability(ios,strict,introduced=14.0))) \ + __attribute__((availability(tvos,strict,introduced=14.0))) \ + __attribute__((availability(watchos,strict,introduced=7.0))) +# if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 110000) || \ + (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ < 140000) || \ + (defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ < 140000) || \ + (defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__) && __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ < 70000) +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_atomic_wait +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_barrier +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_latch +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_semaphore +# endif + + // This controls the availability of the C++20 format library. + // The library is in development and not ABI stable yet. Currently + // P2216 is aiming to be retroactively accepted in C++20. This paper + // contains ABI breaking changes. +# define _LIBCPP_AVAILABILITY_FORMAT \ + __attribute__((unavailable)) +# define _LIBCPP_AVAILABILITY_DISABLE_FTM___cpp_lib_format +#else + +// ...New vendors can add availability markup here... + +# error "It looks like you're trying to enable vendor availability markup, but you haven't defined the corresponding macros yet!" + +#endif + +// Define availability attributes that depend on _LIBCPP_NO_EXCEPTIONS. +// Those are defined in terms of the availability attributes above, and +// should not be vendor-specific. +#if defined(_LIBCPP_NO_EXCEPTIONS) +# define _LIBCPP_AVAILABILITY_FUTURE +# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST +# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS +# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS +#else +# define _LIBCPP_AVAILABILITY_FUTURE _LIBCPP_AVAILABILITY_FUTURE_ERROR +# define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST _LIBCPP_AVAILABILITY_BAD_ANY_CAST +# define _LIBCPP_AVAILABILITY_THROW_BAD_OPTIONAL_ACCESS _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS +# define _LIBCPP_AVAILABILITY_THROW_BAD_VARIANT_ACCESS _LIBCPP_AVAILABILITY_BAD_VARIANT_ACCESS +#endif + +#endif // _LIBCPP___AVAILABILITY diff --git a/gnu/llvm/libcxx/include/__bit_reference b/gnu/llvm/libcxx/include/__bit_reference index 4a2b82064b3..a02492c077d 100644 --- a/gnu/llvm/libcxx/include/__bit_reference +++ b/gnu/llvm/libcxx/include/__bit_reference @@ -11,7 +11,7 @@ #define _LIBCPP___BIT_REFERENCE #include <__config> -#include +#include <__bits> #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -239,8 +239,8 @@ __bit_iterator<_Cp, _IsConst> find(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) { if (static_cast(__value_)) - return __find_bool_true(__first, static_cast(__last - __first)); - return __find_bool_false(__first, static_cast(__last - __first)); + return _VSTD::__find_bool_true(__first, static_cast(__last - __first)); + return _VSTD::__find_bool_false(__first, static_cast(__last - __first)); } // count @@ -313,8 +313,8 @@ typename __bit_iterator<_Cp, _IsConst>::difference_type count(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, const _Tp& __value_) { if (static_cast(__value_)) - return __count_bool_true(__first, static_cast(__last - __first)); - return __count_bool_false(__first, static_cast(__last - __first)); + return _VSTD::__count_bool_true(__first, static_cast(__last - __first)); + return _VSTD::__count_bool_false(__first, static_cast(__last - __first)); } // fill_n @@ -387,9 +387,9 @@ fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __v if (__n > 0) { if (__value_) - __fill_n_true(__first, __n); + _VSTD::__fill_n_true(__first, __n); else - __fill_n_false(__first, __n); + _VSTD::__fill_n_false(__first, __n); } } @@ -538,8 +538,8 @@ __bit_iterator<_Cp, false> copy(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { if (__first.__ctz_ == __result.__ctz_) - return __copy_aligned(__first, __last, __result); - return __copy_unaligned(__first, __last, __result); + return _VSTD::__copy_aligned(__first, __last, __result); + return _VSTD::__copy_unaligned(__first, __last, __result); } // copy_backward @@ -685,8 +685,8 @@ __bit_iterator<_Cp, false> copy_backward(__bit_iterator<_Cp, _IsConst> __first, __bit_iterator<_Cp, _IsConst> __last, __bit_iterator<_Cp, false> __result) { if (__last.__ctz_ == __result.__ctz_) - return __copy_backward_aligned(__first, __last, __result); - return __copy_backward_unaligned(__first, __last, __result); + return _VSTD::__copy_backward_aligned(__first, __last, __result); + return _VSTD::__copy_backward_unaligned(__first, __last, __result); } // move @@ -868,8 +868,8 @@ swap_ranges(__bit_iterator<__C1, false> __first1, __bit_iterator<__C1, false> __ __bit_iterator<__C2, false> __first2) { if (__first1.__ctz_ == __first2.__ctz_) - return __swap_ranges_aligned(__first1, __last1, __first2); - return __swap_ranges_unaligned(__first1, __last1, __first2); + return _VSTD::__swap_ranges_aligned(__first1, __last1, __first2); + return _VSTD::__swap_ranges_unaligned(__first1, __last1, __first2); } // rotate @@ -1083,8 +1083,8 @@ bool equal(__bit_iterator<_Cp, _IC1> __first1, __bit_iterator<_Cp, _IC1> __last1, __bit_iterator<_Cp, _IC2> __first2) { if (__first1.__ctz_ == __first2.__ctz_) - return __equal_aligned(__first1, __last1, __first2); - return __equal_unaligned(__first1, __last1, __first2); + return _VSTD::__equal_aligned(__first1, __last1, __first2); + return _VSTD::__equal_unaligned(__first1, __last1, __first2); } template , struct __private_nat>; - + // When _IsConst=false, this is the copy constructor. + // It is non-trivial. Making it trivial would break ABI. + // When _IsConst=true, this is a converting constructor; + // the copy and move constructors are implicitly generated + // and trivial. _LIBCPP_INLINE_VISIBILITY - __bit_iterator(const __type_for_copy_to_const& __it) _NOEXCEPT + __bit_iterator(const __bit_iterator<_Cp, false>& __it) _NOEXCEPT : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} - // The non-const __bit_iterator has historically had a non-trivial - // copy constructor (as a quirk of its construction). We need to maintain - // this for ABI purposes. - using __type_for_abi_non_trivial_copy_ctor = - _If; - - _LIBCPP_INLINE_VISIBILITY - __bit_iterator(__type_for_abi_non_trivial_copy_ctor const& __it) _NOEXCEPT - : __seg_(__it.__seg_), __ctz_(__it.__ctz_) {} - - // Always declare the copy assignment operator since the implicit declaration - // is deprecated. + // When _IsConst=false, we have a user-provided copy constructor, + // so we must also provide a copy assignment operator because + // the implicit generation of a defaulted one is deprecated. + // When _IsConst=true, the assignment operators are + // implicitly generated and trivial. _LIBCPP_INLINE_VISIBILITY - __bit_iterator& operator=(__bit_iterator const&) = default; + __bit_iterator& operator=(const _If<_IsConst, struct __private_nat, __bit_iterator>& __it) { + __seg_ = __it.__seg_; + __ctz_ = __it.__ctz_; + return *this; + } _LIBCPP_INLINE_VISIBILITY reference operator*() const _NOEXCEPT {return reference(__seg_, __storage_type(1) << __ctz_);} @@ -1302,4 +1300,4 @@ _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // _LIBCPP___BIT_REFERENCE +#endif // _LIBCPP___BIT_REFERENCE diff --git a/gnu/llvm/libcxx/include/__bits b/gnu/llvm/libcxx/include/__bits new file mode 100644 index 00000000000..b565a782358 --- /dev/null +++ b/gnu/llvm/libcxx/include/__bits @@ -0,0 +1,145 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___BITS +#define _LIBCPP___BITS + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifndef _LIBCPP_COMPILER_MSVC + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_ctz(unsigned __x) _NOEXCEPT { return __builtin_ctz(__x); } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_ctz(unsigned long __x) _NOEXCEPT { return __builtin_ctzl(__x); } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_ctz(unsigned long long __x) _NOEXCEPT { return __builtin_ctzll(__x); } + + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_clz(unsigned __x) _NOEXCEPT { return __builtin_clz(__x); } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_clz(unsigned long __x) _NOEXCEPT { return __builtin_clzl(__x); } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_clz(unsigned long long __x) _NOEXCEPT { return __builtin_clzll(__x); } + + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); } + +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__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 __libcpp_ctz(unsigned __x) { + static_assert(sizeof(unsigned) == sizeof(unsigned long), ""); + static_assert(sizeof(unsigned long) == 4, ""); + unsigned long __where; + if (_BitScanForward(&__where, __x)) + return static_cast(__where); + return 32; +} + +inline _LIBCPP_INLINE_VISIBILITY +int __libcpp_ctz(unsigned long __x) { + static_assert(sizeof(unsigned long) == sizeof(unsigned), ""); + return __ctz(static_cast(__x)); +} + +inline _LIBCPP_INLINE_VISIBILITY +int __libcpp_ctz(unsigned long long __x) { + unsigned long __where; +#if defined(_LIBCPP_HAS_BITSCAN64) + if (_BitScanForward64(&__where, __x)) + return static_cast(__where); +#else + // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls. + if (_BitScanForward(&__where, static_cast(__x))) + return static_cast(__where); + if (_BitScanForward(&__where, static_cast(__x >> 32))) + return static_cast(__where + 32); +#endif + return 64; +} + +// Precondition: __x != 0 +inline _LIBCPP_INLINE_VISIBILITY +int __libcpp_clz(unsigned __x) { + static_assert(sizeof(unsigned) == sizeof(unsigned long), ""); + static_assert(sizeof(unsigned long) == 4, ""); + unsigned long __where; + if (_BitScanReverse(&__where, __x)) + return static_cast(31 - __where); + return 32; // Undefined Behavior. +} + +inline _LIBCPP_INLINE_VISIBILITY +int __libcpp_clz(unsigned long __x) { + static_assert(sizeof(unsigned) == sizeof(unsigned long), ""); + return __libcpp_clz(static_cast(__x)); +} + +inline _LIBCPP_INLINE_VISIBILITY +int __libcpp_clz(unsigned long long __x) { + unsigned long __where; +#if defined(_LIBCPP_HAS_BITSCAN64) + if (_BitScanReverse64(&__where, __x)) + return static_cast(63 - __where); +#else + // Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls. + if (_BitScanReverse(&__where, static_cast(__x >> 32))) + return static_cast(63 - (__where + 32)); + if (_BitScanReverse(&__where, static_cast(__x))) + return static_cast(63 - __where); +#endif + return 64; // Undefined Behavior. +} + +inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) { + static_assert(sizeof(unsigned) == 4, ""); + return __popcnt(__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 __libcpp_popcount(unsigned long long __x) { + static_assert(sizeof(unsigned long long) == 8, ""); + return __popcnt64(__x); +} + +#endif // _LIBCPP_COMPILER_MSVC + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___BITS diff --git a/gnu/llvm/libcxx/include/__bsd_locale_fallbacks.h b/gnu/llvm/libcxx/include/__bsd_locale_fallbacks.h index a807fe03955..ed0eabf60ec 100644 --- a/gnu/llvm/libcxx/include/__bsd_locale_fallbacks.h +++ b/gnu/llvm/libcxx/include/__bsd_locale_fallbacks.h @@ -13,9 +13,9 @@ #ifndef _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H #define _LIBCPP_BSD_LOCALE_FALLBACKS_DEFAULTS_H -#include -#include #include +#include +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header diff --git a/gnu/llvm/libcxx/include/__config_site.in b/gnu/llvm/libcxx/include/__config_site.in index a6984b2eefc..e202d923f31 100644 --- a/gnu/llvm/libcxx/include/__config_site.in +++ b/gnu/llvm/libcxx/include/__config_site.in @@ -26,12 +26,16 @@ #cmakedefine _LIBCPP_HAS_THREAD_API_WIN32 #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS +#cmakedefine _LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS #cmakedefine _LIBCPP_NO_VCRUNTIME -#ifndef _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION #cmakedefine _LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION @_LIBCPP_TYPEINFO_COMPARISON_IMPLEMENTATION@ -#endif #cmakedefine _LIBCPP_ABI_NAMESPACE @_LIBCPP_ABI_NAMESPACE@ +#cmakedefine _LIBCPP_HAS_NO_FILESYSTEM_LIBRARY #cmakedefine _LIBCPP_HAS_PARALLEL_ALGORITHMS +#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE +#cmakedefine _LIBCPP_HAS_NO_LOCALIZATION +#cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_FORMAT +#cmakedefine _LIBCPP_HAS_NO_INCOMPLETE_RANGES @_LIBCPP_ABI_DEFINES@ diff --git a/gnu/llvm/libcxx/include/__debug b/gnu/llvm/libcxx/include/__debug index 11367413fcc..771e4316320 100644 --- a/gnu/llvm/libcxx/include/__debug +++ b/gnu/llvm/libcxx/include/__debug @@ -27,26 +27,21 @@ # include #endif -#if _LIBCPP_DEBUG_LEVEL >= 1 && !defined(_LIBCPP_ASSERT) -# define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : \ - _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) -#endif - -#if _LIBCPP_DEBUG_LEVEL >= 2 -#ifndef _LIBCPP_DEBUG_ASSERT -#define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) -#endif -#define _LIBCPP_DEBUG_MODE(...) __VA_ARGS__ -#endif - -#ifndef _LIBCPP_ASSERT -# define _LIBCPP_ASSERT(x, m) ((void)0) -#endif -#ifndef _LIBCPP_DEBUG_ASSERT +#if _LIBCPP_DEBUG_LEVEL == 0 +# define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) +# define _LIBCPP_ASSERT_IMPL(x, m) ((void)0) +#elif _LIBCPP_DEBUG_LEVEL == 1 # define _LIBCPP_DEBUG_ASSERT(x, m) ((void)0) +# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) +#elif _LIBCPP_DEBUG_LEVEL == 2 +# define _LIBCPP_DEBUG_ASSERT(x, m) _LIBCPP_ASSERT(x, m) +# define _LIBCPP_ASSERT_IMPL(x, m) ((x) ? (void)0 : _VSTD::__libcpp_debug_function(_VSTD::__libcpp_debug_info(__FILE__, __LINE__, #x, m))) +#else +# error _LIBCPP_DEBUG_LEVEL must be one of 0, 1, 2 #endif -#ifndef _LIBCPP_DEBUG_MODE -#define _LIBCPP_DEBUG_MODE(...) ((void)0) + +#if !defined(_LIBCPP_ASSERT) +# define _LIBCPP_ASSERT(x, m) _LIBCPP_ASSERT_IMPL(x, m) #endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -59,7 +54,7 @@ struct _LIBCPP_TEMPLATE_VIS __libcpp_debug_info { __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; + _LIBCPP_FUNC_VIS string what() const; const char* __file_; int __line_; @@ -83,7 +78,7 @@ void __libcpp_abort_debug_function(__libcpp_debug_info const&); _LIBCPP_FUNC_VIS bool __libcpp_set_debug_function(__libcpp_debug_function_type __func); -#if _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) +#if _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY) struct _LIBCPP_TYPE_VIS __c_node; @@ -226,7 +221,7 @@ public: template _LIBCPP_INLINE_VISIBILITY static __c_node* __create_C_node(void *__mem, void *__c, __c_node *__next) { - return ::new(__mem) _C_node<_Cont>(__c, __next); + return ::new (__mem) _C_node<_Cont>(__c, __next); } template @@ -271,8 +266,8 @@ _LIBCPP_FUNC_VIS __libcpp_db* __get_db(); _LIBCPP_FUNC_VIS const __libcpp_db* __get_const_db(); -#endif // _LIBCPP_DEBUG_LEVEL >= 2 || defined(_LIBCPP_BUILDING_LIBRARY) +#endif // _LIBCPP_DEBUG_LEVEL == 2 || defined(_LIBCPP_BUILDING_LIBRARY) _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP_DEBUG_H +#endif // _LIBCPP_DEBUG_H diff --git a/gnu/llvm/libcxx/include/__errc b/gnu/llvm/libcxx/include/__errc index a8ad29f364a..81da2e1970c 100644 --- a/gnu/llvm/libcxx/include/__errc +++ b/gnu/llvm/libcxx/include/__errc @@ -214,4 +214,4 @@ _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc) _LIBCPP_END_NAMESPACE_STD -#endif // _LIBCPP___ERRC +#endif // _LIBCPP___ERRC diff --git a/gnu/llvm/libcxx/include/__format/format_error.h b/gnu/llvm/libcxx/include/__format/format_error.h new file mode 100644 index 00000000000..f983d0ce4ac --- /dev/null +++ b/gnu/llvm/libcxx/include/__format/format_error.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FORMAT_FORMAT_ERROR_H +#define _LIBCPP___FORMAT_FORMAT_ERROR_H + +#include <__config> +#include + +#ifdef _LIBCPP_NO_EXCEPTIONS +#include +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +class _LIBCPP_EXCEPTION_ABI format_error : public runtime_error { +public: + _LIBCPP_HIDE_FROM_ABI explicit format_error(const string& __s) + : runtime_error(__s) {} + _LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s) + : runtime_error(__s) {} + virtual ~format_error() noexcept; +}; + +_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void +__throw_format_error(const char* __s) { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw format_error(__s); +#else + (void)__s; + _VSTD::abort(); +#endif +} + +#endif //_LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___FORMAT_FORMAT_ERROR_H diff --git a/gnu/llvm/libcxx/include/__format/format_parse_context.h b/gnu/llvm/libcxx/include/__format/format_parse_context.h new file mode 100644 index 00000000000..db39c1b5483 --- /dev/null +++ b/gnu/llvm/libcxx/include/__format/format_parse_context.h @@ -0,0 +1,113 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FORMAT_FORMAT_PARSE_CONTEXT_H +#define _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H + +#include <__config> +#include <__format/format_error.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +// TODO FMT Remove this once we require compilers with proper C++20 support. +// If the compiler has no concepts support, the format header will be disabled. +// Without concepts support enable_if needs to be used and that too much effort +// to support compilers with partial C++20 support. +#if !defined(_LIBCPP_HAS_NO_CONCEPTS) && \ + !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_AVAILABILITY_FORMAT basic_format_parse_context { +public: + using char_type = _CharT; + using const_iterator = typename basic_string_view<_CharT>::const_iterator; + using iterator = const_iterator; + + _LIBCPP_HIDE_FROM_ABI + constexpr explicit basic_format_parse_context(basic_string_view<_CharT> __fmt, + size_t __num_args = 0) noexcept + : __begin_(__fmt.begin()), + __end_(__fmt.end()), + __indexing_(__unknown), + __next_arg_id_(0), + __num_args_(__num_args) {} + + basic_format_parse_context(const basic_format_parse_context&) = delete; + basic_format_parse_context& + operator=(const basic_format_parse_context&) = delete; + + _LIBCPP_HIDE_FROM_ABI constexpr const_iterator begin() const noexcept { + return __begin_; + } + _LIBCPP_HIDE_FROM_ABI constexpr const_iterator end() const noexcept { + return __end_; + } + _LIBCPP_HIDE_FROM_ABI constexpr void advance_to(const_iterator __it) { + __begin_ = __it; + } + + _LIBCPP_HIDE_FROM_ABI constexpr size_t next_arg_id() { + if (__indexing_ == __manual) + __throw_format_error("Using automatic argument numbering in manual " + "argument numbering mode"); + + if (__indexing_ == __unknown) + __indexing_ = __automatic; + return __next_arg_id_++; + } + _LIBCPP_HIDE_FROM_ABI constexpr void check_arg_id(size_t __id) { + if (__indexing_ == __automatic) + __throw_format_error("Using manual argument numbering in automatic " + "argument numbering mode"); + + if (__indexing_ == __unknown) + __indexing_ = __manual; + + // Throws an exception to make the expression a non core constant + // expression as required by: + // [format.parse.ctx]/11 + // Remarks: Call expressions where id >= num_args_ are not core constant + // expressions ([expr.const]). + // Note: the Throws clause [format.parse.ctx]/10 doesn't specify the + // behavior when id >= num_args_. + if (is_constant_evaluated() && __id >= __num_args_) + __throw_format_error("Argument index outside the valid range"); + } + +private: + iterator __begin_; + iterator __end_; + enum _Indexing { __unknown, __manual, __automatic }; + _Indexing __indexing_; + size_t __next_arg_id_; + size_t __num_args_; +}; + +using format_parse_context = basic_format_parse_context; +using wformat_parse_context = basic_format_parse_context; + +#endif // !defined(_LIBCPP_HAS_NO_CONCEPTS) && !defined(_LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED) + +#endif //_LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___FORMAT_FORMAT_PARSE_CONTEXT_H diff --git a/gnu/llvm/libcxx/include/__function_like.h b/gnu/llvm/libcxx/include/__function_like.h new file mode 100644 index 00000000000..8a3597bacdc --- /dev/null +++ b/gnu/llvm/libcxx/include/__function_like.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_FUNCTION_LIKE_H +#define _LIBCPP___ITERATOR_FUNCTION_LIKE_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +// Per [range.iter.ops.general] and [algorithms.requirements], functions in namespace std::ranges +// can't be found by ADL and inhibit ADL when found by unqualified lookup. The easiest way to +// facilitate this is to use function objects. +// +// Since these are still standard library functions, we use `__function_like` to eliminate most of +// the properties that function objects get by default (e.g. semiregularity, addressability), to +// limit the surface area of the unintended public interface, so as to curb the effect of Hyrum's +// law. +struct __function_like { + __function_like() = delete; + __function_like(__function_like const&) = delete; + __function_like& operator=(__function_like const&) = delete; + + void operator&() const = delete; + + struct __tag { }; + +protected: + constexpr explicit __function_like(__tag) noexcept {} + ~__function_like() = default; +}; +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_FUNCTION_LIKE_H diff --git a/gnu/llvm/libcxx/include/__functional/binary_function.h b/gnu/llvm/libcxx/include/__functional/binary_function.h new file mode 100644 index 00000000000..8ca7b06662a --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/binary_function.h @@ -0,0 +1,31 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_BINARY_FUNCTION_H +#define _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct _LIBCPP_TEMPLATE_VIS binary_function +{ + typedef _Arg1 first_argument_type; + typedef _Arg2 second_argument_type; + typedef _Result result_type; +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H diff --git a/gnu/llvm/libcxx/include/__functional/binary_negate.h b/gnu/llvm/libcxx/include/__functional/binary_negate.h new file mode 100644 index 00000000000..4fc3f1ba287 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/binary_negate.h @@ -0,0 +1,50 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_BINARY_NEGATE_H +#define _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H + +#include <__config> +#include <__functional/binary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate + : public binary_function +{ + _Predicate __pred_; +public: + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 + binary_negate(const _Predicate& __pred) : __pred_(__pred) {} + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::first_argument_type& __x, + const typename _Predicate::second_argument_type& __y) const + {return !__pred_(__x, __y);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +binary_negate<_Predicate> +not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} + +#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H diff --git a/gnu/llvm/libcxx/include/__functional/bind.h b/gnu/llvm/libcxx/include/__functional/bind.h new file mode 100644 index 00000000000..79dfad723c6 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/bind.h @@ -0,0 +1,386 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_BIND_H +#define _LIBCPP___FUNCTIONAL_BIND_H + +#include <__config> +#include <__functional/weak_result_type.h> +#include <__functional/invoke.h> +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template struct __is_bind_expression : public false_type {}; +template struct _LIBCPP_TEMPLATE_VIS is_bind_expression + : public __is_bind_expression::type> {}; + +#if _LIBCPP_STD_VER > 14 +template +_LIBCPP_INLINE_VAR constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; +#endif + +template struct __is_placeholder : public integral_constant {}; +template struct _LIBCPP_TEMPLATE_VIS is_placeholder + : public __is_placeholder::type> {}; + +#if _LIBCPP_STD_VER > 14 +template +_LIBCPP_INLINE_VAR constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; +#endif + +namespace placeholders +{ + +template struct __ph {}; + +#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) +_LIBCPP_FUNC_VIS extern const __ph<1> _1; +_LIBCPP_FUNC_VIS extern const __ph<2> _2; +_LIBCPP_FUNC_VIS extern const __ph<3> _3; +_LIBCPP_FUNC_VIS extern const __ph<4> _4; +_LIBCPP_FUNC_VIS extern const __ph<5> _5; +_LIBCPP_FUNC_VIS extern const __ph<6> _6; +_LIBCPP_FUNC_VIS extern const __ph<7> _7; +_LIBCPP_FUNC_VIS extern const __ph<8> _8; +_LIBCPP_FUNC_VIS extern const __ph<9> _9; +_LIBCPP_FUNC_VIS extern const __ph<10> _10; +#else +/* _LIBCPP_INLINE_VAR */ constexpr __ph<1> _1{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<2> _2{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<3> _3{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<4> _4{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<5> _5{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<6> _6{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<7> _7{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<8> _8{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<9> _9{}; +/* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{}; +#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) + +} // placeholders + +template +struct __is_placeholder > + : public integral_constant {}; + + +#ifndef _LIBCPP_CXX03_LANG + +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp& +__mu(reference_wrapper<_Tp> __t, _Uj&) +{ + return __t.get(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __invoke_of<_Ti&, _Uj...>::type +__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) +{ + return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename _EnableIf +< + is_bind_expression<_Ti>::value, + __invoke_of<_Ti&, _Uj...> +>::type +__mu(_Ti& __ti, tuple<_Uj...>& __uj) +{ + typedef typename __make_tuple_indices::type __indices; + return _VSTD::__mu_expand(__ti, __uj, __indices()); +} + +template +struct __mu_return2 {}; + +template +struct __mu_return2 +{ + typedef typename tuple_element::value - 1, _Uj>::type type; +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if +< + 0 < is_placeholder<_Ti>::value, + typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type +>::type +__mu(_Ti&, _Uj& __uj) +{ + const size_t _Indx = is_placeholder<_Ti>::value - 1; + return _VSTD::forward::type>(_VSTD::get<_Indx>(__uj)); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename enable_if +< + !is_bind_expression<_Ti>::value && + is_placeholder<_Ti>::value == 0 && + !__is_reference_wrapper<_Ti>::value, + _Ti& +>::type +__mu(_Ti& __ti, _Uj&) +{ + return __ti; +} + +template +struct __mu_return_impl; + +template +struct __mu_return_invokable // false +{ + typedef __nat type; +}; + +template +struct __mu_return_invokable +{ + typedef typename __invoke_of<_Ti&, _Uj...>::type type; +}; + +template +struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> > + : public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _Ti, _Uj...> +{ +}; + +template +struct __mu_return_impl<_Ti, false, false, true, _TupleUj> +{ + typedef typename tuple_element::value - 1, + _TupleUj>::type&& type; +}; + +template +struct __mu_return_impl<_Ti, true, false, false, _TupleUj> +{ + typedef typename _Ti::type& type; +}; + +template +struct __mu_return_impl<_Ti, false, false, false, _TupleUj> +{ + typedef _Ti& type; +}; + +template +struct __mu_return + : public __mu_return_impl<_Ti, + __is_reference_wrapper<_Ti>::value, + is_bind_expression<_Ti>::value, + 0 < is_placeholder<_Ti>::value && + is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value, + _TupleUj> +{ +}; + +template +struct __is_valid_bind_return +{ + static const bool value = false; +}; + +template +struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> +{ + static const bool value = __invokable<_Fp, + typename __mu_return<_BoundArgs, _TupleUj>::type...>::value; +}; + +template +struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> +{ + static const bool value = __invokable<_Fp, + typename __mu_return::type...>::value; +}; + +template ::value> +struct __bind_return; + +template +struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> +{ + typedef typename __invoke_of + < + _Fp&, + typename __mu_return + < + _BoundArgs, + _TupleUj + >::type... + >::type type; +}; + +template +struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> +{ + typedef typename __invoke_of + < + _Fp&, + typename __mu_return + < + const _BoundArgs, + _TupleUj + >::type... + >::type type; +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __bind_return<_Fp, _BoundArgs, _Args>::type +__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, + _Args&& __args) +{ + return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...); +} + +template +class __bind +#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public __weak_result_type::type> +#endif +{ +protected: + typedef typename decay<_Fp>::type _Fd; + typedef tuple::type...> _Td; +private: + _Fd __f_; + _Td __bound_args_; + + typedef typename __make_tuple_indices::type __indices; +public: + template ::value && + !is_same::type, + __bind>::value + >::type> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + explicit __bind(_Gp&& __f, _BA&& ...__bound_args) + : __f_(_VSTD::forward<_Gp>(__f)), + __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type + operator()(_Args&& ...__args) + { + return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), + tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); + } + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename __bind_return >::type + operator()(_Args&& ...__args) const + { + return _VSTD::__apply_functor(__f_, __bound_args_, __indices(), + tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...)); + } +}; + +template +struct __is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {}; + +template +class __bind_r + : public __bind<_Fp, _BoundArgs...> +{ + typedef __bind<_Fp, _BoundArgs...> base; + typedef typename base::_Fd _Fd; + typedef typename base::_Td _Td; +public: + typedef _Rp result_type; + + + template ::value && + !is_same::type, + __bind_r>::value + >::type> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) + : base(_VSTD::forward<_Gp>(__f), + _VSTD::forward<_BA>(__bound_args)...) {} + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename enable_if + < + is_convertible >::type, + result_type>::value || is_void<_Rp>::value, + result_type + >::type + operator()(_Args&& ...__args) + { + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); + } + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename enable_if + < + is_convertible >::type, + result_type>::value || is_void<_Rp>::value, + result_type + >::type + operator()(_Args&& ...__args) const + { + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); + } +}; + +template +struct __is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +__bind<_Fp, _BoundArgs...> +bind(_Fp&& __f, _BoundArgs&&... __bound_args) +{ + typedef __bind<_Fp, _BoundArgs...> type; + return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +__bind_r<_Rp, _Fp, _BoundArgs...> +bind(_Fp&& __f, _BoundArgs&&... __bound_args) +{ + typedef __bind_r<_Rp, _Fp, _BoundArgs...> type; + return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); +} + +#endif // _LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_BIND_H diff --git a/gnu/llvm/libcxx/include/__functional/bind_front.h b/gnu/llvm/libcxx/include/__functional/bind_front.h new file mode 100644 index 00000000000..8690499f2b0 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/bind_front.h @@ -0,0 +1,52 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_BIND_FRONT_H +#define _LIBCPP___FUNCTIONAL_BIND_FRONT_H + +#include <__config> +#include <__functional/perfect_forward.h> +#include <__functional/invoke.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +struct __bind_front_op +{ + template + constexpr static auto __call(_Args&&... __args) + noexcept(noexcept(_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) + -> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...)) + { return _VSTD::invoke(_VSTD::forward<_Args>(__args)...); } +}; + +template, _Fn>, + is_move_constructible>, + is_constructible, _Args>..., + is_move_constructible>... + >::value>> +constexpr auto bind_front(_Fn&& __f, _Args&&... __args) +{ + return __perfect_forward<__bind_front_op, _Fn, _Args...>(_VSTD::forward<_Fn>(__f), + _VSTD::forward<_Args>(__args)...); +} + +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H diff --git a/gnu/llvm/libcxx/include/__functional/binder1st.h b/gnu/llvm/libcxx/include/__functional/binder1st.h new file mode 100644 index 00000000000..5dd8f5cf015 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/binder1st.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_BINDER1ST_H +#define _LIBCPP___FUNCTIONAL_BINDER1ST_H + +#include <__config> +#include <__functional/unary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder1st + : public unary_function +{ +protected: + __Operation op; + typename __Operation::first_argument_type value; +public: + _LIBCPP_INLINE_VISIBILITY binder1st(const __Operation& __x, + const typename __Operation::first_argument_type __y) + : op(__x), value(__y) {} + _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() + (typename __Operation::second_argument_type& __x) const + {return op(value, __x);} + _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() + (const typename __Operation::second_argument_type& __x) const + {return op(value, __x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +binder1st<__Operation> +bind1st(const __Operation& __op, const _Tp& __x) + {return binder1st<__Operation>(__op, __x);} + +#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_BINDER1ST_H diff --git a/gnu/llvm/libcxx/include/__functional/binder2nd.h b/gnu/llvm/libcxx/include/__functional/binder2nd.h new file mode 100644 index 00000000000..3ed5f5bf454 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/binder2nd.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_BINDER2ND_H +#define _LIBCPP___FUNCTIONAL_BINDER2ND_H + +#include <__config> +#include <__functional/unary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 binder2nd + : public unary_function +{ +protected: + __Operation op; + typename __Operation::second_argument_type value; +public: + _LIBCPP_INLINE_VISIBILITY + binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y) + : op(__x), value(__y) {} + _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() + ( typename __Operation::first_argument_type& __x) const + {return op(__x, value);} + _LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator() + (const typename __Operation::first_argument_type& __x) const + {return op(__x, value);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +binder2nd<__Operation> +bind2nd(const __Operation& __op, const _Tp& __x) + {return binder2nd<__Operation>(__op, __x);} + +#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_BINDER2ND_H diff --git a/gnu/llvm/libcxx/include/__functional/default_searcher.h b/gnu/llvm/libcxx/include/__functional/default_searcher.h new file mode 100644 index 00000000000..1acbc1883af --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/default_searcher.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_DEFAULT_SEARCHER_H +#define _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H + +#include <__algorithm/search.h> +#include <__config> +#include <__functional/operations.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +// default searcher +template> +class _LIBCPP_TEMPLATE_VIS default_searcher { +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + default_searcher(_ForwardIterator __f, _ForwardIterator __l, + _BinaryPredicate __p = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__p) {} + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + pair<_ForwardIterator2, _ForwardIterator2> + operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const + { + return _VSTD::__search(__f, __l, __first_, __last_, __pred_, + typename iterator_traits<_ForwardIterator>::iterator_category(), + typename iterator_traits<_ForwardIterator2>::iterator_category()); + } + +private: + _ForwardIterator __first_; + _ForwardIterator __last_; + _BinaryPredicate __pred_; + }; + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H diff --git a/gnu/llvm/libcxx/include/__functional/function.h b/gnu/llvm/libcxx/include/__functional/function.h new file mode 100644 index 00000000000..ba629e1d145 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/function.h @@ -0,0 +1,2809 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_FUNCTION_H +#define _LIBCPP___FUNCTIONAL_FUNCTION_H + +#include <__config> +#include <__functional/binary_function.h> +#include <__functional/invoke.h> +#include <__functional/unary_function.h> +#include <__iterator/iterator_traits.h> +#include <__memory/allocator_traits.h> +#include <__memory/compressed_pair.h> +#include <__memory/shared_ptr.h> +#include +#include // TODO: replace with <__memory/__builtin_new_allocator.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// bad_function_call + +class _LIBCPP_EXCEPTION_ABI bad_function_call + : public exception +{ +#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION +public: + virtual ~bad_function_call() _NOEXCEPT; + + virtual const char* what() const _NOEXCEPT; +#endif +}; + +_LIBCPP_NORETURN inline _LIBCPP_INLINE_VISIBILITY +void __throw_bad_function_call() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_function_call(); +#else + _VSTD::abort(); +#endif +} + +#if defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_DISABLE_DEPRECATION_WARNINGS) && __has_attribute(deprecated) +# define _LIBCPP_DEPRECATED_CXX03_FUNCTION \ + __attribute__((deprecated("Using std::function in C++03 is not supported anymore. Please upgrade to C++11 or later, or use a different type"))) +#else +# define _LIBCPP_DEPRECATED_CXX03_FUNCTION /* nothing */ +#endif + +template class _LIBCPP_DEPRECATED_CXX03_FUNCTION _LIBCPP_TEMPLATE_VIS function; // undefined + +namespace __function +{ + +template +struct __maybe_derive_from_unary_function +{ +}; + +template +struct __maybe_derive_from_unary_function<_Rp(_A1)> + : public unary_function<_A1, _Rp> +{ +}; + +template +struct __maybe_derive_from_binary_function +{ +}; + +template +struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> + : public binary_function<_A1, _A2, _Rp> +{ +}; + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Fp const&) { return true; } + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Fp* __ptr) { return __ptr; } + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Ret _Class::*__ptr) { return __ptr; } + +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(function<_Fp> const& __f) { return !!__f; } + +#ifdef _LIBCPP_HAS_EXTENSION_BLOCKS +template +_LIBCPP_INLINE_VISIBILITY +bool __not_null(_Rp (^__p)(_Args...)) { return __p; } +#endif + +} // namespace __function + +#ifndef _LIBCPP_CXX03_LANG + +namespace __function { + +// __alloc_func holds a functor and an allocator. + +template class __alloc_func; +template +class __default_alloc_func; + +template +class __alloc_func<_Fp, _Ap, _Rp(_ArgTypes...)> +{ + __compressed_pair<_Fp, _Ap> __f_; + + public: + 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& __get_allocator() const { return __f_.second(); } + + _LIBCPP_INLINE_VISIBILITY + explicit __alloc_func(_Target&& __f) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), + _VSTD::forward_as_tuple()) + { + } + + _LIBCPP_INLINE_VISIBILITY + explicit __alloc_func(const _Target& __f, const _Alloc& __a) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), + _VSTD::forward_as_tuple(__a)) + { + } + + _LIBCPP_INLINE_VISIBILITY + explicit __alloc_func(const _Target& __f, _Alloc&& __a) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(__f), + _VSTD::forward_as_tuple(_VSTD::move(__a))) + { + } + + _LIBCPP_INLINE_VISIBILITY + explicit __alloc_func(_Target&& __f, _Alloc&& __a) + : __f_(piecewise_construct, _VSTD::forward_as_tuple(_VSTD::move(__f)), + _VSTD::forward_as_tuple(_VSTD::move(__a))) + { + } + + _LIBCPP_INLINE_VISIBILITY + _Rp operator()(_ArgTypes&&... __arg) + { + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), + _VSTD::forward<_ArgTypes>(__arg)...); + } + + _LIBCPP_INLINE_VISIBILITY + __alloc_func* __clone() const + { + typedef allocator_traits<_Alloc> __alloc_traits; + typedef + typename __rebind_alloc_helper<__alloc_traits, __alloc_func>::type + _AA; + _AA __a(__f_.second()); + typedef __allocator_destructor<_AA> _Dp; + unique_ptr<__alloc_func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) __alloc_func(__f_.first(), _Alloc(__a)); + return __hold.release(); + } + + _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 __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_(_VSTD::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 ((void*)__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. + +template class _LIBCPP_TEMPLATE_VIS __base; + +template +class __base<_Rp(_ArgTypes...)> +{ + __base(const __base&); + __base& operator=(const __base&); +public: + _LIBCPP_INLINE_VISIBILITY __base() {} + _LIBCPP_INLINE_VISIBILITY virtual ~__base() {} + virtual __base* __clone() const = 0; + virtual void __clone(__base*) const = 0; + virtual void destroy() _NOEXCEPT = 0; + virtual void destroy_deallocate() _NOEXCEPT = 0; + virtual _Rp operator()(_ArgTypes&& ...) = 0; +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const _NOEXCEPT = 0; + virtual const std::type_info& target_type() const _NOEXCEPT = 0; +#endif // _LIBCPP_NO_RTTI +}; + +// __func implements __base for a given functor type. + +template class __func; + +template +class __func<_Fp, _Alloc, _Rp(_ArgTypes...)> + : public __base<_Rp(_ArgTypes...)> +{ + __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> __f_; +public: + _LIBCPP_INLINE_VISIBILITY + explicit __func(_Fp&& __f) + : __f_(_VSTD::move(__f)) {} + + _LIBCPP_INLINE_VISIBILITY + explicit __func(const _Fp& __f, const _Alloc& __a) + : __f_(__f, __a) {} + + _LIBCPP_INLINE_VISIBILITY + explicit __func(const _Fp& __f, _Alloc&& __a) + : __f_(__f, _VSTD::move(__a)) {} + + _LIBCPP_INLINE_VISIBILITY + explicit __func(_Fp&& __f, _Alloc&& __a) + : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} + + virtual __base<_Rp(_ArgTypes...)>* __clone() const; + virtual void __clone(__base<_Rp(_ArgTypes...)>*) const; + virtual void destroy() _NOEXCEPT; + virtual void destroy_deallocate() _NOEXCEPT; + virtual _Rp operator()(_ArgTypes&&... __arg); +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const _NOEXCEPT; + virtual const std::type_info& target_type() const _NOEXCEPT; +#endif // _LIBCPP_NO_RTTI +}; + +template +__base<_Rp(_ArgTypes...)>* +__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_.__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)); + return __hold.release(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::__clone(__base<_Rp(_ArgTypes...)>* __p) const +{ + ::new ((void*)__p) __func(__f_.__target(), __f_.__get_allocator()); +} + +template +void +__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::destroy() _NOEXCEPT +{ + __f_.destroy(); +} + +template +void +__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_.__get_allocator()); + __f_.destroy(); + __a.deallocate(this, 1); +} + +template +_Rp +__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::operator()(_ArgTypes&& ... __arg) +{ + return __f_(_VSTD::forward<_ArgTypes>(__arg)...); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const void* +__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target(const type_info& __ti) const _NOEXCEPT +{ + if (__ti == typeid(_Fp)) + return &__f_.__target(); + return nullptr; +} + +template +const std::type_info& +__func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT +{ + return typeid(_Fp); +} + +#endif // _LIBCPP_NO_RTTI + +// __value_func creates a value-type from a __func. + +template class __value_func; + +template class __value_func<_Rp(_ArgTypes...)> +{ + typename aligned_storage<3 * sizeof(void*)>::type __buf_; + + typedef __base<_Rp(_ArgTypes...)> __func; + __func* __f_; + + _LIBCPP_NO_CFI static __func* __as_base(void* p) + { + return reinterpret_cast<__func*>(p); + } + + public: + _LIBCPP_INLINE_VISIBILITY + __value_func() _NOEXCEPT : __f_(nullptr) {} + + template + _LIBCPP_INLINE_VISIBILITY __value_func(_Fp&& __f, const _Alloc& __a) + : __f_(nullptr) + { + typedef allocator_traits<_Alloc> __alloc_traits; + typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; + typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type + _FunAlloc; + + if (__function::__not_null(__f)) + { + _FunAlloc __af(__a); + if (sizeof(_Fun) <= sizeof(__buf_) && + is_nothrow_copy_constructible<_Fp>::value && + is_nothrow_copy_constructible<_FunAlloc>::value) + { + __f_ = + ::new ((void*)&__buf_) _Fun(_VSTD::move(__f), _Alloc(__af)); + } + else + { + typedef __allocator_destructor<_FunAlloc> _Dp; + unique_ptr<__func, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); + ::new ((void*)__hold.get()) _Fun(_VSTD::move(__f), _Alloc(__a)); + __f_ = __hold.release(); + } + } + } + + template ::type, __value_func>::value>::type> + _LIBCPP_INLINE_VISIBILITY explicit __value_func(_Fp&& __f) + : __value_func(_VSTD::forward<_Fp>(__f), allocator<_Fp>()) {} + + _LIBCPP_INLINE_VISIBILITY + __value_func(const __value_func& __f) + { + if (__f.__f_ == nullptr) + __f_ = nullptr; + else if ((void*)__f.__f_ == &__f.__buf_) + { + __f_ = __as_base(&__buf_); + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); + } + + _LIBCPP_INLINE_VISIBILITY + __value_func(__value_func&& __f) _NOEXCEPT + { + if (__f.__f_ == nullptr) + __f_ = nullptr; + else if ((void*)__f.__f_ == &__f.__buf_) + { + __f_ = __as_base(&__buf_); + __f.__f_->__clone(__f_); + } + else + { + __f_ = __f.__f_; + __f.__f_ = nullptr; + } + } + + _LIBCPP_INLINE_VISIBILITY + ~__value_func() + { + if ((void*)__f_ == &__buf_) + __f_->destroy(); + else if (__f_) + __f_->destroy_deallocate(); + } + + _LIBCPP_INLINE_VISIBILITY + __value_func& operator=(__value_func&& __f) + { + *this = nullptr; + if (__f.__f_ == nullptr) + __f_ = nullptr; + else if ((void*)__f.__f_ == &__f.__buf_) + { + __f_ = __as_base(&__buf_); + __f.__f_->__clone(__f_); + } + else + { + __f_ = __f.__f_; + __f.__f_ = nullptr; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + __value_func& operator=(nullptr_t) + { + __func* __f = __f_; + __f_ = nullptr; + if ((void*)__f == &__buf_) + __f->destroy(); + else if (__f) + __f->destroy_deallocate(); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + _Rp operator()(_ArgTypes&&... __args) const + { + if (__f_ == nullptr) + __throw_bad_function_call(); + return (*__f_)(_VSTD::forward<_ArgTypes>(__args)...); + } + + _LIBCPP_INLINE_VISIBILITY + void swap(__value_func& __f) _NOEXCEPT + { + if (&__f == this) + return; + if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) + { + typename aligned_storage::type __tempbuf; + __func* __t = __as_base(&__tempbuf); + __f_->__clone(__t); + __f_->destroy(); + __f_ = nullptr; + __f.__f_->__clone(__as_base(&__buf_)); + __f.__f_->destroy(); + __f.__f_ = nullptr; + __f_ = __as_base(&__buf_); + __t->__clone(__as_base(&__f.__buf_)); + __t->destroy(); + __f.__f_ = __as_base(&__f.__buf_); + } + else if ((void*)__f_ == &__buf_) + { + __f_->__clone(__as_base(&__f.__buf_)); + __f_->destroy(); + __f_ = __f.__f_; + __f.__f_ = __as_base(&__f.__buf_); + } + else if ((void*)__f.__f_ == &__f.__buf_) + { + __f.__f_->__clone(__as_base(&__buf_)); + __f.__f_->destroy(); + __f.__f_ = __f_; + __f_ = __as_base(&__buf_); + } + else + _VSTD::swap(__f_, __f.__f_); + } + + _LIBCPP_INLINE_VISIBILITY + explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; } + +#ifndef _LIBCPP_NO_RTTI + _LIBCPP_INLINE_VISIBILITY + const std::type_info& target_type() const _NOEXCEPT + { + if (__f_ == nullptr) + return typeid(void); + return __f_->target_type(); + } + + template + _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT + { + if (__f_ == nullptr) + return nullptr; + return (const _Tp*)__f_->target(typeid(_Tp)); + } +#endif // _LIBCPP_NO_RTTI +}; + +// Storage for a functor object, to be used with __policy to manage copy and +// destruction. +union __policy_storage +{ + mutable char __small[sizeof(void*) * 2]; + void* __large; +}; + +// True if _Fun can safely be held in __policy_storage.__small. +template +struct __use_small_storage + : public integral_constant< + bool, sizeof(_Fun) <= sizeof(__policy_storage) && + _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) && + is_trivially_copy_constructible<_Fun>::value && + is_trivially_destructible<_Fun>::value> {}; + +// Policy contains information about how to copy, destroy, and move the +// underlying functor. You can think of it as a vtable of sorts. +struct __policy +{ + // Used to copy or destroy __large values. null for trivial objects. + void* (*const __clone)(const void*); + void (*const __destroy)(void*); + + // True if this is the null policy (no value). + const bool __is_null; + + // The target type. May be null if RTTI is disabled. + const std::type_info* const __type_info; + + // Returns a pointer to a static policy object suitable for the functor + // type. + template + _LIBCPP_INLINE_VISIBILITY static const __policy* __create() + { + return __choose_policy<_Fun>(__use_small_storage<_Fun>()); + } + + _LIBCPP_INLINE_VISIBILITY + static const __policy* __create_empty() + { + static const _LIBCPP_CONSTEXPR __policy __policy_ = {nullptr, nullptr, + true, +#ifndef _LIBCPP_NO_RTTI + &typeid(void) +#else + nullptr +#endif + }; + return &__policy_; + } + + private: + template static void* __large_clone(const void* __s) + { + const _Fun* __f = static_cast(__s); + return __f->__clone(); + } + + template + static void __large_destroy(void* __s) { + _Fun::__destroy_and_delete(static_cast<_Fun*>(__s)); + } + + template + _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, +#ifndef _LIBCPP_NO_RTTI + &typeid(typename _Fun::_Target) +#else + nullptr +#endif + }; + return &__policy_; + } + + template + _LIBCPP_INLINE_VISIBILITY static const __policy* + __choose_policy(/* is_small = */ true_type) + { + static const _LIBCPP_CONSTEXPR __policy __policy_ = { + nullptr, nullptr, false, +#ifndef _LIBCPP_NO_RTTI + &typeid(typename _Fun::_Target) +#else + nullptr +#endif + }; + return &__policy_; + } +}; + +// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is +// faster for types that can be passed in registers. +template +using __fast_forward = + typename conditional::value, _Tp, _Tp&&>::type; + +// __policy_invoker calls an instance of __alloc_func held in __policy_storage. + +template struct __policy_invoker; + +template +struct __policy_invoker<_Rp(_ArgTypes...)> +{ + typedef _Rp (*__Call)(const __policy_storage*, + __fast_forward<_ArgTypes>...); + + __Call __call_; + + // Creates an invoker that throws bad_function_call. + _LIBCPP_INLINE_VISIBILITY + __policy_invoker() : __call_(&__call_empty) {} + + // Creates an invoker that calls the given instance of __func. + template + _LIBCPP_INLINE_VISIBILITY static __policy_invoker __create() + { + return __policy_invoker(&__call_impl<_Fun>); + } + + private: + _LIBCPP_INLINE_VISIBILITY + explicit __policy_invoker(__Call __c) : __call_(__c) {} + + static _Rp __call_empty(const __policy_storage*, + __fast_forward<_ArgTypes>...) + { + __throw_bad_function_call(); + } + + template + static _Rp __call_impl(const __policy_storage* __buf, + __fast_forward<_ArgTypes>... __args) + { + _Fun* __f = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value + ? &__buf->__small + : __buf->__large); + return (*__f)(_VSTD::forward<_ArgTypes>(__args)...); + } +}; + +// __policy_func uses a __policy and __policy_invoker to create a type-erased, +// copyable functor. + +template class __policy_func; + +template class __policy_func<_Rp(_ArgTypes...)> +{ + // Inline storage for small objects. + __policy_storage __buf_; + + // Calls the value stored in __buf_. This could technically be part of + // policy, but storing it here eliminates a level of indirection inside + // operator(). + typedef __function::__policy_invoker<_Rp(_ArgTypes...)> __invoker; + __invoker __invoker_; + + // The policy that describes how to move / copy / destroy __buf_. Never + // null, even if the function is empty. + const __policy* __policy_; + + public: + _LIBCPP_INLINE_VISIBILITY + __policy_func() : __policy_(__policy::__create_empty()) {} + + template + _LIBCPP_INLINE_VISIBILITY __policy_func(_Fp&& __f, const _Alloc& __a) + : __policy_(__policy::__create_empty()) + { + typedef __alloc_func<_Fp, _Alloc, _Rp(_ArgTypes...)> _Fun; + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, _Fun>::type + _FunAlloc; + + if (__function::__not_null(__f)) + { + __invoker_ = __invoker::template __create<_Fun>(); + __policy_ = __policy::__create<_Fun>(); + + _FunAlloc __af(__a); + if (__use_small_storage<_Fun>()) + { + ::new ((void*)&__buf_.__small) + _Fun(_VSTD::move(__f), _Alloc(__af)); + } + else + { + typedef __allocator_destructor<_FunAlloc> _Dp; + unique_ptr<_Fun, _Dp> __hold(__af.allocate(1), _Dp(__af, 1)); + ::new ((void*)__hold.get()) + _Fun(_VSTD::move(__f), _Alloc(__af)); + __buf_.__large = __hold.release(); + } + } + } + + template ::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 ((void*)__hold.get()) _Fun(_VSTD::move(__f)); + (void)__hold.release(); + } + } + } + + _LIBCPP_INLINE_VISIBILITY + __policy_func(const __policy_func& __f) + : __buf_(__f.__buf_), __invoker_(__f.__invoker_), + __policy_(__f.__policy_) + { + if (__policy_->__clone) + __buf_.__large = __policy_->__clone(__f.__buf_.__large); + } + + _LIBCPP_INLINE_VISIBILITY + __policy_func(__policy_func&& __f) + : __buf_(__f.__buf_), __invoker_(__f.__invoker_), + __policy_(__f.__policy_) + { + if (__policy_->__destroy) + { + __f.__policy_ = __policy::__create_empty(); + __f.__invoker_ = __invoker(); + } + } + + _LIBCPP_INLINE_VISIBILITY + ~__policy_func() + { + if (__policy_->__destroy) + __policy_->__destroy(__buf_.__large); + } + + _LIBCPP_INLINE_VISIBILITY + __policy_func& operator=(__policy_func&& __f) + { + *this = nullptr; + __buf_ = __f.__buf_; + __invoker_ = __f.__invoker_; + __policy_ = __f.__policy_; + __f.__policy_ = __policy::__create_empty(); + __f.__invoker_ = __invoker(); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + __policy_func& operator=(nullptr_t) + { + const __policy* __p = __policy_; + __policy_ = __policy::__create_empty(); + __invoker_ = __invoker(); + if (__p->__destroy) + __p->__destroy(__buf_.__large); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + _Rp operator()(_ArgTypes&&... __args) const + { + return __invoker_.__call_(_VSTD::addressof(__buf_), + _VSTD::forward<_ArgTypes>(__args)...); + } + + _LIBCPP_INLINE_VISIBILITY + void swap(__policy_func& __f) + { + _VSTD::swap(__invoker_, __f.__invoker_); + _VSTD::swap(__policy_, __f.__policy_); + _VSTD::swap(__buf_, __f.__buf_); + } + + _LIBCPP_INLINE_VISIBILITY + explicit operator bool() const _NOEXCEPT + { + return !__policy_->__is_null; + } + +#ifndef _LIBCPP_NO_RTTI + _LIBCPP_INLINE_VISIBILITY + const std::type_info& target_type() const _NOEXCEPT + { + return *__policy_->__type_info; + } + + template + _LIBCPP_INLINE_VISIBILITY const _Tp* target() const _NOEXCEPT + { + if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info) + return nullptr; + if (__policy_->__clone) // Out of line storage. + return reinterpret_cast(__buf_.__large); + else + return reinterpret_cast(&__buf_.__small); + } +#endif // _LIBCPP_NO_RTTI +}; + +#if defined(_LIBCPP_HAS_BLOCKS_RUNTIME) && !defined(_LIBCPP_HAS_OBJC_ARC) + +extern "C" void *_Block_copy(const void *); +extern "C" void _Block_release(const void *); + +template +class __func<_Rp1(^)(_ArgTypes1...), _Alloc, _Rp(_ArgTypes...)> + : public __base<_Rp(_ArgTypes...)> +{ + typedef _Rp1(^__block_type)(_ArgTypes1...); + __block_type __f_; + +public: + _LIBCPP_INLINE_VISIBILITY + explicit __func(__block_type const& __f) + : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) + { } + + // [TODO] add && to save on a retain + + _LIBCPP_INLINE_VISIBILITY + explicit __func(__block_type __f, const _Alloc& /* unused */) + : __f_(reinterpret_cast<__block_type>(__f ? _Block_copy(__f) : nullptr)) + { } + + virtual __base<_Rp(_ArgTypes...)>* __clone() const { + _LIBCPP_ASSERT(false, + "Block pointers are just pointers, so they should always fit into " + "std::function's small buffer optimization. This function should " + "never be invoked."); + return nullptr; + } + + virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const { + ::new ((void*)__p) __func(__f_); + } + + virtual void destroy() _NOEXCEPT { + if (__f_) + _Block_release(__f_); + __f_ = 0; + } + + virtual void destroy_deallocate() _NOEXCEPT { + _LIBCPP_ASSERT(false, + "Block pointers are just pointers, so they should always fit into " + "std::function's small buffer optimization. This function should " + "never be invoked."); + } + + virtual _Rp operator()(_ArgTypes&& ... __arg) { + return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__arg)...); + } + +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(type_info const& __ti) const _NOEXCEPT { + if (__ti == typeid(__func::__block_type)) + return &__f_; + return (const void*)nullptr; + } + + virtual const std::type_info& target_type() const _NOEXCEPT { + return typeid(__func::__block_type); + } +#endif // _LIBCPP_NO_RTTI +}; + +#endif // _LIBCPP_HAS_EXTENSION_BLOCKS && !_LIBCPP_HAS_OBJC_ARC + +} // __function + +template +class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)> +#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, + public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> +#endif +{ +#ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION + typedef __function::__value_func<_Rp(_ArgTypes...)> __func; +#else + typedef __function::__policy_func<_Rp(_ArgTypes...)> __func; +#endif + + __func __f_; + + template , function>, + __invokable<_Fp, _ArgTypes...> + >::value> + struct __callable; + template + struct __callable<_Fp, true> + { + static const bool value = is_void<_Rp>::value || + __is_core_convertible::type, + _Rp>::value; + }; + template + struct __callable<_Fp, false> + { + static const bool value = false; + }; + + template + using _EnableIfLValueCallable = typename enable_if<__callable<_Fp&>::value>::type; +public: + typedef _Rp result_type; + + // construct/copy/destroy: + _LIBCPP_INLINE_VISIBILITY + function() _NOEXCEPT { } + _LIBCPP_INLINE_VISIBILITY + function(nullptr_t) _NOEXCEPT {} + function(const function&); + function(function&&) _NOEXCEPT; + template> + function(_Fp); + +#if _LIBCPP_STD_VER <= 14 + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&) _NOEXCEPT {} + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {} + template + function(allocator_arg_t, const _Alloc&, const function&); + template + function(allocator_arg_t, const _Alloc&, function&&); + template> + function(allocator_arg_t, const _Alloc& __a, _Fp __f); +#endif + + function& operator=(const function&); + function& operator=(function&&) _NOEXCEPT; + function& operator=(nullptr_t) _NOEXCEPT; + template::type>> + function& operator=(_Fp&&); + + ~function(); + + // function modifiers: + void swap(function&) _NOEXCEPT; + +#if _LIBCPP_STD_VER <= 14 + template + _LIBCPP_INLINE_VISIBILITY + void assign(_Fp&& __f, const _Alloc& __a) + {function(allocator_arg, __a, _VSTD::forward<_Fp>(__f)).swap(*this);} +#endif + + // function capacity: + _LIBCPP_INLINE_VISIBILITY + explicit operator bool() const _NOEXCEPT { + return static_cast(__f_); + } + + // deleted overloads close possible hole in the type system + template + bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete; + template + bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete; +public: + // function invocation: + _Rp operator()(_ArgTypes...) const; + +#ifndef _LIBCPP_NO_RTTI + // function target access: + const std::type_info& target_type() const _NOEXCEPT; + template _Tp* target() _NOEXCEPT; + template const _Tp* target() const _NOEXCEPT; +#endif // _LIBCPP_NO_RTTI +}; + +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES +template +function(_Rp(*)(_Ap...)) -> function<_Rp(_Ap...)>; + +template +struct __strip_signature; + +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...)> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile> { using type = _Rp(_Ap...); }; + +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) &> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const &> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile &> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile &> { using type = _Rp(_Ap...); }; + +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) noexcept> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const noexcept> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile noexcept> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile noexcept> { using type = _Rp(_Ap...); }; + +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) & noexcept> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const & noexcept> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) volatile & noexcept> { using type = _Rp(_Ap...); }; +template +struct __strip_signature<_Rp (_Gp::*) (_Ap...) const volatile & noexcept> { using type = _Rp(_Ap...); }; + +template::type> +function(_Fp) -> function<_Stripped>; +#endif // !_LIBCPP_HAS_NO_DEDUCTION_GUIDES + +template +function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {} + +#if _LIBCPP_STD_VER <= 14 +template +template +function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, + const function& __f) : __f_(__f.__f_) {} +#endif + +template +function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT + : __f_(_VSTD::move(__f.__f_)) {} + +#if _LIBCPP_STD_VER <= 14 +template +template +function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, + function&& __f) + : __f_(_VSTD::move(__f.__f_)) {} +#endif + +template +template +function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(_VSTD::move(__f)) {} + +#if _LIBCPP_STD_VER <= 14 +template +template +function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a, + _Fp __f) + : __f_(_VSTD::move(__f), __a) {} +#endif + +template +function<_Rp(_ArgTypes...)>& +function<_Rp(_ArgTypes...)>::operator=(const function& __f) +{ + function(__f).swap(*this); + return *this; +} + +template +function<_Rp(_ArgTypes...)>& +function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT +{ + __f_ = _VSTD::move(__f.__f_); + return *this; +} + +template +function<_Rp(_ArgTypes...)>& +function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT +{ + __f_ = nullptr; + return *this; +} + +template +template +function<_Rp(_ArgTypes...)>& +function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) +{ + function(_VSTD::forward<_Fp>(__f)).swap(*this); + return *this; +} + +template +function<_Rp(_ArgTypes...)>::~function() {} + +template +void +function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT +{ + __f_.swap(__f.__f_); +} + +template +_Rp +function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const +{ + return __f_(_VSTD::forward<_ArgTypes>(__arg)...); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const std::type_info& +function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT +{ + return __f_.target_type(); +} + +template +template +_Tp* +function<_Rp(_ArgTypes...)>::target() _NOEXCEPT +{ + return (_Tp*)(__f_.template target<_Tp>()); +} + +template +template +const _Tp* +function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT +{ + return __f_.template target<_Tp>(); +} + +#endif // _LIBCPP_NO_RTTI + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return !__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return !__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {return (bool)__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {return (bool)__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT +{return __x.swap(__y);} + +#else // _LIBCPP_CXX03_LANG + +namespace __function { + +template class __base; + +template +class __base<_Rp()> +{ + __base(const __base&); + __base& operator=(const __base&); +public: + __base() {} + virtual ~__base() {} + virtual __base* __clone() const = 0; + virtual void __clone(__base*) const = 0; + virtual void destroy() = 0; + virtual void destroy_deallocate() = 0; + virtual _Rp operator()() = 0; +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const = 0; + virtual const std::type_info& target_type() const = 0; +#endif // _LIBCPP_NO_RTTI +}; + +template +class __base<_Rp(_A0)> +{ + __base(const __base&); + __base& operator=(const __base&); +public: + __base() {} + virtual ~__base() {} + virtual __base* __clone() const = 0; + virtual void __clone(__base*) const = 0; + virtual void destroy() = 0; + virtual void destroy_deallocate() = 0; + virtual _Rp operator()(_A0) = 0; +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const = 0; + virtual const std::type_info& target_type() const = 0; +#endif // _LIBCPP_NO_RTTI +}; + +template +class __base<_Rp(_A0, _A1)> +{ + __base(const __base&); + __base& operator=(const __base&); +public: + __base() {} + virtual ~__base() {} + virtual __base* __clone() const = 0; + virtual void __clone(__base*) const = 0; + virtual void destroy() = 0; + virtual void destroy_deallocate() = 0; + virtual _Rp operator()(_A0, _A1) = 0; +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const = 0; + virtual const std::type_info& target_type() const = 0; +#endif // _LIBCPP_NO_RTTI +}; + +template +class __base<_Rp(_A0, _A1, _A2)> +{ + __base(const __base&); + __base& operator=(const __base&); +public: + __base() {} + virtual ~__base() {} + virtual __base* __clone() const = 0; + virtual void __clone(__base*) const = 0; + virtual void destroy() = 0; + virtual void destroy_deallocate() = 0; + virtual _Rp operator()(_A0, _A1, _A2) = 0; +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const = 0; + virtual const std::type_info& target_type() const = 0; +#endif // _LIBCPP_NO_RTTI +}; + +template class __func; + +template +class __func<_Fp, _Alloc, _Rp()> + : public __base<_Rp()> +{ + __compressed_pair<_Fp, _Alloc> __f_; +public: + explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} + explicit __func(_Fp __f, _Alloc __a) : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} + virtual __base<_Rp()>* __clone() const; + virtual void __clone(__base<_Rp()>*) const; + virtual void destroy(); + virtual void destroy_deallocate(); + virtual _Rp operator()(); +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const; + virtual const std::type_info& target_type() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +__base<_Rp()>* +__func<_Fp, _Alloc, _Rp()>::__clone() const +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a)); + return __hold.release(); +} + +template +void +__func<_Fp, _Alloc, _Rp()>::__clone(__base<_Rp()>* __p) const +{ + ::new ((void*)__p) __func(__f_.first(), __f_.second()); +} + +template +void +__func<_Fp, _Alloc, _Rp()>::destroy() +{ + __f_.~__compressed_pair<_Fp, _Alloc>(); +} + +template +void +__func<_Fp, _Alloc, _Rp()>::destroy_deallocate() +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + __f_.~__compressed_pair<_Fp, _Alloc>(); + __a.deallocate(this, 1); +} + +template +_Rp +__func<_Fp, _Alloc, _Rp()>::operator()() +{ + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first()); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const void* +__func<_Fp, _Alloc, _Rp()>::target(const type_info& __ti) const +{ + if (__ti == typeid(_Fp)) + return &__f_.first(); + return (const void*)0; +} + +template +const std::type_info& +__func<_Fp, _Alloc, _Rp()>::target_type() const +{ + return typeid(_Fp); +} + +#endif // _LIBCPP_NO_RTTI + +template +class __func<_Fp, _Alloc, _Rp(_A0)> + : public __base<_Rp(_A0)> +{ + __compressed_pair<_Fp, _Alloc> __f_; +public: + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) + : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} + virtual __base<_Rp(_A0)>* __clone() const; + virtual void __clone(__base<_Rp(_A0)>*) const; + virtual void destroy(); + virtual void destroy_deallocate(); + virtual _Rp operator()(_A0); +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const; + virtual const std::type_info& target_type() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +__base<_Rp(_A0)>* +__func<_Fp, _Alloc, _Rp(_A0)>::__clone() const +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a)); + return __hold.release(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0)>::__clone(__base<_Rp(_A0)>* __p) const +{ + ::new ((void*)__p) __func(__f_.first(), __f_.second()); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0)>::destroy() +{ + __f_.~__compressed_pair<_Fp, _Alloc>(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0)>::destroy_deallocate() +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + __f_.~__compressed_pair<_Fp, _Alloc>(); + __a.deallocate(this, 1); +} + +template +_Rp +__func<_Fp, _Alloc, _Rp(_A0)>::operator()(_A0 __a0) +{ + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const void* +__func<_Fp, _Alloc, _Rp(_A0)>::target(const type_info& __ti) const +{ + if (__ti == typeid(_Fp)) + return &__f_.first(); + return (const void*)0; +} + +template +const std::type_info& +__func<_Fp, _Alloc, _Rp(_A0)>::target_type() const +{ + return typeid(_Fp); +} + +#endif // _LIBCPP_NO_RTTI + +template +class __func<_Fp, _Alloc, _Rp(_A0, _A1)> + : public __base<_Rp(_A0, _A1)> +{ + __compressed_pair<_Fp, _Alloc> __f_; +public: + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) + : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} + virtual __base<_Rp(_A0, _A1)>* __clone() const; + virtual void __clone(__base<_Rp(_A0, _A1)>*) const; + virtual void destroy(); + virtual void destroy_deallocate(); + virtual _Rp operator()(_A0, _A1); +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const; + virtual const std::type_info& target_type() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +__base<_Rp(_A0, _A1)>* +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone() const +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a)); + return __hold.release(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::__clone(__base<_Rp(_A0, _A1)>* __p) const +{ + ::new ((void*)__p) __func(__f_.first(), __f_.second()); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy() +{ + __f_.~__compressed_pair<_Fp, _Alloc>(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::destroy_deallocate() +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + __f_.~__compressed_pair<_Fp, _Alloc>(); + __a.deallocate(this, 1); +} + +template +_Rp +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) +{ + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0, __a1); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const void* +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target(const type_info& __ti) const +{ + if (__ti == typeid(_Fp)) + return &__f_.first(); + return (const void*)0; +} + +template +const std::type_info& +__func<_Fp, _Alloc, _Rp(_A0, _A1)>::target_type() const +{ + return typeid(_Fp); +} + +#endif // _LIBCPP_NO_RTTI + +template +class __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> + : public __base<_Rp(_A0, _A1, _A2)> +{ + __compressed_pair<_Fp, _Alloc> __f_; +public: + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f) : __f_(_VSTD::move(__f), __default_init_tag()) {} + _LIBCPP_INLINE_VISIBILITY explicit __func(_Fp __f, _Alloc __a) + : __f_(_VSTD::move(__f), _VSTD::move(__a)) {} + virtual __base<_Rp(_A0, _A1, _A2)>* __clone() const; + virtual void __clone(__base<_Rp(_A0, _A1, _A2)>*) const; + virtual void destroy(); + virtual void destroy_deallocate(); + virtual _Rp operator()(_A0, _A1, _A2); +#ifndef _LIBCPP_NO_RTTI + virtual const void* target(const type_info&) const; + virtual const std::type_info& target_type() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +__base<_Rp(_A0, _A1, _A2)>* +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone() const +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__func, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) __func(__f_.first(), _Alloc(__a)); + return __hold.release(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::__clone(__base<_Rp(_A0, _A1, _A2)>* __p) const +{ + ::new ((void*)__p) __func(__f_.first(), __f_.second()); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy() +{ + __f_.~__compressed_pair<_Fp, _Alloc>(); +} + +template +void +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::destroy_deallocate() +{ + typedef allocator_traits<_Alloc> __alloc_traits; + typedef typename __rebind_alloc_helper<__alloc_traits, __func>::type _Ap; + _Ap __a(__f_.second()); + __f_.~__compressed_pair<_Fp, _Alloc>(); + __a.deallocate(this, 1); +} + +template +_Rp +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) +{ + typedef __invoke_void_return_wrapper<_Rp> _Invoker; + return _Invoker::__call(__f_.first(), __a0, __a1, __a2); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const void* +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target(const type_info& __ti) const +{ + if (__ti == typeid(_Fp)) + return &__f_.first(); + return (const void*)0; +} + +template +const std::type_info& +__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const +{ + return typeid(_Fp); +} + +#endif // _LIBCPP_NO_RTTI + +} // __function + +template +class _LIBCPP_TEMPLATE_VIS function<_Rp()> +{ + typedef __function::__base<_Rp()> __base; + aligned_storage<3*sizeof(void*)>::type __buf_; + __base* __f_; + +public: + typedef _Rp result_type; + + // 20.7.16.2.1, construct/copy/destroy: + _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} + _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} + function(const function&); + template + function(_Fp, + typename enable_if::value>::type* = 0); + + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&) : __f_(0) {} + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} + template + function(allocator_arg_t, const _Alloc&, const function&); + template + function(allocator_arg_t, const _Alloc& __a, _Fp __f, + typename enable_if::value>::type* = 0); + + function& operator=(const function&); + function& operator=(nullptr_t); + template + typename enable_if + < + !is_integral<_Fp>::value, + function& + >::type + operator=(_Fp); + + ~function(); + + // 20.7.16.2.2, function modifiers: + void swap(function&); + template + _LIBCPP_INLINE_VISIBILITY + void assign(_Fp __f, const _Alloc& __a) + {function(allocator_arg, __a, __f).swap(*this);} + + // 20.7.16.2.3, function capacity: + _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} + +private: + // deleted overloads close possible hole in the type system + template + bool operator==(const function<_R2()>&) const;// = delete; + template + bool operator!=(const function<_R2()>&) const;// = delete; +public: + // 20.7.16.2.4, function invocation: + _Rp operator()() const; + +#ifndef _LIBCPP_NO_RTTI + // 20.7.16.2.5, function target access: + const std::type_info& target_type() const; + template _Tp* target(); + template const _Tp* target() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +function<_Rp()>::function(const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp()>::function(allocator_arg_t, const _Alloc&, const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp()>::function(_Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f); + } + else + { + typedef allocator<_FF> _Ap; + _Ap __a; + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a)); + __f_ = __hold.release(); + } + } +} + +template +template +function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + typedef allocator_traits<_Alloc> __alloc_traits; + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, _Alloc, _Rp()> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f, __a0); + } + else + { + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; + _Ap __a(__a0); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a)); + __f_ = __hold.release(); + } + } +} + +template +function<_Rp()>& +function<_Rp()>::operator=(const function& __f) +{ + if (__f) + function(__f).swap(*this); + else + *this = nullptr; + return *this; +} + +template +function<_Rp()>& +function<_Rp()>::operator=(nullptr_t) +{ + __base* __t = __f_; + __f_ = 0; + if (__t == (__base*)&__buf_) + __t->destroy(); + else if (__t) + __t->destroy_deallocate(); + return *this; +} + +template +template +typename enable_if +< + !is_integral<_Fp>::value, + function<_Rp()>& +>::type +function<_Rp()>::operator=(_Fp __f) +{ + function(_VSTD::move(__f)).swap(*this); + return *this; +} + +template +function<_Rp()>::~function() +{ + if (__f_ == (__base*)&__buf_) + __f_->destroy(); + else if (__f_) + __f_->destroy_deallocate(); +} + +template +void +function<_Rp()>::swap(function& __f) +{ + if (_VSTD::addressof(__f) == this) + return; + if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) + { + typename aligned_storage::type __tempbuf; + __base* __t = (__base*)&__tempbuf; + __f_->__clone(__t); + __f_->destroy(); + __f_ = 0; + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = 0; + __f_ = (__base*)&__buf_; + __t->__clone((__base*)&__f.__buf_); + __t->destroy(); + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f_ == (__base*)&__buf_) + { + __f_->__clone((__base*)&__f.__buf_); + __f_->destroy(); + __f_ = __f.__f_; + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f.__f_ == (__base*)&__f.__buf_) + { + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = __f_; + __f_ = (__base*)&__buf_; + } + else + _VSTD::swap(__f_, __f.__f_); +} + +template +_Rp +function<_Rp()>::operator()() const +{ + if (__f_ == 0) + __throw_bad_function_call(); + return (*__f_)(); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const std::type_info& +function<_Rp()>::target_type() const +{ + if (__f_ == 0) + return typeid(void); + return __f_->target_type(); +} + +template +template +_Tp* +function<_Rp()>::target() +{ + if (__f_ == 0) + return (_Tp*)0; + return (_Tp*) const_cast(__f_->target(typeid(_Tp))); +} + +template +template +const _Tp* +function<_Rp()>::target() const +{ + if (__f_ == 0) + return (const _Tp*)0; + return (const _Tp*)__f_->target(typeid(_Tp)); +} + +#endif // _LIBCPP_NO_RTTI + +template +class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0)> + : public unary_function<_A0, _Rp> +{ + typedef __function::__base<_Rp(_A0)> __base; + aligned_storage<3*sizeof(void*)>::type __buf_; + __base* __f_; + +public: + typedef _Rp result_type; + + // 20.7.16.2.1, construct/copy/destroy: + _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} + _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} + function(const function&); + template + function(_Fp, + typename enable_if::value>::type* = 0); + + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&) : __f_(0) {} + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} + template + function(allocator_arg_t, const _Alloc&, const function&); + template + function(allocator_arg_t, const _Alloc& __a, _Fp __f, + typename enable_if::value>::type* = 0); + + function& operator=(const function&); + function& operator=(nullptr_t); + template + typename enable_if + < + !is_integral<_Fp>::value, + function& + >::type + operator=(_Fp); + + ~function(); + + // 20.7.16.2.2, function modifiers: + void swap(function&); + template + _LIBCPP_INLINE_VISIBILITY + void assign(_Fp __f, const _Alloc& __a) + {function(allocator_arg, __a, __f).swap(*this);} + + // 20.7.16.2.3, function capacity: + _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} + +private: + // deleted overloads close possible hole in the type system + template + bool operator==(const function<_R2(_B0)>&) const;// = delete; + template + bool operator!=(const function<_R2(_B0)>&) const;// = delete; +public: + // 20.7.16.2.4, function invocation: + _Rp operator()(_A0) const; + +#ifndef _LIBCPP_NO_RTTI + // 20.7.16.2.5, function target access: + const std::type_info& target_type() const; + template _Tp* target(); + template const _Tp* target() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +function<_Rp(_A0)>::function(const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc&, const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp(_A0)>::function(_Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f); + } + else + { + typedef allocator<_FF> _Ap; + _Ap __a; + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a)); + __f_ = __hold.release(); + } + } +} + +template +template +function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + typedef allocator_traits<_Alloc> __alloc_traits; + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f, __a0); + } + else + { + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; + _Ap __a(__a0); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a)); + __f_ = __hold.release(); + } + } +} + +template +function<_Rp(_A0)>& +function<_Rp(_A0)>::operator=(const function& __f) +{ + if (__f) + function(__f).swap(*this); + else + *this = nullptr; + return *this; +} + +template +function<_Rp(_A0)>& +function<_Rp(_A0)>::operator=(nullptr_t) +{ + __base* __t = __f_; + __f_ = 0; + if (__t == (__base*)&__buf_) + __t->destroy(); + else if (__t) + __t->destroy_deallocate(); + return *this; +} + +template +template +typename enable_if +< + !is_integral<_Fp>::value, + function<_Rp(_A0)>& +>::type +function<_Rp(_A0)>::operator=(_Fp __f) +{ + function(_VSTD::move(__f)).swap(*this); + return *this; +} + +template +function<_Rp(_A0)>::~function() +{ + if (__f_ == (__base*)&__buf_) + __f_->destroy(); + else if (__f_) + __f_->destroy_deallocate(); +} + +template +void +function<_Rp(_A0)>::swap(function& __f) +{ + if (_VSTD::addressof(__f) == this) + return; + if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) + { + typename aligned_storage::type __tempbuf; + __base* __t = (__base*)&__tempbuf; + __f_->__clone(__t); + __f_->destroy(); + __f_ = 0; + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = 0; + __f_ = (__base*)&__buf_; + __t->__clone((__base*)&__f.__buf_); + __t->destroy(); + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f_ == (__base*)&__buf_) + { + __f_->__clone((__base*)&__f.__buf_); + __f_->destroy(); + __f_ = __f.__f_; + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f.__f_ == (__base*)&__f.__buf_) + { + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = __f_; + __f_ = (__base*)&__buf_; + } + else + _VSTD::swap(__f_, __f.__f_); +} + +template +_Rp +function<_Rp(_A0)>::operator()(_A0 __a0) const +{ + if (__f_ == 0) + __throw_bad_function_call(); + return (*__f_)(__a0); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const std::type_info& +function<_Rp(_A0)>::target_type() const +{ + if (__f_ == 0) + return typeid(void); + return __f_->target_type(); +} + +template +template +_Tp* +function<_Rp(_A0)>::target() +{ + if (__f_ == 0) + return (_Tp*)0; + return (_Tp*) const_cast(__f_->target(typeid(_Tp))); +} + +template +template +const _Tp* +function<_Rp(_A0)>::target() const +{ + if (__f_ == 0) + return (const _Tp*)0; + return (const _Tp*)__f_->target(typeid(_Tp)); +} + +#endif // _LIBCPP_NO_RTTI + +template +class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1)> + : public binary_function<_A0, _A1, _Rp> +{ + typedef __function::__base<_Rp(_A0, _A1)> __base; + aligned_storage<3*sizeof(void*)>::type __buf_; + __base* __f_; + +public: + typedef _Rp result_type; + + // 20.7.16.2.1, construct/copy/destroy: + _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} + _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} + function(const function&); + template + function(_Fp, + typename enable_if::value>::type* = 0); + + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&) : __f_(0) {} + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} + template + function(allocator_arg_t, const _Alloc&, const function&); + template + function(allocator_arg_t, const _Alloc& __a, _Fp __f, + typename enable_if::value>::type* = 0); + + function& operator=(const function&); + function& operator=(nullptr_t); + template + typename enable_if + < + !is_integral<_Fp>::value, + function& + >::type + operator=(_Fp); + + ~function(); + + // 20.7.16.2.2, function modifiers: + void swap(function&); + template + _LIBCPP_INLINE_VISIBILITY + void assign(_Fp __f, const _Alloc& __a) + {function(allocator_arg, __a, __f).swap(*this);} + + // 20.7.16.2.3, function capacity: + _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} + +private: + // deleted overloads close possible hole in the type system + template + bool operator==(const function<_R2(_B0, _B1)>&) const;// = delete; + template + bool operator!=(const function<_R2(_B0, _B1)>&) const;// = delete; +public: + // 20.7.16.2.4, function invocation: + _Rp operator()(_A0, _A1) const; + +#ifndef _LIBCPP_NO_RTTI + // 20.7.16.2.5, function target access: + const std::type_info& target_type() const; + template _Tp* target(); + template const _Tp* target() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +function<_Rp(_A0, _A1)>::function(const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc&, const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp(_A0, _A1)>::function(_Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f); + } + else + { + typedef allocator<_FF> _Ap; + _Ap __a; + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a)); + __f_ = __hold.release(); + } + } +} + +template +template +function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + typedef allocator_traits<_Alloc> __alloc_traits; + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f, __a0); + } + else + { + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; + _Ap __a(__a0); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a)); + __f_ = __hold.release(); + } + } +} + +template +function<_Rp(_A0, _A1)>& +function<_Rp(_A0, _A1)>::operator=(const function& __f) +{ + if (__f) + function(__f).swap(*this); + else + *this = nullptr; + return *this; +} + +template +function<_Rp(_A0, _A1)>& +function<_Rp(_A0, _A1)>::operator=(nullptr_t) +{ + __base* __t = __f_; + __f_ = 0; + if (__t == (__base*)&__buf_) + __t->destroy(); + else if (__t) + __t->destroy_deallocate(); + return *this; +} + +template +template +typename enable_if +< + !is_integral<_Fp>::value, + function<_Rp(_A0, _A1)>& +>::type +function<_Rp(_A0, _A1)>::operator=(_Fp __f) +{ + function(_VSTD::move(__f)).swap(*this); + return *this; +} + +template +function<_Rp(_A0, _A1)>::~function() +{ + if (__f_ == (__base*)&__buf_) + __f_->destroy(); + else if (__f_) + __f_->destroy_deallocate(); +} + +template +void +function<_Rp(_A0, _A1)>::swap(function& __f) +{ + if (_VSTD::addressof(__f) == this) + return; + if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) + { + typename aligned_storage::type __tempbuf; + __base* __t = (__base*)&__tempbuf; + __f_->__clone(__t); + __f_->destroy(); + __f_ = 0; + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = 0; + __f_ = (__base*)&__buf_; + __t->__clone((__base*)&__f.__buf_); + __t->destroy(); + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f_ == (__base*)&__buf_) + { + __f_->__clone((__base*)&__f.__buf_); + __f_->destroy(); + __f_ = __f.__f_; + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f.__f_ == (__base*)&__f.__buf_) + { + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = __f_; + __f_ = (__base*)&__buf_; + } + else + _VSTD::swap(__f_, __f.__f_); +} + +template +_Rp +function<_Rp(_A0, _A1)>::operator()(_A0 __a0, _A1 __a1) const +{ + if (__f_ == 0) + __throw_bad_function_call(); + return (*__f_)(__a0, __a1); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const std::type_info& +function<_Rp(_A0, _A1)>::target_type() const +{ + if (__f_ == 0) + return typeid(void); + return __f_->target_type(); +} + +template +template +_Tp* +function<_Rp(_A0, _A1)>::target() +{ + if (__f_ == 0) + return (_Tp*)0; + return (_Tp*) const_cast(__f_->target(typeid(_Tp))); +} + +template +template +const _Tp* +function<_Rp(_A0, _A1)>::target() const +{ + if (__f_ == 0) + return (const _Tp*)0; + return (const _Tp*)__f_->target(typeid(_Tp)); +} + +#endif // _LIBCPP_NO_RTTI + +template +class _LIBCPP_TEMPLATE_VIS function<_Rp(_A0, _A1, _A2)> +{ + typedef __function::__base<_Rp(_A0, _A1, _A2)> __base; + aligned_storage<3*sizeof(void*)>::type __buf_; + __base* __f_; + +public: + typedef _Rp result_type; + + // 20.7.16.2.1, construct/copy/destroy: + _LIBCPP_INLINE_VISIBILITY explicit function() : __f_(0) {} + _LIBCPP_INLINE_VISIBILITY function(nullptr_t) : __f_(0) {} + function(const function&); + template + function(_Fp, + typename enable_if::value>::type* = 0); + + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&) : __f_(0) {} + template + _LIBCPP_INLINE_VISIBILITY + function(allocator_arg_t, const _Alloc&, nullptr_t) : __f_(0) {} + template + function(allocator_arg_t, const _Alloc&, const function&); + template + function(allocator_arg_t, const _Alloc& __a, _Fp __f, + typename enable_if::value>::type* = 0); + + function& operator=(const function&); + function& operator=(nullptr_t); + template + typename enable_if + < + !is_integral<_Fp>::value, + function& + >::type + operator=(_Fp); + + ~function(); + + // 20.7.16.2.2, function modifiers: + void swap(function&); + template + _LIBCPP_INLINE_VISIBILITY + void assign(_Fp __f, const _Alloc& __a) + {function(allocator_arg, __a, __f).swap(*this);} + + // 20.7.16.2.3, function capacity: + _LIBCPP_INLINE_VISIBILITY explicit operator bool() const {return __f_;} + +private: + // deleted overloads close possible hole in the type system + template + bool operator==(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; + template + bool operator!=(const function<_R2(_B0, _B1, _B2)>&) const;// = delete; +public: + // 20.7.16.2.4, function invocation: + _Rp operator()(_A0, _A1, _A2) const; + +#ifndef _LIBCPP_NO_RTTI + // 20.7.16.2.5, function target access: + const std::type_info& target_type() const; + template _Tp* target(); + template const _Tp* target() const; +#endif // _LIBCPP_NO_RTTI +}; + +template +function<_Rp(_A0, _A1, _A2)>::function(const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc&, + const function& __f) +{ + if (__f.__f_ == 0) + __f_ = 0; + else if (__f.__f_ == (const __base*)&__f.__buf_) + { + __f_ = (__base*)&__buf_; + __f.__f_->__clone(__f_); + } + else + __f_ = __f.__f_->__clone(); +} + +template +template +function<_Rp(_A0, _A1, _A2)>::function(_Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f); + } + else + { + typedef allocator<_FF> _Ap; + _Ap __a; + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, allocator<_Fp>(__a)); + __f_ = __hold.release(); + } + } +} + +template +template +function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, + typename enable_if::value>::type*) + : __f_(0) +{ + typedef allocator_traits<_Alloc> __alloc_traits; + if (__function::__not_null(__f)) + { + typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF; + if (sizeof(_FF) <= sizeof(__buf_)) + { + __f_ = (__base*)&__buf_; + ::new ((void*)__f_) _FF(__f, __a0); + } + else + { + typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; + _Ap __a(__a0); + typedef __allocator_destructor<_Ap> _Dp; + unique_ptr<__base, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _FF(__f, _Alloc(__a)); + __f_ = __hold.release(); + } + } +} + +template +function<_Rp(_A0, _A1, _A2)>& +function<_Rp(_A0, _A1, _A2)>::operator=(const function& __f) +{ + if (__f) + function(__f).swap(*this); + else + *this = nullptr; + return *this; +} + +template +function<_Rp(_A0, _A1, _A2)>& +function<_Rp(_A0, _A1, _A2)>::operator=(nullptr_t) +{ + __base* __t = __f_; + __f_ = 0; + if (__t == (__base*)&__buf_) + __t->destroy(); + else if (__t) + __t->destroy_deallocate(); + return *this; +} + +template +template +typename enable_if +< + !is_integral<_Fp>::value, + function<_Rp(_A0, _A1, _A2)>& +>::type +function<_Rp(_A0, _A1, _A2)>::operator=(_Fp __f) +{ + function(_VSTD::move(__f)).swap(*this); + return *this; +} + +template +function<_Rp(_A0, _A1, _A2)>::~function() +{ + if (__f_ == (__base*)&__buf_) + __f_->destroy(); + else if (__f_) + __f_->destroy_deallocate(); +} + +template +void +function<_Rp(_A0, _A1, _A2)>::swap(function& __f) +{ + if (_VSTD::addressof(__f) == this) + return; + if (__f_ == (__base*)&__buf_ && __f.__f_ == (__base*)&__f.__buf_) + { + typename aligned_storage::type __tempbuf; + __base* __t = (__base*)&__tempbuf; + __f_->__clone(__t); + __f_->destroy(); + __f_ = 0; + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = 0; + __f_ = (__base*)&__buf_; + __t->__clone((__base*)&__f.__buf_); + __t->destroy(); + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f_ == (__base*)&__buf_) + { + __f_->__clone((__base*)&__f.__buf_); + __f_->destroy(); + __f_ = __f.__f_; + __f.__f_ = (__base*)&__f.__buf_; + } + else if (__f.__f_ == (__base*)&__f.__buf_) + { + __f.__f_->__clone((__base*)&__buf_); + __f.__f_->destroy(); + __f.__f_ = __f_; + __f_ = (__base*)&__buf_; + } + else + _VSTD::swap(__f_, __f.__f_); +} + +template +_Rp +function<_Rp(_A0, _A1, _A2)>::operator()(_A0 __a0, _A1 __a1, _A2 __a2) const +{ + if (__f_ == 0) + __throw_bad_function_call(); + return (*__f_)(__a0, __a1, __a2); +} + +#ifndef _LIBCPP_NO_RTTI + +template +const std::type_info& +function<_Rp(_A0, _A1, _A2)>::target_type() const +{ + if (__f_ == 0) + return typeid(void); + return __f_->target_type(); +} + +template +template +_Tp* +function<_Rp(_A0, _A1, _A2)>::target() +{ + if (__f_ == 0) + return (_Tp*)0; + return (_Tp*) const_cast(__f_->target(typeid(_Tp))); +} + +template +template +const _Tp* +function<_Rp(_A0, _A1, _A2)>::target() const +{ + if (__f_ == 0) + return (const _Tp*)0; + return (const _Tp*)__f_->target(typeid(_Tp)); +} + +#endif // _LIBCPP_NO_RTTI + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(const function<_Fp>& __f, nullptr_t) {return !__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(nullptr_t, const function<_Fp>& __f) {return !__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(const function<_Fp>& __f, nullptr_t) {return (bool)__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(nullptr_t, const function<_Fp>& __f) {return (bool)__f;} + +template +inline _LIBCPP_INLINE_VISIBILITY +void +swap(function<_Fp>& __x, function<_Fp>& __y) +{return __x.swap(__y);} + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H diff --git a/gnu/llvm/libcxx/include/__functional/hash.h b/gnu/llvm/libcxx/include/__functional/hash.h new file mode 100644 index 00000000000..ebcbbad1338 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/hash.h @@ -0,0 +1,873 @@ +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_HASH_H +#define _LIBCPP___FUNCTIONAL_HASH_H + +#include <__config> +#include <__functional/unary_function.h> +#include <__tuple> +#include <__utility/forward.h> +#include <__utility/move.h> +#include <__utility/pair.h> +#include <__utility/swap.h> +#include +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY +_Size +__loadword(const void* __p) +{ + _Size __r; + _VSTD::memcpy(&__r, __p, sizeof(__r)); + return __r; +} + +// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t +// is 64 bits. This is because cityhash64 uses 64bit x 64bit +// multiplication, which can be very slow on 32-bit systems. +template +struct __murmur2_or_cityhash; + +template +struct __murmur2_or_cityhash<_Size, 32> +{ + inline _Size operator()(const void* __key, _Size __len) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK; +}; + +// murmur2 +template +_Size +__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) +{ + const _Size __m = 0x5bd1e995; + const _Size __r = 24; + _Size __h = __len; + const unsigned char* __data = static_cast(__key); + for (; __len >= 4; __data += 4, __len -= 4) + { + _Size __k = __loadword<_Size>(__data); + __k *= __m; + __k ^= __k >> __r; + __k *= __m; + __h *= __m; + __h ^= __k; + } + switch (__len) + { + case 3: + __h ^= static_cast<_Size>(__data[2] << 16); + _LIBCPP_FALLTHROUGH(); + case 2: + __h ^= static_cast<_Size>(__data[1] << 8); + _LIBCPP_FALLTHROUGH(); + case 1: + __h ^= __data[0]; + __h *= __m; + } + __h ^= __h >> 13; + __h *= __m; + __h ^= __h >> 15; + return __h; +} + +template +struct __murmur2_or_cityhash<_Size, 64> +{ + inline _Size operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK; + + private: + // Some primes between 2^63 and 2^64. + static const _Size __k0 = 0xc3a5c85c97cb3127ULL; + static const _Size __k1 = 0xb492b66fbe98f273ULL; + static const _Size __k2 = 0x9ae16a3b2f90404fULL; + static const _Size __k3 = 0xc949d7c7509e6557ULL; + + static _Size __rotate(_Size __val, int __shift) { + return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift))); + } + + static _Size __rotate_by_at_least_1(_Size __val, int __shift) { + return (__val >> __shift) | (__val << (64 - __shift)); + } + + static _Size __shift_mix(_Size __val) { + return __val ^ (__val >> 47); + } + + static _Size __hash_len_16(_Size __u, _Size __v) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK + { + const _Size __mul = 0x9ddfea08eb382d69ULL; + _Size __a = (__u ^ __v) * __mul; + __a ^= (__a >> 47); + _Size __b = (__v ^ __a) * __mul; + __b ^= (__b >> 47); + __b *= __mul; + return __b; + } + + static _Size __hash_len_0_to_16(const char* __s, _Size __len) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK + { + if (__len > 8) { + const _Size __a = __loadword<_Size>(__s); + const _Size __b = __loadword<_Size>(__s + __len - 8); + return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b; + } + if (__len >= 4) { + const uint32_t __a = __loadword(__s); + const uint32_t __b = __loadword(__s + __len - 4); + return __hash_len_16(__len + (__a << 3), __b); + } + if (__len > 0) { + const unsigned char __a = static_cast(__s[0]); + const unsigned char __b = static_cast(__s[__len >> 1]); + const unsigned char __c = static_cast(__s[__len - 1]); + const uint32_t __y = static_cast(__a) + + (static_cast(__b) << 8); + const uint32_t __z = __len + (static_cast(__c) << 2); + return __shift_mix(__y * __k2 ^ __z * __k3) * __k2; + } + return __k2; + } + + static _Size __hash_len_17_to_32(const char *__s, _Size __len) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK + { + const _Size __a = __loadword<_Size>(__s) * __k1; + const _Size __b = __loadword<_Size>(__s + 8); + const _Size __c = __loadword<_Size>(__s + __len - 8) * __k2; + const _Size __d = __loadword<_Size>(__s + __len - 16) * __k0; + return __hash_len_16(__rotate(__a - __b, 43) + __rotate(__c, 30) + __d, + __a + __rotate(__b ^ __k3, 20) - __c + __len); + } + + // Return a 16-byte hash for 48 bytes. Quick and dirty. + // Callers do best to use "random-looking" values for a and b. + static pair<_Size, _Size> __weak_hash_len_32_with_seeds( + _Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK + { + __a += __w; + __b = __rotate(__b + __a + __z, 21); + const _Size __c = __a; + __a += __x; + __a += __y; + __b += __rotate(__a, 44); + return pair<_Size, _Size>(__a + __z, __b + __c); + } + + // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty. + static pair<_Size, _Size> __weak_hash_len_32_with_seeds( + const char* __s, _Size __a, _Size __b) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK + { + return __weak_hash_len_32_with_seeds(__loadword<_Size>(__s), + __loadword<_Size>(__s + 8), + __loadword<_Size>(__s + 16), + __loadword<_Size>(__s + 24), + __a, + __b); + } + + // Return an 8-byte hash for 33 to 64 bytes. + static _Size __hash_len_33_to_64(const char *__s, size_t __len) + _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK + { + _Size __z = __loadword<_Size>(__s + 24); + _Size __a = __loadword<_Size>(__s) + + (__len + __loadword<_Size>(__s + __len - 16)) * __k0; + _Size __b = __rotate(__a + __z, 52); + _Size __c = __rotate(__a, 37); + __a += __loadword<_Size>(__s + 8); + __c += __rotate(__a, 7); + __a += __loadword<_Size>(__s + 16); + _Size __vf = __a + __z; + _Size __vs = __b + __rotate(__a, 31) + __c; + __a = __loadword<_Size>(__s + 16) + __loadword<_Size>(__s + __len - 32); + __z += __loadword<_Size>(__s + __len - 8); + __b = __rotate(__a + __z, 52); + __c = __rotate(__a, 37); + __a += __loadword<_Size>(__s + __len - 24); + __c += __rotate(__a, 7); + __a += __loadword<_Size>(__s + __len - 16); + _Size __wf = __a + __z; + _Size __ws = __b + __rotate(__a, 31) + __c; + _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0); + return __shift_mix(__r * __k0 + __vs) * __k2; + } +}; + +// cityhash64 +template +_Size +__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) +{ + const char* __s = static_cast(__key); + if (__len <= 32) { + if (__len <= 16) { + return __hash_len_0_to_16(__s, __len); + } else { + return __hash_len_17_to_32(__s, __len); + } + } else if (__len <= 64) { + return __hash_len_33_to_64(__s, __len); + } + + // For strings over 64 bytes we hash the end first, and then as we + // loop we keep 56 bytes of state: v, w, x, y, and z. + _Size __x = __loadword<_Size>(__s + __len - 40); + _Size __y = __loadword<_Size>(__s + __len - 16) + + __loadword<_Size>(__s + __len - 56); + _Size __z = __hash_len_16(__loadword<_Size>(__s + __len - 48) + __len, + __loadword<_Size>(__s + __len - 24)); + pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z); + pair<_Size, _Size> __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x); + __x = __x * __k1 + __loadword<_Size>(__s); + + // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks. + __len = (__len - 1) & ~static_cast<_Size>(63); + do { + __x = __rotate(__x + __y + __v.first + __loadword<_Size>(__s + 8), 37) * __k1; + __y = __rotate(__y + __v.second + __loadword<_Size>(__s + 48), 42) * __k1; + __x ^= __w.second; + __y += __v.first + __loadword<_Size>(__s + 40); + __z = __rotate(__z + __w.first, 33) * __k1; + __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first); + __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, + __y + __loadword<_Size>(__s + 16)); + _VSTD::swap(__z, __x); + __s += 64; + __len -= 64; + } while (__len != 0); + return __hash_len_16( + __hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z, + __hash_len_16(__v.second, __w.second) + __x); +} + +template +struct __scalar_hash; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct __scalar_hash<_Tp, 0> +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + union + { + _Tp __t; + size_t __a; + } __u; + __u.__a = 0; + __u.__t = __v; + return __u.__a; + } +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct __scalar_hash<_Tp, 1> +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + union + { + _Tp __t; + size_t __a; + } __u; + __u.__t = __v; + return __u.__a; + } +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct __scalar_hash<_Tp, 2> +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + union + { + _Tp __t; + struct + { + size_t __a; + size_t __b; + } __s; + } __u; + __u.__t = __v; + return __murmur2_or_cityhash()(&__u, sizeof(__u)); + } +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct __scalar_hash<_Tp, 3> +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + union + { + _Tp __t; + struct + { + size_t __a; + size_t __b; + size_t __c; + } __s; + } __u; + __u.__t = __v; + return __murmur2_or_cityhash()(&__u, sizeof(__u)); + } +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct __scalar_hash<_Tp, 4> +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + union + { + _Tp __t; + struct + { + size_t __a; + size_t __b; + size_t __c; + size_t __d; + } __s; + } __u; + __u.__t = __v; + return __murmur2_or_cityhash()(&__u, sizeof(__u)); + } +}; + +struct _PairT { + size_t first; + size_t second; +}; + +_LIBCPP_INLINE_VISIBILITY +inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT { + typedef __scalar_hash<_PairT> _HashT; + const _PairT __p = {__lhs, __rhs}; + return _HashT()(__p); +} + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct _LIBCPP_TEMPLATE_VIS hash<_Tp*> +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp*, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp* __v) const _NOEXCEPT + { + union + { + _Tp* __t; + size_t __a; + } __u; + __u.__t = __v; + return __murmur2_or_cityhash()(&__u, sizeof(__u)); + } +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(bool __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef char argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef signed char argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(signed char __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned char argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast(__v);} +}; + +#ifndef _LIBCPP_HAS_NO_CHAR8_T +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef char8_t argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast(__v);} +}; +#endif // !_LIBCPP_HAS_NO_CHAR8_T + +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef char16_t argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef char32_t argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast(__v);} +}; + +#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef wchar_t argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef short argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(short __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned short argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef int argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(int __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned int argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef long argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(long __v) const _NOEXCEPT {return static_cast(__v);} +}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef unsigned long argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast(__v);} +}; + +template <> +struct _LIBCPP_TEMPLATE_VIS hash + : public __scalar_hash +{ +}; + +template <> +struct _LIBCPP_TEMPLATE_VIS hash + : public __scalar_hash +{ +}; + +#ifndef _LIBCPP_HAS_NO_INT128 + +template <> +struct _LIBCPP_TEMPLATE_VIS hash<__int128_t> + : public __scalar_hash<__int128_t> +{ +}; + +template <> +struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t> + : public __scalar_hash<__uint128_t> +{ +}; + +#endif + +template <> +struct _LIBCPP_TEMPLATE_VIS hash + : public __scalar_hash +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(float __v) const _NOEXCEPT + { + // -0.0 and 0.0 should return same hash + if (__v == 0.0f) + return 0; + return __scalar_hash::operator()(__v); + } +}; + +template <> +struct _LIBCPP_TEMPLATE_VIS hash + : public __scalar_hash +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(double __v) const _NOEXCEPT + { + // -0.0 and 0.0 should return same hash + if (__v == 0.0) + return 0; + return __scalar_hash::operator()(__v); + } +}; + +template <> +struct _LIBCPP_TEMPLATE_VIS hash + : public __scalar_hash +{ + _LIBCPP_INLINE_VISIBILITY + size_t operator()(long double __v) const _NOEXCEPT + { + // -0.0 and 0.0 should return same hash + if (__v == 0.0L) + return 0; +#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__)) + // Zero out padding bits + union + { + long double __t; + struct + { + size_t __a; + size_t __b; + size_t __c; + size_t __d; + } __s; + } __u; + __u.__s.__a = 0; + __u.__s.__b = 0; + __u.__s.__c = 0; + __u.__s.__d = 0; + __u.__t = __v; + return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d; +#elif defined(__x86_64__) + // Zero out padding bits + union + { + long double __t; + struct + { + size_t __a; + size_t __b; + } __s; + } __u; + __u.__s.__a = 0; + __u.__s.__b = 0; + __u.__t = __v; + return __u.__s.__a ^ __u.__s.__b; +#else + return __scalar_hash::operator()(__v); +#endif + } +}; + +#if _LIBCPP_STD_VER > 11 + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template ::value> +struct _LIBCPP_TEMPLATE_VIS __enum_hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function<_Tp, size_t> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + typedef typename underlying_type<_Tp>::type type; + return hash{}(static_cast(__v)); + } +}; +template +struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> { + __enum_hash() = delete; + __enum_hash(__enum_hash const&) = delete; + __enum_hash& operator=(__enum_hash const&) = delete; +}; + +template +struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp> +{ +}; +#endif + +#if _LIBCPP_STD_VER > 14 + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template <> +struct _LIBCPP_TEMPLATE_VIS hash +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public unary_function +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef size_t result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef nullptr_t argument_type; +#endif + _LIBCPP_INLINE_VISIBILITY + size_t operator()(nullptr_t) const _NOEXCEPT { + return 662607004ull; + } +}; +#endif + +#ifndef _LIBCPP_CXX03_LANG +template +using __check_hash_requirements _LIBCPP_NODEBUG_TYPE = integral_constant::value && + is_move_constructible<_Hash>::value && + __invokable_r::value +>; + +template > +using __has_enabled_hash _LIBCPP_NODEBUG_TYPE = integral_constant::value && + is_default_constructible<_Hash>::value +>; + +#if _LIBCPP_STD_VER > 14 +template +using __enable_hash_helper_imp _LIBCPP_NODEBUG_TYPE = _Type; + +template +using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = __enable_hash_helper_imp<_Type, + typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type +>; +#else +template +using __enable_hash_helper _LIBCPP_NODEBUG_TYPE = _Type; +#endif + +#endif // !_LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___FUNCTIONAL_HASH_H diff --git a/gnu/llvm/libcxx/include/__functional/identity.h b/gnu/llvm/libcxx/include/__functional/identity.h new file mode 100644 index 00000000000..6b8346b3b2a --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/identity.h @@ -0,0 +1,37 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_IDENTITY_H +#define _LIBCPP___FUNCTIONAL_IDENTITY_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 17 + +struct identity { + template + _LIBCPP_NODISCARD_EXT constexpr _Tp&& operator()(_Tp&& __t) const noexcept + { + return _VSTD::forward<_Tp>(__t); + } + + using is_transparent = void; +}; +#endif // _LIBCPP_STD_VER > 17 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_IDENTITY_H diff --git a/gnu/llvm/libcxx/include/__functional/invoke.h b/gnu/llvm/libcxx/include/__functional/invoke.h new file mode 100644 index 00000000000..0e167c75d69 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/invoke.h @@ -0,0 +1,100 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_INVOKE_H +#define _LIBCPP___FUNCTIONAL_INVOKE_H + +#include <__config> +#include <__functional/weak_result_type.h> +#include <__utility/forward.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template ::value> +struct __invoke_void_return_wrapper +{ +#ifndef _LIBCPP_CXX03_LANG + template + static _Ret __call(_Args&&... __args) { + return _VSTD::__invoke(_VSTD::forward<_Args>(__args)...); + } +#else + template + static _Ret __call(_Fn __f) { + return _VSTD::__invoke(__f); + } + + template + static _Ret __call(_Fn __f, _A0& __a0) { + return _VSTD::__invoke(__f, __a0); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) { + return _VSTD::__invoke(__f, __a0, __a1); + } + + template + static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){ + return _VSTD::__invoke(__f, __a0, __a1, __a2); + } +#endif +}; + +template +struct __invoke_void_return_wrapper<_Ret, true> +{ +#ifndef _LIBCPP_CXX03_LANG + template + static void __call(_Args&&... __args) { + _VSTD::__invoke(_VSTD::forward<_Args>(__args)...); + } +#else + template + static void __call(_Fn __f) { + _VSTD::__invoke(__f); + } + + template + static void __call(_Fn __f, _A0& __a0) { + _VSTD::__invoke(__f, __a0); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1) { + _VSTD::__invoke(__f, __a0, __a1); + } + + template + static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) { + _VSTD::__invoke(__f, __a0, __a1, __a2); + } +#endif +}; + +#if _LIBCPP_STD_VER > 14 + +template +_LIBCPP_CONSTEXPR_AFTER_CXX17 invoke_result_t<_Fn, _Args...> +invoke(_Fn&& __f, _Args&&... __args) + noexcept(is_nothrow_invocable_v<_Fn, _Args...>) +{ + return _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...); +} + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_INVOKE_H diff --git a/gnu/llvm/libcxx/include/__functional/is_transparent.h b/gnu/llvm/libcxx/include/__functional/is_transparent.h new file mode 100644 index 00000000000..4a72aa8e29e --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/is_transparent.h @@ -0,0 +1,36 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_IS_TRANSPARENT +#define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 11 + +template +struct __is_transparent : false_type {}; + +template +struct __is_transparent<_Tp, _Up, + typename __void_t::type> + : true_type {}; + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT diff --git a/gnu/llvm/libcxx/include/__functional/mem_fn.h b/gnu/llvm/libcxx/include/__functional/mem_fn.h new file mode 100644 index 00000000000..1fa070a42cc --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/mem_fn.h @@ -0,0 +1,161 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_MEM_FN_H +#define _LIBCPP___FUNCTIONAL_MEM_FN_H + +#include <__config> +#include <__functional/weak_result_type.h> +#include <__functional/binary_function.h> +#include <__functional/invoke.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class __mem_fn +#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public __weak_result_type<_Tp> +#endif +{ +public: + // types + typedef _Tp type; +private: + type __f_; + +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} + +#ifndef _LIBCPP_CXX03_LANG + // invoke + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename __invoke_return::type + operator() (_ArgTypes&&... __args) const { + return _VSTD::__invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); + } +#else + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0& __a0) const { + return _VSTD::__invoke(__f_, __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return _VSTD::__invoke(__f_, __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1& __a1) const { + return _VSTD::__invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return _VSTD::__invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return _VSTD::__invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return _VSTD::__invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(__f_, __a0, __a1, __a2); + } +#endif +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +__mem_fn<_Rp _Tp::*> +mem_fn(_Rp _Tp::* __pm) _NOEXCEPT +{ + return __mem_fn<_Rp _Tp::*>(__pm); +} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_MEM_FN_H diff --git a/gnu/llvm/libcxx/include/__functional/mem_fun_ref.h b/gnu/llvm/libcxx/include/__functional/mem_fun_ref.h new file mode 100644 index 00000000000..4616da0b074 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/mem_fun_ref.h @@ -0,0 +1,173 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_MEM_FUN_REF_H +#define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H + +#include <__config> +#include <__functional/unary_function.h> +#include <__functional/binary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t + : public unary_function<_Tp*, _Sp> +{ + _Sp (_Tp::*__p_)(); +public: + _LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)()) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const + {return (__p->*__p_)();} +}; + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t + : public binary_function<_Tp*, _Ap, _Sp> +{ + _Sp (_Tp::*__p_)(_Ap); +public: + _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const + {return (__p->*__p_)(__x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +mem_fun_t<_Sp,_Tp> +mem_fun(_Sp (_Tp::*__f)()) + {return mem_fun_t<_Sp,_Tp>(__f);} + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +mem_fun1_t<_Sp,_Tp,_Ap> +mem_fun(_Sp (_Tp::*__f)(_Ap)) + {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t + : public unary_function<_Tp, _Sp> +{ + _Sp (_Tp::*__p_)(); +public: + _LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const + {return (__p.*__p_)();} +}; + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t + : public binary_function<_Tp, _Ap, _Sp> +{ + _Sp (_Tp::*__p_)(_Ap); +public: + _LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const + {return (__p.*__p_)(__x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +mem_fun_ref_t<_Sp,_Tp> +mem_fun_ref(_Sp (_Tp::*__f)()) + {return mem_fun_ref_t<_Sp,_Tp>(__f);} + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +mem_fun1_ref_t<_Sp,_Tp,_Ap> +mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) + {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t + : public unary_function +{ + _Sp (_Tp::*__p_)() const; +public: + _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const + {return (__p->*__p_)();} +}; + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t + : public binary_function +{ + _Sp (_Tp::*__p_)(_Ap) const; +public: + _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const + {return (__p->*__p_)(__x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +const_mem_fun_t<_Sp,_Tp> +mem_fun(_Sp (_Tp::*__f)() const) + {return const_mem_fun_t<_Sp,_Tp>(__f);} + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +const_mem_fun1_t<_Sp,_Tp,_Ap> +mem_fun(_Sp (_Tp::*__f)(_Ap) const) + {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t + : public unary_function<_Tp, _Sp> +{ + _Sp (_Tp::*__p_)() const; +public: + _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const + {return (__p.*__p_)();} +}; + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t + : public binary_function<_Tp, _Ap, _Sp> +{ + _Sp (_Tp::*__p_)(_Ap) const; +public: + _LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) + : __p_(__p) {} + _LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const + {return (__p.*__p_)(__x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +const_mem_fun_ref_t<_Sp,_Tp> +mem_fun_ref(_Sp (_Tp::*__f)() const) + {return const_mem_fun_ref_t<_Sp,_Tp>(__f);} + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +const_mem_fun1_ref_t<_Sp,_Tp,_Ap> +mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) + {return const_mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} + +#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H diff --git a/gnu/llvm/libcxx/include/__functional/not_fn.h b/gnu/llvm/libcxx/include/__functional/not_fn.h new file mode 100644 index 00000000000..632be5ff096 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/not_fn.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_NOT_FN_H +#define _LIBCPP___FUNCTIONAL_NOT_FN_H + +#include <__config> +#include <__functional/perfect_forward.h> +#include <__functional/invoke.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +struct __not_fn_op +{ + template + static _LIBCPP_CONSTEXPR_AFTER_CXX17 auto __call(_Args&&... __args) + noexcept(noexcept(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...))) + -> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...)) + { return !_VSTD::invoke(_VSTD::forward<_Args>(__args)...); } +}; + +template, _Fn> && + is_move_constructible_v<_Fn>>> +_LIBCPP_CONSTEXPR_AFTER_CXX17 auto not_fn(_Fn&& __f) +{ + return __perfect_forward<__not_fn_op, _Fn>(_VSTD::forward<_Fn>(__f)); +} + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H diff --git a/gnu/llvm/libcxx/include/__functional/operations.h b/gnu/llvm/libcxx/include/__functional/operations.h new file mode 100644 index 00000000000..667d17988bc --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/operations.h @@ -0,0 +1,729 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_OPERATIONS_H +#define _LIBCPP___FUNCTIONAL_OPERATIONS_H + +#include <__config> +#include <__functional/binary_function.h> +#include <__functional/unary_function.h> +#include <__utility/forward.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Arithmetic operations + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS plus +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x + __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS plus +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS minus +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x - __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS minus +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS multiplies +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x * __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS multiplies +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS divides +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x / __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS divides +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS modulus +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x % __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS modulus +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS negate +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : unary_function<_Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const + {return -__x;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS negate +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const + _NOEXCEPT_(noexcept(- _VSTD::forward<_Tp>(__x))) + -> decltype (- _VSTD::forward<_Tp>(__x)) + { return - _VSTD::forward<_Tp>(__x); } + typedef void is_transparent; +}; +#endif + +// Bitwise operations + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS bit_and +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x & __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS bit_and +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +#if _LIBCPP_STD_VER > 11 +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct _LIBCPP_TEMPLATE_VIS bit_not +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : unary_function<_Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const + {return ~__x;} +}; + +template <> +struct _LIBCPP_TEMPLATE_VIS bit_not +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const + _NOEXCEPT_(noexcept(~_VSTD::forward<_Tp>(__x))) + -> decltype (~_VSTD::forward<_Tp>(__x)) + { return ~_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS bit_or +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x | __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS bit_or +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS bit_xor +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, _Tp> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef _Tp __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const + {return __x ^ __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS bit_xor +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +// Comparison operations + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS equal_to +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x == __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS equal_to +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS not_equal_to +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x != __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS not_equal_to +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS less +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x < __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS less +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS less_equal +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x <= __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS less_equal +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS greater_equal +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x >= __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS greater_equal +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS greater +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x > __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS greater +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +// Logical operations + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS logical_and +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x && __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS logical_and +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS logical_not +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : unary_function<_Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x) const + {return !__x;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS logical_not +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const + _NOEXCEPT_(noexcept(!_VSTD::forward<_Tp>(__x))) + -> decltype (!_VSTD::forward<_Tp>(__x)) + { return !_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +#if _LIBCPP_STD_VER > 11 +template +#else +template +#endif +struct _LIBCPP_TEMPLATE_VIS logical_or +#if !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : binary_function<_Tp, _Tp, bool> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP + typedef bool __result_type; // used by valarray +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef bool result_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp first_argument_type; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp second_argument_type; +#endif + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const + {return __x || __y;} +}; + +#if _LIBCPP_STD_VER > 11 +template <> +struct _LIBCPP_TEMPLATE_VIS logical_or +{ + template + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const + _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))) + -> decltype (_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)) + { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } + typedef void is_transparent; +}; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H diff --git a/gnu/llvm/libcxx/include/__functional/perfect_forward.h b/gnu/llvm/libcxx/include/__functional/perfect_forward.h new file mode 100644 index 00000000000..a5678e1593b --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/perfect_forward.h @@ -0,0 +1,88 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_PERFECT_FORWARD_H +#define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H + +#include <__config> +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template::value>::type> +struct __perfect_forward_impl; + +template +struct __perfect_forward_impl<_Op, __tuple_types<_Bound...>, __tuple_indices<_Idxs...>> +{ + tuple<_Bound...> __bound_; + + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) & + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} + + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const& + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(__bound_)..., _VSTD::forward<_Args>(__args)...);} + + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) && + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...);} + + template + _LIBCPP_INLINE_VISIBILITY constexpr auto operator()(_Args&&... __args) const&& + noexcept(noexcept(_Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...))) + -> decltype( _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...)) + {return _Op::__call(_VSTD::get<_Idxs>(_VSTD::move(__bound_))..., + _VSTD::forward<_Args>(__args)...);} + + template>::type, + class = _EnableIf>> + constexpr __perfect_forward_impl(__perfect_forward_impl const& __other) + : __bound_(__other.__bound_) {} + + template>::type, + class = _EnableIf>> + constexpr __perfect_forward_impl(__perfect_forward_impl && __other) + : __bound_(_VSTD::move(__other.__bound_)) {} + + template + explicit constexpr __perfect_forward_impl(_BoundArgs&&... __bound) : + __bound_(_VSTD::forward<_BoundArgs>(__bound)...) { } +}; + +template +using __perfect_forward = + __perfect_forward_impl<_Op, __tuple_types...>>; + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H diff --git a/gnu/llvm/libcxx/include/__functional/pointer_to_binary_function.h b/gnu/llvm/libcxx/include/__functional/pointer_to_binary_function.h new file mode 100644 index 00000000000..d4a6c1674ae --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/pointer_to_binary_function.h @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H +#define _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H + +#include <__config> +#include <__functional/binary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function + : public binary_function<_Arg1, _Arg2, _Result> +{ + _Result (*__f_)(_Arg1, _Arg2); +public: + _LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) + : __f_(__f) {} + _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const + {return __f_(__x, __y);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +pointer_to_binary_function<_Arg1,_Arg2,_Result> +ptr_fun(_Result (*__f)(_Arg1,_Arg2)) + {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} + +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H diff --git a/gnu/llvm/libcxx/include/__functional/pointer_to_unary_function.h b/gnu/llvm/libcxx/include/__functional/pointer_to_unary_function.h new file mode 100644 index 00000000000..0ac4561cc30 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/pointer_to_unary_function.h @@ -0,0 +1,46 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H +#define _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H + +#include <__config> +#include <__functional/unary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function + : public unary_function<_Arg, _Result> +{ + _Result (*__f_)(_Arg); +public: + _LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg)) + : __f_(__f) {} + _LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const + {return __f_(__x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY +pointer_to_unary_function<_Arg,_Result> +ptr_fun(_Result (*__f)(_Arg)) + {return pointer_to_unary_function<_Arg,_Result>(__f);} + +#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H diff --git a/gnu/llvm/libcxx/include/__functional/ranges_operations.h b/gnu/llvm/libcxx/include/__functional/ranges_operations.h new file mode 100644 index 00000000000..777c5352510 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/ranges_operations.h @@ -0,0 +1,97 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_RANGES_OPERATIONS_H +#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H + +#include <__config> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) +namespace ranges { + +struct equal_to { + template + requires equality_comparable_with<_Tp, _Up> + [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const + noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) { + return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u); + } + + using is_transparent = void; +}; + +struct not_equal_to { + template + requires equality_comparable_with<_Tp, _Up> + [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const + noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) { + return !(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)); + } + + using is_transparent = void; +}; + +struct less { + template + requires totally_ordered_with<_Tp, _Up> + [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const + noexcept(noexcept(bool(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) { + return _VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u); + } + + using is_transparent = void; +}; + +struct less_equal { + template + requires totally_ordered_with<_Tp, _Up> + [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const + noexcept(noexcept(bool(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) { + return !(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)); + } + + using is_transparent = void; +}; + +struct greater { + template + requires totally_ordered_with<_Tp, _Up> + [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const + noexcept(noexcept(bool(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) { + return _VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t); + } + + using is_transparent = void; +}; + +struct greater_equal { + template + requires totally_ordered_with<_Tp, _Up> + [[nodiscard]] constexpr bool operator()(_Tp &&__t, _Up &&__u) const + noexcept(noexcept(bool(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) { + return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)); + } + + using is_transparent = void; +}; + +} // namespace ranges +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H diff --git a/gnu/llvm/libcxx/include/__functional/reference_wrapper.h b/gnu/llvm/libcxx/include/__functional/reference_wrapper.h new file mode 100644 index 00000000000..09f4a649450 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/reference_wrapper.h @@ -0,0 +1,223 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_REFERENCE_WRAPPER_H +#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H + +#include <__config> +#include <__functional/weak_result_type.h> +#include <__memory/addressof.h> +#include <__utility/forward.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class _LIBCPP_TEMPLATE_VIS reference_wrapper +#if _LIBCPP_STD_VER <= 17 || !defined(_LIBCPP_ABI_NO_BINDER_BASES) + : public __weak_result_type<_Tp> +#endif +{ +public: + // types + typedef _Tp type; +private: + type* __f_; + +#ifndef _LIBCPP_CXX03_LANG + static void __fun(_Tp&) _NOEXCEPT; + static void __fun(_Tp&&) = delete; +#endif + +public: + // construct/copy/destroy +#ifdef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + reference_wrapper(type& __f) _NOEXCEPT + : __f_(_VSTD::addressof(__f)) {} +#else + template ::value, decltype(__fun(declval<_Up>())) >> + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(declval<_Up>()))) { + type& __f = static_cast<_Up&&>(__u); + __f_ = _VSTD::addressof(__f); + } +#endif + + // access + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + operator type&() const _NOEXCEPT {return *__f_;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + type& get() const _NOEXCEPT {return *__f_;} + +#ifndef _LIBCPP_CXX03_LANG + // invoke + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + typename __invoke_of::type + operator() (_ArgTypes&&... __args) const { + return _VSTD::__invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); + } +#else + + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return::type + operator() () const { + return _VSTD::__invoke(get()); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0& __a0) const { + return _VSTD::__invoke(get(), __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return _VSTD::__invoke(get(), __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1& __a1) const { + return _VSTD::__invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return _VSTD::__invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return _VSTD::__invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return _VSTD::__invoke(get(), __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { + return _VSTD::__invoke(get(), __a0, __a1, __a2); + } +#endif // _LIBCPP_CXX03_LANG +}; + +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES +template +reference_wrapper(_Tp&) -> reference_wrapper<_Tp>; +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +reference_wrapper<_Tp> +ref(_Tp& __t) _NOEXCEPT +{ + return reference_wrapper<_Tp>(__t); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +reference_wrapper<_Tp> +ref(reference_wrapper<_Tp> __t) _NOEXCEPT +{ + return _VSTD::ref(__t.get()); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +reference_wrapper +cref(const _Tp& __t) _NOEXCEPT +{ + return reference_wrapper(__t); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +reference_wrapper +cref(reference_wrapper<_Tp> __t) _NOEXCEPT +{ + return _VSTD::cref(__t.get()); +} + +#ifndef _LIBCPP_CXX03_LANG +template void ref(const _Tp&&) = delete; +template void cref(const _Tp&&) = delete; +#endif + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H diff --git a/gnu/llvm/libcxx/include/__functional/unary_function.h b/gnu/llvm/libcxx/include/__functional/unary_function.h new file mode 100644 index 00000000000..8084ef4b034 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/unary_function.h @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_UNARY_FUNCTION_H +#define _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct _LIBCPP_TEMPLATE_VIS unary_function +{ + typedef _Arg argument_type; + typedef _Result result_type; +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H diff --git a/gnu/llvm/libcxx/include/__functional/unary_negate.h b/gnu/llvm/libcxx/include/__functional/unary_negate.h new file mode 100644 index 00000000000..71257cf40c0 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/unary_negate.h @@ -0,0 +1,47 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_UNARY_NEGATE_H +#define _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H + +#include <__config> +#include <__functional/unary_function.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) + +template +class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate + : public unary_function +{ + _Predicate __pred_; +public: + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + explicit unary_negate(const _Predicate& __pred) + : __pred_(__pred) {} + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::argument_type& __x) const + {return !__pred_(__x);} +}; + +template +_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY +unary_negate<_Predicate> +not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} + +#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H diff --git a/gnu/llvm/libcxx/include/__functional/unwrap_ref.h b/gnu/llvm/libcxx/include/__functional/unwrap_ref.h new file mode 100644 index 00000000000..4d091ec35c5 --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/unwrap_ref.h @@ -0,0 +1,62 @@ +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_UNWRAP_REF_H +#define _LIBCPP___FUNCTIONAL_UNWRAP_REF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct __unwrap_reference { typedef _LIBCPP_NODEBUG_TYPE _Tp type; }; + +template +class reference_wrapper; + +template +struct __unwrap_reference > { typedef _LIBCPP_NODEBUG_TYPE _Tp& type; }; + +template +struct decay; + +#if _LIBCPP_STD_VER > 17 +template +struct unwrap_reference : __unwrap_reference<_Tp> { }; + +template +using unwrap_reference_t = typename unwrap_reference<_Tp>::type; + +template +struct unwrap_ref_decay : unwrap_reference::type> { }; + +template +using unwrap_ref_decay_t = typename unwrap_ref_decay<_Tp>::type; +#endif // > C++17 + +template +struct __unwrap_ref_decay +#if _LIBCPP_STD_VER > 17 + : unwrap_ref_decay<_Tp> +#else + : __unwrap_reference::type> +#endif +{ }; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___FUNCTIONAL_UNWRAP_REF_H diff --git a/gnu/llvm/libcxx/include/__functional/weak_result_type.h b/gnu/llvm/libcxx/include/__functional/weak_result_type.h new file mode 100644 index 00000000000..2ee85acf1ef --- /dev/null +++ b/gnu/llvm/libcxx/include/__functional/weak_result_type.h @@ -0,0 +1,481 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL_WEAK_RESULT_TYPE_H +#define _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H + +#include <__config> +#include <__functional/binary_function.h> +#include <__functional/unary_function.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct __has_result_type +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::result_type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + +// __weak_result_type + +template +struct __derives_from_unary_function +{ +private: + struct __two {char __lx; char __lxx;}; + static __two __test(...); + template + static unary_function<_Ap, _Rp> + __test(const volatile unary_function<_Ap, _Rp>*); +public: + static const bool value = !is_same::value; + typedef decltype(__test((_Tp*)0)) type; +}; + +template +struct __derives_from_binary_function +{ +private: + struct __two {char __lx; char __lxx;}; + static __two __test(...); + template + static binary_function<_A1, _A2, _Rp> + __test(const volatile binary_function<_A1, _A2, _Rp>*); +public: + static const bool value = !is_same::value; + typedef decltype(__test((_Tp*)0)) type; +}; + +template ::value> +struct __maybe_derive_from_unary_function // bool is true + : public __derives_from_unary_function<_Tp>::type +{ +}; + +template +struct __maybe_derive_from_unary_function<_Tp, false> +{ +}; + +template ::value> +struct __maybe_derive_from_binary_function // bool is true + : public __derives_from_binary_function<_Tp>::type +{ +}; + +template +struct __maybe_derive_from_binary_function<_Tp, false> +{ +}; + +template ::value> +struct __weak_result_type_imp // bool is true + : public __maybe_derive_from_unary_function<_Tp>, + public __maybe_derive_from_binary_function<_Tp> +{ + typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type; +}; + +template +struct __weak_result_type_imp<_Tp, false> + : public __maybe_derive_from_unary_function<_Tp>, + public __maybe_derive_from_binary_function<_Tp> +{ +}; + +template +struct __weak_result_type + : public __weak_result_type_imp<_Tp> +{ +}; + +// 0 argument case + +template +struct __weak_result_type<_Rp ()> +{ + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (&)()> +{ + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (*)()> +{ + typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; +}; + +// 1 argument case + +template +struct __weak_result_type<_Rp (_A1)> + : public unary_function<_A1, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (&)(_A1)> + : public unary_function<_A1, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (*)(_A1)> + : public unary_function<_A1, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)()> + : public unary_function<_Cp*, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)() const> + : public unary_function +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)() volatile> + : public unary_function +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)() const volatile> + : public unary_function +{ +}; + +// 2 argument case + +template +struct __weak_result_type<_Rp (_A1, _A2)> + : public binary_function<_A1, _A2, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (*)(_A1, _A2)> + : public binary_function<_A1, _A2, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (&)(_A1, _A2)> + : public binary_function<_A1, _A2, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1)> + : public binary_function<_Cp*, _A1, _Rp> +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1) const> + : public binary_function +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> + : public binary_function +{ +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> + : public binary_function +{ +}; + + +#ifndef _LIBCPP_CXX03_LANG +// 3 or more arguments + +template +struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)> +{ + typedef _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> +{ + typedef _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> +{ + typedef _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> +{ + typedef _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> +{ + typedef _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> +{ + typedef _Rp result_type; +}; + +template +struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> +{ + typedef _Rp result_type; +}; + +template +struct __invoke_return +{ + typedef decltype(_VSTD::__invoke(declval<_Tp>(), declval<_Args>()...)) type; +}; + +#else // defined(_LIBCPP_CXX03_LANG) + +template +struct __enable_invoke_imp; + +template +struct __enable_invoke_imp<_Ret, _T1, true, true> { + typedef _Ret _Bullet1; + typedef _Bullet1 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, true, false> { + typedef _Ret _Bullet2; + typedef _Bullet2 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, false, true> { + typedef typename add_lvalue_reference< + typename __apply_cv<_T1, _Ret>::type + >::type _Bullet3; + typedef _Bullet3 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1, false, false> { + typedef typename add_lvalue_reference< + typename __apply_cv()), _Ret>::type + >::type _Bullet4; + typedef _Bullet4 type; +}; + +template +struct __enable_invoke_imp<_Ret, _T1*, false, false> { + typedef typename add_lvalue_reference< + typename __apply_cv<_T1, _Ret>::type + >::type _Bullet4; + typedef _Bullet4 type; +}; + +template , + class _Ret = typename _Traits::_ReturnType, + class _Class = typename _Traits::_ClassType> +struct __enable_invoke : __enable_invoke_imp< + _Ret, _T1, + is_member_function_pointer<_Fn>::value, + is_base_of<_Class, typename remove_reference<_T1>::type>::value> +{ +}; + +__nat __invoke(__any, ...); + +// first bullet + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1) { + return (__t1.*__f)(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { + return (__t1.*__f)(__a0); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { + return (__t1.*__f)(__a0, __a1); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { + return (__t1.*__f)(__a0, __a1, __a2); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1) { + return ((*__t1).*__f)(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { + return ((*__t1).*__f)(__a0); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { + return ((*__t1).*__f)(__a0, __a1); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { + return ((*__t1).*__f)(__a0, __a1, __a2); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet3 +__invoke(_Fn __f, _T1& __t1) { + return __t1.*__f; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename __enable_invoke<_Fn, _T1>::_Bullet4 +__invoke(_Fn __f, _T1& __t1) { + return (*__t1).*__f; +} + +// fifth bullet + +template +inline _LIBCPP_INLINE_VISIBILITY +decltype(declval<_Fp&>()()) +__invoke(_Fp& __f) +{ + return __f(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +decltype(declval<_Fp&>()(declval<_A0&>())) +__invoke(_Fp& __f, _A0& __a0) +{ + return __f(__a0); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>())) +__invoke(_Fp& __f, _A0& __a0, _A1& __a1) +{ + return __f(__a0, __a1); +} + +template +inline _LIBCPP_INLINE_VISIBILITY +decltype(declval<_Fp&>()(declval<_A0&>(), declval<_A1&>(), declval<_A2&>())) +__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) +{ + return __f(__a0, __a1, __a2); +} + +template >::value> +struct __invoke_return +{ + typedef typename __weak_result_type<_Fp>::result_type type; +}; + +template +struct __invoke_return<_Fp, false> +{ + typedef decltype(_VSTD::__invoke(declval<_Fp&>())) type; +}; + +template +struct __invoke_return0 +{ + typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>())) type; +}; + +template +struct __invoke_return0<_Rp _Tp::*, _A0> +{ + typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; +}; + +template +struct __invoke_return1 +{ + typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(), + declval<_A1&>())) type; +}; + +template +struct __invoke_return1<_Rp _Class::*, _A0, _A1> { + typedef typename __enable_invoke<_Rp _Class::*, _A0>::type type; +}; + +template +struct __invoke_return2 +{ + typedef decltype(_VSTD::__invoke(declval<_Tp&>(), declval<_A0&>(), + declval<_A1&>(), + declval<_A2&>())) type; +}; + +template +struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { + typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; +}; + +#endif // !defined(_LIBCPP_CXX03_LANG) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H diff --git a/gnu/llvm/libcxx/include/__functional_base b/gnu/llvm/libcxx/include/__functional_base index f591bf5a9dc..ccc3f3a58ca 100644 --- a/gnu/llvm/libcxx/include/__functional_base +++ b/gnu/llvm/libcxx/include/__functional_base @@ -11,642 +11,22 @@ #define _LIBCPP_FUNCTIONAL_BASE #include <__config> -#include -#include +#include <__functional/binary_function.h> +#include <__functional/invoke.h> +#include <__functional/operations.h> +#include <__functional/reference_wrapper.h> +#include <__functional/unary_function.h> +#include <__functional/weak_result_type.h> +#include <__memory/allocator_arg_t.h> +#include <__memory/uses_allocator.h> #include #include +#include +#include #include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD - -template -struct _LIBCPP_TEMPLATE_VIS binary_function -{ - typedef _Arg1 first_argument_type; - typedef _Arg2 second_argument_type; - typedef _Result result_type; -}; - -template -struct __has_result_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::result_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -#if _LIBCPP_STD_VER > 11 -template -#else -template -#endif -struct _LIBCPP_TEMPLATE_VIS less : binary_function<_Tp, _Tp, bool> -{ - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY - bool operator()(const _Tp& __x, const _Tp& __y) const - {return __x < __y;} -}; - -#if _LIBCPP_STD_VER > 11 -template <> -struct _LIBCPP_TEMPLATE_VIS less -{ - template - _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY - auto operator()(_T1&& __t, _T2&& __u) const - _NOEXCEPT_(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))) - -> decltype (_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)) - { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } - typedef void is_transparent; -}; -#endif - -// __weak_result_type - -template -struct __derives_from_unary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static unary_function<_Ap, _Rp> - __test(const volatile unary_function<_Ap, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template -struct __derives_from_binary_function -{ -private: - struct __two {char __lx; char __lxx;}; - static __two __test(...); - template - static binary_function<_A1, _A2, _Rp> - __test(const volatile binary_function<_A1, _A2, _Rp>*); -public: - static const bool value = !is_same::value; - typedef decltype(__test((_Tp*)0)) type; -}; - -template ::value> -struct __maybe_derive_from_unary_function // bool is true - : public __derives_from_unary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_unary_function<_Tp, false> -{ -}; - -template ::value> -struct __maybe_derive_from_binary_function // bool is true - : public __derives_from_binary_function<_Tp>::type -{ -}; - -template -struct __maybe_derive_from_binary_function<_Tp, false> -{ -}; - -template ::value> -struct __weak_result_type_imp // bool is true - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ - typedef _LIBCPP_NODEBUG_TYPE typename _Tp::result_type result_type; -}; - -template -struct __weak_result_type_imp<_Tp, false> - : public __maybe_derive_from_unary_function<_Tp>, - public __maybe_derive_from_binary_function<_Tp> -{ -}; - -template -struct __weak_result_type - : public __weak_result_type_imp<_Tp> -{ -}; - -// 0 argument case - -template -struct __weak_result_type<_Rp ()> -{ - typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)()> -{ - typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)()> -{ - typedef _LIBCPP_NODEBUG_TYPE _Rp result_type; -}; - -// 1 argument case - -template -struct __weak_result_type<_Rp (_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1)> - : public unary_function<_A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)()> - : public unary_function<_Cp*, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() volatile> - : public unary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)() const volatile> - : public unary_function -{ -}; - -// 2 argument case - -template -struct __weak_result_type<_Rp (_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2)> - : public binary_function<_A1, _A2, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1)> - : public binary_function<_Cp*, _A1, _Rp> -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> - : public binary_function -{ -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> - : public binary_function -{ -}; - - -#ifndef _LIBCPP_CXX03_LANG -// 3 or more arguments - -template -struct __weak_result_type<_Rp (_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> -{ - typedef _Rp result_type; -}; - -template -struct __invoke_return -{ - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; -}; - -#else // defined(_LIBCPP_CXX03_LANG) - -#include <__functional_base_03> - -#endif // !defined(_LIBCPP_CXX03_LANG) - - -template -struct __invoke_void_return_wrapper -{ -#ifndef _LIBCPP_CXX03_LANG - template - static _Ret __call(_Args&&... __args) { - return __invoke(_VSTD::forward<_Args>(__args)...); - } -#else - template - static _Ret __call(_Fn __f) { - return __invoke(__f); - } - - template - static _Ret __call(_Fn __f, _A0& __a0) { - return __invoke(__f, __a0); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1) { - return __invoke(__f, __a0, __a1); - } - - template - static _Ret __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2){ - return __invoke(__f, __a0, __a1, __a2); - } -#endif -}; - -template <> -struct __invoke_void_return_wrapper -{ -#ifndef _LIBCPP_CXX03_LANG - template - static void __call(_Args&&... __args) { - __invoke(_VSTD::forward<_Args>(__args)...); - } -#else - template - static void __call(_Fn __f) { - __invoke(__f); - } - - template - static void __call(_Fn __f, _A0& __a0) { - __invoke(__f, __a0); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1) { - __invoke(__f, __a0, __a1); - } - - template - static void __call(_Fn __f, _A0& __a0, _A1& __a1, _A2& __a2) { - __invoke(__f, __a0, __a1, __a2); - } -#endif -}; - -template -class _LIBCPP_TEMPLATE_VIS reference_wrapper - : public __weak_result_type<_Tp> -{ -public: - // types - typedef _Tp type; -private: - type* __f_; - -public: - // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT - : __f_(_VSTD::addressof(__f)) {} -#ifndef _LIBCPP_CXX03_LANG - private: reference_wrapper(type&&); public: // = delete; // do not bind to temps -#endif - - // access - _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;} - _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;} - -#ifndef _LIBCPP_CXX03_LANG - // invoke - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_of::type - operator() (_ArgTypes&&... __args) const { - return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); - } -#else - - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return::type - operator() () const { - return __invoke(get()); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0& __a0) const { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return0::type - operator() (_A0 const& __a0) const { - return __invoke(get(), __a0); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0 const& __a0, _A1& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0& __a0, _A1 const& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return1::type - operator() (_A0 const& __a0, _A1 const& __a1) const { - return __invoke(get(), __a0, __a1); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } - - template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return2::type - operator() (_A0 const& __a0, _A1 const& __a1, _A2 const& __a2) const { - return __invoke(get(), __a0, __a1, __a2); - } -#endif // _LIBCPP_CXX03_LANG -}; - - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(_Tp& __t) _NOEXCEPT -{ - return reference_wrapper<_Tp>(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(reference_wrapper<_Tp> __t) _NOEXCEPT -{ - return _VSTD::ref(__t.get()); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(const _Tp& __t) _NOEXCEPT -{ - return reference_wrapper(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(reference_wrapper<_Tp> __t) _NOEXCEPT -{ - return _VSTD::cref(__t.get()); -} - -#ifndef _LIBCPP_CXX03_LANG -template void ref(const _Tp&&) = delete; -template void cref(const _Tp&&) = delete; -#endif - -#if _LIBCPP_STD_VER > 11 -template -struct __is_transparent : false_type {}; - -template -struct __is_transparent<_Tp, _Up, - typename __void_t::type> - : true_type {}; -#endif - -// allocator_arg_t - -struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; }; - -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; -#else -/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); -#endif - -// uses_allocator - -template -struct __has_allocator_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template ::value> -struct __uses_allocator - : public integral_constant::value> -{ -}; - -template -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#if _LIBCPP_STD_VER > 14 -template -_LIBCPP_INLINE_VAR constexpr size_t uses_allocator_v = uses_allocator<_Tp, _Alloc>::value; -#endif - -#ifndef _LIBCPP_CXX03_LANG - -// allocator construction - -template -struct __uses_alloc_ctor_imp -{ - 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; - static const int value = __ua ? 2 - __ic : 0; -}; - -template -struct __uses_alloc_ctor - : integral_constant::value> - {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &, _Args &&... __args ) -{ - new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); -} - -// FIXME: This should have a version which takes a non-const alloc. -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); -} - -// FIXME: This should have a version which takes a non-const alloc. -template -inline _LIBCPP_INLINE_VISIBILITY -void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) -{ - new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); -} - -#endif // _LIBCPP_CXX03_LANG - -_LIBCPP_END_NAMESPACE_STD - -#endif // _LIBCPP_FUNCTIONAL_BASE +#endif // _LIBCPP_FUNCTIONAL_BASE diff --git a/gnu/llvm/libcxx/include/__hash_table b/gnu/llvm/libcxx/include/__hash_table index 13ff096897b..df0f7c80db2 100644 --- a/gnu/llvm/libcxx/include/__hash_table +++ b/gnu/llvm/libcxx/include/__hash_table @@ -10,16 +10,16 @@ #ifndef _LIBCPP__HASH_TABLE #define _LIBCPP__HASH_TABLE +#include <__bits> // __libcpp_clz #include <__config> -#include -#include -#include +#include <__debug> #include #include -#include +#include +#include +#include #include - -#include <__debug> +#include #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -34,19 +34,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct __hash_value_type; -#ifndef _LIBCPP_CXX03_LANG template struct __is_hash_value_type_imp : false_type {}; template -struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value>> : true_type {}; +struct __is_hash_value_type_imp<__hash_value_type<_Key, _Value> > : true_type {}; template struct __is_hash_value_type : false_type {}; template struct __is_hash_value_type<_One> : __is_hash_value_type_imp::type> {}; -#endif _LIBCPP_FUNC_VIS size_t __next_prime(size_t __n); @@ -91,7 +89,7 @@ struct __hash_node_base }; template -struct __hash_node +struct _LIBCPP_STANDALONE_DEBUG __hash_node : public __hash_node_base < typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type @@ -122,7 +120,7 @@ inline _LIBCPP_INLINE_VISIBILITY size_t __next_hash_pow2(size_t __n) { - return __n < 2 ? __n : (size_t(1) << (std::numeric_limits::digits - __libcpp_clz(__n-1))); + return __n < 2 ? __n : (size_t(1) << (numeric_limits::digits - __libcpp_clz(__n-1))); } @@ -155,12 +153,10 @@ struct __hash_key_value_types { static __container_value_type* __get_ptr(__node_value_type& __n) { return _VSTD::addressof(__n); } -#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY static __container_value_type&& __move(__node_value_type& __v) { return _VSTD::move(__v); } -#endif }; template @@ -197,13 +193,10 @@ struct __hash_key_value_types<__hash_value_type<_Key, _Tp> > { static __container_value_type* __get_ptr(__node_value_type& __n) { return _VSTD::addressof(__n.__get_value()); } -#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY static pair __move(__node_value_type& __v) { return __v.__move(); } -#endif - }; template , @@ -295,10 +288,12 @@ public: typedef typename _NodeTypes::__node_value_type_pointer pointer; _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_iterator(const __hash_iterator& __i) : __node_(__i.__node_) @@ -322,7 +317,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif // _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -341,7 +336,7 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_iterator& operator++() { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container iterator"); + "Attempted to increment a non-incrementable unordered container iterator"); __node_ = __node_->__next_; return *this; } @@ -364,7 +359,7 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_iterator(__next_pointer __node, const void* __c) _NOEXCEPT : __node_(__node) @@ -405,17 +400,21 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(const __non_const_iterator& __x) _NOEXCEPT : __node_(__x.__node_) { - _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__iterator_copy(this, &__x); +#endif } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(const __hash_const_iterator& __i) : __node_(__i.__node_) @@ -439,7 +438,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif // _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -457,7 +456,7 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_iterator& operator++() { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container const_iterator"); + "Attempted to increment a non-incrementable unordered container const_iterator"); __node_ = __node_->__next_; return *this; } @@ -480,7 +479,7 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_const_iterator(__next_pointer __node, const void* __c) _NOEXCEPT : __node_(__node) @@ -518,10 +517,12 @@ public: typedef typename _NodeTypes::__node_value_type_pointer pointer; _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(const __hash_local_iterator& __i) : __node_(__i.__node_), @@ -549,7 +550,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif // _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -568,7 +569,7 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_local_iterator& operator++() { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container local_iterator"); + "Attempted to increment a non-incrementable unordered container local_iterator"); __node_ = __node_->__next_; if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) __node_ = nullptr; @@ -593,7 +594,7 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_local_iterator(__next_pointer __node, size_t __bucket, size_t __bucket_count, const void* __c) _NOEXCEPT @@ -650,7 +651,9 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT : __node_(nullptr) { - _LIBCPP_DEBUG_MODE(__get_db()->__insert_i(this)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif } _LIBCPP_INLINE_VISIBILITY @@ -659,10 +662,12 @@ public: __bucket_(__x.__bucket_), __bucket_count_(__x.__bucket_count_) { - _LIBCPP_DEBUG_MODE(__get_db()->__iterator_copy(this, &__x)); +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__iterator_copy(this, &__x); +#endif } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator(const __hash_const_local_iterator& __i) : __node_(__i.__node_), @@ -690,7 +695,7 @@ public: } return *this; } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif // _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY reference operator*() const { @@ -709,7 +714,7 @@ public: _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator& operator++() { _LIBCPP_DEBUG_ASSERT(__get_const_db()->__dereferenceable(this), - "Attempted to increment non-incrementable unordered container const_local_iterator"); + "Attempted to increment a non-incrementable unordered container const_local_iterator"); __node_ = __node_->__next_; if (__node_ != nullptr && __constrain_hash(__node_->__hash(), __bucket_count_) != __bucket_) __node_ = nullptr; @@ -734,11 +739,11 @@ public: {return !(__x == __y);} private: -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(__next_pointer __node, size_t __bucket, + __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, size_t __bucket_count, const void* __c) _NOEXCEPT - : __node_(__node), + : __node_(__node_ptr), __bucket_(__bucket), __bucket_count_(__bucket_count) { @@ -748,9 +753,9 @@ private: } #else _LIBCPP_INLINE_VISIBILITY - __hash_const_local_iterator(__next_pointer __node, size_t __bucket, + __hash_const_local_iterator(__next_pointer __node_ptr, size_t __bucket, size_t __bucket_count) _NOEXCEPT - : __node_(__node), + : __node_(__node_ptr), __bucket_(__bucket), __bucket_count_(__bucket_count) { @@ -783,7 +788,6 @@ public: _NOEXCEPT_(is_nothrow_copy_constructible::value) : __data_(__size, __a) {} -#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY __bucket_list_deallocator(__bucket_list_deallocator&& __x) _NOEXCEPT_(is_nothrow_move_constructible::value) @@ -791,7 +795,6 @@ public: { __x.size() = 0; } -#endif _LIBCPP_INLINE_VISIBILITY size_type& size() _NOEXCEPT {return __data_.first();} @@ -1007,7 +1010,6 @@ public: explicit __hash_table(const allocator_type& __a); __hash_table(const __hash_table& __u); __hash_table(const __hash_table& __u, const allocator_type& __a); -#ifndef _LIBCPP_CXX03_LANG __hash_table(__hash_table&& __u) _NOEXCEPT_( is_nothrow_move_constructible<__bucket_list>::value && @@ -1016,11 +1018,9 @@ public: is_nothrow_move_constructible::value && is_nothrow_move_constructible::value); __hash_table(__hash_table&& __u, const allocator_type& __a); -#endif // _LIBCPP_CXX03_LANG ~__hash_table(); __hash_table& operator=(const __hash_table& __u); -#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY __hash_table& operator=(__hash_table&& __u) _NOEXCEPT_( @@ -1028,7 +1028,6 @@ public: is_nothrow_move_assignable<__node_allocator>::value && is_nothrow_move_assignable::value && is_nothrow_move_assignable::value); -#endif template void __assign_unique(_InputIterator __first, _InputIterator __last); template @@ -1037,7 +1036,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT { - return std::min( + return _VSTD::min( __node_traits::max_size(__node_alloc()), numeric_limits::max() ); @@ -1066,7 +1065,6 @@ public: iterator __node_insert_multi(const_iterator __p, __node_pointer __nd); -#ifndef _LIBCPP_CXX03_LANG template _LIBCPP_INLINE_VISIBILITY pair __emplace_unique_key_args(_Key const& __k, _Args&&... __args); @@ -1151,15 +1149,6 @@ public: return __emplace_hint_multi(__p, _VSTD::forward<_Pp>(__x)); } -#else // !defined(_LIBCPP_CXX03_LANG) - template - _LIBCPP_INLINE_VISIBILITY - pair __emplace_unique_key_args(_Key const&, _Args& __args); - - iterator __insert_multi(const __container_value_type& __x); - iterator __insert_multi(const_iterator __p, const __container_value_type& __x); -#endif - _LIBCPP_INLINE_VISIBILITY pair __insert_unique(const __container_value_type& __x) { return __emplace_unique_key_args(_NodeTypes::__get_key(__x), __x); @@ -1295,7 +1284,7 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::begin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return local_iterator(__bucket_list_[__n], __n, bucket_count(), this); #else return local_iterator(__bucket_list_[__n], __n, bucket_count()); @@ -1308,7 +1297,7 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::end(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return local_iterator(nullptr, __n, bucket_count(), this); #else return local_iterator(nullptr, __n, bucket_count()); @@ -1321,7 +1310,7 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::cbegin(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return const_local_iterator(__bucket_list_[__n], __n, bucket_count(), this); #else return const_local_iterator(__bucket_list_[__n], __n, bucket_count()); @@ -1334,35 +1323,30 @@ public: { _LIBCPP_ASSERT(__n < bucket_count(), "unordered container::cend(n) called with n >= bucket_count()"); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return const_local_iterator(nullptr, __n, bucket_count(), this); #else return const_local_iterator(nullptr, __n, bucket_count()); #endif } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 bool __dereferenceable(const const_iterator* __i) const; bool __decrementable(const const_iterator* __i) const; bool __addable(const const_iterator* __i, ptrdiff_t __n) const; bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif // _LIBCPP_DEBUG_LEVEL == 2 private: void __rehash(size_type __n); -#ifndef _LIBCPP_CXX03_LANG template __node_holder __construct_node(_Args&& ...__args); template __node_holder __construct_node_hash(size_t __hash, _First&& __f, _Rest&&... __rest); -#else // _LIBCPP_CXX03_LANG - __node_holder __construct_node(const __container_value_type& __v); - __node_holder __construct_node_hash(size_t __hash, const __container_value_type& __v); -#endif _LIBCPP_INLINE_VISIBILITY @@ -1373,7 +1357,6 @@ private: _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const __hash_table&, false_type) {} -#ifndef _LIBCPP_CXX03_LANG void __move_assign(__hash_table& __u, false_type); void __move_assign(__hash_table& __u, true_type) _NOEXCEPT_( @@ -1400,7 +1383,6 @@ private: } _LIBCPP_INLINE_VISIBILITY void __move_assign_alloc(__hash_table&, false_type) _NOEXCEPT {} -#endif // _LIBCPP_CXX03_LANG void __deallocate_node(__next_pointer __np) _NOEXCEPT; __next_pointer __detach() _NOEXCEPT; @@ -1477,8 +1459,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const __hash_table& __u, { } -#ifndef _LIBCPP_CXX03_LANG - template __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_( @@ -1526,8 +1506,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u, } } -#endif // _LIBCPP_CXX03_LANG - template __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() { @@ -1539,7 +1517,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::~__hash_table() #endif __deallocate_node(__p1_.first().__next_); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 __get_db()->__erase_c(this); #endif } @@ -1583,7 +1561,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) while (__np != nullptr) { __next_pointer __next = __np->__next_; -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __p = __c->end_; __p != __c->beg_; ) { @@ -1593,7 +1571,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__deallocate_node(__next_pointer __np) { (*__p)->__c_ = nullptr; if (--__c->end_ != __p) - memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); + _VSTD::memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -1618,8 +1596,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__detach() _NOEXCEPT return __cache; } -#ifndef _LIBCPP_CXX03_LANG - template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( @@ -1646,7 +1622,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __u.__p1_.first().__next_ = nullptr; __u.size() = 0; } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 __get_db()->swap(this, &__u); #endif } @@ -1669,7 +1645,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( #ifndef _LIBCPP_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_NO_EXCEPTIONS const_iterator __i = __u.begin(); while (__cache != nullptr && __u.size() != 0) { @@ -1686,7 +1662,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( __deallocate_node(__cache); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_NO_EXCEPTIONS __deallocate_node(__cache); } const_iterator __i = __u.begin(); @@ -1714,8 +1690,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) return *this; } -#endif // _LIBCPP_CXX03_LANG - template template void @@ -1733,7 +1707,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first #ifndef _LIBCPP_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__upcast()->__value_ = *__first; @@ -1748,7 +1722,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_unique(_InputIterator __first __deallocate_node(__cache); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_NO_EXCEPTIONS __deallocate_node(__cache); } for (; __first != __last; ++__first) @@ -1773,7 +1747,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, #ifndef _LIBCPP_NO_EXCEPTIONS try { -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_NO_EXCEPTIONS for (; __cache != nullptr && __first != __last; ++__first) { __cache->__upcast()->__value_ = *__first; @@ -1788,7 +1762,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, __deallocate_node(__cache); throw; } -#endif // _LIBCPP_NO_EXCEPTIONS +#endif // _LIBCPP_NO_EXCEPTIONS __deallocate_node(__cache); } for (; __first != __last; ++__first) @@ -1800,7 +1774,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(__p1_.first().__next_, this); #else return iterator(__p1_.first().__next_); @@ -1812,7 +1786,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(nullptr, this); #else return iterator(nullptr); @@ -1824,7 +1798,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return const_iterator(__p1_.first().__next_, this); #else return const_iterator(__p1_.first().__next_); @@ -1836,7 +1810,7 @@ inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return const_iterator(nullptr, this); #else return const_iterator(nullptr); @@ -1945,7 +1919,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ __existing_node = __nd->__ptr(); __inserted = true; } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return pair(iterator(__existing_node, this), __inserted); #else return pair(iterator(__existing_node), __inserted); @@ -1955,7 +1929,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_unique(__node_pointer __ // Prepare the container for an insertion of the value __cp_val with the hash // __cp_hash. This does a lookup into the container to see if __cp_value is // already present, and performs a rehash if necessary. Returns a pointer to the -// last occurance of __cp_val in the map. +// last occurrence of __cp_val in the map. // // Note that this function does forward exceptions if key_eq() throws, and never // mutates __value or actually inserts into the map. @@ -2043,7 +2017,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi(__node_pointer __c __next_pointer __pn = __node_insert_multi_prepare(__cp->__hash(), __cp->__value_); __node_insert_multi_perform(__cp, __pn); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(__cp->__ptr(), this); #else return iterator(__cp->__ptr()); @@ -2055,7 +2029,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( const_iterator __p, __node_pointer __cp) { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" " referring to this unordered container"); @@ -2078,7 +2052,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( __cp->__next_ = __np; __pp->__next_ = static_cast<__next_pointer>(__cp); ++size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(static_cast<__next_pointer>(__cp), this); #else return iterator(static_cast<__next_pointer>(__cp)); @@ -2089,17 +2063,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_insert_multi( -#ifndef _LIBCPP_CXX03_LANG template template pair::iterator, bool> __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args&&... __args) -#else -template -template -pair::iterator, bool> -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __k, _Args& __args) -#endif { size_t __hash = hash_function()(__k); @@ -2123,11 +2090,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& } } { -#ifndef _LIBCPP_CXX03_LANG __node_holder __h = __construct_node_hash(__hash, _VSTD::forward<_Args>(__args)...); -#else - __node_holder __h = __construct_node_hash(__hash, __args); -#endif if (size()+1 > __bc * max_load_factor() || __bc == 0) { rehash(_VSTD::max(2 * __bc + !__is_hash_power2(__bc), @@ -2159,15 +2122,13 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_unique_key_args(_Key const& __inserted = true; } __done: -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return pair(iterator(__nd, this), __inserted); #else return pair(iterator(__nd), __inserted); #endif } -#ifndef _LIBCPP_CXX03_LANG - template template pair::iterator, bool> @@ -2197,7 +2158,7 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( const_iterator __p, _Args&&... __args) { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container::emplace_hint(const_iterator, args...) called with an iterator not" " referring to this unordered container"); @@ -2208,36 +2169,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__emplace_hint_multi( return __r; } -#else // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const __container_value_type& __x) -{ - __node_holder __h = __construct_node(__x); - iterator __r = __node_insert_multi(__h.get()); - __h.release(); - return __r; -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__insert_multi(const_iterator __p, - const __container_value_type& __x) -{ -#if _LIBCPP_DEBUG_LEVEL >= 2 - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered container::insert(const_iterator, lvalue) called with an iterator not" - " referring to this unordered container"); -#endif - __node_holder __h = __construct_node(__x); - iterator __r = __node_insert_multi(__p, __h.get()); - __h.release(); - return __r; -} - -#endif // _LIBCPP_CXX03_LANG - #if _LIBCPP_STD_VER > 14 template template @@ -2368,7 +2299,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_handle_merge_multi( __node_insert_multi_perform(__src_ptr, __pn); } } -#endif // _LIBCPP_STD_VER > 14 +#endif // _LIBCPP_STD_VER > 14 template void @@ -2399,9 +2330,9 @@ template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::__rehash(size_type __nbc) { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 __get_db()->__invalidate_all(this); -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif __pointer_allocator& __npa = __bucket_list_.get_deleter().__alloc(); __bucket_list_.reset(__nbc > 0 ? __pointer_alloc_traits::allocate(__npa, __nbc) : nullptr); @@ -2470,7 +2401,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) { if ((__nd->__hash() == __hash) && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return iterator(__nd, this); #else return iterator(__nd); @@ -2501,7 +2432,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const { if ((__nd->__hash() == __hash) && key_eq()(__nd->__upcast()->__value_, __k)) -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return const_iterator(__nd, this); #else return const_iterator(__nd); @@ -2513,8 +2444,6 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::find(const _Key& __k) const return end(); } -#ifndef _LIBCPP_CXX03_LANG - template template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder @@ -2550,43 +2479,12 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash( return __h; } -#else // _LIBCPP_CXX03_LANG - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = hash_function()(__h->__value_); - __h->__next_ = nullptr; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -template -typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::__node_holder -__hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node_hash(size_t __hash, - const __container_value_type& __v) -{ - __node_allocator& __na = __node_alloc(); - __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); - __node_traits::construct(__na, _NodeTypes::__get_ptr(__h->__value_), __v); - __h.get_deleter().__value_constructed = true; - __h->__hash_ = __hash; - __h->__next_ = nullptr; - return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 -} - -#endif // _LIBCPP_CXX03_LANG - template typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __p) { __next_pointer __np = __p.__node_; -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered container erase(iterator) called with an iterator not" " referring to this container"); @@ -2606,13 +2504,13 @@ typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, const_iterator __last) { -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, - "unodered container::erase(iterator, iterator) called with an iterator not" - " referring to this unodered container"); + "unordered container::erase(iterator, iterator) called with an iterator not" + " referring to this container"); _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__last) == this, - "unodered container::erase(iterator, iterator) called with an iterator not" - " referring to this unodered container"); + "unordered container::erase(iterator, iterator) called with an iterator not" + " referring to this container"); #endif for (const_iterator __p = __first; __first != __last; __p = __first) { @@ -2620,7 +2518,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::erase(const_iterator __first, erase(__p); } __next_pointer __np = __last.__node_; -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 return iterator (__np, this); #else return iterator (__np); @@ -2691,7 +2589,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT __pn->__next_ = __cn->__next_; __cn->__next_ = nullptr; --size(); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 __c_node* __c = __get_db()->__find_c_and_lock(this); for (__i_node** __dp = __c->end_; __dp != __c->beg_; ) { @@ -2701,7 +2599,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT { (*__dp)->__c_ = nullptr; if (--__c->end_ != __dp) - memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*)); + _VSTD::memmove(__dp, __dp+1, (__c->end_ - __dp)*sizeof(__i_node*)); } } __get_db()->unlock(); @@ -2830,9 +2728,9 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) __u.__bucket_list_.reset(__npp); } _VSTD::swap(__bucket_list_.get_deleter().size(), __u.__bucket_list_.get_deleter().size()); - __swap_allocator(__bucket_list_.get_deleter().__alloc(), + _VSTD::__swap_allocator(__bucket_list_.get_deleter().__alloc(), __u.__bucket_list_.get_deleter().__alloc()); - __swap_allocator(__node_alloc(), __u.__node_alloc()); + _VSTD::__swap_allocator(__node_alloc(), __u.__node_alloc()); _VSTD::swap(__p1_.first().__next_, __u.__p1_.first().__next_); __p2_.swap(__u.__p2_); __p3_.swap(__u.__p3_); @@ -2842,7 +2740,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) if (__u.size() > 0) __u.__bucket_list_[__constrain_hash(__u.__p1_.first().__next_->__hash(), __u.bucket_count())] = __u.__p1_.first().__ptr(); -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 __get_db()->swap(this, &__u); #endif } @@ -2876,7 +2774,7 @@ swap(__hash_table<_Tp, _Hash, _Equal, _Alloc>& __x, __x.swap(__y); } -#if _LIBCPP_DEBUG_LEVEL >= 2 +#if _LIBCPP_DEBUG_LEVEL == 2 template bool @@ -2906,10 +2804,10 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__subscriptable(const const_iterator*, return false; } -#endif // _LIBCPP_DEBUG_LEVEL >= 2 +#endif // _LIBCPP_DEBUG_LEVEL == 2 _LIBCPP_END_NAMESPACE_STD _LIBCPP_POP_MACROS -#endif // _LIBCPP__HASH_TABLE +#endif // _LIBCPP__HASH_TABLE diff --git a/gnu/llvm/libcxx/include/__iterator/access.h b/gnu/llvm/libcxx/include/__iterator/access.h new file mode 100644 index 00000000000..c0576b45902 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/access.h @@ -0,0 +1,134 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ACCESS_H +#define _LIBCPP___ITERATOR_ACCESS_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp* +begin(_Tp (&__array)[_Np]) +{ + return __array; +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +_Tp* +end(_Tp (&__array)[_Np]) +{ + return __array + _Np; +} + +#if !defined(_LIBCPP_CXX03_LANG) + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +begin(_Cp& __c) -> decltype(__c.begin()) +{ + return __c.begin(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +begin(const _Cp& __c) -> decltype(__c.begin()) +{ + return __c.begin(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +end(_Cp& __c) -> decltype(__c.end()) +{ + return __c.end(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +end(const _Cp& __c) -> decltype(__c.end()) +{ + return __c.end(); +} + +#if _LIBCPP_STD_VER > 11 + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +auto cbegin(const _Cp& __c) -> decltype(_VSTD::begin(__c)) +{ + return _VSTD::begin(__c); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +auto cend(const _Cp& __c) -> decltype(_VSTD::end(__c)) +{ + return _VSTD::end(__c); +} + +#endif + + +#else // defined(_LIBCPP_CXX03_LANG) + +template +_LIBCPP_INLINE_VISIBILITY +typename _Cp::iterator +begin(_Cp& __c) +{ + return __c.begin(); +} + +template +_LIBCPP_INLINE_VISIBILITY +typename _Cp::const_iterator +begin(const _Cp& __c) +{ + return __c.begin(); +} + +template +_LIBCPP_INLINE_VISIBILITY +typename _Cp::iterator +end(_Cp& __c) +{ + return __c.end(); +} + +template +_LIBCPP_INLINE_VISIBILITY +typename _Cp::const_iterator +end(const _Cp& __c) +{ + return __c.end(); +} + +#endif // !defined(_LIBCPP_CXX03_LANG) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ACCESS_H diff --git a/gnu/llvm/libcxx/include/__iterator/advance.h b/gnu/llvm/libcxx/include/__iterator/advance.h new file mode 100644 index 00000000000..47bce1ddfbe --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/advance.h @@ -0,0 +1,200 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ADVANCE_H +#define _LIBCPP___ITERATOR_ADVANCE_H + +#include <__config> +#include <__debug> +#include <__function_like.h> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <__utility/move.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void __advance(_InputIter& __i, typename iterator_traits<_InputIter>::difference_type __n, input_iterator_tag) { + for (; __n > 0; --__n) + ++__i; +} + +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void __advance(_BiDirIter& __i, typename iterator_traits<_BiDirIter>::difference_type __n, bidirectional_iterator_tag) { + if (__n >= 0) + for (; __n > 0; --__n) + ++__i; + else + for (; __n < 0; ++__n) + --__i; +} + +template +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void __advance(_RandIter& __i, typename iterator_traits<_RandIter>::difference_type __n, random_access_iterator_tag) { + __i += __n; +} + +template < + class _InputIter, class _Distance, + class _IntegralDistance = decltype(_VSTD::__convert_to_integral(declval<_Distance>())), + class = _EnableIf::value> > +_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX14 +void advance(_InputIter& __i, _Distance __orig_n) { + typedef typename iterator_traits<_InputIter>::difference_type _Difference; + _Difference __n = static_cast<_Difference>(_VSTD::__convert_to_integral(__orig_n)); + _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to advance(it, n) with negative n on a non-bidirectional iterator"); + _VSTD::__advance(__i, __n, typename iterator_traits<_InputIter>::iterator_category()); +} + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +// [range.iter.op.advance] +struct __advance_fn final : private __function_like { +private: + template + _LIBCPP_HIDE_FROM_ABI + static constexpr _Tp __magnitude_geq(_Tp __a, _Tp __b) noexcept { + return __a < 0 ? (__a <= __b) : (__a >= __b); + } + + template + _LIBCPP_HIDE_FROM_ABI + static constexpr void __advance_forward(_Ip& __i, iter_difference_t<_Ip> __n) { + while (__n > 0) { + --__n; + ++__i; + } + } + + template + _LIBCPP_HIDE_FROM_ABI + static constexpr void __advance_backward(_Ip& __i, iter_difference_t<_Ip> __n) { + while (__n < 0) { + ++__n; + --__i; + } + } + +public: + constexpr explicit __advance_fn(__tag __x) noexcept : __function_like(__x) {} + + // Preconditions: If `I` does not model `bidirectional_iterator`, `n` is not negative. + template + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_Ip& __i, iter_difference_t<_Ip> __n) const { + _LIBCPP_ASSERT(__n >= 0 || bidirectional_iterator<_Ip>, + "If `n < 0`, then `bidirectional_iterator` must be true."); + + // If `I` models `random_access_iterator`, equivalent to `i += n`. + if constexpr (random_access_iterator<_Ip>) { + __i += __n; + return; + } else if constexpr (bidirectional_iterator<_Ip>) { + // Otherwise, if `n` is non-negative, increments `i` by `n`. + __advance_forward(__i, __n); + // Otherwise, decrements `i` by `-n`. + __advance_backward(__i, __n); + return; + } else { + // Otherwise, if `n` is non-negative, increments `i` by `n`. + __advance_forward(__i, __n); + return; + } + } + + // Preconditions: Either `assignable_from || sized_sentinel_for` is modeled, or [i, bound) denotes a range. + template _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_Ip& __i, _Sp __bound) const { + // If `I` and `S` model `assignable_from`, equivalent to `i = std::move(bound)`. + if constexpr (assignable_from<_Ip&, _Sp>) { + __i = _VSTD::move(__bound); + } + // Otherwise, if `S` and `I` model `sized_sentinel_for`, equivalent to `ranges::advance(i, bound - i)`. + else if constexpr (sized_sentinel_for<_Sp, _Ip>) { + (*this)(__i, __bound - __i); + } + // Otherwise, while `bool(i != bound)` is true, increments `i`. + else { + while (__i != __bound) { + ++__i; + } + } + } + + // Preconditions: + // * If `n > 0`, [i, bound) denotes a range. + // * If `n == 0`, [i, bound) or [bound, i) denotes a range. + // * If `n < 0`, [bound, i) denotes a range, `I` models `bidirectional_iterator`, and `I` and `S` model `same_as`. + // Returns: `n - M`, where `M` is the difference between the the ending and starting position. + template _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Ip> operator()(_Ip& __i, iter_difference_t<_Ip> __n, _Sp __bound) const { + _LIBCPP_ASSERT((__n >= 0) || (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>), + "If `n < 0`, then `bidirectional_iterator && same_as` must be true."); + // If `S` and `I` model `sized_sentinel_for`: + if constexpr (sized_sentinel_for<_Sp, _Ip>) { + // If |n| >= |bound - i|, equivalent to `ranges::advance(i, bound)`. + if (const auto __M = __bound - __i; __magnitude_geq(__n, __M)) { + (*this)(__i, __bound); + return __n - __M; + } + + // Otherwise, equivalent to `ranges::advance(i, n)`. + (*this)(__i, __n); + return 0; + } else { + // Otherwise, if `n` is non-negative, while `bool(i != bound)` is true, increments `i` but at + // most `n` times. + while (__i != __bound && __n > 0) { + ++__i; + --__n; + } + + // Otherwise, while `bool(i != bound)` is true, decrements `i` but at most `-n` times. + if constexpr (bidirectional_iterator<_Ip> && same_as<_Ip, _Sp>) { + while (__i != __bound && __n < 0) { + --__i; + ++__n; + } + } + return __n; + } + + _LIBCPP_UNREACHABLE(); + } +}; + +inline constexpr auto advance = __advance_fn(__function_like::__tag()); +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ADVANCE_H diff --git a/gnu/llvm/libcxx/include/__iterator/back_insert_iterator.h b/gnu/llvm/libcxx/include/__iterator/back_insert_iterator.h new file mode 100644 index 00000000000..f34cb863bc0 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/back_insert_iterator.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_BACK_INSERT_ITERATOR_H +#define _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__utility/move.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +class _LIBCPP_TEMPLATE_VIS back_insert_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +protected: + _Container* container; +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _Container container_type; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit back_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_back(__value_); return *this;} +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_back(_VSTD::move(__value_)); return *this;} +#endif // _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 back_insert_iterator operator++(int) {return *this;} +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +back_insert_iterator<_Container> +back_inserter(_Container& __x) +{ + return back_insert_iterator<_Container>(__x); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_BACK_INSERT_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/common_iterator.h b/gnu/llvm/libcxx/include/__iterator/common_iterator.h new file mode 100644 index 00000000000..fb01d8bd4b9 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/common_iterator.h @@ -0,0 +1,301 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_COMMON_ITERATOR_H +#define _LIBCPP___ITERATOR_COMMON_ITERATOR_H + +#include <__config> +#include <__debug> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iter_move.h> +#include <__iterator/iter_swap.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template _Sent> + requires (!same_as<_Iter, _Sent> && copyable<_Iter>) +class common_iterator { + class __proxy { + friend common_iterator; + + iter_value_t<_Iter> __value; + // We can move __x because the only caller verifies that __x is not a reference. + constexpr __proxy(iter_reference_t<_Iter>&& __x) + : __value(_VSTD::move(__x)) {} + + public: + const iter_value_t<_Iter>* operator->() const { + return _VSTD::addressof(__value); + } + }; + + class __postfix_proxy { + friend common_iterator; + + iter_value_t<_Iter> __value; + constexpr __postfix_proxy(iter_reference_t<_Iter>&& __x) + : __value(_VSTD::forward>(__x)) {} + + public: + constexpr static bool __valid_for_iter = + constructible_from, iter_reference_t<_Iter>> && + move_constructible>; + + const iter_value_t<_Iter>& operator*() const { + return __value; + } + }; + +public: + variant<_Iter, _Sent> __hold_; + + common_iterator() requires default_initializable<_Iter> = default; + + constexpr common_iterator(_Iter __i) : __hold_(in_place_type<_Iter>, _VSTD::move(__i)) {} + constexpr common_iterator(_Sent __s) : __hold_(in_place_type<_Sent>, _VSTD::move(__s)) {} + + template + requires convertible_to && convertible_to + constexpr common_iterator(const common_iterator<_I2, _S2>& __other) + : __hold_([&]() -> variant<_Iter, _Sent> { + _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Constructed from valueless iterator."); + if (__other.__hold_.index() == 0) + return variant<_Iter, _Sent>{in_place_index<0>, _VSTD::__unchecked_get<0>(__other.__hold_)}; + return variant<_Iter, _Sent>{in_place_index<1>, _VSTD::__unchecked_get<1>(__other.__hold_)}; + }()) {} + + template + requires convertible_to && convertible_to && + assignable_from<_Iter&, const _I2&> && assignable_from<_Sent&, const _S2&> + common_iterator& operator=(const common_iterator<_I2, _S2>& __other) { + _LIBCPP_ASSERT(!__other.__hold_.valueless_by_exception(), "Assigned from valueless iterator."); + + auto __idx = __hold_.index(); + auto __other_idx = __other.__hold_.index(); + + // If they're the same index, just assign. + if (__idx == 0 && __other_idx == 0) + _VSTD::__unchecked_get<0>(__hold_) = _VSTD::__unchecked_get<0>(__other.__hold_); + else if (__idx == 1 && __other_idx == 1) + _VSTD::__unchecked_get<1>(__hold_) = _VSTD::__unchecked_get<1>(__other.__hold_); + + // Otherwise replace with the oposite element. + else if (__other_idx == 1) + __hold_.template emplace<1>(_VSTD::__unchecked_get<1>(__other.__hold_)); + else if (__other_idx == 0) + __hold_.template emplace<0>(_VSTD::__unchecked_get<0>(__other.__hold_)); + + return *this; + } + + decltype(auto) operator*() + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + return *_VSTD::__unchecked_get<_Iter>(__hold_); + } + + decltype(auto) operator*() const + requires __dereferenceable + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + return *_VSTD::__unchecked_get<_Iter>(__hold_); + } + + template + decltype(auto) operator->() const + requires indirectly_readable && + (requires(const _I2& __i) { __i.operator->(); } || + is_reference_v> || + constructible_from, iter_reference_t<_I2>>) + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot dereference sentinel. Common iterator not holding an iterator."); + + if constexpr (is_pointer_v<_Iter> || requires(const _Iter& __i) { __i.operator->(); }) { + return _VSTD::__unchecked_get<_Iter>(__hold_); + } else if constexpr (is_reference_v>) { + auto&& __tmp = *_VSTD::__unchecked_get<_Iter>(__hold_); + return _VSTD::addressof(__tmp); + } else { + return __proxy(*_VSTD::__unchecked_get<_Iter>(__hold_)); + } + } + + common_iterator& operator++() { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot increment sentinel. Common iterator not holding an iterator."); + ++_VSTD::__unchecked_get<_Iter>(__hold_); return *this; + } + + decltype(auto) operator++(int) { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__hold_), + "Cannot increment sentinel. Common iterator not holding an iterator."); + + if constexpr (forward_iterator<_Iter>) { + auto __tmp = *this; + ++*this; + return __tmp; + } else if constexpr (requires (_Iter& __i) { { *__i++ } -> __referenceable; } || + !__postfix_proxy::__valid_for_iter) { + return _VSTD::__unchecked_get<_Iter>(__hold_)++; + } else { + __postfix_proxy __p(**this); + ++*this; + return __p; + } + } + + template _S2> + requires sentinel_for<_Sent, _I2> + friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); + + auto __x_index = __x.__hold_.index(); + auto __y_index = __y.__hold_.index(); + + if (__x_index == __y_index) + return true; + + if (__x_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_); + + return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); + } + + template _S2> + requires sentinel_for<_Sent, _I2> && equality_comparable_with<_Iter, _I2> + friend bool operator==(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot compare valueless iterators.)"); + + auto __x_index = __x.__hold_.index(); + auto __y_index = __y.__hold_.index(); + + if (__x_index == 1 && __y_index == 1) + return true; + + if (__x_index == 0 && __y_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); + + if (__x_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) == _VSTD::__unchecked_get<_S2>(__y.__hold_); + + return _VSTD::__unchecked_get<_Sent>(__x.__hold_) == _VSTD::__unchecked_get<_I2>(__y.__hold_); + } + + template _I2, sized_sentinel_for<_Iter> _S2> + requires sized_sentinel_for<_Sent, _I2> + friend iter_difference_t<_I2> operator-(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) { + _LIBCPP_ASSERT(!__x.__hold_.valueless_by_exception() && + !__y.__hold_.valueless_by_exception(), + "One or both common_iterators are valueless. (Cannot subtract valueless iterators.)"); + + auto __x_index = __x.__hold_.index(); + auto __y_index = __y.__hold_.index(); + + if (__x_index == 1 && __y_index == 1) + return 0; + + if (__x_index == 0 && __y_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); + + if (__x_index == 0) + return _VSTD::__unchecked_get<_Iter>(__x.__hold_) - _VSTD::__unchecked_get<_S2>(__y.__hold_); + + return _VSTD::__unchecked_get<_Sent>(__x.__hold_) - _VSTD::__unchecked_get<_I2>(__y.__hold_); + } + + friend iter_rvalue_reference_t<_Iter> iter_move(const common_iterator& __i) + noexcept(noexcept(ranges::iter_move(declval()))) + requires input_iterator<_Iter> + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__i.__hold_), + "Cannot iter_move a sentinel. Common iterator not holding an iterator."); + return ranges::iter_move( _VSTD::__unchecked_get<_Iter>(__i.__hold_)); + } + + template _I2, class _S2> + friend void iter_swap(const common_iterator& __x, const common_iterator<_I2, _S2>& __y) + noexcept(noexcept(ranges::iter_swap(declval(), declval()))) + { + _LIBCPP_ASSERT(holds_alternative<_Iter>(__x.__hold_), + "Cannot swap __y with a sentinel. Common iterator (__x) not holding an iterator."); + _LIBCPP_ASSERT(holds_alternative<_Iter>(__y.__hold_), + "Cannot swap __x with a sentinel. Common iterator (__y) not holding an iterator."); + return ranges::iter_swap( _VSTD::__unchecked_get<_Iter>(__x.__hold_), _VSTD::__unchecked_get<_Iter>(__y.__hold_)); + } +}; + +template +struct incrementable_traits> { + using difference_type = iter_difference_t<_Iter>; +}; + +template +concept __denotes_forward_iter = + requires { typename iterator_traits<_Iter>::iterator_category; } && + derived_from::iterator_category, forward_iterator_tag>; + +template +concept __common_iter_has_ptr_op = requires(const common_iterator<_Iter, _Sent>& __a) { + __a.operator->(); +}; + +template +struct __arrow_type_or_void { + using type = void; +}; + +template + requires __common_iter_has_ptr_op<_Iter, _Sent> +struct __arrow_type_or_void<_Iter, _Sent> { + using type = decltype(declval>().operator->()); +}; + +template +struct iterator_traits> { + using iterator_concept = _If, + forward_iterator_tag, + input_iterator_tag>; + using iterator_category = _If<__denotes_forward_iter<_Iter>, + forward_iterator_tag, + input_iterator_tag>; + using pointer = typename __arrow_type_or_void<_Iter, _Sent>::type; + using value_type = iter_value_t<_Iter>; + using difference_type = iter_difference_t<_Iter>; + using reference = iter_reference_t<_Iter>; +}; + + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_COMMON_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/concepts.h b/gnu/llvm/libcxx/include/__iterator/concepts.h new file mode 100644 index 00000000000..6eb4aef1052 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/concepts.h @@ -0,0 +1,272 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_CONCEPTS_H +#define _LIBCPP___ITERATOR_CONCEPTS_H + +#include <__config> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iter_move.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <__memory/pointer_traits.h> +#include <__utility/forward.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// clang-format off + +// [iterator.concept.readable] +template +concept __indirectly_readable_impl = + requires(const _In __i) { + typename iter_value_t<_In>; + typename iter_reference_t<_In>; + typename iter_rvalue_reference_t<_In>; + { *__i } -> same_as>; + { ranges::iter_move(__i) } -> same_as>; + } && + common_reference_with&&, iter_value_t<_In>&> && + common_reference_with&&, iter_rvalue_reference_t<_In>&&> && + common_reference_with&&, const iter_value_t<_In>&>; + +template +concept indirectly_readable = __indirectly_readable_impl>; + +template +using iter_common_reference_t = common_reference_t, iter_value_t<_Tp>&>; + +// [iterator.concept.writable] +template +concept indirectly_writable = + requires(_Out&& __o, _Tp&& __t) { + *__o = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + *_VSTD::forward<_Out>(__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + const_cast&&>(*__o) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + const_cast&&>(*_VSTD::forward<_Out>(__o)) = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + }; + +// [iterator.concept.winc] +template +concept __integer_like = integral<_Tp> && !same_as<_Tp, bool>; + +template +concept __signed_integer_like = signed_integral<_Tp>; + +template +concept weakly_incrementable = + movable<_Ip> && + requires(_Ip __i) { + typename iter_difference_t<_Ip>; + requires __signed_integer_like>; + { ++__i } -> same_as<_Ip&>; // not required to be equality-preserving + __i++; // not required to be equality-preserving + }; + +// [iterator.concept.inc] +template +concept incrementable = + regular<_Ip> && + weakly_incrementable<_Ip> && + requires(_Ip __i) { + { __i++ } -> same_as<_Ip>; + }; + +// [iterator.concept.iterator] +template +concept input_or_output_iterator = + requires(_Ip __i) { + { *__i } -> __referenceable; + } && + weakly_incrementable<_Ip>; + +// [iterator.concept.sentinel] +template +concept sentinel_for = + semiregular<_Sp> && + input_or_output_iterator<_Ip> && + __weakly_equality_comparable_with<_Sp, _Ip>; + +template +inline constexpr bool disable_sized_sentinel_for = false; + +template +concept sized_sentinel_for = + sentinel_for<_Sp, _Ip> && + !disable_sized_sentinel_for, remove_cv_t<_Ip>> && + requires(const _Ip& __i, const _Sp& __s) { + { __s - __i } -> same_as>; + { __i - __s } -> same_as>; + }; + +// [iterator.concept.input] +template +concept input_iterator = + input_or_output_iterator<_Ip> && + indirectly_readable<_Ip> && + requires { typename _ITER_CONCEPT<_Ip>; } && + derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>; + +// [iterator.concept.output] +template +concept output_iterator = + input_or_output_iterator<_Ip> && + indirectly_writable<_Ip, _Tp> && + requires (_Ip __it, _Tp&& __t) { + *__it++ = _VSTD::forward<_Tp>(__t); // not required to be equality-preserving + }; + +// [iterator.concept.forward] +template +concept forward_iterator = + input_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, forward_iterator_tag> && + incrementable<_Ip> && + sentinel_for<_Ip, _Ip>; + +// [iterator.concept.bidir] +template +concept bidirectional_iterator = + forward_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, bidirectional_iterator_tag> && + requires(_Ip __i) { + { --__i } -> same_as<_Ip&>; + { __i-- } -> same_as<_Ip>; + }; + +template +concept random_access_iterator = + bidirectional_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, random_access_iterator_tag> && + totally_ordered<_Ip> && + sized_sentinel_for<_Ip, _Ip> && + requires(_Ip __i, const _Ip __j, const iter_difference_t<_Ip> __n) { + { __i += __n } -> same_as<_Ip&>; + { __j + __n } -> same_as<_Ip>; + { __n + __j } -> same_as<_Ip>; + { __i -= __n } -> same_as<_Ip&>; + { __j - __n } -> same_as<_Ip>; + { __j[__n] } -> same_as>; + }; + +template +concept contiguous_iterator = + random_access_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, contiguous_iterator_tag> && + is_lvalue_reference_v> && + same_as, remove_cvref_t>> && + (is_pointer_v<_Ip> || requires { sizeof(__pointer_traits_element_type<_Ip>); }) && + requires(const _Ip& __i) { + { _VSTD::to_address(__i) } -> same_as>>; + }; + +template +concept __has_arrow = input_iterator<_Ip> && (is_pointer_v<_Ip> || requires(_Ip __i) { __i.operator->(); }); + +// [indirectcallable.indirectinvocable] +template +concept indirectly_unary_invocable = + indirectly_readable<_It> && + copy_constructible<_Fp> && + invocable<_Fp&, iter_value_t<_It>&> && + invocable<_Fp&, iter_reference_t<_It>> && + invocable<_Fp&, iter_common_reference_t<_It>> && + common_reference_with< + invoke_result_t<_Fp&, iter_value_t<_It>&>, + invoke_result_t<_Fp&, iter_reference_t<_It>>>; + +template +concept indirectly_regular_unary_invocable = + indirectly_readable<_It> && + copy_constructible<_Fp> && + regular_invocable<_Fp&, iter_value_t<_It>&> && + regular_invocable<_Fp&, iter_reference_t<_It>> && + regular_invocable<_Fp&, iter_common_reference_t<_It>> && + common_reference_with< + invoke_result_t<_Fp&, iter_value_t<_It>&>, + invoke_result_t<_Fp&, iter_reference_t<_It>>>; + +template +concept indirect_unary_predicate = + indirectly_readable<_It> && + copy_constructible<_Fp> && + predicate<_Fp&, iter_value_t<_It>&> && + predicate<_Fp&, iter_reference_t<_It>> && + predicate<_Fp&, iter_common_reference_t<_It>>; + +template +concept indirect_binary_predicate = + indirectly_readable<_It1> && indirectly_readable<_It2> && + copy_constructible<_Fp> && + predicate<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && + predicate<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && + predicate<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && + predicate<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && + predicate<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + +template +concept indirect_equivalence_relation = + indirectly_readable<_It1> && indirectly_readable<_It2> && + copy_constructible<_Fp> && + equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && + equivalence_relation<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && + equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && + equivalence_relation<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && + equivalence_relation<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + +template +concept indirect_strict_weak_order = + indirectly_readable<_It1> && indirectly_readable<_It2> && + copy_constructible<_Fp> && + strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_value_t<_It2>&> && + strict_weak_order<_Fp&, iter_value_t<_It1>&, iter_reference_t<_It2>> && + strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_value_t<_It2>&> && + strict_weak_order<_Fp&, iter_reference_t<_It1>, iter_reference_t<_It2>> && + strict_weak_order<_Fp&, iter_common_reference_t<_It1>, iter_common_reference_t<_It2>>; + +template + requires (indirectly_readable<_Its> && ...) && invocable<_Fp, iter_reference_t<_Its>...> +using indirect_result_t = invoke_result_t<_Fp, iter_reference_t<_Its>...>; + +template +concept indirectly_movable = + indirectly_readable<_In> && + indirectly_writable<_Out, iter_rvalue_reference_t<_In>>; + +template +concept indirectly_movable_storable = + indirectly_movable<_In, _Out> && + indirectly_writable<_Out, iter_value_t<_In>> && + movable> && + constructible_from, iter_rvalue_reference_t<_In>> && + assignable_from&, iter_rvalue_reference_t<_In>>; + +// Note: indirectly_swappable is located in iter_swap.h to prevent a dependency cycle +// (both iter_swap and indirectly_swappable require indirectly_readable). + +// clang-format on + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_CONCEPTS_H diff --git a/gnu/llvm/libcxx/include/__iterator/counted_iterator.h b/gnu/llvm/libcxx/include/__iterator/counted_iterator.h new file mode 100644 index 00000000000..7136aaf0258 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/counted_iterator.h @@ -0,0 +1,306 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_COUNTED_ITERATOR_H +#define _LIBCPP___ITERATOR_COUNTED_ITERATOR_H + +#include <__config> +#include <__debug> +#include <__iterator/concepts.h> +#include <__iterator/default_sentinel.h> +#include <__iterator/iter_move.h> +#include <__iterator/iter_swap.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <__memory/pointer_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template +struct __counted_iterator_concept {}; + +template + requires requires { typename _Iter::iterator_concept; } +struct __counted_iterator_concept<_Iter> { + using iterator_concept = typename _Iter::iterator_concept; +}; + +template +struct __counted_iterator_category {}; + +template + requires requires { typename _Iter::iterator_category; } +struct __counted_iterator_category<_Iter> { + using iterator_category = typename _Iter::iterator_category; +}; + +template +struct __counted_iterator_value_type {}; + +template +struct __counted_iterator_value_type<_Iter> { + using value_type = iter_value_t<_Iter>; +}; + +template +class counted_iterator + : public __counted_iterator_concept<_Iter> + , public __counted_iterator_category<_Iter> + , public __counted_iterator_value_type<_Iter> +{ +public: + [[no_unique_address]] _Iter __current_ = _Iter(); + iter_difference_t<_Iter> __count_ = 0; + + using iterator_type = _Iter; + using difference_type = iter_difference_t<_Iter>; + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator() requires default_initializable<_Iter> = default; + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator(_Iter __iter, iter_difference_t<_Iter> __n) + : __current_(_VSTD::move(__iter)), __count_(__n) { + _LIBCPP_ASSERT(__n >= 0, "__n must not be negative."); + } + + template + requires convertible_to + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator(const counted_iterator<_I2>& __other) + : __current_(__other.__current_), __count_(__other.__count_) {} + + template + requires assignable_from<_Iter&, const _I2&> + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator=(const counted_iterator<_I2>& __other) { + __current_ = __other.__current_; + __count_ = __other.__count_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr const _Iter& base() const& { return __current_; } + + _LIBCPP_HIDE_FROM_ABI + constexpr _Iter base() && { return _VSTD::move(__current_); } + + _LIBCPP_HIDE_FROM_ABI + constexpr iter_difference_t<_Iter> count() const noexcept { return __count_; } + + _LIBCPP_HIDE_FROM_ABI + constexpr decltype(auto) operator*() { + _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end."); + return *__current_; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr decltype(auto) operator*() const + requires __dereferenceable + { + _LIBCPP_ASSERT(__count_ > 0, "Iterator is equal to or past end."); + return *__current_; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr auto operator->() const noexcept + requires contiguous_iterator<_Iter> + { + return _VSTD::to_address(__current_); + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator++() { + _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); + ++__current_; + --__count_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + decltype(auto) operator++(int) { + _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); + --__count_; +#ifndef _LIBCPP_NO_EXCEPTIONS + try { return __current_++; } + catch(...) { ++__count_; throw; } +#else + return __current_++; +#endif // _LIBCPP_NO_EXCEPTIONS + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator++(int) + requires forward_iterator<_Iter> + { + _LIBCPP_ASSERT(__count_ > 0, "Iterator already at or past end."); + counted_iterator __tmp = *this; + ++*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator--() + requires bidirectional_iterator<_Iter> + { + --__current_; + ++__count_; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator--(int) + requires bidirectional_iterator<_Iter> + { + counted_iterator __tmp = *this; + --*this; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator+(iter_difference_t<_Iter> __n) const + requires random_access_iterator<_Iter> + { + return counted_iterator(__current_ + __n, __count_ - __n); + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr counted_iterator operator+( + iter_difference_t<_Iter> __n, const counted_iterator& __x) + requires random_access_iterator<_Iter> + { + return __x + __n; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator+=(iter_difference_t<_Iter> __n) + requires random_access_iterator<_Iter> + { + _LIBCPP_ASSERT(__n <= __count_, "Cannot advance iterator past end."); + __current_ += __n; + __count_ -= __n; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator operator-(iter_difference_t<_Iter> __n) const + requires random_access_iterator<_Iter> + { + return counted_iterator(__current_ - __n, __count_ + __n); + } + + template _I2> + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_difference_t<_I2> operator-( + const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) + { + return __rhs.__count_ - __lhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_difference_t<_Iter> operator-( + const counted_iterator& __lhs, default_sentinel_t) + { + return -__lhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_difference_t<_Iter> operator-( + default_sentinel_t, const counted_iterator& __rhs) + { + return __rhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr counted_iterator& operator-=(iter_difference_t<_Iter> __n) + requires random_access_iterator<_Iter> + { + _LIBCPP_ASSERT(-__n <= __count_, "Attempt to subtract too large of a size: " + "counted_iterator would be decremented before the " + "first element of its range."); + __current_ -= __n; + __count_ += __n; + return *this; + } + + _LIBCPP_HIDE_FROM_ABI + constexpr decltype(auto) operator[](iter_difference_t<_Iter> __n) const + requires random_access_iterator<_Iter> + { + _LIBCPP_ASSERT(__n < __count_, "Subscript argument must be less than size."); + return __current_[__n]; + } + + template _I2> + _LIBCPP_HIDE_FROM_ABI + friend constexpr bool operator==( + const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) + { + return __lhs.__count_ == __rhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr bool operator==( + const counted_iterator& __lhs, default_sentinel_t) + { + return __lhs.__count_ == 0; + } + + template _I2> + friend constexpr strong_ordering operator<=>( + const counted_iterator& __lhs, const counted_iterator<_I2>& __rhs) + { + return __rhs.__count_ <=> __lhs.__count_; + } + + _LIBCPP_HIDE_FROM_ABI + friend constexpr iter_rvalue_reference_t<_Iter> iter_move(const counted_iterator& __i) + noexcept(noexcept(ranges::iter_move(__i.__current_))) + requires input_iterator<_Iter> + { + _LIBCPP_ASSERT(__i.__count_ > 0, "Iterator must not be past end of range."); + return ranges::iter_move(__i.__current_); + } + + template _I2> + _LIBCPP_HIDE_FROM_ABI + friend constexpr void iter_swap(const counted_iterator& __x, const counted_iterator<_I2>& __y) + noexcept(noexcept(ranges::iter_swap(__x.__current_, __y.__current_))) + { + _LIBCPP_ASSERT(__x.__count_ > 0 && __y.__count_ > 0, + "Iterators must not be past end of range."); + return ranges::iter_swap(__x.__current_, __y.__current_); + } +}; + +template + requires same_as<_ITER_TRAITS<_Iter>, iterator_traits<_Iter>> +struct iterator_traits> : iterator_traits<_Iter> { + using pointer = conditional_t, + add_pointer_t>, void>; +}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_COUNTED_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/data.h b/gnu/llvm/libcxx/include/__iterator/data.h new file mode 100644 index 00000000000..cd8e37b96b6 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/data.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_DATA_H +#define _LIBCPP___ITERATOR_DATA_H + +#include <__config> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template constexpr +_LIBCPP_INLINE_VISIBILITY +auto data(_Cont& __c) +_NOEXCEPT_(noexcept(__c.data())) +-> decltype (__c.data()) +{ return __c.data(); } + +template constexpr +_LIBCPP_INLINE_VISIBILITY +auto data(const _Cont& __c) +_NOEXCEPT_(noexcept(__c.data())) +-> decltype (__c.data()) +{ return __c.data(); } + +template +_LIBCPP_INLINE_VISIBILITY +constexpr _Tp* data(_Tp (&__array)[_Sz]) noexcept { return __array; } + +template +_LIBCPP_INLINE_VISIBILITY +constexpr const _Ep* data(initializer_list<_Ep> __il) noexcept { return __il.begin(); } + +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_DATA_H diff --git a/gnu/llvm/libcxx/include/__iterator/default_sentinel.h b/gnu/llvm/libcxx/include/__iterator/default_sentinel.h new file mode 100644 index 00000000000..934a56fd9e2 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/default_sentinel.h @@ -0,0 +1,35 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_DEFAULT_SENTINEL_H +#define _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +struct default_sentinel_t { }; +inline constexpr default_sentinel_t default_sentinel{}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_DEFAULT_SENTINEL_H diff --git a/gnu/llvm/libcxx/include/__iterator/distance.h b/gnu/llvm/libcxx/include/__iterator/distance.h new file mode 100644 index 00000000000..33e4af84d36 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/distance.h @@ -0,0 +1,56 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_DISTANCE_H +#define _LIBCPP___ITERATOR_DISTANCE_H + +#include <__config> +#include <__iterator/iterator_traits.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename iterator_traits<_InputIter>::difference_type +__distance(_InputIter __first, _InputIter __last, input_iterator_tag) +{ + typename iterator_traits<_InputIter>::difference_type __r(0); + for (; __first != __last; ++__first) + ++__r; + return __r; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename iterator_traits<_RandIter>::difference_type +__distance(_RandIter __first, _RandIter __last, random_access_iterator_tag) +{ + return __last - __first; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +typename iterator_traits<_InputIter>::difference_type +distance(_InputIter __first, _InputIter __last) +{ + return _VSTD::__distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_DISTANCE_H diff --git a/gnu/llvm/libcxx/include/__iterator/empty.h b/gnu/llvm/libcxx/include/__iterator/empty.h new file mode 100644 index 00000000000..4dd59f5cccb --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/empty.h @@ -0,0 +1,49 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_EMPTY_H +#define _LIBCPP___ITERATOR_EMPTY_H + +#include <__config> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template +_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY +constexpr auto empty(const _Cont& __c) +_NOEXCEPT_(noexcept(__c.empty())) +-> decltype (__c.empty()) +{ return __c.empty(); } + +template +_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY +constexpr bool empty(const _Tp (&)[_Sz]) noexcept { return false; } + +template +_LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY +constexpr bool empty(initializer_list<_Ep> __il) noexcept { return __il.size() == 0; } + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_EMPTY_H diff --git a/gnu/llvm/libcxx/include/__iterator/erase_if_container.h b/gnu/llvm/libcxx/include/__iterator/erase_if_container.h new file mode 100644 index 00000000000..a5dfd072053 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/erase_if_container.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ERASE_IF_CONTAINER_H +#define _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +_LIBCPP_HIDE_FROM_ABI +typename _Container::size_type +__libcpp_erase_if_container(_Container& __c, _Predicate& __pred) { + typename _Container::size_type __old_size = __c.size(); + + const typename _Container::iterator __last = __c.end(); + for (typename _Container::iterator __iter = __c.begin(); __iter != __last;) { + if (__pred(*__iter)) + __iter = __c.erase(__iter); + else + ++__iter; + } + + return __old_size - __c.size(); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ERASE_IF_CONTAINER_H diff --git a/gnu/llvm/libcxx/include/__iterator/front_insert_iterator.h b/gnu/llvm/libcxx/include/__iterator/front_insert_iterator.h new file mode 100644 index 00000000000..0421dd5c4b2 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/front_insert_iterator.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_FRONT_INSERT_ITERATOR_H +#define _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__utility/move.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +class _LIBCPP_TEMPLATE_VIS front_insert_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +protected: + _Container* container; +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _Container container_type; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 explicit front_insert_iterator(_Container& __x) : container(_VSTD::addressof(__x)) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(const typename _Container::value_type& __value_) + {container->push_front(__value_); return *this;} +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator=(typename _Container::value_type&& __value_) + {container->push_front(_VSTD::move(__value_)); return *this;} +#endif // _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 front_insert_iterator operator++(int) {return *this;} +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +front_insert_iterator<_Container> +front_inserter(_Container& __x) +{ + return front_insert_iterator<_Container>(__x); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_FRONT_INSERT_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/incrementable_traits.h b/gnu/llvm/libcxx/include/__iterator/incrementable_traits.h new file mode 100644 index 00000000000..5a433982ba2 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/incrementable_traits.h @@ -0,0 +1,77 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_INCREMENTABLE_TRAITS_H +#define _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H + +#include <__config> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// [incrementable.traits] +template struct incrementable_traits {}; + +template +requires is_object_v<_Tp> +struct incrementable_traits<_Tp*> { + using difference_type = ptrdiff_t; +}; + +template +struct incrementable_traits : incrementable_traits<_Ip> {}; + +template +concept __has_member_difference_type = requires { typename _Tp::difference_type; }; + +template<__has_member_difference_type _Tp> +struct incrementable_traits<_Tp> { + using difference_type = typename _Tp::difference_type; +}; + +template +concept __has_integral_minus = + requires(const _Tp& __x, const _Tp& __y) { + { __x - __y } -> integral; + }; + +template<__has_integral_minus _Tp> +requires (!__has_member_difference_type<_Tp>) +struct incrementable_traits<_Tp> { + using difference_type = make_signed_t() - declval<_Tp>())>; +}; + +template +struct iterator_traits; + +// Let `RI` be `remove_cvref_t`. The type `iter_difference_t` denotes +// `incrementable_traits::difference_type` if `iterator_traits` names a specialization +// generated from the primary template, and `iterator_traits::difference_type` otherwise. +template +using iter_difference_t = typename conditional_t<__is_primary_template > >::value, + incrementable_traits >, + iterator_traits > >::difference_type; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_INCREMENTABLE_TRAITS_H diff --git a/gnu/llvm/libcxx/include/__iterator/insert_iterator.h b/gnu/llvm/libcxx/include/__iterator/insert_iterator.h new file mode 100644 index 00000000000..26581418247 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/insert_iterator.h @@ -0,0 +1,77 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_INSERT_ITERATOR_H +#define _LIBCPP___ITERATOR_INSERT_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include <__utility/move.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +class _LIBCPP_TEMPLATE_VIS insert_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +protected: + _Container* container; + typename _Container::iterator iter; // FIXME: `ranges::iterator_t` in C++20 mode +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _Container container_type; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator(_Container& __x, typename _Container::iterator __i) + : container(_VSTD::addressof(__x)), iter(__i) {} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(const typename _Container::value_type& __value_) + {iter = container->insert(iter, __value_); ++iter; return *this;} +#ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator=(typename _Container::value_type&& __value_) + {iter = container->insert(iter, _VSTD::move(__value_)); ++iter; return *this;} +#endif // _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 insert_iterator& operator++(int) {return *this;} +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +insert_iterator<_Container> +inserter(_Container& __x, typename _Container::iterator __i) +{ + return insert_iterator<_Container>(__x, __i); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_INSERT_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/istream_iterator.h b/gnu/llvm/libcxx/include/__iterator/istream_iterator.h new file mode 100644 index 00000000000..f39faa6d590 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/istream_iterator.h @@ -0,0 +1,103 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ISTREAM_ITERATOR_H +#define _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include // for forward declarations of char_traits and basic_istream + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template , class _Distance = ptrdiff_t> +class _LIBCPP_TEMPLATE_VIS istream_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef input_iterator_tag iterator_category; + typedef _Tp value_type; + typedef _Distance difference_type; + typedef const _Tp* pointer; + typedef const _Tp& reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_istream<_CharT,_Traits> istream_type; +private: + istream_type* __in_stream_; + _Tp __value_; +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istream_iterator() : __in_stream_(nullptr), __value_() {} + _LIBCPP_INLINE_VISIBILITY istream_iterator(istream_type& __s) : __in_stream_(_VSTD::addressof(__s)) + { + if (!(*__in_stream_ >> __value_)) + __in_stream_ = nullptr; + } + + _LIBCPP_INLINE_VISIBILITY const _Tp& operator*() const {return __value_;} + _LIBCPP_INLINE_VISIBILITY const _Tp* operator->() const {return _VSTD::addressof((operator*()));} + _LIBCPP_INLINE_VISIBILITY istream_iterator& operator++() + { + if (!(*__in_stream_ >> __value_)) + __in_stream_ = nullptr; + return *this; + } + _LIBCPP_INLINE_VISIBILITY istream_iterator operator++(int) + {istream_iterator __t(*this); ++(*this); return __t;} + + template + friend _LIBCPP_INLINE_VISIBILITY + bool + operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, + const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); + + template + friend _LIBCPP_INLINE_VISIBILITY + bool + operator==(const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __x, + const istream_iterator<_Up, _CharU, _TraitsU, _DistanceU>& __y); +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator==(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, + const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) +{ + return __x.__in_stream_ == __y.__in_stream_; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool +operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __x, + const istream_iterator<_Tp, _CharT, _Traits, _Distance>& __y) +{ + return !(__x == __y); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ISTREAM_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/istreambuf_iterator.h b/gnu/llvm/libcxx/include/__iterator/istreambuf_iterator.h new file mode 100644 index 00000000000..119698d54ce --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/istreambuf_iterator.h @@ -0,0 +1,110 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ISTREAMBUF_ITERATOR_H +#define _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include // for forward declaration of basic_streambuf + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +class _LIBCPP_TEMPLATE_VIS istreambuf_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef input_iterator_tag iterator_category; + typedef _CharT value_type; + typedef typename _Traits::off_type difference_type; + typedef _CharT* pointer; + typedef _CharT reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef typename _Traits::int_type int_type; + typedef basic_streambuf<_CharT,_Traits> streambuf_type; + typedef basic_istream<_CharT,_Traits> istream_type; +private: + mutable streambuf_type* __sbuf_; + + class __proxy + { + char_type __keep_; + streambuf_type* __sbuf_; + _LIBCPP_INLINE_VISIBILITY __proxy(char_type __c, streambuf_type* __s) + : __keep_(__c), __sbuf_(__s) {} + friend class istreambuf_iterator; + public: + _LIBCPP_INLINE_VISIBILITY char_type operator*() const {return __keep_;} + }; + + _LIBCPP_INLINE_VISIBILITY + bool __test_for_eof() const + { + if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sgetc(), traits_type::eof())) + __sbuf_ = nullptr; + return __sbuf_ == nullptr; + } +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR istreambuf_iterator() _NOEXCEPT : __sbuf_(nullptr) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(istream_type& __s) _NOEXCEPT + : __sbuf_(__s.rdbuf()) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(streambuf_type* __s) _NOEXCEPT + : __sbuf_(__s) {} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator(const __proxy& __p) _NOEXCEPT + : __sbuf_(__p.__sbuf_) {} + + _LIBCPP_INLINE_VISIBILITY char_type operator*() const + {return static_cast(__sbuf_->sgetc());} + _LIBCPP_INLINE_VISIBILITY istreambuf_iterator& operator++() + { + __sbuf_->sbumpc(); + return *this; + } + _LIBCPP_INLINE_VISIBILITY __proxy operator++(int) + { + return __proxy(__sbuf_->sbumpc(), __sbuf_); + } + + _LIBCPP_INLINE_VISIBILITY bool equal(const istreambuf_iterator& __b) const + {return __test_for_eof() == __b.__test_for_eof();} +}; + +template +inline _LIBCPP_INLINE_VISIBILITY +bool operator==(const istreambuf_iterator<_CharT,_Traits>& __a, + const istreambuf_iterator<_CharT,_Traits>& __b) + {return __a.equal(__b);} + +template +inline _LIBCPP_INLINE_VISIBILITY +bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, + const istreambuf_iterator<_CharT,_Traits>& __b) + {return !__a.equal(__b);} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ISTREAMBUF_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/iter_move.h b/gnu/llvm/libcxx/include/__iterator/iter_move.h new file mode 100644 index 00000000000..5540799e197 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/iter_move.h @@ -0,0 +1,91 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ITER_MOVE_H +#define _LIBCPP___ITERATOR_ITER_MOVE_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include <__utility/forward.h> +#include // __class_or_enum +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges::__iter_move { +void iter_move(); + +template +concept __unqualified_iter_move = requires(_Ip&& __i) { + iter_move(_VSTD::forward<_Ip>(__i)); +}; + +// [iterator.cust.move]/1 +// The name ranges::iter_move denotes a customization point object. +// The expression ranges::iter_move(E) for a subexpression E is +// expression-equivalent to: +struct __fn { + // [iterator.cust.move]/1.1 + // iter_move(E), if E has class or enumeration type and iter_move(E) is a + // well-formed expression when treated as an unevaluated operand, [...] + template + requires __class_or_enum> && __unqualified_iter_move<_Ip> + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const + noexcept(noexcept(iter_move(_VSTD::forward<_Ip>(__i)))) + { + return iter_move(_VSTD::forward<_Ip>(__i)); + } + + // [iterator.cust.move]/1.2 + // Otherwise, if the expression *E is well-formed: + // 1.2.1 if *E is an lvalue, std::move(*E); + // 1.2.2 otherwise, *E. + template + requires (!(__class_or_enum> && __unqualified_iter_move<_Ip>)) && + requires(_Ip&& __i) { *_VSTD::forward<_Ip>(__i); } + [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) operator()(_Ip&& __i) const + noexcept(noexcept(*_VSTD::forward<_Ip>(__i))) + { + if constexpr (is_lvalue_reference_v(__i))>) { + return _VSTD::move(*_VSTD::forward<_Ip>(__i)); + } else { + return *_VSTD::forward<_Ip>(__i); + } + } + + // [iterator.cust.move]/1.3 + // Otherwise, ranges::iter_move(E) is ill-formed. +}; +} // namespace ranges::__iter_move + +namespace ranges::inline __cpo { + inline constexpr auto iter_move = __iter_move::__fn{}; +} + +template<__dereferenceable _Tp> +requires requires(_Tp& __t) { { ranges::iter_move(__t) } -> __referenceable; } +using iter_rvalue_reference_t = decltype(ranges::iter_move(declval<_Tp&>())); + +#endif // !_LIBCPP_HAS_NO_RANGES + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ITER_MOVE_H diff --git a/gnu/llvm/libcxx/include/__iterator/iter_swap.h b/gnu/llvm/libcxx/include/__iterator/iter_swap.h new file mode 100644 index 00000000000..d70da09b4ab --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/iter_swap.h @@ -0,0 +1,107 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ITER_SWAP_H +#define _LIBCPP___ITERATOR_ITER_SWAP_H + +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/iter_move.h> +#include <__iterator/iterator_traits.h> +#include <__iterator/readable_traits.h> +#include <__ranges/access.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +namespace __iter_swap { + template + void iter_swap(_I1, _I2) = delete; + + template + concept __unqualified_iter_swap = requires(_T1&& __x, _T2&& __y) { + iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); + }; + + template + concept __readable_swappable = + indirectly_readable<_T1> && indirectly_readable<_T2> && + swappable_with, iter_reference_t<_T2>>; + + struct __fn { + template + requires __unqualified_iter_swap<_T1, _T2> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_T1&& __x, _T2&& __y) const + noexcept(noexcept(iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)))) + { + (void)iter_swap(_VSTD::forward<_T1>(__x), _VSTD::forward<_T2>(__y)); + } + + template + requires (!__unqualified_iter_swap<_T1, _T2>) && + __readable_swappable<_T1, _T2> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_T1&& __x, _T2&& __y) const + noexcept(noexcept(ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y)))) + { + ranges::swap(*_VSTD::forward<_T1>(__x), *_VSTD::forward<_T2>(__y)); + } + + template + requires (!__unqualified_iter_swap<_T1, _T2> && + !__readable_swappable<_T1, _T2>) && + indirectly_movable_storable<_T1, _T2> && + indirectly_movable_storable<_T2, _T1> + _LIBCPP_HIDE_FROM_ABI + constexpr void operator()(_T1&& __x, _T2&& __y) const + noexcept(noexcept(iter_value_t<_T2>(ranges::iter_move(__y))) && + noexcept(*__y = ranges::iter_move(__x)) && + noexcept(*_VSTD::forward<_T1>(__x) = declval>())) + { + iter_value_t<_T2> __old(ranges::iter_move(__y)); + *__y = ranges::iter_move(__x); + *_VSTD::forward<_T1>(__x) = _VSTD::move(__old); + } + }; +} // end namespace __iter_swap + +inline namespace __cpo { + inline constexpr auto iter_swap = __iter_swap::__fn{}; +} // namespace __cpo + +} // namespace ranges + +template +concept indirectly_swappable = + indirectly_readable<_I1> && indirectly_readable<_I2> && + requires(const _I1 __i1, const _I2 __i2) { + ranges::iter_swap(__i1, __i1); + ranges::iter_swap(__i2, __i2); + ranges::iter_swap(__i1, __i2); + ranges::iter_swap(__i2, __i1); + }; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ITER_SWAP_H diff --git a/gnu/llvm/libcxx/include/__iterator/iterator.h b/gnu/llvm/libcxx/include/__iterator/iterator.h new file mode 100644 index 00000000000..dfd481e3571 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/iterator.h @@ -0,0 +1,40 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ITERATOR_H +#define _LIBCPP___ITERATOR_ITERATOR_H + +#include <__config> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 iterator +{ + typedef _Tp value_type; + typedef _Distance difference_type; + typedef _Pointer pointer; + typedef _Reference reference; + typedef _Category iterator_category; +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/iterator_traits.h b/gnu/llvm/libcxx/include/__iterator/iterator_traits.h new file mode 100644 index 00000000000..5275705c117 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/iterator_traits.h @@ -0,0 +1,500 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_ITERATOR_TRAITS_H +#define _LIBCPP___ITERATOR_ITERATOR_TRAITS_H + +#include <__config> +#include <__iterator/incrementable_traits.h> +#include <__iterator/readable_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template +using __with_reference = _Tp&; + +template +concept __referenceable = requires { + typename __with_reference<_Tp>; +}; + +template +concept __dereferenceable = requires(_Tp& __t) { + { *__t } -> __referenceable; // not required to be equality-preserving +}; + +// [iterator.traits] +template<__dereferenceable _Tp> +using iter_reference_t = decltype(*declval<_Tp&>()); + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +template +struct _LIBCPP_TEMPLATE_VIS iterator_traits; + +struct _LIBCPP_TEMPLATE_VIS input_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS output_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS forward_iterator_tag : public input_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; +struct _LIBCPP_TEMPLATE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; +#if _LIBCPP_STD_VER > 17 +struct _LIBCPP_TEMPLATE_VIS contiguous_iterator_tag : public random_access_iterator_tag {}; +#endif + +template +struct __iter_traits_cache { + using type = _If< + __is_primary_template >::value, + _Iter, + iterator_traits<_Iter> + >; +}; +template +using _ITER_TRAITS = typename __iter_traits_cache<_Iter>::type; + +struct __iter_concept_concept_test { + template + using _Apply = typename _ITER_TRAITS<_Iter>::iterator_concept; +}; +struct __iter_concept_category_test { + template + using _Apply = typename _ITER_TRAITS<_Iter>::iterator_category; +}; +struct __iter_concept_random_fallback { + template + using _Apply = _EnableIf< + __is_primary_template >::value, + random_access_iterator_tag + >; +}; + +template struct __test_iter_concept + : _IsValidExpansion<_Tester::template _Apply, _Iter>, + _Tester +{ +}; + +template +struct __iter_concept_cache { + using type = _Or< + __test_iter_concept<_Iter, __iter_concept_concept_test>, + __test_iter_concept<_Iter, __iter_concept_category_test>, + __test_iter_concept<_Iter, __iter_concept_random_fallback> + >; +}; + +template +using _ITER_CONCEPT = typename __iter_concept_cache<_Iter>::type::template _Apply<_Iter>; + + +template +struct __has_iterator_typedefs +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename __void_t::type* = 0, + typename __void_t::type* = 0, + typename __void_t::type* = 0, + typename __void_t::type* = 0, + typename __void_t::type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1; +}; + + +template +struct __has_iterator_category +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::iterator_category* = nullptr); +public: + static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; +}; + +template +struct __has_iterator_concept +{ +private: + struct __two {char __lx; char __lxx;}; + template static __two __test(...); + template static char __test(typename _Up::iterator_concept* = nullptr); +public: + static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; +}; + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// The `cpp17-*-iterator` exposition-only concepts are easily confused with the Cpp17*Iterator tables, +// so they've been banished to a namespace that makes it obvious they have a niche use-case. +namespace __iterator_traits_detail { +template +concept __cpp17_iterator = + requires(_Ip __i) { + { *__i } -> __referenceable; + { ++__i } -> same_as<_Ip&>; + { *__i++ } -> __referenceable; + } && + copyable<_Ip>; + +template +concept __cpp17_input_iterator = + __cpp17_iterator<_Ip> && + equality_comparable<_Ip> && + requires(_Ip __i) { + typename incrementable_traits<_Ip>::difference_type; + typename indirectly_readable_traits<_Ip>::value_type; + typename common_reference_t&&, + typename indirectly_readable_traits<_Ip>::value_type&>; + typename common_reference_t::value_type&>; + requires signed_integral::difference_type>; + }; + +template +concept __cpp17_forward_iterator = + __cpp17_input_iterator<_Ip> && + constructible_from<_Ip> && + is_lvalue_reference_v> && + same_as>, + typename indirectly_readable_traits<_Ip>::value_type> && + requires(_Ip __i) { + { __i++ } -> convertible_to<_Ip const&>; + { *__i++ } -> same_as>; + }; + +template +concept __cpp17_bidirectional_iterator = + __cpp17_forward_iterator<_Ip> && + requires(_Ip __i) { + { --__i } -> same_as<_Ip&>; + { __i-- } -> convertible_to<_Ip const&>; + { *__i-- } -> same_as>; + }; + +template +concept __cpp17_random_access_iterator = + __cpp17_bidirectional_iterator<_Ip> && + totally_ordered<_Ip> && + requires(_Ip __i, typename incrementable_traits<_Ip>::difference_type __n) { + { __i += __n } -> same_as<_Ip&>; + { __i -= __n } -> same_as<_Ip&>; + { __i + __n } -> same_as<_Ip>; + { __n + __i } -> same_as<_Ip>; + { __i - __n } -> same_as<_Ip>; + { __i - __i } -> same_as; + { __i[__n] } -> convertible_to>; + }; +} // namespace __iterator_traits_detail + +template +concept __has_member_reference = requires { typename _Ip::reference; }; + +template +concept __has_member_pointer = requires { typename _Ip::pointer; }; + +template +concept __has_member_iterator_category = requires { typename _Ip::iterator_category; }; + +template +concept __specifies_members = requires { + typename _Ip::value_type; + typename _Ip::difference_type; + requires __has_member_reference<_Ip>; + requires __has_member_iterator_category<_Ip>; + }; + +template +struct __iterator_traits_member_pointer_or_void { + using type = void; +}; + +template<__has_member_pointer _Tp> +struct __iterator_traits_member_pointer_or_void<_Tp> { + using type = typename _Tp::pointer; +}; + +template +concept __cpp17_iterator_missing_members = + !__specifies_members<_Tp> && + __iterator_traits_detail::__cpp17_iterator<_Tp>; + +template +concept __cpp17_input_iterator_missing_members = + __cpp17_iterator_missing_members<_Tp> && + __iterator_traits_detail::__cpp17_input_iterator<_Tp>; + +// Otherwise, `pointer` names `void`. +template +struct __iterator_traits_member_pointer_or_arrow_or_void { using type = void; }; + +// [iterator.traits]/3.2.1 +// If the qualified-id `I::pointer` is valid and denotes a type, `pointer` names that type. +template<__has_member_pointer _Ip> +struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { using type = typename _Ip::pointer; }; + +// Otherwise, if `decltype(declval().operator->())` is well-formed, then `pointer` names that +// type. +template + requires requires(_Ip& __i) { __i.operator->(); } && (!__has_member_pointer<_Ip>) +struct __iterator_traits_member_pointer_or_arrow_or_void<_Ip> { + using type = decltype(declval<_Ip&>().operator->()); +}; + +// Otherwise, `reference` names `iter-reference-t`. +template +struct __iterator_traits_member_reference { using type = iter_reference_t<_Ip>; }; + +// [iterator.traits]/3.2.2 +// If the qualified-id `I::reference` is valid and denotes a type, `reference` names that type. +template<__has_member_reference _Ip> +struct __iterator_traits_member_reference<_Ip> { using type = typename _Ip::reference; }; + +// [iterator.traits]/3.2.3.4 +// input_iterator_tag +template +struct __deduce_iterator_category { + using type = input_iterator_tag; +}; + +// [iterator.traits]/3.2.3.1 +// `random_access_iterator_tag` if `I` satisfies `cpp17-random-access-iterator`, or otherwise +template<__iterator_traits_detail::__cpp17_random_access_iterator _Ip> +struct __deduce_iterator_category<_Ip> { + using type = random_access_iterator_tag; +}; + +// [iterator.traits]/3.2.3.2 +// `bidirectional_iterator_tag` if `I` satisfies `cpp17-bidirectional-iterator`, or otherwise +template<__iterator_traits_detail::__cpp17_bidirectional_iterator _Ip> +struct __deduce_iterator_category<_Ip> { + using type = bidirectional_iterator_tag; +}; + +// [iterator.traits]/3.2.3.3 +// `forward_iterator_tag` if `I` satisfies `cpp17-forward-iterator`, or otherwise +template<__iterator_traits_detail::__cpp17_forward_iterator _Ip> +struct __deduce_iterator_category<_Ip> { + using type = forward_iterator_tag; +}; + +template +struct __iterator_traits_iterator_category : __deduce_iterator_category<_Ip> {}; + +// [iterator.traits]/3.2.3 +// If the qualified-id `I::iterator-category` is valid and denotes a type, `iterator-category` names +// that type. +template<__has_member_iterator_category _Ip> +struct __iterator_traits_iterator_category<_Ip> { + using type = typename _Ip::iterator_category; +}; + +// otherwise, it names void. +template +struct __iterator_traits_difference_type { using type = void; }; + +// If the qualified-id `incrementable_traits::difference_type` is valid and denotes a type, then +// `difference_type` names that type; +template +requires requires { typename incrementable_traits<_Ip>::difference_type; } +struct __iterator_traits_difference_type<_Ip> { + using type = typename incrementable_traits<_Ip>::difference_type; +}; + +// [iterator.traits]/3.4 +// Otherwise, `iterator_traits` has no members by any of the above names. +template +struct __iterator_traits {}; + +// [iterator.traits]/3.1 +// If `I` has valid ([temp.deduct]) member types `difference-type`, `value-type`, `reference`, and +// `iterator-category`, then `iterator-traits` has the following publicly accessible members: +template<__specifies_members _Ip> +struct __iterator_traits<_Ip> { + using iterator_category = typename _Ip::iterator_category; + using value_type = typename _Ip::value_type; + using difference_type = typename _Ip::difference_type; + using pointer = typename __iterator_traits_member_pointer_or_void<_Ip>::type; + using reference = typename _Ip::reference; +}; + +// [iterator.traits]/3.2 +// Otherwise, if `I` satisfies the exposition-only concept `cpp17-input-iterator`, +// `iterator-traits` has the following publicly accessible members: +template<__cpp17_input_iterator_missing_members _Ip> +struct __iterator_traits<_Ip> { + using iterator_category = typename __iterator_traits_iterator_category<_Ip>::type; + using value_type = typename indirectly_readable_traits<_Ip>::value_type; + using difference_type = typename incrementable_traits<_Ip>::difference_type; + using pointer = typename __iterator_traits_member_pointer_or_arrow_or_void<_Ip>::type; + using reference = typename __iterator_traits_member_reference<_Ip>::type; +}; + +// Otherwise, if `I` satisfies the exposition-only concept `cpp17-iterator`, then +// `iterator_traits` has the following publicly accessible members: +template<__cpp17_iterator_missing_members _Ip> +struct __iterator_traits<_Ip> { + using iterator_category = output_iterator_tag; + using value_type = void; + using difference_type = typename __iterator_traits_difference_type<_Ip>::type; + using pointer = void; + using reference = void; +}; + +template +struct iterator_traits : __iterator_traits<_Ip> { + using __primary_template = iterator_traits; +}; + +#else // !defined(_LIBCPP_HAS_NO_RANGES) + +template struct __iterator_traits {}; + +template struct __iterator_traits_impl {}; + +template +struct __iterator_traits_impl<_Iter, true> +{ + typedef typename _Iter::difference_type difference_type; + typedef typename _Iter::value_type value_type; + typedef typename _Iter::pointer pointer; + typedef typename _Iter::reference reference; + typedef typename _Iter::iterator_category iterator_category; +}; + +template +struct __iterator_traits<_Iter, true> + : __iterator_traits_impl + < + _Iter, + is_convertible::value || + is_convertible::value + > +{}; + +// iterator_traits will only have the nested types if Iterator::iterator_category +// exists. Else iterator_traits will be an empty class. This is a +// conforming extension which allows some programs to compile and behave as +// the client expects instead of failing at compile time. + +template +struct _LIBCPP_TEMPLATE_VIS iterator_traits + : __iterator_traits<_Iter, __has_iterator_typedefs<_Iter>::value> { + + using __primary_template = iterator_traits; +}; +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +template +#if !defined(_LIBCPP_HAS_NO_RANGES) +requires is_object_v<_Tp> +#endif +struct _LIBCPP_TEMPLATE_VIS iterator_traits<_Tp*> +{ + typedef ptrdiff_t difference_type; + typedef typename remove_cv<_Tp>::type value_type; + typedef _Tp* pointer; + typedef _Tp& reference; + typedef random_access_iterator_tag iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef contiguous_iterator_tag iterator_concept; +#endif +}; + +template >::value> +struct __has_iterator_category_convertible_to + : is_convertible::iterator_category, _Up> +{}; + +template +struct __has_iterator_category_convertible_to<_Tp, _Up, false> : false_type {}; + +template ::value> +struct __has_iterator_concept_convertible_to + : is_convertible +{}; + +template +struct __has_iterator_concept_convertible_to<_Tp, _Up, false> : false_type {}; + +template +struct __is_cpp17_input_iterator : public __has_iterator_category_convertible_to<_Tp, input_iterator_tag> {}; + +template +struct __is_cpp17_forward_iterator : public __has_iterator_category_convertible_to<_Tp, forward_iterator_tag> {}; + +template +struct __is_cpp17_bidirectional_iterator : public __has_iterator_category_convertible_to<_Tp, bidirectional_iterator_tag> {}; + +template +struct __is_cpp17_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; + +// __is_cpp17_contiguous_iterator determines if an iterator is known by +// libc++ to be contiguous, either because it advertises itself as such +// (in C++20) or because it is a pointer type or a known trivial wrapper +// around a (possibly fancy) pointer type, such as __wrap_iter. +// Such iterators receive special "contiguous" optimizations in +// std::copy and std::sort. +// +#if _LIBCPP_STD_VER > 17 +template +struct __is_cpp17_contiguous_iterator : _Or< + __has_iterator_category_convertible_to<_Tp, contiguous_iterator_tag>, + __has_iterator_concept_convertible_to<_Tp, contiguous_iterator_tag> +> {}; +#else +template +struct __is_cpp17_contiguous_iterator : false_type {}; +#endif + +// Any native pointer which is an iterator is also a contiguous iterator. +template +struct __is_cpp17_contiguous_iterator<_Up*> : true_type {}; + + +template +struct __is_exactly_cpp17_input_iterator + : public integral_constant::value && + !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; + +#ifndef _LIBCPP_HAS_NO_DEDUCTION_GUIDES +template +using __iter_value_type = typename iterator_traits<_InputIterator>::value_type; + +template +using __iter_key_type = remove_const_t::value_type::first_type>; + +template +using __iter_mapped_type = typename iterator_traits<_InputIterator>::value_type::second_type; + +template +using __iter_to_alloc_type = pair< + add_const_t::value_type::first_type>, + typename iterator_traits<_InputIterator>::value_type::second_type>; +#endif // _LIBCPP_HAS_NO_DEDUCTION_GUIDES + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_ITERATOR_TRAITS_H diff --git a/gnu/llvm/libcxx/include/__iterator/move_iterator.h b/gnu/llvm/libcxx/include/__iterator/move_iterator.h new file mode 100644 index 00000000000..7819743bdb3 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/move_iterator.h @@ -0,0 +1,189 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_MOVE_ITERATOR_H +#define _LIBCPP___ITERATOR_MOVE_ITERATOR_H + +#include <__config> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class _LIBCPP_TEMPLATE_VIS move_iterator +{ +private: + _Iter __i; +public: + typedef _Iter iterator_type; + typedef typename iterator_traits::value_type value_type; + typedef typename iterator_traits::difference_type difference_type; + typedef iterator_type pointer; + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + typename iterator_traits<_Iter>::iterator_category> iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef input_iterator_tag iterator_concept; +#endif + +#ifndef _LIBCPP_CXX03_LANG + typedef typename iterator_traits::reference __reference; + typedef typename conditional< + is_reference<__reference>::value, + typename remove_reference<__reference>::type&&, + __reference + >::type reference; +#else + typedef typename iterator_traits::reference reference; +#endif + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator() : __i() {} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit move_iterator(_Iter __x) : __i(__x) {} + + template ::value && is_convertible<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator(const move_iterator<_Up>& __u) : __i(__u.base()) {} + + template ::value && + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Iter&, _Up const&>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator=(const move_iterator<_Up>& __u) { + __i = __u.base(); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 _Iter base() const {return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator*() const { return static_cast(*__i); } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + pointer operator->() const { return __i;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator++() {++__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator++(int) {move_iterator __tmp(*this); ++__i; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator--() {--__i; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator--(int) {move_iterator __tmp(*this); --__i; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator+ (difference_type __n) const {return move_iterator(__i + __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator+=(difference_type __n) {__i += __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator operator- (difference_type __n) const {return move_iterator(__i - __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + move_iterator& operator-=(difference_type __n) {__i -= __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator[](difference_type __n) const { return static_cast(__i[__n]); } +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator==(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() == __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() < __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator!=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() != __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() > __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() >= __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<=(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() <= __y.base(); +} + +#ifndef _LIBCPP_CXX03_LANG +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +-> decltype(__x.base() - __y.base()) +{ + return __x.base() - __y.base(); +} +#else +template +inline _LIBCPP_INLINE_VISIBILITY +typename move_iterator<_Iter1>::difference_type +operator-(const move_iterator<_Iter1>& __x, const move_iterator<_Iter2>& __y) +{ + return __x.base() - __y.base(); +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +move_iterator<_Iter> +operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterator<_Iter>& __x) +{ + return move_iterator<_Iter>(__x.base() + __n); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +move_iterator<_Iter> +make_move_iterator(_Iter __i) +{ + return move_iterator<_Iter>(__i); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_MOVE_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/next.h b/gnu/llvm/libcxx/include/__iterator/next.h new file mode 100644 index 00000000000..1eecaa9750b --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/next.h @@ -0,0 +1,87 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_NEXT_H +#define _LIBCPP___ITERATOR_NEXT_H + +#include <__config> +#include <__debug> +#include <__function_like.h> +#include <__iterator/advance.h> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type + next(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { + _LIBCPP_ASSERT(__n >= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to next(it, n) with negative n on a non-bidirectional iterator"); + + _VSTD::advance(__x, __n); + return __x; +} + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +struct __next_fn final : private __function_like { + _LIBCPP_HIDE_FROM_ABI + constexpr explicit __next_fn(__tag __x) noexcept : __function_like(__x) {} + + template + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x) const { + ++__x; + return __x; + } + + template + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { + ranges::advance(__x, __n); + return __x; + } + + template _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, _Sp __bound) const { + ranges::advance(__x, __bound); + return __x; + } + + template _Sp> + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Sp __bound) const { + ranges::advance(__x, __n, __bound); + return __x; + } +}; + +inline constexpr auto next = __next_fn(__function_like::__tag()); +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_PRIMITIVES_H diff --git a/gnu/llvm/libcxx/include/__iterator/ostream_iterator.h b/gnu/llvm/libcxx/include/__iterator/ostream_iterator.h new file mode 100644 index 00000000000..5b4466c8639 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/ostream_iterator.h @@ -0,0 +1,75 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_OSTREAM_ITERATOR_H +#define _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include // for forward declarations of char_traits and basic_ostream + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template > +class _LIBCPP_TEMPLATE_VIS ostream_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + +private: + ostream_type* __out_stream_; + const char_type* __delim_; +public: + _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s) _NOEXCEPT + : __out_stream_(_VSTD::addressof(__s)), __delim_(nullptr) {} + _LIBCPP_INLINE_VISIBILITY ostream_iterator(ostream_type& __s, const _CharT* __delimiter) _NOEXCEPT + : __out_stream_(_VSTD::addressof(__s)), __delim_(__delimiter) {} + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator=(const _Tp& __value_) + { + *__out_stream_ << __value_; + if (__delim_) + *__out_stream_ << __delim_; + return *this; + } + + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostream_iterator& operator++(int) {return *this;} +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_OSTREAM_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/ostreambuf_iterator.h b/gnu/llvm/libcxx/include/__iterator/ostreambuf_iterator.h new file mode 100644 index 00000000000..90309dacd42 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/ostreambuf_iterator.h @@ -0,0 +1,81 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_OSTREAMBUF_ITERATOR_H +#define _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include // for forward declaration of basic_streambuf + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +class _LIBCPP_TEMPLATE_VIS ostreambuf_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +public: + typedef output_iterator_tag iterator_category; + typedef void value_type; +#if _LIBCPP_STD_VER > 17 + typedef ptrdiff_t difference_type; +#else + typedef void difference_type; +#endif + typedef void pointer; + typedef void reference; + typedef _CharT char_type; + typedef _Traits traits_type; + typedef basic_streambuf<_CharT, _Traits> streambuf_type; + typedef basic_ostream<_CharT, _Traits> ostream_type; + +private: + streambuf_type* __sbuf_; +public: + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(ostream_type& __s) _NOEXCEPT + : __sbuf_(__s.rdbuf()) {} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator(streambuf_type* __s) _NOEXCEPT + : __sbuf_(__s) {} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator=(_CharT __c) + { + if (__sbuf_ && traits_type::eq_int_type(__sbuf_->sputc(__c), traits_type::eof())) + __sbuf_ = nullptr; + return *this; + } + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator*() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++() {return *this;} + _LIBCPP_INLINE_VISIBILITY ostreambuf_iterator& operator++(int) {return *this;} + _LIBCPP_INLINE_VISIBILITY bool failed() const _NOEXCEPT {return __sbuf_ == nullptr;} + + template + friend + _LIBCPP_HIDDEN + ostreambuf_iterator<_Ch, _Tr> + __pad_and_output(ostreambuf_iterator<_Ch, _Tr> __s, + const _Ch* __ob, const _Ch* __op, const _Ch* __oe, + ios_base& __iob, _Ch __fl); +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_OSTREAMBUF_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/prev.h b/gnu/llvm/libcxx/include/__iterator/prev.h new file mode 100644 index 00000000000..cb8a5713550 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/prev.h @@ -0,0 +1,79 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_PREV_H +#define _LIBCPP___ITERATOR_PREV_H + +#include <__config> +#include <__debug> +#include <__function_like.h> +#include <__iterator/advance.h> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include <__iterator/iterator_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + typename enable_if<__is_cpp17_input_iterator<_InputIter>::value, _InputIter>::type + prev(_InputIter __x, typename iterator_traits<_InputIter>::difference_type __n = 1) { + _LIBCPP_ASSERT(__n <= 0 || __is_cpp17_bidirectional_iterator<_InputIter>::value, + "Attempt to prev(it, n) with a positive n on a non-bidirectional iterator"); + _VSTD::advance(__x, -__n); + return __x; +} + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +namespace ranges { +struct __prev_fn final : private __function_like { + _LIBCPP_HIDE_FROM_ABI + constexpr explicit __prev_fn(__tag __x) noexcept : __function_like(__x) {} + + template + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x) const { + --__x; + return __x; + } + + template + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n) const { + ranges::advance(__x, -__n); + return __x; + } + + template + _LIBCPP_HIDE_FROM_ABI + constexpr _Ip operator()(_Ip __x, iter_difference_t<_Ip> __n, _Ip __bound) const { + ranges::advance(__x, -__n, __bound); + return __x; + } +}; + +inline constexpr auto prev = __prev_fn(__function_like::__tag()); +} // namespace ranges + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_PREV_H diff --git a/gnu/llvm/libcxx/include/__iterator/projected.h b/gnu/llvm/libcxx/include/__iterator/projected.h new file mode 100644 index 00000000000..7064a5eb919 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/projected.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_PROJECTED_H +#define _LIBCPP___ITERATOR_PROJECTED_H + +#include <__config> +#include <__iterator/concepts.h> +#include <__iterator/incrementable_traits.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +template _Proj> +struct projected { + using value_type = remove_cvref_t>; + indirect_result_t<_Proj&, _It> operator*() const; // not defined +}; + +template +struct incrementable_traits> { + using difference_type = iter_difference_t<_It>; +}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_PROJECTED_H diff --git a/gnu/llvm/libcxx/include/__iterator/readable_traits.h b/gnu/llvm/libcxx/include/__iterator/readable_traits.h new file mode 100644 index 00000000000..fbad106e4ee --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/readable_traits.h @@ -0,0 +1,91 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_READABLE_TRAITS_H +#define _LIBCPP___ITERATOR_READABLE_TRAITS_H + +#include <__config> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +// [readable.traits] +template struct __cond_value_type {}; + +template +requires is_object_v<_Tp> +struct __cond_value_type<_Tp> { using value_type = remove_cv_t<_Tp>; }; + +template +concept __has_member_value_type = requires { typename _Tp::value_type; }; + +template +concept __has_member_element_type = requires { typename _Tp::element_type; }; + +template struct indirectly_readable_traits {}; + +template +requires is_array_v<_Ip> +struct indirectly_readable_traits<_Ip> { + using value_type = remove_cv_t>; +}; + +template +struct indirectly_readable_traits : indirectly_readable_traits<_Ip> {}; + +template +struct indirectly_readable_traits<_Tp*> : __cond_value_type<_Tp> {}; + +template<__has_member_value_type _Tp> +struct indirectly_readable_traits<_Tp> + : __cond_value_type {}; + +template<__has_member_element_type _Tp> +struct indirectly_readable_traits<_Tp> + : __cond_value_type {}; + +// Pre-emptively applies LWG3541 +template<__has_member_value_type _Tp> +requires __has_member_element_type<_Tp> +struct indirectly_readable_traits<_Tp> {}; +template<__has_member_value_type _Tp> +requires __has_member_element_type<_Tp> && + same_as, + remove_cv_t> +struct indirectly_readable_traits<_Tp> + : __cond_value_type {}; + +template +struct iterator_traits; + +// Let `RI` be `remove_cvref_t`. The type `iter_value_t` denotes +// `indirectly_readable_traits::value_type` if `iterator_traits` names a specialization +// generated from the primary template, and `iterator_traits::value_type` otherwise. +template +using iter_value_t = typename conditional_t<__is_primary_template > >::value, + indirectly_readable_traits >, + iterator_traits > >::value_type; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_READABLE_TRAITS_H diff --git a/gnu/llvm/libcxx/include/__iterator/reverse_access.h b/gnu/llvm/libcxx/include/__iterator/reverse_access.h new file mode 100644 index 00000000000..66cc3568c1c --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/reverse_access.h @@ -0,0 +1,109 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_REVERSE_ACCESS_H +#define _LIBCPP___ITERATOR_REVERSE_ACCESS_H + +#include <__config> +#include <__iterator/reverse_iterator.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_CXX03_LANG) + +#if _LIBCPP_STD_VER > 11 + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array + _Np); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator rbegin(initializer_list<_Ep> __il) +{ + return reverse_iterator(__il.end()); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator rend(initializer_list<_Ep> __il) +{ + return reverse_iterator(__il.begin()); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) +{ + return __c.rbegin(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) +{ + return __c.rbegin(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rend(_Cp& __c) -> decltype(__c.rend()) +{ + return __c.rend(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto rend(const _Cp& __c) -> decltype(__c.rend()) +{ + return __c.rend(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto crbegin(const _Cp& __c) -> decltype(_VSTD::rbegin(__c)) +{ + return _VSTD::rbegin(__c); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto crend(const _Cp& __c) -> decltype(_VSTD::rend(__c)) +{ + return _VSTD::rend(__c); +} + +#endif + +#endif // !defined(_LIBCPP_CXX03_LANG) + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_REVERSE_ACCESS_H diff --git a/gnu/llvm/libcxx/include/__iterator/reverse_iterator.h b/gnu/llvm/libcxx/include/__iterator/reverse_iterator.h new file mode 100644 index 00000000000..76424a89a19 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/reverse_iterator.h @@ -0,0 +1,239 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_REVERSE_ITERATOR_H +#define _LIBCPP___ITERATOR_REVERSE_ITERATOR_H + +#include <__config> +#include <__iterator/iterator.h> +#include <__iterator/iterator_traits.h> +#include <__memory/addressof.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +struct __is_stashing_iterator : false_type {}; + +template +struct __is_stashing_iterator<_Tp, typename __void_t::type> + : true_type {}; + +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +class _LIBCPP_TEMPLATE_VIS reverse_iterator +#if _LIBCPP_STD_VER <= 14 || !defined(_LIBCPP_ABI_NO_ITERATOR_BASES) + : public iterator::iterator_category, + typename iterator_traits<_Iter>::value_type, + typename iterator_traits<_Iter>::difference_type, + typename iterator_traits<_Iter>::pointer, + typename iterator_traits<_Iter>::reference> +#endif +{ +_LIBCPP_SUPPRESS_DEPRECATED_POP +private: +#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES + _Iter __t; // no longer used as of LWG #2360, not removed due to ABI break +#endif + + static_assert(!__is_stashing_iterator<_Iter>::value, + "The specified iterator type cannot be used with reverse_iterator; " + "Using stashing iterators with reverse_iterator causes undefined behavior"); + +protected: + _Iter current; +public: + typedef _Iter iterator_type; + typedef typename iterator_traits<_Iter>::difference_type difference_type; + typedef typename iterator_traits<_Iter>::reference reference; + typedef typename iterator_traits<_Iter>::pointer pointer; + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + typename iterator_traits<_Iter>::iterator_category> iterator_category; + typedef typename iterator_traits<_Iter>::value_type value_type; + +#if _LIBCPP_STD_VER > 17 + typedef _If<__is_cpp17_random_access_iterator<_Iter>::value, + random_access_iterator_tag, + bidirectional_iterator_tag> iterator_concept; +#endif + +#ifndef _LIBCPP_ABI_NO_ITERATOR_BASES + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator() : __t(), current() {} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit reverse_iterator(_Iter __x) : __t(__x), current(__x) {} + + template ::value && is_convertible<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator(const reverse_iterator<_Up>& __u) + : __t(__u.base()), current(__u.base()) + { } + + template ::value && + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { + __t = current = __u.base(); + return *this; + } +#else + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator() : current() {} + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + explicit reverse_iterator(_Iter __x) : current(__x) {} + + template ::value && is_convertible<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator(const reverse_iterator<_Up>& __u) + : current(__u.base()) + { } + + template ::value && + is_convertible<_Up const&, _Iter>::value && + is_assignable<_Up const&, _Iter>::value + > > + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator=(const reverse_iterator<_Up>& __u) { + current = __u.base(); + return *this; + } +#endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + _Iter base() const {return current;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator*() const {_Iter __tmp = current; return *--__tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + pointer operator->() const {return _VSTD::addressof(operator*());} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator++() {--current; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator++(int) {reverse_iterator __tmp(*this); --current; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator--() {++current; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator--(int) {reverse_iterator __tmp(*this); ++current; return __tmp;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator+ (difference_type __n) const {return reverse_iterator(current - __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator+=(difference_type __n) {current -= __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator operator- (difference_type __n) const {return reverse_iterator(current + __n);} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reverse_iterator& operator-=(difference_type __n) {current += __n; return *this;} + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 + reference operator[](difference_type __n) const {return *(*this + __n);} +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator==(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() == __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() > __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() != __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() < __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator>=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() <= __y.base(); +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +bool +operator<=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __x.base() >= __y.base(); +} + +#ifndef _LIBCPP_CXX03_LANG +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +auto +operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +-> decltype(__y.base() - __x.base()) +{ + return __y.base() - __x.base(); +} +#else +template +inline _LIBCPP_INLINE_VISIBILITY +typename reverse_iterator<_Iter1>::difference_type +operator-(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y) +{ + return __y.base() - __x.base(); +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Iter> +operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_iterator<_Iter>& __x) +{ + return reverse_iterator<_Iter>(__x.base() - __n); +} + +#if _LIBCPP_STD_VER > 11 +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 +reverse_iterator<_Iter> make_reverse_iterator(_Iter __i) +{ + return reverse_iterator<_Iter>(__i); +} +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_REVERSE_ITERATOR_H diff --git a/gnu/llvm/libcxx/include/__iterator/size.h b/gnu/llvm/libcxx/include/__iterator/size.h new file mode 100644 index 00000000000..259424f1d31 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/size.h @@ -0,0 +1,58 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_SIZE_H +#define _LIBCPP___ITERATOR_SIZE_H + +#include <__config> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if _LIBCPP_STD_VER > 14 + +template +_LIBCPP_INLINE_VISIBILITY +constexpr auto size(const _Cont& __c) +_NOEXCEPT_(noexcept(__c.size())) +-> decltype (__c.size()) +{ return __c.size(); } + +template +_LIBCPP_INLINE_VISIBILITY +constexpr size_t size(const _Tp (&)[_Sz]) noexcept { return _Sz; } + +#if _LIBCPP_STD_VER > 17 +template +_LIBCPP_INLINE_VISIBILITY +constexpr auto ssize(const _Cont& __c) +_NOEXCEPT_(noexcept(static_cast>>(__c.size()))) +-> common_type_t> +{ return static_cast>>(__c.size()); } + +template +_LIBCPP_INLINE_VISIBILITY +constexpr ptrdiff_t ssize(const _Tp (&)[_Sz]) noexcept { return _Sz; } +#endif + +#endif // _LIBCPP_STD_VER > 14 + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_SIZE_H diff --git a/gnu/llvm/libcxx/include/__iterator/wrap_iter.h b/gnu/llvm/libcxx/include/__iterator/wrap_iter.h new file mode 100644 index 00000000000..e35a372b426 --- /dev/null +++ b/gnu/llvm/libcxx/include/__iterator/wrap_iter.h @@ -0,0 +1,300 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___ITERATOR_WRAP_ITER_H +#define _LIBCPP___ITERATOR_WRAP_ITER_H + +#include <__config> +#include <__debug> +#include <__iterator/iterator_traits.h> +#include <__memory/pointer_traits.h> // __to_address +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template +class __wrap_iter +{ +public: + typedef _Iter iterator_type; + typedef typename iterator_traits::value_type value_type; + typedef typename iterator_traits::difference_type difference_type; + typedef typename iterator_traits::pointer pointer; + typedef typename iterator_traits::reference reference; + typedef typename iterator_traits::iterator_category iterator_category; +#if _LIBCPP_STD_VER > 17 + typedef contiguous_iterator_tag iterator_concept; +#endif + +private: + iterator_type __i; +public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __i{} +#endif + { +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__insert_i(this); +#endif + } + template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + __wrap_iter(const __wrap_iter<_Up>& __u, + typename enable_if::value>::type* = nullptr) _NOEXCEPT + : __i(__u.base()) + { +#if _LIBCPP_DEBUG_LEVEL == 2 + __get_db()->__iterator_copy(this, &__u); +#endif + } +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + __wrap_iter(const __wrap_iter& __x) + : __i(__x.base()) + { + __get_db()->__iterator_copy(this, &__x); + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + __wrap_iter& operator=(const __wrap_iter& __x) + { + if (this != &__x) + { + __get_db()->__iterator_copy(this, &__x); + __i = __x.__i; + } + return *this; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG + ~__wrap_iter() + { + __get_db()->__erase_i(this); + } +#endif + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG reference operator*() const _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif + return *__i; + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG pointer operator->() const _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to dereference a non-dereferenceable iterator"); +#endif + return _VSTD::__to_address(__i); + } + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter& operator++() _NOEXCEPT + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), + "Attempted to increment a non-incrementable iterator"); +#endif + ++__i; + return *this; + } + _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 + { +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__decrementable(this), + "Attempted to decrement a non-decrementable iterator"); +#endif + --__i; + return *this; + } + _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 + {__wrap_iter __w(*this); __w += __n; return __w;} + _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), + "Attempted to add/subtract an iterator outside its valid range"); +#endif + __i += __n; + return *this; + } + _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 + {*this += -__n; return *this;} + _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), + "Attempted to subscript an iterator outside its valid range"); +#endif + return __i[__n]; + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG iterator_type base() const _NOEXCEPT {return __i;} + +private: +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(const void* __p, iterator_type __x) : __i(__x) + { + __get_db()->__insert_ic(this, __p); + } +#else + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} +#endif + + template friend class __wrap_iter; + template friend class basic_string; + template friend class _LIBCPP_TEMPLATE_VIS vector; + template friend class _LIBCPP_TEMPLATE_VIS span; +}; + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return __x.base() == __y.base(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator==(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return __x.base() == __y.base(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to compare incomparable iterators"); +#endif + return __x.base() < __y.base(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool 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), + "Attempted to compare incomparable iterators"); +#endif + return __x.base() < __y.base(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__x == __y); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator!=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return !(__x == __y); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return __y < __x; +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return __y < __x; +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__x < __y); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator>=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return !(__x < __y); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter1>& __y) _NOEXCEPT +{ + return !(__y < __x); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +bool operator<=(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +{ + return !(__y < __x); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +#ifndef _LIBCPP_CXX03_LANG +auto operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT + -> decltype(__x.base() - __y.base()) +#else +typename __wrap_iter<_Iter1>::difference_type +operator-(const __wrap_iter<_Iter1>& __x, const __wrap_iter<_Iter2>& __y) _NOEXCEPT +#endif // C++03 +{ +#if _LIBCPP_DEBUG_LEVEL == 2 + _LIBCPP_ASSERT(__get_const_db()->__less_than_comparable(&__x, &__y), + "Attempted to subtract incompatible iterators"); +#endif + return __x.base() - __y.base(); +} + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_IF_NODEBUG +__wrap_iter<_Iter1> operator+(typename __wrap_iter<_Iter1>::difference_type __n, __wrap_iter<_Iter1> __x) _NOEXCEPT +{ + __x += __n; + return __x; +} + +#if _LIBCPP_STD_VER <= 17 +template +struct __is_cpp17_contiguous_iterator<__wrap_iter<_It> > : true_type {}; +#endif + +template +_LIBCPP_CONSTEXPR +decltype(_VSTD::__to_address(declval<_Iter>())) +__to_address(__wrap_iter<_Iter> __w) _NOEXCEPT { + return _VSTD::__to_address(__w.base()); +} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___ITERATOR_WRAP_ITER_H diff --git a/gnu/llvm/libcxx/include/__libcpp_version b/gnu/llvm/libcxx/include/__libcpp_version index 82b3803a20e..09514aa4db9 100644 --- a/gnu/llvm/libcxx/include/__libcpp_version +++ b/gnu/llvm/libcxx/include/__libcpp_version @@ -1 +1 @@ -11000 +13000 diff --git a/gnu/llvm/libcxx/include/__memory/addressof.h b/gnu/llvm/libcxx/include/__memory/addressof.h new file mode 100644 index 00000000000..5efdb587862 --- /dev/null +++ b/gnu/llvm/libcxx/include/__memory/addressof.h @@ -0,0 +1,96 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___MEMORY_ADDRESSOF_H +#define _LIBCPP___MEMORY_ADDRESSOF_H + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#ifndef _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF + +template +inline _LIBCPP_CONSTEXPR_AFTER_CXX14 +_LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return __builtin_addressof(__x); +} + +#else + +template +inline _LIBCPP_NO_CFI _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return reinterpret_cast<_Tp *>( + const_cast(&reinterpret_cast(__x))); +} + +#endif // _LIBCPP_HAS_NO_BUILTIN_ADDRESSOF + +#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) +// Objective-C++ Automatic Reference Counting uses qualified pointers +// that require special addressof() signatures. When +// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler +// itself is providing these definitions. Otherwise, we provide them. +template +inline _LIBCPP_INLINE_VISIBILITY +__strong _Tp* +addressof(__strong _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK +template +inline _LIBCPP_INLINE_VISIBILITY +__weak _Tp* +addressof(__weak _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +__autoreleasing _Tp* +addressof(__autoreleasing _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +__unsafe_unretained _Tp* +addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + +#if !defined(_LIBCPP_CXX03_LANG) +template _Tp* addressof(const _Tp&&) noexcept = delete; +#endif + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___MEMORY_ADDRESSOF_H diff --git a/gnu/llvm/libcxx/include/__memory/allocation_guard.h b/gnu/llvm/libcxx/include/__memory/allocation_guard.h new file mode 100644 index 00000000000..4987af293d1 --- /dev/null +++ b/gnu/llvm/libcxx/include/__memory/allocation_guard.h @@ -0,0 +1,89 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___MEMORY_ALLOCATION_GUARD_H +#define _LIBCPP___MEMORY_ALLOCATION_GUARD_H + +#include <__config> +#include <__memory/allocator_traits.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + + +_LIBCPP_BEGIN_NAMESPACE_STD + +// Helper class to allocate memory using an Allocator in an exception safe +// manner. +// +// The intended usage of this class is as follows: +// +// 0 +// 1 __allocation_guard guard(alloc, 10); +// 2 do_some_initialization_that_may_throw(guard.__get()); +// 3 save_allocated_pointer_in_a_noexcept_operation(guard.__release_ptr()); +// 4 +// +// If line (2) throws an exception during initialization of the memory, the +// guard's destructor will be called, and the memory will be released using +// Allocator deallocation. Otherwise, we release the memory from the guard on +// line (3) in an operation that can't throw -- after that, the guard is not +// responsible for the memory anymore. +// +// This is similar to a unique_ptr, except it's easier to use with a +// custom allocator. +template +struct __allocation_guard { + using _Pointer = typename allocator_traits<_Alloc>::pointer; + using _Size = typename allocator_traits<_Alloc>::size_type; + + template // we perform the allocator conversion inside the constructor + _LIBCPP_HIDE_FROM_ABI + explicit __allocation_guard(_AllocT __alloc, _Size __n) + : __alloc_(_VSTD::move(__alloc)) + , __n_(__n) + , __ptr_(allocator_traits<_Alloc>::allocate(__alloc_, __n_)) // initialization order is important + { } + + _LIBCPP_HIDE_FROM_ABI + ~__allocation_guard() _NOEXCEPT { + if (__ptr_ != nullptr) { + allocator_traits<_Alloc>::deallocate(__alloc_, __ptr_, __n_); + } + } + + _LIBCPP_HIDE_FROM_ABI + _Pointer __release_ptr() _NOEXCEPT { // not called __release() because it's a keyword in objective-c++ + _Pointer __tmp = __ptr_; + __ptr_ = nullptr; + return __tmp; + } + + _LIBCPP_HIDE_FROM_ABI + _Pointer __get() const _NOEXCEPT { + return __ptr_; + } + +private: + _Alloc __alloc_; + _Size __n_; + _Pointer __ptr_; +}; + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___MEMORY_ALLOCATION_GUARD_H diff --git a/gnu/llvm/libcxx/include/__memory/allocator.h b/gnu/llvm/libcxx/include/__memory/allocator.h new file mode 100644 index 00000000000..2c21a16e7e8 --- /dev/null +++ b/gnu/llvm/libcxx/include/__memory/allocator.h @@ -0,0 +1,254 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___MEMORY_ALLOCATOR_H +#define _LIBCPP___MEMORY_ALLOCATOR_H + +#include <__config> +#include <__memory/allocator_traits.h> +#include <__utility/forward.h> +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +template class allocator; + +#if _LIBCPP_STD_VER <= 17 +template <> +class _LIBCPP_TEMPLATE_VIS allocator +{ +public: + _LIBCPP_DEPRECATED_IN_CXX17 typedef void* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef void value_type; + + template struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; +}; + +template <> +class _LIBCPP_TEMPLATE_VIS allocator +{ +public: + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const void value_type; + + template struct _LIBCPP_DEPRECATED_IN_CXX17 rebind {typedef allocator<_Up> other;}; +}; +#endif + +// This class provides a non-trivial default constructor to the class that derives from it +// if the condition is satisfied. +// +// The second template parameter exists to allow giving a unique type to __non_trivial_if, +// which makes it possible to avoid breaking the ABI when making this a base class of an +// existing class. Without that, imagine we have classes D1 and D2, both of which used to +// have no base classes, but which now derive from __non_trivial_if. The layout of a class +// that inherits from both D1 and D2 will change because the two __non_trivial_if base +// classes are not allowed to share the same address. +// +// By making those __non_trivial_if base classes unique, we work around this problem and +// it is safe to start deriving from __non_trivial_if in existing classes. +template +struct __non_trivial_if { }; + +template +struct __non_trivial_if { + _LIBCPP_INLINE_VISIBILITY + _LIBCPP_CONSTEXPR __non_trivial_if() _NOEXCEPT { } +}; + +// allocator +// +// Note: For ABI compatibility between C++20 and previous standards, we make +// allocator trivial in C++20. + +template +class _LIBCPP_TEMPLATE_VIS allocator + : private __non_trivial_if::value, allocator<_Tp> > +{ +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef _Tp value_type; + typedef true_type propagate_on_container_move_assignment; + typedef true_type is_always_equal; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + allocator() _NOEXCEPT _LIBCPP_DEFAULT + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + allocator(const allocator<_Up>&) _NOEXCEPT { } + + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + _Tp* allocate(size_t __n) { + if (__n > allocator_traits::max_size(*this)) + __throw_length_error("allocator::allocate(size_t n)" + " 'n' exceeds maximum supported size"); + if (__libcpp_is_constant_evaluated()) { + return static_cast<_Tp*>(::operator new(__n * sizeof(_Tp))); + } else { + return static_cast<_Tp*>(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); + } + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + void deallocate(_Tp* __p, size_t __n) _NOEXCEPT { + if (__libcpp_is_constant_evaluated()) { + ::operator delete(__p); + } else { + _VSTD::__libcpp_deallocate((void*)__p, __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); + } + } + + // C++20 Removed members +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef _Tp& reference; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; + + template + struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { + typedef allocator<_Up> other; + }; + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + pointer address(reference __x) const _NOEXCEPT { + return _VSTD::addressof(__x); + } + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + const_pointer address(const_reference __x) const _NOEXCEPT { + return _VSTD::addressof(__x); + } + + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17 + _Tp* allocate(size_t __n, const void*) { + return allocate(__n); + } + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT { + return size_type(~0) / sizeof(_Tp); + } + + template + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + void construct(_Up* __p, _Args&&... __args) { + ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); + } + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + void destroy(pointer __p) { + __p->~_Tp(); + } +#endif +}; + +template +class _LIBCPP_TEMPLATE_VIS allocator + : private __non_trivial_if::value, allocator > +{ +public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef const _Tp value_type; + typedef true_type propagate_on_container_move_assignment; + typedef true_type is_always_equal; + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + allocator() _NOEXCEPT _LIBCPP_DEFAULT + + template + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + allocator(const allocator<_Up>&) _NOEXCEPT { } + + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + const _Tp* allocate(size_t __n) { + if (__n > allocator_traits::max_size(*this)) + __throw_length_error("allocator::allocate(size_t n)" + " 'n' exceeds maximum supported size"); + if (__libcpp_is_constant_evaluated()) { + return static_cast(::operator new(__n * sizeof(_Tp))); + } else { + return static_cast(_VSTD::__libcpp_allocate(__n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp))); + } + } + + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 + void deallocate(const _Tp* __p, size_t __n) { + if (__libcpp_is_constant_evaluated()) { + ::operator delete(const_cast<_Tp*>(__p)); + } else { + _VSTD::__libcpp_deallocate((void*) const_cast<_Tp *>(__p), __n * sizeof(_Tp), _LIBCPP_ALIGNOF(_Tp)); + } + } + + // C++20 Removed members +#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS) + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp* const_pointer; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& reference; + _LIBCPP_DEPRECATED_IN_CXX17 typedef const _Tp& const_reference; + + template + struct _LIBCPP_DEPRECATED_IN_CXX17 rebind { + typedef allocator<_Up> other; + }; + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + const_pointer address(const_reference __x) const _NOEXCEPT { + return _VSTD::addressof(__x); + } + + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY _LIBCPP_DEPRECATED_IN_CXX17 + const _Tp* allocate(size_t __n, const void*) { + return allocate(__n); + } + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT { + return size_type(~0) / sizeof(_Tp); + } + + template + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + void construct(_Up* __p, _Args&&... __args) { + ::new ((void*)__p) _Up(_VSTD::forward<_Args>(__args)...); + } + + _LIBCPP_DEPRECATED_IN_CXX17 _LIBCPP_INLINE_VISIBILITY + void destroy(pointer __p) { + __p->~_Tp(); + } +#endif +}; + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool operator==(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return true;} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17 +bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} + +_LIBCPP_END_NAMESPACE_STD + +_LIBCPP_POP_MACROS + +#endif // _LIBCPP___MEMORY_ALLOCATOR_H diff --git a/gnu/llvm/libcxx/include/__memory/allocator_arg_t.h b/gnu/llvm/libcxx/include/__memory/allocator_arg_t.h new file mode 100644 index 00000000000..830c6b8148e --- /dev/null +++ b/gnu/llvm/libcxx/include/__memory/allocator_arg_t.h @@ -0,0 +1,78 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___FUNCTIONAL___ALLOCATOR_ARG_T_H +#define _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H + +#include <__config> +#include <__memory/uses_allocator.h> +#include <__utility/forward.h> +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { explicit allocator_arg_t() = default; }; + +#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) +extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg; +#else +/* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#endif + +#ifndef _LIBCPP_CXX03_LANG + +// allocator construction + +template +struct __uses_alloc_ctor_imp +{ + 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; + static const int value = __ua ? 2 - __ic : 0; +}; + +template +struct __uses_alloc_ctor + : integral_constant::value> + {}; + +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); +} + +// FIXME: This should have a version which takes a non-const alloc. +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); +} + +// FIXME: This should have a version which takes a non-const alloc. +template +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); +} + +#endif // _LIBCPP_CXX03_LANG + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___FUNCTIONAL___ALLOCATOR_ARG_T_H diff --git a/gnu/llvm/libcxx/include/__memory/allocator_traits.h b/gnu/llvm/libcxx/include/__memory/allocator_traits.h new file mode 100644 index 00000000000..a02af0deafc --- /dev/null +++ b/gnu/llvm/libcxx/include/__memory/allocator_traits.h @@ -0,0 +1,405 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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___MEMORY_ALLOCATOR_TRAITS_H +#define _LIBCPP___MEMORY_ALLOCATOR_TRAITS_H + +#include <__config> +#include <__memory/construct_at.h> +#include <__memory/pointer_traits.h> +#include <__utility/forward.h> +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_PUSH_MACROS +#include <__undef_macros> + +_LIBCPP_BEGIN_NAMESPACE_STD + +#define _LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(NAME, PROPERTY) \ + template struct NAME : false_type { }; \ + template struct NAME<_Tp, typename __void_t::type> : true_type { } + +// __pointer +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_pointer, pointer); +template ::type, + bool = __has_pointer<_RawAlloc>::value> +struct __pointer { + using type _LIBCPP_NODEBUG_TYPE = typename _RawAlloc::pointer; +}; +template +struct __pointer<_Tp, _Alloc, _RawAlloc, false> { + using type _LIBCPP_NODEBUG_TYPE = _Tp*; +}; + +// __const_pointer +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_pointer, const_pointer); +template ::value> +struct __const_pointer { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_pointer; +}; +template +struct __const_pointer<_Tp, _Ptr, _Alloc, false> { +#ifdef _LIBCPP_CXX03_LANG + using type = typename pointer_traits<_Ptr>::template rebind::other; +#else + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; +#endif +}; + +// __void_pointer +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_void_pointer, void_pointer); +template ::value> +struct __void_pointer { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::void_pointer; +}; +template +struct __void_pointer<_Ptr, _Alloc, false> { +#ifdef _LIBCPP_CXX03_LANG + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind::other; +#else + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; +#endif +}; + +// __const_void_pointer +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_const_void_pointer, const_void_pointer); +template ::value> +struct __const_void_pointer { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::const_void_pointer; +}; +template +struct __const_void_pointer<_Ptr, _Alloc, false> { +#ifdef _LIBCPP_CXX03_LANG + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind::other; +#else + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::template rebind; +#endif +}; + +// __size_type +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_size_type, size_type); +template ::value> +struct __size_type : make_unsigned<_DiffType> { }; +template +struct __size_type<_Alloc, _DiffType, true> { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::size_type; +}; + +// __alloc_traits_difference_type +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_alloc_traits_difference_type, difference_type); +template ::value> +struct __alloc_traits_difference_type { + using type _LIBCPP_NODEBUG_TYPE = typename pointer_traits<_Ptr>::difference_type; +}; +template +struct __alloc_traits_difference_type<_Alloc, _Ptr, true> { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::difference_type; +}; + +// __propagate_on_container_copy_assignment +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_copy_assignment, propagate_on_container_copy_assignment); +template ::value> +struct __propagate_on_container_copy_assignment : false_type { }; +template +struct __propagate_on_container_copy_assignment<_Alloc, true> { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_copy_assignment; +}; + +// __propagate_on_container_move_assignment +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_move_assignment, propagate_on_container_move_assignment); +template ::value> +struct __propagate_on_container_move_assignment : false_type { }; +template +struct __propagate_on_container_move_assignment<_Alloc, true> { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_move_assignment; +}; + +// __propagate_on_container_swap +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_propagate_on_container_swap, propagate_on_container_swap); +template ::value> +struct __propagate_on_container_swap : false_type { }; +template +struct __propagate_on_container_swap<_Alloc, true> { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::propagate_on_container_swap; +}; + +// __is_always_equal +_LIBCPP_ALLOCATOR_TRAITS_HAS_XXX(__has_is_always_equal, is_always_equal); +template ::value> +struct __is_always_equal : is_empty<_Alloc> { }; +template +struct __is_always_equal<_Alloc, true> { + using type _LIBCPP_NODEBUG_TYPE = typename _Alloc::is_always_equal; +}; + +// __allocator_traits_rebind +_LIBCPP_SUPPRESS_DEPRECATED_PUSH +template +struct __has_rebind_other : false_type { }; +template +struct __has_rebind_other<_Tp, _Up, typename __void_t< + typename _Tp::template rebind<_Up>::other +>::type> : true_type { }; + +template ::value> +struct __allocator_traits_rebind { + using type _LIBCPP_NODEBUG_TYPE = typename _Tp::template rebind<_Up>::other; +}; +template