From b4c64ad90b81d2a779786b7edb4c5c6dd28cc57d Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 30 Dec 2015 11:54:09 +0000 Subject: [PATCH 1/8] Vendor import of libc++ trunk r256633: https://llvm.org/svn/llvm-project/libcxx/trunk@256633 --- CMakeLists.txt | 466 +++--- TODO.TXT | 21 +- cmake/Modules/HandleLibCXXABI.cmake | 13 +- cmake/Modules/HandleLibcxxFlags.cmake | 169 ++ cmake/Modules/HandleOutOfTreeLLVM.cmake | 138 ++ cmake/config-ix.cmake | 22 +- docs/BuildingLibcxx.rst | 306 ++++ docs/CMakeLists.txt | 9 + docs/DesignDocs/ABIVersioning.rst | 17 + docs/DesignDocs/CapturingConfigInfo.rst | 88 + docs/Makefile.sphinx | 37 + docs/README.txt | 13 + docs/TestingLibcxx.rst | 191 +++ docs/UsingLibcxx.rst | 89 ++ docs/conf.py | 251 +++ docs/index.rst | 185 +++ include/CMakeLists.txt | 28 + include/__config | 137 +- include/__config_site.in | 23 + include/__functional_03 | 571 +------ include/__functional_base | 239 ++- include/__functional_base_03 | 1130 ++----------- include/__hash_table | 42 +- include/__locale | 6 +- include/__mutex_base | 5 +- include/__nullptr | 66 + include/__split_buffer | 15 +- include/__std_stream | 1 - include/__tree | 10 +- include/__tuple | 40 +- include/algorithm | 8 +- include/array | 20 +- include/atomic | 38 +- include/bitset | 124 +- include/cctype | 101 -- include/cerrno | 360 ----- include/cfenv | 2 +- include/cfloat | 8 - include/chrono | 131 ++ include/cinttypes | 3 - include/cmath | 1168 +------------- include/complex.h | 10 +- include/condition_variable | 21 +- include/csetjmp | 4 - include/cstddef | 50 +- include/cstdio | 35 - include/cstdlib | 22 - include/ctype.h | 69 + include/cwchar | 9 +- include/cwctype | 126 -- include/deque | 110 +- include/errno.h | 398 +++++ include/exception | 2 +- include/experimental/algorithm | 6 + include/experimental/any | 590 +++++++ include/experimental/dynarray | 2 +- include/experimental/functional | 454 ++++++ include/ext/hash_map | 2 +- include/float.h | 83 + include/forward_list | 3 + include/functional | 213 ++- include/future | 141 +- include/inttypes.h | 251 +++ include/ios | 21 +- include/istream | 47 +- include/iterator | 10 +- include/list | 49 +- include/locale | 25 +- include/map | 8 +- include/math.h | 1419 +++++++++++++++++ include/memory | 177 +- include/module.modulemap | 6 +- include/mutex | 2 + include/ostream | 32 +- include/random | 20 +- include/ratio | 33 + include/regex | 246 +-- include/scoped_allocator | 4 + include/set | 6 + include/setjmp.h | 45 + include/sstream | 56 +- include/stddef.h | 62 + include/stdio.h | 127 ++ include/stdlib.h | 130 ++ include/streambuf | 38 +- include/string | 113 +- include/support/musl/xlocale.h | 58 + include/system_error | 2 +- include/thread | 56 +- include/tuple | 42 +- include/type_traits | 726 ++++++++- include/unordered_map | 2 +- include/utility | 98 +- include/valarray | 312 ++-- include/vector | 39 +- include/wchar.h | 136 ++ include/wctype.h | 79 + lib/CMakeLists.txt | 150 +- lib/libc++abi2.exp | 10 + src/any.cpp | 18 + src/exception.cpp | 10 +- src/future.cpp | 2 + src/{support => include}/atomic_support.h | 7 + src/{ => include}/config_elast.h | 0 src/ios.cpp | 4 +- src/locale.cpp | 20 +- src/memory.cpp | 6 +- src/mutex.cpp | 2 +- src/new.cpp | 10 +- src/stdexcept.cpp | 6 +- src/system_error.cpp | 2 +- src/typeinfo.cpp | 9 +- test/CMakeLists.txt | 105 +- .../atomics/libcpp-has-no-threads.fail.cpp | 0 .../atomics/libcpp-has-no-threads.pass.cpp | 2 +- test/libcxx/compiler.py | 36 + .../sequences/deque/incomplete.pass.cpp | 31 + .../containers/sequences/vector/asan.pass.cpp | 31 +- .../sequences/vector/asan_throw.pass.cpp | 1 + test/libcxx/double_include.sh.cpp | 7 + .../any/size_and_alignment.pass.cpp | 23 + .../experimental/any/small_type.pass.cpp | 114 ++ test/libcxx/experimental/any/version.pass.cpp | 20 + .../dynarray/dynarray.cons/default.pass.cpp | 44 +- .../default_throws_bad_alloc.pass.cpp | 34 + .../dynarray/dynarray.data/default.pass.cpp | 41 +- .../dynarray/dynarray.overview/at.pass.cpp | 1 + .../dynarray.overview/front_back.pass.cpp | 45 +- test/libcxx/test/config.py | 294 ++-- test/libcxx/test/format.py | 21 +- test/libcxx/test/target_info.py | 227 ++- test/libcxx/test/tracing.py | 6 +- .../thread/futures/version.pass.cpp | 0 .../type_traits/convert_to_integral.pass.cpp | 17 +- .../type_traits/lazy_metafunctions.pass.cpp | 137 ++ .../util.smartptr/race_condition.pass.cpp | 3 +- .../date.time/asctime.thread-unsafe.fail.cpp | 0 .../date.time/ctime.thread-unsafe.fail.cpp | 0 .../date.time/gmtime.thread-unsafe.fail.cpp | 0 .../localtime.thread-unsafe.fail.cpp | 0 test/lit.site.cfg.in | 9 +- .../alg.partitions/stable_partition.pass.cpp | 10 +- .../mismatch/mismatch.pass.cpp | 8 +- .../mismatch/mismatch_pred.pass.cpp | 5 +- .../includes/includes.pass.cpp | 4 +- .../includes/includes_comp.pass.cpp | 4 +- .../atomics.flag/atomic_flag_clear.pass.cpp | 4 +- .../atomic_flag_clear_explicit.pass.cpp | 12 +- test/std/atomics/atomics.flag/clear.pass.cpp | 16 +- .../std/atomics/atomics.flag/default.pass.cpp | 3 +- test/std/atomics/atomics.flag/init.pass.cpp | 1 + .../atomics.flag/init03.pass.cpp} | 15 +- .../atomics.types.generic/address.pass.cpp | 3 +- .../atomics.types.generic/bool.pass.cpp | 3 - .../atomics.types.generic/integral.pass.cpp | 1 + .../trivially_copyable.fail.cpp | 6 +- .../atomic_compare_exchange_strong.pass.cpp | 38 +- ..._compare_exchange_strong_explicit.pass.cpp | 38 +- .../atomic_compare_exchange_weak.pass.cpp | 37 +- ...ic_compare_exchange_weak_explicit.pass.cpp | 38 +- .../atomic_exchange.pass.cpp | 39 +- .../atomic_exchange_explicit.pass.cpp | 39 +- .../atomic_fetch_add.pass.cpp | 82 +- .../atomic_fetch_add_explicit.pass.cpp | 41 +- .../atomic_fetch_and.pass.cpp | 27 +- .../atomic_fetch_and_explicit.pass.cpp | 27 +- .../atomic_fetch_or.pass.cpp | 27 +- .../atomic_fetch_or_explicit.pass.cpp | 27 +- .../atomic_fetch_sub.pass.cpp | 82 +- .../atomic_fetch_sub_explicit.pass.cpp | 86 +- .../atomic_fetch_xor.pass.cpp | 27 +- .../atomic_fetch_xor_explicit.pass.cpp | 27 +- .../atomic_helpers.h | 51 + .../atomic_init.pass.cpp | 40 +- .../atomic_is_lock_free.pass.cpp | 33 +- .../atomic_load.pass.cpp | 40 +- .../atomic_load_explicit.pass.cpp | 38 +- .../atomic_store.pass.cpp | 40 +- .../atomic_store_explicit.pass.cpp | 40 +- .../atomic_var_init.pass.cpp | 1 + .../ctor.pass.cpp | 44 +- .../map/allocator_mismatch.fail.cpp | 18 + .../associative/map/compare.pass.cpp | 30 +- .../associative/map/map.access/at.pass.cpp | 1 + .../map/map.access/index_rv_key.pass.cpp | 8 +- .../map/map.cons/default_noexcept.pass.cpp | 5 +- .../map/map.cons/dtor_noexcept.pass.cpp | 5 +- .../map.cons/move_assign_noexcept.pass.cpp | 5 +- .../map/map.cons/move_noexcept.pass.cpp | 5 +- .../map/map.special/swap_noexcept.pass.cpp | 15 +- .../multimap/allocator_mismatch.fail.cpp | 18 + .../multimap.cons/default_noexcept.pass.cpp | 5 +- .../multimap.cons/dtor_noexcept.pass.cpp | 5 +- .../move_assign_noexcept.pass.cpp | 5 +- .../multimap.cons/move_noexcept.pass.cpp | 5 +- .../multimap.special/swap_noexcept.pass.cpp | 15 +- .../associative/multimap/scary.pass.cpp | 1 + .../multiset/allocator_mismatch.fail.cpp | 18 + .../associative/multiset/scary.pass.cpp | 1 + .../set/allocator_mismatch.fail.cpp | 18 + .../array.cons/initializer_list.pass.cpp | 4 + .../sequences/array/array.data/data.pass.cpp | 4 + .../array/array.data/data_const.pass.cpp | 4 + .../sequences/array/array.fill/fill.pass.cpp | 4 + .../sequences/array/array.size/size.pass.cpp | 4 + .../array/array.special/swap.pass.cpp | 4 + .../sequences/array/array.swap/swap.pass.cpp | 4 + .../sequences/array/array.tuple/get.fail.cpp | 18 +- .../sequences/array/array.tuple/get.pass.cpp | 13 +- .../array/array.tuple/get_const.pass.cpp | 8 +- .../array/array.tuple/get_const_rv.pass.cpp | 51 + .../array/array.tuple/get_rv.pass.cpp | 9 +- .../containers/sequences/array/at.pass.cpp | 11 +- .../containers/sequences/array/begin.pass.cpp | 6 +- .../sequences/array/front_back.pass.cpp | 10 +- .../sequences/array/indexing.pass.cpp | 12 +- .../deque/allocator_mismatch.fail.cpp | 18 + .../deque/deque.capacity/resize_size.pass.cpp | 4 +- .../deque.capacity/resize_size_value.pass.cpp | 4 +- .../deque.capacity/shrink_to_fit.pass.cpp | 4 +- .../deque.cons/assign_iter_iter.pass.cpp | 9 +- .../deque.cons/assign_size_value.pass.cpp | 6 +- .../deque/deque.modifiers/emplace.pass.cpp | 11 +- .../deque.modifiers/insert_iter_iter.pass.cpp | 19 +- .../deque.modifiers/insert_rvalue.pass.cpp | 12 +- .../insert_size_value.pass.cpp | 6 +- .../deque.modifiers/insert_value.pass.cpp | 6 +- .../push_back_exception_safety.pass.cpp | 1 + .../push_front_exception_safety.pass.cpp | 1 + .../forwardlist/allocator_mismatch.fail.cpp | 18 + .../forwardlist.cons/move.pass.cpp | 6 +- .../forwardlist.cons/move_alloc.pass.cpp | 6 +- .../push_front_exception_safety.pass.cpp | 1 + .../forwardlist.ops/splice_after_one.pass.cpp | 4 +- .../forwardlist.spec/equal.pass.cpp | 4 +- .../forwardlist.spec/relational.pass.cpp | 4 +- .../list/allocator_mismatch.fail.cpp | 18 + .../sequences/list/incomplete_type.pass.cpp | 27 + .../insert_iter_iter_iter.pass.cpp | 1 + .../insert_iter_size_value.pass.cpp | 1 + .../list.modifiers/insert_iter_value.pass.cpp | 1 + .../push_back_exception_safety.pass.cpp | 1 + .../push_front_exception_safety.pass.cpp | 1 + .../vector.bool/move_assign_noexcept.pass.cpp | 41 + .../vector/allocator_mismatch.fail.cpp | 18 + .../vector.cons/move_assign_noexcept.pass.cpp | 44 + .../push_back_exception_safety.pass.cpp | 1 + .../unord.map/allocator_mismatch.fail.cpp | 18 + .../unord/unord.map/bucket_count.pass.cpp | 9 +- .../unord/unord.map/compare.pass.cpp | 13 +- .../unord/unord.map/load_factor.pass.cpp | 5 +- .../unord/unord.map/max_bucket_count.pass.cpp | 7 +- .../unord/unord.map/max_load_factor.pass.cpp | 11 +- .../unord/unord.map/rehash.pass.cpp | 12 + .../unord/unord.map/reserve.pass.cpp | 16 + .../unord/unord.map/swap_member.pass.cpp | 6 +- .../unord.map/unord.map.cnstr/move.pass.cpp | 26 +- .../unord.map/unord.map.elem/at.pass.cpp | 1 + .../clear.pass.cpp | 0 .../emplace.pass.cpp | 0 .../emplace_hint.pass.cpp | 0 .../erase_const_iter.pass.cpp | 9 +- .../erase_iter_db1.pass.cpp | 0 .../erase_iter_db2.pass.cpp | 0 .../erase_iter_iter_db1.pass.cpp | 0 .../erase_iter_iter_db2.pass.cpp | 0 .../erase_iter_iter_db3.pass.cpp | 0 .../erase_iter_iter_db4.pass.cpp | 0 .../erase_key.pass.cpp | 11 +- .../erase_range.pass.cpp | 0 .../insert_const_lvalue.pass.cpp | 0 .../insert_hint_const_lvalue.pass.cpp | 0 .../insert_hint_rvalue.pass.cpp | 0 .../insert_init.pass.cpp | 0 .../insert_or_assign.pass.cpp | 10 +- .../insert_range.pass.cpp | 0 .../insert_rvalue.pass.cpp | 0 .../try.emplace.pass.cpp | 11 +- .../unord.map.swap/swap_non_member.pass.cpp | 6 +- .../allocator_mismatch.fail.cpp | 18 + .../unord/unord.multimap/rehash.pass.cpp | 12 + .../unord/unord.multimap/reserve.pass.cpp | 16 + .../swap_noexcept.pass.cpp | 24 +- .../allocator_mismatch.fail.cpp | 18 + .../unord/unord.multiset/rehash.pass.cpp | 12 + .../unord/unord.multiset/reserve.pass.cpp | 16 + .../unord.set/allocator_mismatch.fail.cpp | 18 + .../unord/unord.set/rehash.pass.cpp | 12 + .../unord/unord.set/reserve.pass.cpp | 16 + .../convert_to_auto_ptr_ref.pass.cpp | 4 + .../auto.ptr/element_type.pass.cpp | 3 +- .../std/depr/depr.c.headers/extern_c.pass.cpp | 43 + .../depr/depr.c.headers/inttypes_h.pass.cpp | 286 ++++ .../std/depr/depr.c.headers/locale_h.pass.cpp | 2 +- test/std/depr/depr.c.headers/math_h.pass.cpp | 846 +++++++++- .../depr/depr.c.headers/math_h_isinf.pass.cpp | 30 + .../depr/depr.c.headers/math_h_isnan.pass.cpp | 30 + .../std/depr/depr.c.headers/setjmp_h.pass.cpp | 4 + .../std/depr/depr.c.headers/signal_h.pass.cpp | 2 +- .../std/depr/depr.c.headers/stdarg_h.pass.cpp | 1 + .../std/depr/depr.c.headers/stddef_h.pass.cpp | 22 + .../std/depr/depr.c.headers/stdint_h.pass.cpp | 4 +- test/std/depr/depr.c.headers/stdio_h.pass.cpp | 31 +- .../std/depr/depr.c.headers/stdlib_h.pass.cpp | 38 +- test/std/depr/depr.c.headers/time_h.pass.cpp | 2 +- test/std/depr/depr.c.headers/wchar_h.pass.cpp | 43 +- .../depr/depr.ios.members/io_state.pass.cpp | 5 + .../depr/depr.ios.members/open_mode.pass.cpp | 5 + .../depr/depr.ios.members/seek_dir.pass.cpp | 5 + .../depr/depr.ios.members/streamoff.pass.cpp | 5 + .../depr/depr.ios.members/streampos.pass.cpp | 5 + .../unexpected_handler.pass.cpp | 1 + .../error_category.pass.cpp | 1 + .../algorithms/alg.search/search.pass.cpp | 45 + .../any/any.class/any.assign/copy.pass.cpp | 197 +++ .../any/any.class/any.assign/move.pass.cpp | 102 ++ .../any/any.class/any.assign/value.pass.cpp | 177 ++ .../value_non_copyable_assign.fail.cpp | 38 + .../any/any.class/any.cons/copy.pass.cpp | 100 ++ .../any/any.class/any.cons/default.pass.cpp | 38 + .../any/any.class/any.cons/move.pass.cpp | 102 ++ .../any.cons/non_copyable_value.fail.cpp | 36 + .../any/any.class/any.cons/value.pass.cpp | 116 ++ .../any.class/any.modifiers/clear.pass.cpp | 63 + .../any/any.class/any.modifiers/swap.pass.cpp | 101 ++ .../any.class/any.observers/empty.pass.cpp | 64 + .../any/any.class/any.observers/type.pass.cpp | 41 + .../any/any.class/nothing_to_do.pass.cpp | 12 + .../any.cast/any_cast_pointer.pass.cpp | 146 ++ .../any.cast/any_cast_reference.pass.cpp | 309 ++++ .../any.cast/const_correctness.fail.cpp | 38 + .../any.cast/not_copy_constructible.fail.cpp | 45 + .../any.cast/reference_types.fail.cpp | 37 + .../any/any.nonmembers/swap.pass.cpp | 40 + .../default.pass.cpp | 128 ++ .../func.searchers.boyer_moore/hash.pass.cpp | 124 ++ .../hash.pred.pass.cpp | 135 ++ .../func.searchers.boyer_moore/pred.pass.cpp | 131 ++ .../default.pass.cpp | 128 ++ .../hash.pass.cpp | 123 ++ .../hash.pred.pass.cpp | 134 ++ .../pred.pass.cpp | 130 ++ .../func.searchers.default/default.pass.cpp | 95 ++ .../default.pred.pass.cpp | 102 ++ .../make_default_searcher.pass.cpp | 81 + .../make_default_searcher.pred.pass.cpp | 88 + .../func.searchers/nothing_to_do.pass.cpp | 13 + .../header.functional.synop/includes.pass.cpp | 21 + .../experimental/func/nothing_to_do.pass.cpp | 13 + .../optional.object.assign/copy.pass.cpp | 1 + .../optional.object.assign/emplace.pass.cpp | 1 + .../emplace_initializer_list.pass.cpp | 1 + .../optional.object.assign/move.pass.cpp | 1 + .../optional.object.ctor/const_T.pass.cpp | 12 +- .../optional.object.ctor/copy.pass.cpp | 1 + .../optional.object.ctor/in_place_t.pass.cpp | 11 +- .../initializer_list.pass.cpp | 1 + .../optional.object.ctor/move.pass.cpp | 1 + .../optional.object.ctor/rvalue_T.pass.cpp | 11 +- .../optional.object.observe/value.pass.cpp | 1 + .../value_const.pass.cpp | 1 + .../optional.object.swap/swap.pass.cpp | 1 + .../optional/optional.specalg/swap.pass.cpp | 1 + .../string.view.access/at.pass.cpp | 1 + .../compare.pointer_size.pass.cpp | 1 + .../compare.size_size_sv.pass.cpp | 1 + ...compare.size_size_sv_pointer_size.pass.cpp | 1 + .../compare.size_size_sv_size_size.pass.cpp | 1 + .../string.view/string.view.ops/copy.pass.cpp | 1 + .../string.view.ops/substr.pass.cpp | 1 + .../tuple/tuple.apply/arg_type.pass.cpp | 5 + .../tuple/tuple.apply/extended_types.pass.cpp | 4 + .../tuple/tuple.apply/types.pass.cpp | 4 + .../file.streams/c.files/cstdio.pass.cpp | 1 + .../istream.unformatted/seekg.pass.cpp | 9 + .../istream.unformatted/seekg_off.pass.cpp | 9 + .../ostream_sentry/destruct.pass.cpp | 1 + .../ctor_string_error_code.pass.cpp | 3 + .../ios/basic.ios.members/copyfmt.pass.cpp | 1 + .../ios/basic.ios.members/set_rdbuf.pass.cpp | 1 + .../ios/iostate.flags/clear.pass.cpp | 1 + .../iostate.flags/exceptions_iostate.pass.cpp | 1 + .../ios/iostate.flags/setstate.pass.cpp | 1 + .../stringbuf.virtuals/overflow.pass.cpp | 6 +- .../stringbuf.virtuals/pbackfail.pass.cpp | 6 +- .../iterator.operations/next.pass.cpp | 4 + .../ostream.iterator.ops/assign_t.pass.cpp | 4 + .../new.handler/new_handler.pass.cpp | 4 + .../new.delete.array/new_array.pass.cpp | 4 +- .../new_array_nothrow.pass.cpp | 1 + .../sized_delete_array14.pass.cpp | 7 +- .../new.delete/new.delete.single/new.pass.cpp | 2 + .../new.delete.single/new_nothrow.pass.cpp | 1 + .../new.delete.single/sized_delete14.pass.cpp | 7 +- .../except.nested/assign.pass.cpp | 1 + .../except.nested/ctor_copy.pass.cpp | 1 + .../except.nested/ctor_default.pass.cpp | 1 + .../except.nested/rethrow_if_nested.pass.cpp | 11 +- .../except.nested/rethrow_nested.pass.cpp | 1 + .../except.nested/throw_with_nested.pass.cpp | 1 + .../terminate_handler.pass.cpp | 4 + .../propagation/current_exception.pass.cpp | 1 + .../propagation/make_exception_ptr.pass.cpp | 1 + .../propagation/rethrow_exception.pass.cpp | 1 + .../uncaught/uncaught_exception.pass.cpp | 1 + .../uncaught/uncaught_exceptions.pass.cpp | 1 + .../support.runtime/csignal.pass.cpp | 3 +- .../support.runtime/cstdarg.pass.cpp | 1 + .../support.runtime/cstdlib.pass.cpp | 24 +- .../support.runtime/ctime.pass.cpp | 1 + .../support.types/nullptr_t.pass.cpp | 23 +- .../locale.collate.byname/transform.pass.cpp | 2 +- .../char16_t_in.pass.cpp | 2 +- .../char16_t_length.pass.cpp | 2 +- .../char16_t_out.pass.cpp | 2 +- .../char16_t_unshift.pass.cpp | 2 +- .../char32_t_in.pass.cpp | 2 +- .../char32_t_length.pass.cpp | 2 +- .../char32_t_out.pass.cpp | 2 +- .../char32_t_unshift.pass.cpp | 2 +- .../locale.codecvt.members/char_in.pass.cpp | 2 +- .../char_length.pass.cpp | 2 +- .../locale.codecvt.members/char_out.pass.cpp | 2 +- .../char_unshift.pass.cpp | 2 +- .../utf_sanity_check.pass.cpp | 2 +- .../wchar_t_in.pass.cpp | 2 +- .../wchar_t_length.pass.cpp | 2 +- .../wchar_t_out.pass.cpp | 6 +- .../wchar_t_unshift.pass.cpp | 2 +- .../get_monthname.pass.cpp | 2 +- .../get_monthname_wide.pass.cpp | 2 +- .../ctor_err_string.pass.cpp | 1 + .../use_facet.pass.cpp | 1 + .../locale/locale.cons/char_pointer.pass.cpp | 1 + .../locale/locale.members/combine.pass.cpp | 1 + .../numerics/rand/rand.device/ctor.pass.cpp | 1 + .../numerics/rand/rand.device/eval.pass.cpp | 1 + .../std/re/re.alg/re.alg.search/grep.pass.cpp | 28 + .../re.regex/re.regex.assign/assign.pass.cpp | 1 + .../re.regex.construct/bad_escape.pass.cpp | 3 +- .../re.regex.construct/bad_repeat.pass.cpp | 43 + .../basic.string/allocator_mismatch.fail.cpp | 18 + .../basic.string/string.access/at.pass.cpp | 1 + .../string.capacity/capacity.pass.cpp | 1 + .../string.capacity/max_size.pass.cpp | 1 + .../string.capacity/over_max_size.pass.cpp | 1 + .../string.capacity/reserve.pass.cpp | 1 + .../string.capacity/resize_size.pass.cpp | 1 + .../string.capacity/resize_size_char.pass.cpp | 1 + .../string.cons/move_assign_noexcept.pass.cpp | 56 +- .../basic.string/string.cons/substr.pass.cpp | 1 + .../string_append/string_size_size.pass.cpp | 1 + .../string_assign/string.pass.cpp | 6 + .../string_assign/string_size_size.pass.cpp | 1 + .../string_copy/copy.pass.cpp | 1 + .../string_erase/size_size.pass.cpp | 1 + .../string_insert/size_pointer.pass.cpp | 1 + .../string_insert/size_pointer_size.pass.cpp | 1 + .../string_insert/size_size_char.pass.cpp | 1 + .../string_insert/size_string.pass.cpp | 1 + .../size_string_size_size.pass.cpp | 1 + .../string_replace/size_size_pointer.pass.cpp | 1 + .../size_size_pointer_size.pass.cpp | 1 + .../size_size_size_char.pass.cpp | 1 + .../string_replace/size_size_string.pass.cpp | 1 + .../size_size_string_size_size.pass.cpp | 1 + .../string_compare/size_size_pointer.pass.cpp | 1 + .../size_size_pointer_size.pass.cpp | 1 + .../string_compare/size_size_string.pass.cpp | 1 + .../size_size_string_size_size.pass.cpp | 1 + .../string.ops/string_substr/substr.pass.cpp | 1 + test/std/strings/c.strings/cctype.pass.cpp | 28 +- test/std/strings/c.strings/cwchar.pass.cpp | 2 +- .../strings/string.conversions/stod.pass.cpp | 1 + .../strings/string.conversions/stof.pass.cpp | 1 + .../strings/string.conversions/stoi.pass.cpp | 1 + .../strings/string.conversions/stol.pass.cpp | 1 + .../strings/string.conversions/stold.pass.cpp | 1 + .../strings/string.conversions/stoll.pass.cpp | 1 + .../strings/string.conversions/stoul.pass.cpp | 1 + .../string.conversions/stoull.pass.cpp | 1 + .../futures/futures.async/async.pass.cpp | 2 + .../futures/futures.async/async_race.pass.cpp | 1 + .../futures.promise/alloc_ctor.pass.cpp | 29 +- .../futures.promise/copy_assign.fail.cpp | 82 +- .../futures.promise/copy_ctor.fail.cpp | 76 +- .../futures/futures.promise/default.pass.cpp | 1 + .../futures/futures.promise/dtor.pass.cpp | 2 + .../futures.promise/get_future.pass.cpp | 2 + .../futures.promise/move_assign.pass.cpp | 38 +- .../futures.promise/move_ctor.pass.cpp | 32 +- .../futures.promise/set_exception.pass.cpp | 2 + .../set_exception_at_thread_exit.pass.cpp | 2 + .../futures.promise/set_lvalue.pass.cpp | 2 + .../set_lvalue_at_thread_exit.pass.cpp | 1 + .../futures.promise/set_rvalue.pass.cpp | 1 + .../set_value_at_thread_exit_const.pass.cpp | 1 + .../set_value_at_thread_exit_void.pass.cpp | 1 + .../futures.promise/set_value_const.pass.cpp | 2 + .../futures.promise/set_value_void.pass.cpp | 2 + .../futures/futures.promise/swap.pass.cpp | 45 +- .../futures.promise/uses_allocator.pass.cpp | 2 +- .../copy_assign.pass.cpp | 3 +- .../futures.shared_future/copy_ctor.pass.cpp | 1 + .../ctor_future.pass.cpp | 1 + .../futures.shared_future/dtor.pass.cpp | 30 +- .../futures.shared_future/get.pass.cpp | 2 + .../move_assign.pass.cpp | 3 +- .../futures.shared_future/move_ctor.pass.cpp | 1 + .../futures.shared_future/wait.pass.cpp | 1 + .../futures.shared_future/wait_for.pass.cpp | 1 + .../futures.shared_future/wait_until.pass.cpp | 1 + .../futures.task.members/assign_copy.fail.cpp | 30 +- .../futures.task.members/assign_move.pass.cpp | 1 + .../futures.task.members/ctor1.fail.cpp | 5 +- .../futures.task.members/ctor2.fail.cpp | 7 +- .../futures.task.members/ctor_copy.fail.cpp | 25 +- .../ctor_default.pass.cpp | 1 + .../futures.task.members/ctor_func.pass.cpp | 1 + .../ctor_func_alloc.pass.cpp | 19 +- .../futures.task.members/ctor_move.pass.cpp | 1 + .../futures.task.members/dtor.pass.cpp | 2 + .../futures.task.members/get_future.pass.cpp | 2 + .../make_ready_at_thread_exit.pass.cpp | 2 + .../futures.task.members/operator.pass.cpp | 2 + .../futures.task.members/reset.pass.cpp | 2 + .../futures.task.members/swap.pass.cpp | 1 + .../futures.task.nonmembers/swap.pass.cpp | 1 + .../uses_allocator.pass.cpp | 8 +- .../thread/futures/futures.tas/types.pass.cpp | 1 + .../copy_assign.fail.cpp | 63 +- .../futures.unique_future/copy_ctor.fail.cpp | 55 +- .../futures.unique_future/dtor.pass.cpp | 30 +- .../futures.unique_future/get.pass.cpp | 2 + .../futures.unique_future/share.pass.cpp | 1 + .../futures.unique_future/wait.pass.cpp | 1 + .../futures.unique_future/wait_for.pass.cpp | 1 + .../futures.unique_future/wait_until.pass.cpp | 221 +-- test/std/thread/futures/test_allocator.h | 158 -- .../notify_all_at_thread_exit.pass.cpp | 7 +- .../notify_one.pass.cpp | 11 +- .../wait.exception.pass.cpp | 63 - .../wait_for.exception.pass.cpp | 63 - .../wait_terminates.sh.cpp | 134 ++ .../thread.lock.algorithm/lock.pass.cpp | 1 + .../thread.lock.algorithm/try_lock.pass.cpp | 1 + .../thread.lock.shared.cons/default.pass.cpp | 3 +- .../move_assign.pass.cpp | 7 +- .../move_ctor.pass.cpp | 8 +- .../thread.lock.shared.cons/mutex.pass.cpp | 64 +- .../mutex_adopt_lock.pass.cpp | 3 +- .../mutex_defer_lock.pass.cpp | 3 +- .../mutex_duration.pass.cpp | 35 +- .../mutex_time_point.pass.cpp | 34 +- .../mutex_try_to_lock.pass.cpp | 7 +- .../thread.lock.shared.locking/lock.pass.cpp | 26 +- .../try_lock.pass.cpp | 9 +- .../try_lock_for.pass.cpp | 8 +- .../try_lock_until.pass.cpp | 8 +- .../unlock.pass.cpp | 8 +- .../member_swap.pass.cpp | 7 +- .../nonmember_swap.pass.cpp | 7 +- .../thread.lock.shared.mod/release.pass.cpp | 7 +- .../thread.lock.shared.obs/mutex.pass.cpp | 7 +- .../thread.lock.shared.obs/op_bool.pass.cpp | 7 +- .../thread.lock.shared.obs/owns_lock.pass.cpp | 7 +- .../thread.lock.shared/types.pass.cpp | 4 +- .../thread.lock.unique.locking/lock.pass.cpp | 1 + .../try_lock.pass.cpp | 1 + .../try_lock_for.pass.cpp | 1 + .../try_lock_until.pass.cpp | 1 + .../unlock.pass.cpp | 1 + .../thread.shared_mutex.class/assign.fail.cpp | 10 +- .../thread.shared_mutex.class/copy.fail.cpp | 10 +- .../thread.shared_mutex.class/lock.pass.cpp | 18 +- .../lock_shared.pass.cpp | 23 +- .../lock.pass.cpp | 15 + .../lock_shared.pass.cpp | 25 +- .../try_lock_for.pass.cpp | 30 +- .../try_lock_shared.pass.cpp | 11 +- .../try_lock_shared_for.pass.cpp | 29 +- .../try_lock_shared_until.pass.cpp | 29 +- .../try_lock_until.pass.cpp | 28 +- .../thread.once.callonce/call_once.pass.cpp | 1 + .../thread.thread.assign/move2.pass.cpp | 17 +- .../thread.thread.constr/F.pass.cpp | 9 +- .../thread.thread.destr/dtor.pass.cpp | 4 +- .../thread.thread.member/detach.pass.cpp | 2 +- .../copy_assign.pass.cpp | 72 + .../move_assign.pass.cpp | 72 + .../func.bind/func.bind.bind/copy.pass.cpp | 2 + .../invoke_function_object.pass.cpp | 2 + .../func.bind.bind/invoke_int_0.pass.cpp | 2 + .../func.bind.bind/invoke_lvalue.pass.cpp | 2 + .../func.bind.bind/invoke_rvalue.pass.cpp | 2 + .../func.bind.bind/invoke_void_0.pass.cpp | 2 + .../func.bind/func.bind.bind/nested.pass.cpp | 2 + .../is_bind_expression.pass.cpp | 2 + .../is_bind_expression_03.pass.cpp | 39 + .../func.invoke/invoke.pass.cpp | 1 + .../func.memfn/member_function.pass.cpp | 3 + .../func.require/bullet_1_and_2.pass.cpp | 318 ++++ .../func.require/bullet_3_and_4.pass.cpp | 164 ++ .../func.require/bullet_5.pass.cpp | 327 ++++ .../func.require/invoke_helpers.h | 317 ++++ .../func.wrap.func.con/F.pass.cpp | 6 +- .../func.wrap.func.con/F_nullptr.pass.cpp | 247 +++ .../func.wrap.func.inv/invoke.fail.cpp | 14 +- .../func.wrap.func.inv/invoke.pass.cpp | 382 +++-- .../func.wrap.func.inv/invoke_int_0.pass.cpp | 58 - .../invoke_no_variadics.pass.cpp | 60 - .../func.wrap.func.inv/invoke_void_0.pass.cpp | 67 - .../refwrap/refwrap.const/type_ctor.fail.cpp | 2 + .../refwrap/refwrap.helpers/ref_1.fail.cpp | 2 + .../unord.hash/integral.pass.cpp | 40 + .../intseq.make/make_integer_seq.fail.cpp | 18 +- .../intseq.make/make_integer_seq.pass.cpp | 6 +- .../make_integer_seq_fallback.fail.cpp | 18 + .../make_integer_seq_fallback.pass.cpp | 18 + .../max_size.pass.cpp | 4 +- .../allocator.members/construct.pass.cpp | 25 +- .../allocator.members/max_size.pass.cpp | 4 +- .../uninitialized_copy.pass.cpp | 15 +- .../uninitialized_copy_n.pass.cpp | 15 +- .../uninitialized_fill_n.pass.cpp | 14 +- .../uninitialized_fill.pass.cpp | 14 +- .../raw_storag_iterator.pass.cpp | 27 +- .../std/utilities/memory/unique.ptr/deleter.h | 234 ++- .../unique.ptr.runtime/move01.fail.cpp | 25 +- .../unique.ptr.runtime.ctor/move01.pass.cpp | 22 +- .../unique.ptr.runtime.ctor/move02.pass.cpp | 23 +- .../pointer_deleter04.fail.cpp | 34 +- .../unique.ptr.single.asgn/move01.fail.cpp | 25 +- .../unique.ptr.single.asgn/move02.fail.cpp | 27 +- .../unique.ptr.single.asgn/move03.fail.cpp | 47 +- .../unique.ptr.single.asgn/move04.fail.cpp | 48 +- .../move_convert.pass.cpp | 89 ++ .../move_convert01.fail.cpp | 41 +- .../move_convert01.pass.cpp | 56 - .../move_convert02.fail.cpp | 44 +- .../move_convert02.pass.cpp | 60 - .../move_convert03.fail.cpp | 47 +- .../move_convert03.pass.cpp | 63 - .../move_convert04.fail.cpp | 40 +- .../move_convert13.fail.cpp | 2 +- .../auto_pointer.pass.cpp | 16 +- .../unique.ptr.single.ctor/default.pass.cpp | 86 + .../unique.ptr.single.ctor/default01.pass.cpp | 46 - .../unique.ptr.single.ctor/default02.pass.cpp | 84 - .../unique.ptr.single.ctor/move.pass.cpp | 140 ++ .../unique.ptr.single.ctor/move01.pass.cpp | 142 -- .../unique.ptr.single.ctor/move02.pass.cpp | 143 -- .../move_convert.pass.cpp | 171 ++ .../move_convert01.pass.cpp | 58 - .../move_convert02.pass.cpp | 62 - .../move_convert03.pass.cpp | 79 - .../move_convert04.pass.cpp | 58 - .../move_convert05.pass.cpp | 62 - .../move_convert06.pass.cpp | 79 - .../move_convert07.pass.cpp | 63 - .../unique.ptr.single.ctor/pointer.pass.cpp | 163 ++ .../unique.ptr.single.ctor/pointer01.pass.cpp | 63 - .../unique.ptr.single.ctor/pointer02.pass.cpp | 95 -- .../unique.ptr.single.ctor/pointer03.pass.cpp | 78 - .../pointer_deleter.pass.cpp | 123 ++ .../pointer_deleter01.pass.cpp | 99 -- .../pointer_deleter02.pass.cpp | 58 - .../pointer_deleter03.pass.cpp | 60 - .../pointer_deleter04.fail.cpp | 43 +- .../pointer_deleter04.pass.cpp | 58 - .../pointer_deleter05.pass.cpp | 66 - .../pointer_deleter06.pass.cpp | 39 - .../auto_ptr.pass.cpp | 1 + ...nullptr_t_deleter_allocator_throw.pass.cpp | 1 + .../nullptr_t_deleter_throw.pass.cpp | 1 + .../pointer_deleter_allocator_throw.pass.cpp | 1 + .../pointer_deleter_throw.pass.cpp | 1 + .../pointer_throw.pass.cpp | 1 + .../unique_ptr.pass.cpp | 1 + .../weak_ptr.pass.cpp | 1 + .../owner_less.pass.cpp | 40 + .../meta/meta.logical/conjunction.pass.cpp | 66 + .../meta/meta.logical/disjunction.pass.cpp | 66 + .../meta/meta.logical/negation.pass.cpp | 39 + .../meta/meta.rel/is_base_of.pass.cpp | 8 + .../meta/meta.rel/is_convertible.pass.cpp | 14 + .../meta.rel/is_convertible_fallback.pass.cpp | 8 + .../utilities/meta/meta.rel/is_same.pass.cpp | 18 +- .../meta.trans.other/aligned_storage.pass.cpp | 44 +- .../meta.trans.other/common_type.pass.cpp | 58 +- .../meta.trans.ref/add_lvalue_ref.pass.cpp | 36 + .../alignment_of.pass.cpp | 8 + .../meta.unary.prop.query/extent.pass.cpp | 14 + .../meta/meta.unary.prop.query/rank.pass.cpp | 8 + .../meta.unary.prop.query/void_t.pass.cpp | 9 +- .../meta.unary.cat/is_array.pass.cpp | 93 ++ .../meta.unary.cat/is_class.pass.cpp | 98 ++ .../meta.unary.cat/is_enum.pass.cpp | 93 ++ .../meta.unary.cat/is_floating_point.pass.cpp | 101 ++ .../meta.unary.cat/is_function.pass.cpp | 98 ++ .../meta.unary.cat/is_integral.pass.cpp | 104 ++ .../is_lvalue_reference.pass.cpp | 95 ++ .../is_member_object_pointer.pass.cpp | 97 ++ .../meta.unary.cat/is_member_pointer.pass.cpp | 98 ++ .../meta.unary.cat/is_null_pointer.pass.cpp | 95 ++ .../meta.unary.cat/is_pointer.pass.cpp | 94 ++ .../is_rvalue_reference.pass.cpp | 95 ++ .../meta.unary.cat/is_union.pass.cpp | 93 ++ .../meta.unary.cat/is_void.pass.cpp | 92 ++ .../meta.unary.cat/nullptr.pass.cpp | 1 + .../meta.unary.comp/is_arithmetic.pass.cpp | 104 ++ .../meta.unary.comp/is_compound.pass.cpp | 95 ++ .../meta.unary.comp/is_fundamental.pass.cpp | 112 ++ .../is_member_pointer.pass.cpp | 102 ++ .../meta.unary.comp/is_object.pass.cpp | 101 ++ .../meta.unary.comp/is_reference.pass.cpp | 101 ++ .../meta.unary.comp/is_scalar.pass.cpp | 111 ++ .../has_virtual_destructor.pass.cpp | 12 + .../meta.unary.prop/is_abstract.pass.cpp | 13 + .../meta.unary.prop/is_assignable.pass.cpp | 7 + .../meta.unary.prop/is_const.pass.cpp | 7 + .../meta.unary.prop/is_constructible.pass.cpp | 20 +- .../is_copy_assignable.pass.cpp | 7 + .../is_copy_constructible.pass.cpp | 7 + .../is_default_constructible.pass.cpp | 13 + .../meta.unary.prop/is_destructible.pass.cpp | 27 +- .../meta.unary.prop/is_empty.pass.cpp | 13 + .../meta.unary.prop/is_final.pass.cpp | 13 + .../meta.unary.prop/is_literal_type.pass.cpp | 77 +- .../is_move_assignable.pass.cpp | 11 +- .../is_move_constructible.pass.cpp | 7 + .../is_nothrow_assignable.pass.cpp | 7 + .../is_nothrow_constructible.pass.cpp | 16 + .../is_nothrow_copy_assignable.pass.cpp | 7 + .../is_nothrow_copy_constructible.pass.cpp | 11 + .../is_nothrow_default_constructible.pass.cpp | 13 + .../is_nothrow_destructible.pass.cpp | 70 +- .../is_nothrow_move_assignable.pass.cpp | 7 + .../is_nothrow_move_constructible.pass.cpp | 11 + .../meta.unary.prop/is_pod.pass.cpp | 13 + .../meta.unary.prop/is_polymorphic.pass.cpp | 13 + .../meta.unary.prop/is_signed.pass.cpp | 13 + .../is_standard_layout.pass.cpp | 13 + .../meta.unary.prop/is_trivial.pass.cpp | 13 + .../is_trivially_assignable.pass.cpp | 7 + .../is_trivially_constructible.pass.cpp | 16 + .../is_trivially_copy_assignable.pass.cpp | 7 + .../is_trivially_copy_constructible.pass.cpp | 9 + .../is_trivially_copyable.pass.cpp | 13 + ...s_trivially_default_constructible.pass.cpp | 13 + .../is_trivially_destructible.pass.cpp | 47 +- .../is_trivially_move_assignable.pass.cpp | 7 + .../is_trivially_move_constructible.pass.cpp | 7 + .../meta.unary.prop/is_unsigned.pass.cpp | 13 + .../meta.unary.prop/is_volatile.pass.cpp | 7 + .../ratio.comparison/ratio_equal.pass.cpp | 27 +- .../ratio.comparison/ratio_greater.pass.cpp | 27 +- .../ratio_greater_equal.pass.cpp | 27 +- .../ratio.comparison/ratio_less.pass.cpp | 39 +- .../ratio_less_equal.pass.cpp | 27 +- .../ratio.comparison/ratio_not_equal.pass.cpp | 27 +- .../bitset.cons/char_ptr_ctor.pass.cpp | 3 + .../bitset.cons/string_ctor.pass.cpp | 3 + .../bitset.cons/ull_ctor.pass.cpp | 1 + .../bitset.members/flip_one.pass.cpp | 1 + .../bitset.members/reset_one.pass.cpp | 1 + .../bitset.members/set_one.pass.cpp | 1 + .../bitset.members/test.pass.cpp | 1 + .../date.time/ctime.pass.cpp} | 2 + .../time.duration.alg/abs.fail.cpp | 27 + .../time.duration.alg/abs.pass.cpp | 50 + .../time.duration.cast/ceil.fail.cpp | 26 + .../time.duration.cast/ceil.pass.cpp | 51 + .../time.duration.cast/floor.fail.cpp | 26 + .../time.duration.cast/floor.pass.cpp | 50 + .../time.duration.cast/round.fail.cpp | 26 + .../time.duration.cast/round.pass.cpp | 50 + .../time.point/time.point.cast/ceil.fail.cpp | 26 + .../time.point/time.point.cast/ceil.pass.cpp | 69 + .../time.point/time.point.cast/floor.fail.cpp | 26 + .../time.point/time.point.cast/floor.pass.cpp | 68 + .../time.point/time.point.cast/round.fail.cpp | 26 + .../time.point/time.point.cast/round.pass.cpp | 68 + .../treat_as_floating_point.pass.cpp | 4 + .../tuple.elem/get_const_rv.fail.cpp | 34 + .../tuple.elem/get_const_rv.pass.cpp | 80 + .../tuple.elem/tuple.by.type.pass.cpp | 45 +- .../utility/as_const/as_const.fail.cpp | 22 + .../utility/as_const/as_const.pass.cpp | 46 + .../utility/declval/declval.pass.cpp | 6 +- .../utility/forward/move_if_noexcept.pass.cpp | 15 +- .../pairs/pair.astuple/get_const_rv.pass.cpp | 66 + .../pairs/pair.astuple/pairs.by.type.pass.cpp | 50 +- .../pairs/pairs.pair/default-sfinae.pass.cpp | 164 ++ .../utility/pairs/pairs.pair/default.pass.cpp | 17 +- .../utility/pairs/pairs.pair/swap.pass.cpp | 19 + test/support/allocators.h | 8 +- test/support/any_helpers.h | 318 ++++ test/support/count_new.hpp | 43 + test/support/disable_missing_braces_warning.h | 8 + test/support/test_allocator.h | 4 +- test/support/test_macros.h | 27 + test/testit | 2 +- utils/gen_link_script/gen_link_script.py | 79 + www/cxx1y_status.html | 302 ++-- www/cxx1z_status.html | 171 +- www/index.html | 30 +- www/kona.html | 154 ++ www/ts1z_status.html | 23 +- 809 files changed, 24752 insertions(+), 10143 deletions(-) create mode 100644 cmake/Modules/HandleLibcxxFlags.cmake create mode 100644 cmake/Modules/HandleOutOfTreeLLVM.cmake create mode 100644 docs/BuildingLibcxx.rst create mode 100644 docs/CMakeLists.txt create mode 100644 docs/DesignDocs/ABIVersioning.rst create mode 100644 docs/DesignDocs/CapturingConfigInfo.rst create mode 100644 docs/Makefile.sphinx create mode 100644 docs/README.txt create mode 100644 docs/TestingLibcxx.rst create mode 100644 docs/UsingLibcxx.rst create mode 100644 docs/conf.py create mode 100644 docs/index.rst create mode 100644 include/__config_site.in create mode 100644 include/__nullptr create mode 100644 include/ctype.h create mode 100644 include/errno.h create mode 100644 include/experimental/any create mode 100644 include/experimental/functional create mode 100644 include/float.h create mode 100644 include/inttypes.h create mode 100644 include/math.h create mode 100644 include/setjmp.h create mode 100644 include/stddef.h create mode 100644 include/stdio.h create mode 100644 include/stdlib.h create mode 100644 include/support/musl/xlocale.h create mode 100644 include/wchar.h create mode 100644 include/wctype.h create mode 100644 src/any.cpp rename src/{support => include}/atomic_support.h (96%) rename src/{ => include}/config_elast.h (100%) rename test/{std => libcxx}/atomics/libcpp-has-no-threads.fail.cpp (100%) rename test/{std => libcxx}/atomics/libcpp-has-no-threads.pass.cpp (87%) create mode 100644 test/libcxx/containers/sequences/deque/incomplete.pass.cpp rename test/{std => libcxx}/containers/sequences/vector/asan.pass.cpp (66%) rename test/{std => libcxx}/containers/sequences/vector/asan_throw.pass.cpp (99%) create mode 100644 test/libcxx/experimental/any/size_and_alignment.pass.cpp create mode 100644 test/libcxx/experimental/any/small_type.pass.cpp create mode 100644 test/libcxx/experimental/any/version.pass.cpp create mode 100644 test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp rename test/{std => libcxx}/thread/futures/version.pass.cpp (100%) create mode 100644 test/libcxx/type_traits/lazy_metafunctions.pass.cpp rename test/{std/utilities => libcxx/utilities/time}/date.time/asctime.thread-unsafe.fail.cpp (100%) rename test/{std/utilities => libcxx/utilities/time}/date.time/ctime.thread-unsafe.fail.cpp (100%) rename test/{std/utilities => libcxx/utilities/time}/date.time/gmtime.thread-unsafe.fail.cpp (100%) rename test/{std/utilities => libcxx/utilities/time}/date.time/localtime.thread-unsafe.fail.cpp (100%) rename test/std/{utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp => atomics/atomics.flag/init03.pass.cpp} (66%) create mode 100644 test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h create mode 100644 test/std/containers/associative/map/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/associative/multimap/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/associative/multiset/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/associative/set/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp create mode 100644 test/std/containers/sequences/deque/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/sequences/list/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/sequences/list/incomplete_type.pass.cpp create mode 100644 test/std/containers/sequences/vector/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/clear.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/emplace.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/emplace_hint.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_const_iter.pass.cpp (95%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_iter_db1.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_iter_db2.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_iter_iter_db1.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_iter_iter_db2.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_iter_iter_db3.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_iter_iter_db4.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_key.pass.cpp (97%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/erase_range.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_const_lvalue.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_hint_const_lvalue.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_hint_rvalue.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_init.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_or_assign.pass.cpp (96%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_range.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/insert_rvalue.pass.cpp (100%) rename test/std/containers/unord/unord.map/{unorder.map.modifiers => unord.map.modifiers}/try.emplace.pass.cpp (97%) create mode 100644 test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp create mode 100644 test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp create mode 100644 test/std/depr/depr.c.headers/extern_c.pass.cpp create mode 100644 test/std/depr/depr.c.headers/math_h_isinf.pass.cpp create mode 100644 test/std/depr/depr.c.headers/math_h_isnan.pass.cpp create mode 100644 test/std/experimental/algorithms/alg.search/search.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.assign/copy.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.assign/move.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.assign/value.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp create mode 100644 test/std/experimental/any/any.class/any.cons/copy.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.cons/default.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.cons/move.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp create mode 100644 test/std/experimental/any/any.class/any.cons/value.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.observers/empty.pass.cpp create mode 100644 test/std/experimental/any/any.class/any.observers/type.pass.cpp create mode 100644 test/std/experimental/any/any.class/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp create mode 100644 test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp create mode 100644 test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp create mode 100644 test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp create mode 100644 test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp create mode 100644 test/std/experimental/any/any.nonmembers/swap.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore/default.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/default.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pred.pass.cpp create mode 100644 test/std/experimental/func/func.searchers/nothing_to_do.pass.cpp create mode 100644 test/std/experimental/func/header.functional.synop/includes.pass.cpp create mode 100644 test/std/experimental/func/nothing_to_do.pass.cpp create mode 100644 test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp create mode 100644 test/std/strings/basic.string/allocator_mismatch.fail.cpp delete mode 100644 test/std/thread/futures/test_allocator.h delete mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp delete mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp create mode 100644 test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp create mode 100644 test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp create mode 100644 test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp create mode 100644 test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/bullet_5.pass.cpp create mode 100644 test/std/utilities/function.objects/func.require/invoke_helpers.h create mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp delete mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp delete mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp delete mode 100644 test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp create mode 100644 test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp create mode 100644 test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp create mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp delete mode 100644 test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp create mode 100644 test/std/utilities/meta/meta.logical/conjunction.pass.cpp create mode 100644 test/std/utilities/meta/meta.logical/disjunction.pass.cpp create mode 100644 test/std/utilities/meta/meta.logical/negation.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp create mode 100644 test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp rename test/std/utilities/{date.time/tested_elsewhere.pass.cpp => time/date.time/ctime.pass.cpp} (96%) create mode 100644 test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp create mode 100644 test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/round.fail.cpp create mode 100644 test/std/utilities/time/time.point/time.point.cast/round.pass.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp create mode 100644 test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp create mode 100644 test/std/utilities/utility/as_const/as_const.fail.cpp create mode 100644 test/std/utilities/utility/as_const/as_const.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp create mode 100644 test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp create mode 100644 test/support/any_helpers.h create mode 100644 test/support/disable_missing_braces_warning.h create mode 100755 utils/gen_link_script/gen_link_script.py create mode 100644 www/kona.html diff --git a/CMakeLists.txt b/CMakeLists.txt index 687c4cfc29a9..e6c96f64711b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,13 +3,16 @@ #=============================================================================== # Setup Project #=============================================================================== - -project(libcxx CXX C) cmake_minimum_required(VERSION 2.8) 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() + +project(libcxx CXX C) set(PACKAGE_NAME libcxx) set(PACKAGE_VERSION trunk-svn) @@ -30,61 +33,40 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD( build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there." ) -if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) - set(LIBCXX_LIBDIR_SUFFIX "" CACHE STRING - "Define suffix of library directory name (32/64)") - - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) - - set(LIBCXX_BUILT_STANDALONE 1) -else() - set(LIBCXX_LIBDIR_SUFFIX ${LLVM_LIBDIR_SUFFIX}) +# Find the LLVM sources and simulate LLVM CMake options. +include(HandleOutOfTreeLLVM) +if (LIBCXX_BUILT_STANDALONE AND NOT LLVM_FOUND) + message(WARNING "UNSUPPORTED LIBCXX CONFIGURATION DETECTED: " + "llvm-config not found and LLVM_PATH not defined.\n" + "Reconfigure with -DLLVM_CONFIG=path/to/llvm-config " + "or -DLLVM_PATH=path/to/llvm-source-root.") endif() #=============================================================================== # Setup CMake Options #=============================================================================== -# Define options. -option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) -option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) +# Basic options --------------------------------------------------------------- option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON) -option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) -option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) -option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF) option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) -option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) -option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) -option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) -option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) -option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) -option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF) -option(LIBCXX_ENABLE_MONOTONIC_CLOCK - "Build libc++ with support for a monotonic clock. - This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON) + +option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS}) +option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." ${LLVM_INCLUDE_DOCS}) +set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING + "Define suffix of library directory name (32/64)") option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON) +option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON) option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON) -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") -option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) -set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.") -set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") -if (LIBCXX_BUILT_STANDALONE) - set(LLVM_USE_SANITIZER "" CACHE STRING - "Define the sanitizer used to build the library and tests") -endif() - -if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) - if (APPLE) - message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X") - else() - message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") - endif() -endif() +set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.") +option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF) +# ABI Library options --------------------------------------------------------- +set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING + "Specify C++ ABI library to use." FORCE) set(CXXABIS none libcxxabi libcxxrt libstdc++ libsupc++) +set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) + +# Setup the default options if LIBCXX_CXX_ABI is not specified. if (NOT LIBCXX_CXX_ABI) if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") @@ -97,14 +79,139 @@ if (NOT LIBCXX_CXX_ABI) else () set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") endif () -set(LIBCXX_CXX_ABI "${LIBCXX_CXX_ABI}" CACHE STRING - "Specify C++ ABI library to use." FORCE) -set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS}) + +# Use a static copy of the ABI library when linking libc++. This option +# cannot be used with LIBCXX_ENABLE_ABI_LINKER_SCRIPT. +option(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "Statically link the ABI library" OFF) + +# Generate and install a linker script inplace of libc++.so. The linker script +# will link libc++ to the correct ABI library. This option is on by default +# On UNIX platforms other than Apple unless 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' +# is on. This option is also disabled when the ABI library is not specified +# or is specified to be "none". +set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE OFF) +if (LLVM_HAVE_LINK_VERSION_SCRIPT AND NOT LIBCXX_ENABLE_STATIC_ABI_LIBRARY + AND NOT LIBCXX_CXX_ABI_LIBNAME STREQUAL "none" + AND PYTHONINTERP_FOUND) + set(ENABLE_LINKER_SCRIPT_DEFAULT_VALUE ON) +endif() + +option(LIBCXX_ENABLE_ABI_LINKER_SCRIPT + "Use and install a linker script for the given ABI library" + ${ENABLE_LINKER_SCRIPT_DEFAULT_VALUE}) # 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_SYSROOT "" CACHE STRING "Use alternate sysroot.") +set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.") + +# Feature options ------------------------------------------------------------- +option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON) +option(LIBCXX_ENABLE_RTTI "Use run time type information." ON) +option(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE "Build libc++ with support for the global filesystem namespace." ON) +option(LIBCXX_ENABLE_STDIN "Build libc++ with support for stdin/std::cin." ON) +option(LIBCXX_ENABLE_STDOUT "Build libc++ with support for stdout/std::cout." ON) +option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) +option(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS "Build libc++ with support for thread-unsafe C functions" ON) +option(LIBCXX_ENABLE_MONOTONIC_CLOCK + "Build libc++ with support for a monotonic clock. + This option may only be set to OFF when LIBCXX_ENABLE_THREADS=OFF." ON) +option(LIBCXX_HAS_MUSL_LIBC "Build libc++ with support for the Musl C library" OFF) + +# Misc options ---------------------------------------------------------------- +# FIXME: Turn -pedantic back ON. It is currently off because it warns +# about #include_next which is used everywhere. +option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." OFF) +option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) + +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) +endif() +option(LIBCXX_CONFIGURE_IDE "Configure libcxx for use within an IDE" + ${LIBCXX_CONFIGURE_IDE_DEFAULT}) + +#=============================================================================== +# Check option configurations +#=============================================================================== + +# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON only when +# LIBCXX_ENABLE_THREADS is on. +if(LIBCXX_ENABLE_THREADS AND NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) + message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" + " when LIBCXX_ENABLE_THREADS is also set to OFF.") +endif() + +# Ensure LLVM_USE_SANITIZER is not specified when LIBCXX_GENERATE_COVERAGE +# is ON. +if (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) + message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") +endif() + +# Set LIBCXX_BUILD_32_BITS to (LIBCXX_BUILD_32_BITS OR LLVM_BUILD_32_BITS) +# and check that we can build with 32 bits if requested. +if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) + if (LIBCXX_BUILD_32_BITS AND NOT LLVM_BUILD_32_BITS) # Don't duplicate the output from LLVM + message(STATUS "Building 32 bits executables and libraries.") + endif() +elseif(LIBCXX_BUILD_32_BITS) + message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") +endif() + +# Check that this option is not enabled on Apple and emit a usage warning. +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) + if (APPLE) + message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X") + else() + message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option") + endif() +endif() + +if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) + if (APPLE) + message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT cannot be used on APPLE targets") + endif() + if (NOT PYTHONINTERP_FOUND) + message(FATAL_ERROR "LIBCXX_ENABLE_ABI_LINKER_SCRIPT requires python but it was not found.") + endif() +endif() + +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) + message(FATAL_ERROR "Conflicting options given. + LIBCXX_ENABLE_STATIC_ABI_LIBRARY cannot be specified with + 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() + #=============================================================================== # Configure System #=============================================================================== @@ -114,232 +221,183 @@ set(LIBCXX_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) set(LIBCXX_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(LIBCXX_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib${LIBCXX_LIBDIR_SUFFIX}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBCXX_LIBRARY_DIR}) + # Declare libc++ configuration variables. # They are intended for use as follows: # LIBCXX_CXX_FLAGS: General flags for both the compiler and linker. # LIBCXX_COMPILE_FLAGS: Compile only flags. # LIBCXX_LINK_FLAGS: Linker only flags. -set(LIBCXX_CXX_FLAGS "") set(LIBCXX_COMPILE_FLAGS "") set(LIBCXX_LINK_FLAGS "") +set(LIBCXX_LIBRARIES "") # Configure compiler. include(config-ix) -# Configure ABI library -include(HandleLibCXXABI) + # Configure coverage options. if (LIBCXX_GENERATE_COVERAGE) include(CodeCoverage) set(CMAKE_BUILD_TYPE "COVERAGE" CACHE STRING "" FORCE) endif() +string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) + #=============================================================================== # Setup Compiler Flags #=============================================================================== -# Get required flags. +include(HandleLibCXXABI) # Steup the ABI library flags + +# Include macros for adding and removing libc++ flags. +include(HandleLibcxxFlags) + +# Remove flags that may have snuck in. +remove_flags(-DNDEBUG -UNDEBUG -D_DEBUG + -stdlib=libc++ -stdlib=libstdc++ -lc++abi -m32) + +# FIXME(EricWF): See the FIXME on LIBCXX_ENABLE_PEDANTIC. +# Remove the -pedantic flag and -Wno-pedantic and -pedantic-errors +# so they don't get transformed into -Wno and -errors respectivly. +remove_flags(-Wno-pedantic -pedantic-errors -pedantic) + +# Required flags ============================================================== +add_compile_flags_if_supported(-std=c++11) +if (NOT MSVC AND NOT LIBCXX_SUPPORTS_STD_EQ_CXX11_FLAG) + message(FATAL_ERROR "C++11 is required but the compiler does not support -std=c++11") +endif() + # On all systems the system c++ standard library headers need to be excluded. -if (MSVC) - # 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++ - # headers. -else() - if (LIBCXX_HAS_NOSTDINCXX_FLAG) - list(APPEND LIBCXX_COMPILE_FLAGS -nostdinc++) - string(REPLACE "-stdlib=libc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - string(REPLACE "-stdlib=libstdc++" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") - endif() - # If c++1y has been enabled then attempt to use it. Fail if it is no supported - # by the compiler. Otherwise choose c++11 and ensure the compiler supports it. - if (LIBCXX_ENABLE_CXX1Y) - if (LIBCXX_HAS_STDCXX1Y_FLAG) - set(LIBCXX_STD_VERSION c++1y) - else() - message(FATAL_ERROR "c++1y was enabled but the compiler does not support it.") - endif() - else() - if (LIBCXX_HAS_STDCXX11_FLAG) - set(LIBCXX_STD_VERSION c++11) - else() - message(FATAL_ERROR "c++11 is required by libc++ but is not supported by the compiler") - endif() - endif() - # LIBCXX_STD_VERSION should always be set at this point. - list(APPEND LIBCXX_CXX_FLAGS "-std=${LIBCXX_STD_VERSION}") -endif() +# 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++ +# headers +add_compile_flags_if_supported(-nostdinc++) -macro(append_if list condition var) - if (${condition}) - list(APPEND ${list} ${var}) - endif() -endmacro() +# Target flags ================================================================ +add_flags_if(LIBCXX_BUILD_32_BITS -m32) +add_flags_if(LIBCXX_TARGET_TRIPLE "-target ${LIBCXX_TARGET_TRIPLE}") +add_flags_if(LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}") +add_flags_if(LIBCXX_GCC_TOOLCHAIN "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}") -# Get warning flags -if (NOT MSVC) - append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WALL_FLAG -Wall) - list(APPEND LIBCXX_COMPILE_FLAGS -Werror=return-type) -endif() - -append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_W_FLAG -W) -append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter) -append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings) -append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long) +# Warning flags =============================================================== +add_definitions(-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +add_compile_flags_if_supported( + -Wall -W -Wwrite-strings + -Wno-unused-parameter -Wno-long-long + -Werror=return-type) if (LIBCXX_ENABLE_WERROR) - append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror) - append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WX_FLAG -WX) + add_compile_flags_if_supported(-Werror) + add_compile_flags_if_supported(-WX) else() - append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_WNO_ERROR_FLAG -Wno-error) - append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_NO_WX_FLAG -WX-) + # TODO(EricWF) Remove this. We shouldn't be suppressing errors when -Werror is + # added elsewhere. + add_compile_flags_if_supported(-Wno-error) endif() if (LIBCXX_ENABLE_PEDANTIC) - append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic) + add_compile_flags_if_supported(-pedantic) endif() -# Get feature flags. -# Exceptions +# Exception flags ============================================================= if (LIBCXX_ENABLE_EXCEPTIONS) # Catches C++ exceptions only and tells the compiler to assume that extern C # functions never throw a C++ exception. - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc) + add_compile_flags_if_supported(-EHsc) else() - list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_EXCEPTIONS) - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-) - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-) - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions) + add_definitions(-D_LIBCPP_NO_EXCEPTIONS) + add_compile_flags_if_supported(-EHs- -EHa-) + add_compile_flags_if_supported(-fno-exceptions) endif() -# RTTI + +# RTTI flags ================================================================== if (NOT LIBCXX_ENABLE_RTTI) - list(APPEND LIBCXX_CXX_FLAGS -D_LIBCPP_NO_RTTI) - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-) - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti) + add_definitions(-D_LIBCPP_NO_RTTI) + add_compile_flags_if_supported(-GR-) + add_compile_flags_if_supported(-fno-rtti) endif() -# Assert -string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE) + +# Assertion flags ============================================================= +define_if(LIBCXX_ENABLE_ASSERTIONS -UNDEBUG) +define_if_not(LIBCXX_ENABLE_ASSERTIONS -DNDEBUG) if (LIBCXX_ENABLE_ASSERTIONS) # MSVC doesn't like _DEBUG on release builds. See PR 4379. - if (NOT MSVC) - list(APPEND LIBCXX_COMPILE_FLAGS -D_DEBUG) - endif() - # On Release builds cmake automatically defines NDEBUG, so we - # explicitly undefine it: - if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") - list(APPEND LIBCXX_COMPILE_FLAGS -UNDEBUG) - endif() -else() - if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE") - list(APPEND LIBCXX_COMPILE_FLAGS -DNDEBUG) - endif() -endif() -# Static library -if (NOT LIBCXX_ENABLE_SHARED) - list(APPEND LIBCXX_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC) + define_if_not(MSVC -D_DEBUG) endif() -if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) - if (LIBCXX_BUILD_32_BITS) - message(STATUS "Building 32 bits executables and libraries.") - list(APPEND LIBCXX_CXX_FLAGS "-m32") - endif() -elseif(LIBCXX_BUILD_32_BITS) - message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") -endif() -# This is the _ONLY_ place where add_definitions is called. -if (MSVC) - add_definitions(-D_CRT_SECURE_NO_WARNINGS) -endif() +# Feature flags =============================================================== +define_if(MSVC -D_CRT_SECURE_NO_WARNINGS) -# LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE configuration -if (NOT LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE) - add_definitions(-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) -endif() - -# LIBCXX_ENABLE_STDIN configuration -if (NOT LIBCXX_ENABLE_STDIN) - add_definitions(-D_LIBCPP_HAS_NO_STDIN) -endif() - -# LIBCXX_ENABLE_STDOUT configuration -if (NOT LIBCXX_ENABLE_STDOUT) - add_definitions(-D_LIBCPP_HAS_NO_STDOUT) -endif() - -# LIBCXX_ENABLE_THREADS configuration -if (NOT LIBCXX_ENABLE_THREADS) - add_definitions(-D_LIBCPP_HAS_NO_THREADS) - if (NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) - add_definitions(-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK) - endif() -# Ensure LIBCXX_ENABLE_MONOTONIC_CLOCK is set to ON. -elseif(NOT LIBCXX_ENABLE_MONOTONIC_CLOCK) - message(FATAL_ERROR "LIBCXX_ENABLE_MONOTONIC_CLOCK can only be set to OFF" - " when LIBCXX_ENABLE_THREADS is also set to OFF.") -endif() - -# LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS configuration -if (NOT LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS) - add_definitions(-D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS) -endif() +# Sanitizer flags ============================================================= # Configure for sanitizers. If LIBCXX_BUILT_STANDALONE then we have to do # the flag translation ourselves. Othewise LLVM's CMakeList.txt will handle it. if (LIBCXX_BUILT_STANDALONE) + set(LLVM_USE_SANITIZER "" CACHE STRING + "Define the sanitizer used to build the library and tests") # NOTE: LLVM_USE_SANITIZER checks for a UNIX like system instead of MSVC. # But we don't have LLVM_ON_UNIX so checking for MSVC is the best we can do. if (LLVM_USE_SANITIZER AND NOT MSVC) - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG - "-fno-omit-frame-pointer") + add_flags_if_supported("-fno-omit-frame-pointer") + add_flags_if_supported("-gline-tables-only") + if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" AND NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO") - append_if(LIBCXX_CXX_FLAGS LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG - "-gline-tables-only") + add_flags_if_supported("-gline-tables-only") endif() if (LLVM_USE_SANITIZER STREQUAL "Address") - list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=address") + add_flags("-fsanitize=address") elseif (LLVM_USE_SANITIZER MATCHES "Memory(WithOrigins)?") - list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=memory") + add_flags(-fsanitize=memory) if (LLVM_USE_SANITIZER STREQUAL "MemoryWithOrigins") - list(APPEND LIBCXX_CXX_FLAGS "-fsanitize-memory-track-origins") + add_flags("-fsanitize-memory-track-origins") endif() elseif (LLVM_USE_SANITIZER STREQUAL "Undefined") - list(APPEND LIBCXX_CXX_FLAGS - "-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover") + add_flags("-fsanitize=undefined -fno-sanitize=vptr,function -fno-sanitize-recover=all") elseif (LLVM_USE_SANITIZER STREQUAL "Thread") - list(APPEND LIBCXX_CXX_FLAGS "-fsanitize=thread") + add_flags(-fsanitize=thread) else() message(WARNING "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}") endif() - elseif(MSVC) - message(WARNING "LLVM_USE_SANITIZER is not supported with MSVC") + elseif(LLVM_USE_SANITIZER AND MSVC) + message(WARNING "LLVM_USE_SANITIZER is not supported on this platform.") endif() endif() -append_if(LIBCXX_CXX_FLAGS LIBCXX_TARGET_TRIPLE - "-target ${LIBCXX_TARGET_TRIPLE}") +# Configuration file flags ===================================================== +if (NOT LIBCXX_ABI_VERSION EQUAL "1") + config_define(${LIBCXX_ABI_VERSION} _LIBCPP_ABI_VERSION) +endif() +config_define_if(LIBCXX_ABI_UNSTABLE _LIBCPP_ABI_UNSTABLE) -append_if(LIBCXX_CXX_FLAGS LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}") -append_if(LIBCXX_CXX_FLAGS LIBCXX_GCC_TOOLCHAIN - "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}") +config_define_if_not(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE) +config_define_if_not(LIBCXX_ENABLE_STDIN _LIBCPP_HAS_NO_STDIN) +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 (LLVM_USE_SANITIZER AND LIBCXX_GENERATE_COVERAGE) - message(FATAL_ERROR "LLVM_USE_SANITIZER cannot be used with LIBCXX_GENERATE_COVERAGE") +config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC) + +if (LIBCXX_NEEDS_SITE_CONFIG) + configure_file( + include/__config_site.in + ${LIBCXX_BINARY_DIR}/__config_site + @ONLY) + # Provide the config definitions by included the generated __config_site + # file at compile time. + add_compile_flags("-include ${LIBCXX_BINARY_DIR}/__config_site") endif() -string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}") - #=============================================================================== -# Setup Source Code +# Setup Source Code And Tests #=============================================================================== - include_directories(include) add_subdirectory(include) - -# Add source code. This also contains all of the logic for deciding linker flags -# soname, etc... add_subdirectory(lib) -#=============================================================================== -# Setup Tests -#=============================================================================== - -add_subdirectory(test) +if (LIBCXX_INCLUDE_TESTS) + add_subdirectory(test) +endif() +if (LIBCXX_INCLUDE_DOCS) + add_subdirectory(docs) +endif() diff --git a/TODO.TXT b/TODO.TXT index 513b86377244..bdb94de343d6 100644 --- a/TODO.TXT +++ b/TODO.TXT @@ -1,5 +1,15 @@ This is meant to be a general place to list things that should be done "someday" +3.8 Release Goals +================= +* LFTS v1 (EricWF, MClow) +* Filesystem TS (EricWF) +* ASIO TS (MClow) +* Improvements (MClow) +* Setup ABI Versioning policy (EricWF) +* Fix PR19302 - Fix UB in list and __tree. + + ABI Related Tasks ================= * Explicitly manage and verify symbols exported from the dylib. @@ -21,18 +31,18 @@ CXX Runtime Library Tasks Atomic Related Tasks ==================== -* Support in C++03 (needed for internal use). +* Enable mixing of clang and GCC atomics internally. Currently some + parts of libc++ use atomics only when clang provides them. + (see memory@5380 for an example) * Audit use of libatomic builtins in with GCC. * future should use for synchronization. -* call_once should use for synchronization. -* Audit shared_ptr use of Test Suite Tasks ================ -* Get test suite passing in C++03. * Move all libc++ specific tests from test/std into test/libcxx. * Improve how LIT handles compiler warnings. * Improve the quality and portability of the locale test data. +* Convert failure tests to use Clang Verify. Misc Tasks ========== @@ -42,8 +52,5 @@ Misc Tasks * Look at basic_string's move assignment operator, re LWG 2063 and POCMA * libc++ is missing try_emplace * Put a static_assert in std::allocator to deny const/volatile types (LWG 2447) -* Investigate the effect of using __decltype instead of __typeof__ to provide - decltype in C++03. What code could be broken by this change? -* Convert failure tests to use Clang Verify. * Document support (or lack of) for C++11 libraries in C++03. * Document supported compilers. diff --git a/cmake/Modules/HandleLibCXXABI.cmake b/cmake/Modules/HandleLibCXXABI.cmake index 73723e3559b1..d9c652d87bad 100644 --- a/cmake/Modules/HandleLibCXXABI.cmake +++ b/cmake/Modules/HandleLibCXXABI.cmake @@ -41,10 +41,13 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs) file(COPY "${incpath}/${fpath}" DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}" ) - install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}" - DESTINATION include/c++/v1/${dstdir} - PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ - ) + if (LIBCXX_INSTALL_HEADERS) + install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}" + DESTINATION include/c++/v1/${dstdir} + COMPONENT libcxx + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + ) + endif() list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}") endif() endforeach() @@ -58,6 +61,8 @@ macro(setup_abi_lib abidefines abilib abifiles abidirs) endmacro() + +# Configure based on the selected ABI library. if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++") set(_LIBSUPCXX_INCLUDE_FILES diff --git a/cmake/Modules/HandleLibcxxFlags.cmake b/cmake/Modules/HandleLibcxxFlags.cmake new file mode 100644 index 000000000000..bb886fa8a01f --- /dev/null +++ b/cmake/Modules/HandleLibcxxFlags.cmake @@ -0,0 +1,169 @@ +# HandleLibcxxFlags - A set of macros used to setup the flags used to compile +# and link libc++. These macros add flags to the following CMake variables. +# - LIBCXX_COMPILE_FLAGS: flags used to compile libc++ +# - LIBCXX_LINK_FLAGS: flags used to link libc++ +# - LIBCXX_LIBRARIES: libraries to link libc++ to. + +include(CheckCXXCompilerFlag) + +unset(add_flag_if_supported) + +# Mangle the name of a compiler flag into a valid CMake identifier. +# Ex: --std=c++11 -> STD_EQ_CXX11 +macro(mangle_name str output) + string(STRIP "${str}" strippedStr) + string(REGEX REPLACE "^/" "" strippedStr "${strippedStr}") + string(REGEX REPLACE "^-+" "" strippedStr "${strippedStr}") + string(REGEX REPLACE "-+$" "" strippedStr "${strippedStr}") + string(REPLACE "-" "_" strippedStr "${strippedStr}") + string(REPLACE "=" "_EQ_" strippedStr "${strippedStr}") + string(REPLACE "+" "X" strippedStr "${strippedStr}") + string(TOUPPER "${strippedStr}" ${output}) +endmacro() + +# Remove a list of flags from all CMake variables that affect compile flags. +# This can be used to remove unwanted flags specified on the command line +# or added in other parts of LLVM's cmake configuration. +macro(remove_flags) + foreach(var ${ARGN}) + string(REPLACE "${var}" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + string(REPLACE "${var}" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") + string(REPLACE "${var}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") + string(REPLACE "${var}" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") + string(REPLACE "${var}" "" CMAKE_SHARED_MODULE_FLAGS "${CMAKE_SHARED_MODULE_FLAGS}") + remove_definitions(${var}) + endforeach() +endmacro(remove_flags) + +# Add a macro definition if condition is true. +macro(define_if condition def) + if (${condition}) + add_definitions(${def}) + endif() +endmacro() + +# Add a macro definition if condition is not true. +macro(define_if_not condition def) + if (NOT ${condition}) + add_definitions(${def}) + endif() +endmacro() + +# Add a macro definition to the __config_site file if the specified condition +# is 'true'. Note that '-D${def}' is not added. Instead it is expected that +# the build include the '__config_site' header. +macro(config_define_if condition def) + if (${condition}) + set(${def} ON) + set(LIBCXX_NEEDS_SITE_CONFIG ON) + endif() +endmacro() + +macro(config_define_if_not condition def) + if (NOT ${condition}) + set(${def} ON) + set(LIBCXX_NEEDS_SITE_CONFIG ON) + endif() +endmacro() + +macro(config_define value def) + set(${def} ${value}) + set(LIBCXX_NEEDS_SITE_CONFIG ON) +endmacro() + +# Add a specified list of flags to both 'LIBCXX_COMPILE_FLAGS' and +# 'LIBCXX_LINK_FLAGS'. +macro(add_flags) + foreach(value ${ARGN}) + list(APPEND LIBCXX_COMPILE_FLAGS ${value}) + list(APPEND LIBCXX_LINK_FLAGS ${value}) + endforeach() +endmacro() + +# If the specified 'condition' is true then add a list of flags to both +# 'LIBCXX_COMPILE_FLAGS' and 'LIBCXX_LINK_FLAGS'. +macro(add_flags_if condition) + if (${condition}) + add_flags(${ARGN}) + endif() +endmacro() + +# Add each flag in the list to LIBCXX_COMPILE_FLAGS and LIBCXX_LINK_FLAGS +# if that flag is supported by the current compiler. +macro(add_flags_if_supported) + foreach(flag ${ARGN}) + mangle_name("${flag}" flagname) + check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") + add_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + endforeach() +endmacro() + +# Add a list of flags to 'LIBCXX_COMPILE_FLAGS'. +macro(add_compile_flags) + foreach(f ${ARGN}) + list(APPEND LIBCXX_COMPILE_FLAGS ${f}) + endforeach() +endmacro() + +# If 'condition' is true then add the specified list of flags to +# 'LIBCXX_COMPILE_FLAGS' +macro(add_compile_flags_if condition) + if (${condition}) + add_compile_flags(${ARGN}) + endif() +endmacro() + +# For each specified flag, add that flag to 'LIBCXX_COMPILE_FLAGS' if the +# flag is supported by the C++ compiler. +macro(add_compile_flags_if_supported) + foreach(flag ${ARGN}) + mangle_name("${flag}" flagname) + check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") + add_compile_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + endforeach() +endmacro() + +# Add a list of flags to 'LIBCXX_LINK_FLAGS'. +macro(add_link_flags) + foreach(f ${ARGN}) + list(APPEND LIBCXX_LINK_FLAGS ${f}) + endforeach() +endmacro() + +# If 'condition' is true then add the specified list of flags to +# 'LIBCXX_LINK_FLAGS' +macro(add_link_flags_if condition) + if (${condition}) + add_link_flags(${ARGN}) + endif() +endmacro() + +# For each specified flag, add that flag to 'LIBCXX_LINK_FLAGS' if the +# flag is supported by the C++ compiler. +macro(add_link_flags_if_supported) + foreach(flag ${ARGN}) + mangle_name("${flag}" flagname) + check_cxx_compiler_flag("${flag}" "LIBCXX_SUPPORTS_${flagname}_FLAG") + add_link_flags_if(LIBCXX_SUPPORTS_${flagname}_FLAG ${flag}) + endforeach() +endmacro() + +# Add a list of libraries or link flags to 'LIBCXX_LIBRARIES'. +macro(add_library_flags) + foreach(lib ${ARGN}) + list(APPEND LIBCXX_LIBRARIES ${lib}) + endforeach() +endmacro() + +# if 'condition' is true then add the specified list of libraries and flags +# to 'LIBCXX_LIBRARIES'. +macro(add_library_flags_if condition) + if(${condition}) + add_library_flags(${ARGN}) + endif() +endmacro() + +# Turn a comma separated CMake list into a space separated string. +macro(split_list listname) + string(REPLACE ";" " " ${listname} "${${listname}}") +endmacro() diff --git a/cmake/Modules/HandleOutOfTreeLLVM.cmake b/cmake/Modules/HandleOutOfTreeLLVM.cmake new file mode 100644 index 000000000000..6215be7f586a --- /dev/null +++ b/cmake/Modules/HandleOutOfTreeLLVM.cmake @@ -0,0 +1,138 @@ +macro(find_llvm_parts) +# Rely on llvm-config. + set(CONFIG_OUTPUT) + find_program(LLVM_CONFIG "llvm-config") + if(DEFINED LLVM_PATH) + set(LLVM_INCLUDE_DIR ${LLVM_INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_PATH ${LLVM_PATH} CACHE PATH "Path to LLVM source tree") + set(LLVM_MAIN_SRC_DIR ${LLVM_PATH}) + set(LLVM_CMAKE_PATH "${LLVM_PATH}/cmake/modules") + elseif(LLVM_CONFIG) + message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}") + set(CONFIG_COMMAND ${LLVM_CONFIG} + "--includedir" + "--prefix" + "--src-root") + execute_process( + COMMAND ${CONFIG_COMMAND} + RESULT_VARIABLE HAD_ERROR + OUTPUT_VARIABLE CONFIG_OUTPUT + ) + if(NOT HAD_ERROR) + string(REGEX REPLACE + "[ \t]*[\r\n]+[ \t]*" ";" + CONFIG_OUTPUT ${CONFIG_OUTPUT}) + else() + string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}") + message(STATUS "${CONFIG_COMMAND_STR}") + message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") + endif() + + list(GET CONFIG_OUTPUT 0 INCLUDE_DIR) + list(GET CONFIG_OUTPUT 1 LLVM_OBJ_ROOT) + list(GET CONFIG_OUTPUT 2 MAIN_SRC_DIR) + + set(LLVM_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include") + set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree") + set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree") + set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/share/llvm/cmake") + else() + set(LLVM_FOUND OFF) + return() + endif() + + if (NOT EXISTS ${LLVM_MAIN_SRC_DIR}) + set(LLVM_FOUND OFF) + message(WARNING "Not found: ${LLVM_MAIN_SRC_DIR}") + return() + endif() + + if(NOT EXISTS ${LLVM_CMAKE_PATH}) + set(LLVM_FOUND OFF) + message(WARNING "Not found: ${LLVM_CMAKE_PATH}") + return() + endif() + + list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}") + list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules") + + set(LLVM_FOUND ON) +endmacro(find_llvm_parts) + + +if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + set(LIBCXX_BUILT_STANDALONE 1) + message(STATUS "Configuring for standalone build.") + + find_llvm_parts() + + # LLVM Options -------------------------------------------------------------- + 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) + endif() + + if (NOT DEFINED LLVM_INCLUDE_TESTS) + set(LLVM_INCLUDE_TESTS ${LLVM_FOUND}) + endif() + if (NOT DEFINED LLVM_INCLUDE_DOCS) + set(LLVM_INCLUDE_DOCS ${LLVM_FOUND}) + endif() + if (NOT DEFINED LLVM_ENABLE_SPHINX) + set(LLVM_ENABLE_SPHINX OFF) + endif() + + # Required LIT Configuration ------------------------------------------------ + # Define the default arguments to use with 'lit', and an option for the user + # to override. + set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported") + if (MSVC OR XCODE) + set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") + endif() + set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for lit") + + # Make sure we can use the console pool for recent cmake and ninja > 1.5 + # Needed for add_lit_testsuite + if(CMAKE_VERSION VERSION_LESS 3.1.20141117) + set(cmake_3_2_USES_TERMINAL) + else() + set(cmake_3_2_USES_TERMINAL USES_TERMINAL) + endif() + + # Required doc configuration + if (LLVM_ENABLE_SPHINX) + message(STATUS "Sphinx enabled.") + find_package(Sphinx REQUIRED) + else() + message(STATUS "Sphinx disabled.") + endif() + + # FIXME - This is cribbed from HandleLLVMOptions.cmake. + if(WIN32) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) + if(CYGWIN) + set(LLVM_ON_WIN32 0) + set(LLVM_ON_UNIX 1) + else(CYGWIN) + set(LLVM_ON_WIN32 1) + set(LLVM_ON_UNIX 0) + endif(CYGWIN) + else(WIN32) + if(UNIX) + set(LLVM_ON_WIN32 0) + set(LLVM_ON_UNIX 1) + if(APPLE) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 0) + else(APPLE) + set(LLVM_HAVE_LINK_VERSION_SCRIPT 1) + endif(APPLE) + else(UNIX) + MESSAGE(SEND_ERROR "Unable to determine platform") + endif(UNIX) + endif(WIN32) + + # Add LLVM Functions -------------------------------------------------------- + include(AddLLVM OPTIONAL) +endif() diff --git a/cmake/config-ix.cmake b/cmake/config-ix.cmake index 428d737c749d..c05597ea73dd 100644 --- a/cmake/config-ix.cmake +++ b/cmake/config-ix.cmake @@ -2,23 +2,7 @@ include(CheckLibraryExists) include(CheckCXXCompilerFlag) # Check compiler flags -check_cxx_compiler_flag(-std=c++11 LIBCXX_HAS_STDCXX11_FLAG) -check_cxx_compiler_flag(-std=c++1y LIBCXX_HAS_STDCXX1Y_FLAG) -check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG) -check_cxx_compiler_flag(-fno-omit-frame-pointer LIBCXX_HAS_FNO_OMIT_FRAME_POINTER_FLAG) -check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG) -check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG) -check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG) -check_cxx_compiler_flag(-W LIBCXX_HAS_W_FLAG) -check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG) -check_cxx_compiler_flag(-Wwrite-strings LIBCXX_HAS_WWRITE_STRINGS_FLAG) -check_cxx_compiler_flag(-Wno-long-long LIBCXX_HAS_WNO_LONG_LONG_FLAG) -check_cxx_compiler_flag(-pedantic LIBCXX_HAS_PEDANTIC_FLAG) -check_cxx_compiler_flag(-Werror LIBCXX_HAS_WERROR_FLAG) -check_cxx_compiler_flag(-Wno-error LIBCXX_HAS_WNO_ERROR_FLAG) -check_cxx_compiler_flag(-fno-exceptions LIBCXX_HAS_FNO_EXCEPTIONS_FLAG) -check_cxx_compiler_flag(-fno-rtti LIBCXX_HAS_FNO_RTTI_FLAG) -check_cxx_compiler_flag(-gline-tables-only LIBCXX_HAS_GLINE_TABLES_ONLY_FLAG) + check_cxx_compiler_flag(/WX LIBCXX_HAS_WX_FLAG) check_cxx_compiler_flag(/WX- LIBCXX_HAS_NO_WX_FLAG) check_cxx_compiler_flag(/EHsc LIBCXX_HAS_EHSC_FLAG) @@ -26,10 +10,10 @@ check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG) check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG) check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG) + # Check libraries check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB) -check_library_exists(c printf "" LIBCXX_HAS_C_LIB) +check_library_exists(c fopen "" LIBCXX_HAS_C_LIB) check_library_exists(m ccos "" LIBCXX_HAS_M_LIB) check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB) check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB) - diff --git a/docs/BuildingLibcxx.rst b/docs/BuildingLibcxx.rst new file mode 100644 index 000000000000..f00ce4f9cff1 --- /dev/null +++ b/docs/BuildingLibcxx.rst @@ -0,0 +1,306 @@ + +=============== +Building libc++ +=============== + +.. contents:: + :local: + +Getting Started +=============== + +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. + +The basic steps needed to build libc++ are: + +#. Checkout LLVM: + + * ``cd where-you-want-llvm-to-live`` + * ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm`` + +#. Checkout libc++: + + * ``cd where-you-want-llvm-to-live`` + * ``cd llvm/projects`` + * ``svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx`` + +#. Checkout libc++abi: + + * ``cd where-you-want-llvm-to-live`` + * ``cd llvm/projects`` + * ``svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi`` + +#. Configure and build libc++ with libc++abi: + + CMake is the only supported configuration system. Unlike other LLVM + projects autotools is not supported for either libc++ or libc++abi. + + Clang is the preferred compiler when building and using libc++. + + * ``cd where you want to build llvm`` + * ``mkdir build`` + * ``cd build`` + * ``cmake -G [options] `` + + For more information about configuring libc++ see :ref:`CMake Options`. + + * ``make cxx`` --- will build libc++ and libc++abi. + * ``make check-libcxx check-libcxxabi`` --- will run the test suites. + + Shared libraries for libc++ and libc++ abi should now be present in llvm/build/lib. + See :ref:`using an alternate libc++ installation ` + +#. **Optional**: 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++. + + * ``make install-libcxx install-libcxxabi`` --- Will install the libraries and the headers + + .. warning:: + * Replacing your systems libc++ installation could render the system non-functional. + * Mac OS X will not boot without a valid copy of ``libc++.1.dylib`` in ``/usr/lib``. + + +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 sometimes beneficial to build outside of the LLVM tree. An out-of-tree +build would look like this: + +.. code-block:: bash + + $ cd where-you-want-libcxx-to-live + $ # Check out llvm, libc++ and libc++abi. + $ ``svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm`` + $ ``svn co http://llvm.org/svn/llvm-project/libcxx/trunk libcxx`` + $ ``svn co http://llvm.org/svn/llvm-project/libcxxabi/trunk libcxxabi`` + $ cd where-you-want-to-build + $ mkdir build && cd build + $ export CC=clang CXX=clang++ + $ cmake -DLLVM_PATH=path/to/llvm \ + -DLIBCXX_CXX_ABI=libcxxabi \ + -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxabi/include \ + path/to/libcxx + $ make + $ make check-libcxx # optional + + +.. _`libc++abi`: http://libcxxabi.llvm.org/ + + +.. _CMake Options: + +CMake Options +============= + +Here are some of the CMake variables that are used often, along with a +brief explanation and LLVM-specific notes. For full documentation, check the +CMake docs or execute ``cmake --help-variable VARIABLE_NAME``. + +**CMAKE_BUILD_TYPE**:STRING + Sets the build type for ``make`` based generators. Possible values are + Release, Debug, RelWithDebInfo and MinSizeRel. On systems like Visual Studio + the user sets the build type with the IDE settings. + +**CMAKE_INSTALL_PREFIX**:PATH + Path where LLVM will be installed if "make install" is invoked or the + "INSTALL" target is built. + +**CMAKE_CXX_COMPILER**:STRING + The C++ compiler to use when building and testing libc++. + + +.. _libcxx-specific options: + +libc++ specific options +----------------------- + +.. option:: LIBCXX_ENABLE_ASSERTIONS:BOOL + + **Default**: ``ON`` + + Build libc++ with assertions enabled. + +.. option:: LIBCXX_BUILD_32_BITS:BOOL + + **Default**: ``OFF`` + + Build libc++ as a 32 bit library. Also see :option:`LLVM_BUILD_32_BITS`. + +.. option:: LIBCXX_ENABLE_SHARED:BOOL + + **Default**: ``ON`` + + Build libc++ as a shared library. If ``OFF`` is specified then libc++ is + built as a static library. + +.. option:: LIBCXX_LIBDIR_SUFFIX:STRING + + Extra suffix to append to the directory where libraries are to be installed. + This option overrides :option:`LLVM_LIBDIR_SUFFIX`. + +.. _ABI Library Specific Options: + +ABI Library Specific Options +---------------------------- + +.. option:: LIBCXX_CXX_ABI:STRING + + **Values**: ``none``, ``libcxxabi``, ``libcxxrt``, ``libstdc++``, ``libsupc++``. + + Select the ABI library to build libc++ against. + +.. option:: LIBCXX_CXX_ABI_INCLUDE_PATHS:PATHS + + Provide additional search paths for the ABI library headers. + +.. option:: LIBCXX_CXX_ABI_LIBRARY_PATH:PATH + + Provide the path to the ABI library that libc++ should link against. + +.. option:: LIBCXX_ENABLE_STATIC_ABI_LIBRARY:BOOL + + **Default**: ``OFF`` + + If this option is enabled, libc++ will try and link the selected ABI library + statically. + +.. option:: LIBCXX_ENABLE_ABI_LINKER_SCRIPT:BOOL + + **Default**: ``ON`` by default on UNIX platforms other than Apple unless + 'LIBCXX_ENABLE_STATIC_ABI_LIBRARY' is ON. Otherwise the default value is ``OFF``. + + This option generate and installs a linker script as ``libc++.so`` which + links the correct ABI library. + +.. option:: LIBCXXABI_USE_LLVM_UNWINDER:BOOL + + **Default**: ``OFF`` + + Build and use the LLVM unwinder. Note: This option can only be used when + libc++abi is the C++ ABI library used. + + +libc++ Feature options +---------------------- + +.. option:: LIBCXX_ENABLE_EXCEPTIONS:BOOL + + **Default**: ``ON`` + + Build libc++ with exception support. + +.. option:: LIBCXX_ENABLE_RTTI:BOOL + + **Default**: ``ON`` + + Build libc++ with run time type information. + + +libc++ Feature options +---------------------- + +The following options allow building libc++ for a different ABI version. + +.. option:: LIBCXX_ABI_VERSION:STRING + + **Default**: ``1`` + + Defines the target ABI version of libc++. + +.. option:: LIBCXX_ABI_UNSTABLE:BOOL + + **Default**: ``OFF`` + + Build the "unstable" ABI version of libc++. Includes all ABI changing features + on top of the current stable version. + +.. _LLVM-specific variables: + +LLVM-specific options +--------------------- + +.. option:: LLVM_LIBDIR_SUFFIX:STRING + + Extra suffix to append to the directory where libraries are to be + installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64`` + to install libraries to ``/usr/lib64``. + +.. option:: LLVM_BUILD_32_BITS:BOOL + + Build 32-bits executables and libraries on 64-bits systems. This option is + available only on some 64-bits unix systems. Defaults to OFF. + +.. option:: LLVM_LIT_ARGS:STRING + + Arguments given to lit. ``make check`` and ``make clang-test`` are affected. + By default, ``'-sv --no-progress-bar'`` on Visual C++ and Xcode, ``'-sv'`` on + others. + + +Using Alternate ABI libraries +============================= + + +.. _libsupcxx: + +Using libsupc++ on Linux +------------------------ + +You will need libstdc++ in order to provide libsupc++. + +Figure out where the libsupc++ headers are on your system. On Ubuntu this +is ``/usr/include/c++/`` and ``/usr/include/c++//`` + +You can also figure this out by running + +.. code-block:: bash + + $ echo | g++ -Wp,-v -x c++ - -fsyntax-only + ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu" + ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../x86_64-linux-gnu/include" + #include "..." search starts here: + #include <...> search starts here: + /usr/include/c++/4.7 + /usr/include/c++/4.7/x86_64-linux-gnu + /usr/include/c++/4.7/backward + /usr/lib/gcc/x86_64-linux-gnu/4.7/include + /usr/local/include + /usr/lib/gcc/x86_64-linux-gnu/4.7/include-fixed + /usr/include/x86_64-linux-gnu + /usr/include + 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. + +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 \ + + + +You can also substitute ``-DLIBCXX_CXX_ABI=libsupc++`` +above, which will cause the library to be linked to libsupc++ instead +of libstdc++, but this is only recommended if you know that you will +never need to link against libstdc++ in the same executable as libc++. +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++. diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt new file mode 100644 index 000000000000..f63ee00a5a02 --- /dev/null +++ b/docs/CMakeLists.txt @@ -0,0 +1,9 @@ + +if (LLVM_ENABLE_SPHINX) + if (SPHINX_FOUND) + include(AddSphinxTarget) + if (${SPHINX_OUTPUT_HTML}) + add_sphinx_target(html libcxx) + endif() + endif() +endif() \ No newline at end of file diff --git a/docs/DesignDocs/ABIVersioning.rst b/docs/DesignDocs/ABIVersioning.rst new file mode 100644 index 000000000000..5960dd18610c --- /dev/null +++ b/docs/DesignDocs/ABIVersioning.rst @@ -0,0 +1,17 @@ + +==================== +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. + +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. + +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. diff --git a/docs/DesignDocs/CapturingConfigInfo.rst b/docs/DesignDocs/CapturingConfigInfo.rst new file mode 100644 index 000000000000..73378a21c0a9 --- /dev/null +++ b/docs/DesignDocs/CapturingConfigInfo.rst @@ -0,0 +1,88 @@ +======================================================= +Capturing configuration information during installation +======================================================= + +.. contents:: + :local: + +The Problem +=========== + +Currently the libc++ supports building the library with a number of different +configuration options. Unfortunately all of that configuration information is +lost when libc++ is installed. In order to support "persistent" +configurations libc++ needs a mechanism to capture the configuration options +in the INSTALLED headers. + + +Design Goals +============ + +* The solution should not INSTALL any additional headers. We don't want an extra + #include slowing everybody down. + +* The solution should not unduly affect libc++ developers. The problem is limited + to installed versions of libc++ and the solution should be as well. + +* The solution should not modify any existing headers EXCEPT during installation. + It makes developers lives harder if they have to regenerate the libc++ headers + every time they are modified. + +* The solution should not make any of the libc++ headers dependant on + files generated by the build system. The headers should be able to compile + out of the box without any modification. + +* The solution should not have ANY effect on users who don't need special + configuration options. The vast majority of users will never need this so it + shouldn't cost them. + + +The Solution +============ + +When you first configure libc++ using CMake we check to see if we need to +capture any options. If we haven't been given any "persistent" options then +we do NOTHING. + +Otherwise we create a custom installation rule that modifies the installed __config +header. The rule first generates a dummy "__config_site" header containing the required +#defines. The contents of the dummy header are then prependend to the installed +__config header. By manually prepending the files we avoid the cost of an +extra #include and we allow the __config header to be ignorant of the extra +configuration all together. An example "__config" header generated when +-DLIBCXX_ENABLE_THREADS=OFF is given to CMake would look something like: + +.. code-block:: cpp + + //===----------------------------------------------------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file is dual licensed under the MIT and the University of Illinois Open + // Source Licenses. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + + #ifndef _LIBCPP_CONFIG_SITE + #define _LIBCPP_CONFIG_SITE + + /* #undef _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE */ + /* #undef _LIBCPP_HAS_NO_STDIN */ + /* #undef _LIBCPP_HAS_NO_STDOUT */ + #define _LIBCPP_HAS_NO_THREADS + /* #undef _LIBCPP_HAS_NO_MONOTONIC_CLOCK */ + /* #undef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS */ + + #endif + // -*- C++ -*- + //===--------------------------- __config ---------------------------------===// + // + // The LLVM Compiler Infrastructure + // + // This file is dual licensed under the MIT and the University of Illinois Open + // Source Licenses. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + + #ifndef _LIBCPP_CONFIG + #define _LIBCPP_CONFIG diff --git a/docs/Makefile.sphinx b/docs/Makefile.sphinx new file mode 100644 index 000000000000..2ca1e4d3faf2 --- /dev/null +++ b/docs/Makefile.sphinx @@ -0,0 +1,37 @@ +# Makefile for Sphinx documentation +# +# FIXME: This hack is only in place to allow the libcxx.llvm.org/docs builder +# to work with libcxx. This should be removed when that builder supports +# out-of-tree builds. + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext default + +default: html + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @# FIXME: Remove this `cp` once HTML->Sphinx transition is completed. + @# Kind of a hack, but HTML-formatted docs are on the way out anyway. + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + diff --git a/docs/README.txt b/docs/README.txt new file mode 100644 index 000000000000..06d94f5b5fc4 --- /dev/null +++ b/docs/README.txt @@ -0,0 +1,13 @@ +libc++ Documentation +==================== + +The libc++ documentation is written using the Sphinx documentation generator. It is +currently tested with Sphinx 1.1.3. + +To build the documents into html configure libc++ with the following cmake options: + + * -DLLVM_ENABLE_SPHINX=ON + * -DLIBCXX_INCLUDE_DOCS=ON + +After configuring libc++ with these options the make rule `docs-libcxx-html` +should be available. diff --git a/docs/TestingLibcxx.rst b/docs/TestingLibcxx.rst new file mode 100644 index 000000000000..98162d9c2e05 --- /dev/null +++ b/docs/TestingLibcxx.rst @@ -0,0 +1,191 @@ +============== +Testing libc++ +============== + +.. contents:: + :local: + +Getting Started +=============== + +libc++ uses LIT to configure and run its tests. The primary way to run the +libc++ tests is by using make check-libcxx. However since libc++ can be used +in any number of possible configurations it is important to customize the way +LIT builds and runs the tests. This guide provides information on how to use +LIT directly to test libc++. + +Please see the `Lit Command Guide`_ for more information about LIT. + +.. _LIT Command Guide: http://llvm.org/docs/CommandGuide/lit.html + +Setting up the Environment +-------------------------- + +After building libc++ you must setup your environment to test libc++ using +LIT. + +#. Create a shortcut to the actual lit executable so that you can invoke it + easily from the command line. + + .. code-block:: bash + + $ alias lit='python path/to/llvm/utils/lit/lit.py' + +#. Tell LIT where to find your build configuration. + + .. code-block:: bash + + $ export LIBCXX_SITE_CONFIG=path/to/build-libcxx/test/lit.site.cfg + +Example Usage +------------- + +Once you have your environment set up and you have built libc++ you can run +parts of the libc++ test suite by simply running `lit` on a specified test or +directory. For example: + +.. code-block:: bash + + $ cd path/to/src/libcxx + $ lit -sv test/std/re # Run all of the std::regex tests + $ lit -sv test/std/depr/depr.c.headers/stdlib_h.pass.cpp # Run a single test + $ lit -sv test/std/atomics test/std/threads # Test std::thread and std::atomic + +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 +test suite will select the newest C++ dialect supported by the compiler and use +that. However if you want to manually specify the option like so: + +.. code-block:: bash + + $ lit -sv test/std/containers # Run the tests with the newest -std + $ lit -sv --param=std=c++03 test/std/containers # Run the tests in C++03 + +Occasionally you'll want to add extra compile or link flags when testing. +You can do this as follows: + +.. code-block:: bash + + $ lit -sv --param=compile_flags='-Wcustom-warning' + $ lit -sv --param=link_flags='-L/custom/library/path' + +Some other common examples include: + +.. code-block:: bash + + # Specify a custom compiler. + $ lit -sv --param=cxx_under_test=/opt/bin/g++ test/std + + # Enable warnings in the test suite + $ lit -sv --param=enable_warnings=true test/std + + # Use UBSAN when running the tests. + $ lit -sv --param=use_sanitizer=Undefined + + +LIT Options +=========== + +:program:`lit` [*options*...] [*filenames*...] + +Command Line Options +-------------------- + +To use these options you pass them on the LIT command line as --param NAME or +--param NAME=VALUE. Some options have default values specified during CMake's +configuration. Passing the option on the command line will override the default. + +.. program:: lit + +.. option:: cxx_under_test= + + Specify the compiler used to build the tests. + +.. option:: std= + + **Values**: c++98, c++03, c++11, c++14, c++1z + + Change the standard version used when building the tests. + +.. option:: libcxx_site_config= + + Specify the site configuration to use when running the tests. This option + overrides the enviroment variable LIBCXX_SITE_CONFIG. + +.. option:: libcxx_headers= + + Specify the libc++ headers that are tested. By default the headers in the + source tree are used. + +.. option:: libcxx_library= + + Specify the libc++ library that is tested. By default the library in the + build directory is used. This option cannot be used when use_system_lib is + provided. + +.. option:: use_system_lib= + + **Default**: False + + Enable or disable testing against the installed version of libc++ library. + Note: This does not use the installed headers. + +.. option:: use_lit_shell= + + Enable or disable the use of LIT's internal shell in ShTests. If the + environment variable LIT_USE_INTERNAL_SHELL is present then that is used as + the default value. Otherwise the default value is True on Windows and False + on every other platform. + +.. option:: no_default_flags= + + **Default**: False + + Disable all default compile and link flags from being added. When this + option is used only flags specified using the compile_flags and link_flags + will be used. + +.. option:: compile_flags="" + + Specify additional compile flags as a space delimited string. + Note: This options should not be used to change the standard version used. + +.. option:: link_flags="" + + Specify additional link flags as a space delimited string. + +.. option:: debug_level= + + **Values**: 0, 1 + + Enable the use of debug mode. Level 0 enables assertions and level 1 enables + assertions and debugging of iterator misuse. + +.. option:: use_sanitizer= + + **Values**: Memory, MemoryWithOrigins, Address, Undefined + + Run the tests using the given sanitizer. If LLVM_USE_SANITIZER was given when + building libc++ then that sanitizer will be used by default. + +.. option:: color_diagnostics + + Enable the use of colorized compile diagnostics. If the color_diagnostics + option is specified or the environment variable LIBCXX_COLOR_DIAGNOSTICS is + present then color diagnostics will be enabled. + + +Environment Variables +--------------------- + +.. envvar:: LIBCXX_SITE_CONFIG= + + Specify the site configuration to use when running the tests. + Also see :option:`libcxx_site_config`. + +.. envvar:: LIBCXX_COLOR_DIAGNOSTICS + + If ``LIBCXX_COLOR_DIAGNOSTICS`` is defined then the test suite will attempt + to use color diagnostic outputs from the compiler. + Also see :option:`color_diagnostics`. diff --git a/docs/UsingLibcxx.rst b/docs/UsingLibcxx.rst new file mode 100644 index 000000000000..2a117917638c --- /dev/null +++ b/docs/UsingLibcxx.rst @@ -0,0 +1,89 @@ +============ +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 + +On OS X and FreeBSD libc++ is the default standard library +and the ``-stdlib=libc++`` is not required. + +.. _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 OS X) can +be used to change the dynamic linkers search paths after a program is compiled. + +An example of using ``LD_LIBRARY_PATH``: + +.. 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 + + + +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: + +.. code-block:: bash + + $ clang++ -stdlib=libc++ test.cpp -lc++ -lc++abi -lm -lc -lgcc_s -lgcc + +Alternately, you could just add libc++abi to your libraries list, which in +most situations will give the same result: + +.. code-block:: bash + + $ clang++ -stdlib=libc++ test.cpp -lc++abi + + +Using libc++ with GCC +--------------------- + +GCC does not provide a way to switch from libstdc++ to libc++. You must manually +configure the compile and link commands. + +In particular you must tell GCC to remove the libstdc++ include directories +using ``-nostdinc++`` and to not link libstdc++.so using ``-nodefaultlibs``. + +Note that ``-nodefaultlibs`` removes all of the standard system libraries and +not just libstdc++ so they must be manually linked. For example: + +.. code-block:: bash + + $ g++ -nostdinc++ -I/include/c++/v1 \ + test.cpp -nodefaultlibs -lc++ -lc++abi -lm -lc -lgcc_s -lgcc diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 000000000000..915daa47a514 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,251 @@ +# -*- coding: utf-8 -*- +# +# libc++ documentation build configuration file. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# 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 +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'libc++' +copyright = u'2011-2015, LLVM Project' + +# 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 = '3.8' +# The full version, including alpha/beta/rc tags. +release = '3.8' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +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'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'friendly' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'haiku' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'libcxxdoc' + + +# -- Options for LaTeX output -------------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('contents', 'libcxx.tex', u'libcxx Documentation', + u'LLVM project', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output -------------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('contents', 'libc++', u'libc++ Documentation', + [u'LLVM project'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------------ + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('contents', 'libc++', u'libc++ Documentation', + u'LLVM project', 'libc++', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + + +# FIXME: Define intersphinx configration. +intersphinx_mapping = {} + + +# -- Options for extensions ---------------------------------------------------- + +# Enable this if you want TODOs to show up in the generated documentation. +todo_include_todos = True diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 000000000000..b0c8b813f57f --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,185 @@ +.. _index: + +============================= +"libc++" C++ Standard Library +============================= + +Overview +======== + +libc++ is a new implementation of the C++ standard library, targeting C++11. + +* Features and Goals + + * Correctness as defined by the C++11 standard. + * Fast execution. + * Minimal memory use. + * Fast compile times. + * ABI compatibility with gcc's libstdc++ for some low-level features + such as exception objects, rtti and memory allocation. + * Extensive unit tests. + +* Design and Implementation: + + * Extensive unit tests + * Internal linker model can be dumped/read to textual format + * Additional linking features can be plugged in as "passes" + * OS specific and CPU specific code factored out + + +Getting Started with libc++ +--------------------------- + +.. toctree:: + :maxdepth: 2 + + UsingLibcxx + BuildingLibcxx + TestingLibcxx + + +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 +libstdcxx, GNU's libstdc++, STLport, etc). There are many contributing +reasons, but some of the major ones are: + +* From years of experience (including having implemented the standard + library before), we've learned many things about implementing + the standard containers which require ABI breakage and fundamental changes + to how they are implemented. For example, it is generally accepted that + building std::string using the "short string optimization" instead of + using Copy On Write (COW) is a superior approach for multicore + machines (particularly in C++11, which has rvalue references). Breaking + ABI compatibility with old versions of the library was + determined to be critical to achieving the performance goals of + libc++. + +* Mainline libstdc++ has switched to GPL3, a license which the developers + of libc++ cannot use. libstdc++ 4.2 (the last GPL2 version) could be + independently extended to support C++11, but this would be a fork of the + codebase (which is often seen as worse for a project than starting a new + independent one). Another problem with libstdc++ is that it is tightly + integrated with G++ development, tending to be tied fairly closely to the + matching version of G++. + +* STLport and the Apache libstdcxx library are two other popular + candidates, but both lack C++11 support. Our experience (and the + experience of libstdc++ developers) is that adding support for C++11 (in + particular rvalue references and move-only types) requires changes to + almost every class and function, essentially amounting to a rewrite. + Faced with a rewrite, we decided to start from scratch and evaluate every + design decision from first principles based on experience. + 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 +----------------------------- + +libc++ is known to work on the following platforms, using gcc-4.2 and +clang (lack of C++11 language support disables some functionality). +Note that functionality provided by ```` is only functional with clang +and GCC. + +============ ==================== ============ ======================== +OS Arch Compilers ABI Library +============ ==================== ============ ======================== +Mac OS X 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 strongly recommended. + +* Clang 3.5 and above +* GCC 4.7 and above. + +Anything older *may* work. + +C++ Dialect Support +--------------------- + +* C++11 - Complete +* `C++14 - Complete `__ +* `C++1z - In Progress `__ +* `Post C++14 Technical Specifications - In Progress `__ + +Notes and Known Issues +---------------------- + +This list contains known issues with libc++ + +* Building libc++ with ``-fno-rtti`` is not supported. However + linking against it with ``-fno-rtti`` is supported. +* On OS X v10.8 and older the CMake option ``-DLIBCXX_LIBCPPABI_VERSION=""`` + must be used during configuration. + + +A full list of currently open libc++ bugs can be `found here`__. + +.. __: https://llvm.org/bugs/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/CapturingConfigInfo + DesignDocs/ABIVersioning + + +* ` design `_ +* ` design `_ +* `Status of debug mode `_ +* `Notes by Marshall Clow`__ + +.. __: https://cplusplusmusings.wordpress.com/2012/07/05/clang-and-standard-libraries-on-mac-os-x/ + +Build Bots and Test Coverage +---------------------------- + +* `LLVM Buildbot Builders `_ +* `Apple Jenkins Builders `_ +* `EricWF's Nightly Builders `_ +* `Code Coverage Results `_ + +Getting Involved +================ + +First please review our `Developer's Policy `__ +and `Getting started with LLVM `__. + +**Bug Reports** + +If you think you've found a bug in libc++, please report it using +the `LLVM Bugzilla`_. If you're not sure, you +can post a message to the `cfe-dev mailing list`_ or on IRC. +Please include "libc++" in your subject. + +**Patches** + +If you want to contribute a patch to libc++, the best place for that is +`Phabricator `_. Please include [libcxx] in the subject and +add `cfe-commits` as a subscriber. Also make sure you are subscribed to the +`cfe-commits mailing list `_. + +**Discussion and Questions** + +Send discussions and questions to the +`cfe-dev mailing list `_. +Please include [libcxx] in the subject. + + + +Quick Links +=========== +* `LLVM Homepage `_ +* `libc++abi Homepage `_ +* `LLVM Bugzilla `_ +* `cfe-commits Mailing List`_ +* `cfe-dev Mailing List`_ +* `Browse libc++ -- SVN `_ +* `Browse libc++ -- ViewVC `_ diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index 95206bfeeaff..e16dc8b4de63 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -1,10 +1,12 @@ if (NOT LIBCXX_INSTALL_SUPPORT_HEADERS) set(LIBCXX_SUPPORT_HEADER_PATTERN PATTERN "support" EXCLUDE) endif() + set(LIBCXX_HEADER_PATTERN PATTERN "*" PATTERN "CMakeLists.txt" EXCLUDE PATTERN ".svn" EXCLUDE + PATTERN "__config_site.in" EXCLUDE ${LIBCXX_SUPPORT_HEADER_PATTERN} ) @@ -17,8 +19,34 @@ file(COPY . if (LIBCXX_INSTALL_HEADERS) install(DIRECTORY . DESTINATION include/c++/v1 + COMPONENT libcxx FILES_MATCHING ${LIBCXX_HEADER_PATTERN} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ ) + + if (LIBCXX_NEEDS_SITE_CONFIG) + set(UNIX_CAT cat) + if (WIN32) + set(UNIX_CAT type) + endif() + # Generate and install 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 ${CMAKE_COMMAND} -E copy ${LIBCXX_BINARY_DIR}/__config_site ${LIBCXX_BINARY_DIR}/__generated_config + COMMAND ${UNIX_CAT} ${LIBCXX_SOURCE_DIR}/include/__config >> ${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(generate_config_header ALL + DEPENDS ${LIBCXX_BINARY_DIR}/__generated_config) + # Install the generated header as __config. + install(FILES ${LIBCXX_BINARY_DIR}/__generated_config + DESTINATION include/c++/v1 + PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ + RENAME __config + COMPONENT libcxx) + endif() + endif() diff --git a/include/__config b/include/__config index 888f3c098cf4..f141f4f1b7f9 100644 --- a/include/__config +++ b/include/__config @@ -11,19 +11,35 @@ #ifndef _LIBCPP_CONFIG #define _LIBCPP_CONFIG -#if !defined(_MSC_VER) || defined(__clang__) +#if defined(_MSC_VER) && !defined(__clang__) +#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER +#endif + +#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #pragma GCC system_header #endif +#ifdef __cplusplus + #ifdef __GNUC__ #define _GNUC_VER (__GNUC__ * 100 + __GNUC_MINOR__) #else #define _GNUC_VER 0 #endif -#define _LIBCPP_VERSION 3700 +#define _LIBCPP_VERSION 3800 +#ifndef _LIBCPP_ABI_VERSION #define _LIBCPP_ABI_VERSION 1 +#endif + +#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2 +// Change short string represention so that string data starts at offset 0, +// improving its alignment in some cases. +#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT +// Fix deque iterator type in order to support incomplete types. +#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +#endif #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y #define _LIBCPP_CONCAT(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) @@ -37,6 +53,9 @@ #ifndef __has_builtin #define __has_builtin(__x) 0 #endif +#ifndef __has_extension +#define __has_extension(__x) 0 +#endif #ifndef __has_feature #define __has_feature(__x) 0 #endif @@ -61,6 +80,16 @@ #endif // __BIG_ENDIAN__ #endif // __BIG_ENDIAN__ +#ifdef __BYTE_ORDER__ +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ +#define _LIBCPP_LITTLE_ENDIAN 1 +#define _LIBCPP_BIG_ENDIAN 0 +#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#define _LIBCPP_LITTLE_ENDIAN 0 +#define _LIBCPP_BIG_ENDIAN 1 +#endif // __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +#endif // __BYTE_ORDER__ + #ifdef __FreeBSD__ # include # if _BYTE_ORDER == _LITTLE_ENDIAN @@ -227,9 +256,12 @@ #if defined(__clang__) -#if defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ - !defined(__arm__) -#define _LIBCPP_ALTERNATE_STRING_LAYOUT +// _LIBCPP_ALTERNATE_STRING_LAYOUT is an old name for +// _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT left here for backward compatibility. +#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \ + !defined(__arm__)) || \ + defined(_LIBCPP_ALTERNATE_STRING_LAYOUT) +#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT #endif #if __has_feature(cxx_alignas) @@ -273,6 +305,10 @@ typedef __char32_t char32_t; #define _LIBCPP_UNUSED __attribute__((__unused__)) +#if !(__has_feature(cxx_default_function_template_args)) +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS +#endif + #if !(__has_feature(cxx_defaulted_functions)) #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #endif // !(__has_feature(cxx_defaulted_functions)) @@ -354,24 +390,23 @@ typedef __char32_t char32_t; #elif defined(__ANDROID__) #define _LIBCPP_HAS_QUICK_EXIT #elif defined(__linux__) -#include +#if !defined(_LIBCPP_HAS_MUSL_LIBC) +# include #if __GLIBC_PREREQ(2, 15) #define _LIBCPP_HAS_QUICK_EXIT #endif #if __GLIBC_PREREQ(2, 17) #define _LIBCPP_HAS_C11_FEATURES #endif +#else // defined(_LIBCPP_HAS_MUSL_LIBC) +#define _LIBCPP_HAS_QUICK_EXIT +#define _LIBCPP_HAS_C11_FEATURES #endif +#endif // __linux__ #endif -#if (__has_feature(cxx_noexcept)) -# define _NOEXCEPT noexcept -# define _NOEXCEPT_(x) noexcept(x) -# define _NOEXCEPT_OR_FALSE(x) noexcept(x) -#else -# define _NOEXCEPT throw() -# define _NOEXCEPT_(x) -# define _NOEXCEPT_OR_FALSE(x) false +#if !(__has_feature(cxx_noexcept)) +#define _LIBCPP_HAS_NO_NOEXCEPT #endif #if __has_feature(underlying_type) @@ -429,19 +464,21 @@ namespace std { #define _LIBCPP_HAS_NO_CONSTEXPR #endif -// No version of GCC supports relaxed constexpr rules +// Determine if GCC supports relaxed constexpr +#if !defined(__cpp_constexpr) || __cpp_constexpr < 201304L #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR -// GCC 5 will support variable templates -#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif -#define _NOEXCEPT throw() -#define _NOEXCEPT_(x) -#define _NOEXCEPT_OR_FALSE(x) false +// GCC 5 will support variable templates +#if !defined(__cpp_variable_templates) || __cpp_variable_templates < 201304L +#define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES +#endif #ifndef __GXX_EXPERIMENTAL_CXX0X__ #define _LIBCPP_HAS_NO_ADVANCED_SFINAE #define _LIBCPP_HAS_NO_DECLTYPE +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_NULLPTR @@ -449,31 +486,29 @@ namespace std { #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #define _LIBCPP_HAS_NO_STRONG_ENUMS +#define _LIBCPP_HAS_NO_NOEXCEPT #else // __GXX_EXPERIMENTAL_CXX0X__ -#define _LIBCPP_HAS_NO_TRAILING_RETURN -#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS - #if _GNUC_VER < 403 +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif - -#if _GNUC_VER < 403 #define _LIBCPP_HAS_NO_STATIC_ASSERT #endif + #if _GNUC_VER < 404 #define _LIBCPP_HAS_NO_DECLTYPE #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_TRAILING_RETURN #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _GNUC_VER < 404 #if _GNUC_VER < 406 +#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NULLPTR #endif @@ -501,22 +536,20 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #elif defined(_LIBCPP_MSVC) #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES -#define _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_CXX14_CONSTEXPR #define _LIBCPP_HAS_NO_VARIABLE_TEMPLATES #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS +#define _LIBCPP_HAS_NO_NOEXCEPT #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _LIBCPP_UNUSED #define _ALIGNAS(x) __declspec(align(x)) #define _LIBCPP_HAS_NO_VARIADICS -#define _NOEXCEPT throw () -#define _NOEXCEPT_(x) -#define _NOEXCEPT_OR_FALSE(x) false + #define _LIBCPP_BEGIN_NAMESPACE_STD namespace std { #define _LIBCPP_END_NAMESPACE_STD } @@ -536,14 +569,11 @@ namespace std { #define _LIBCPP_NORETURN __attribute__((noreturn)) #define _LIBCPP_UNUSED -#define _NOEXCEPT throw() -#define _NOEXCEPT_(x) -#define _NOEXCEPT_OR_FALSE(x) false - +#define _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS #define _LIBCPP_HAS_NO_TEMPLATE_ALIASES #define _LIBCPP_HAS_NO_ADVANCED_SFINAE -#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS #define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#define _LIBCPP_HAS_NO_NOEXCEPT #define _LIBCPP_HAS_NO_NULLPTR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_IS_BASE_OF @@ -567,6 +597,14 @@ namespace std { #endif // __clang__ || __GNUC__ || _MSC_VER || __IBMCPP__ +#ifndef _LIBCPP_HAS_NO_NOEXCEPT +# define _NOEXCEPT noexcept +# define _NOEXCEPT_(x) noexcept(x) +#else +# define _NOEXCEPT throw() +# define _NOEXCEPT_(x) +#endif + #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; typedef unsigned int char32_t; @@ -578,9 +616,11 @@ typedef unsigned int char32_t; #ifdef _LIBCPP_HAS_NO_STATIC_ASSERT +extern "C++" { template struct __static_assert_test; template <> struct __static_assert_test {}; template struct __static_assert_check {}; +} #define static_assert(__b, __m) \ typedef __static_assert_check)> \ _LIBCPP_CONCAT(__t, __LINE__) @@ -716,6 +756,12 @@ template struct __static_assert_check {}; #define _LIBCPP_CONSTEXPR_AFTER_CXX11 #endif +#ifdef _LIBCPP_HAS_NO_RVALUE_REFERENCES +# define _LIBCPP_EXPLICIT_MOVE(x) _VSTD::move(x) +#else +# define _LIBCPP_EXPLICIT_MOVE(x) (x) +#endif + #ifndef _LIBCPP_HAS_NO_ASAN extern "C" void __sanitizer_annotate_contiguous_container( const void *, const void *, const void *, const void *); @@ -725,7 +771,7 @@ extern "C" void __sanitizer_annotate_contiguous_container( // g++ and cl.exe have RTTI on by default and define a macro when it is. // g++ only defines the macro in 4.3.2 and onwards. #if !defined(_LIBCPP_NO_RTTI) -# if defined(__GNUG__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ +# if defined(__GNUC__) && ((__GNUC__ >= 5) || (__GNUC__ == 4 && \ (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2))) && !defined(__GXX_RTTI) # define _LIBCPP_NO_RTTI # elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) @@ -757,7 +803,7 @@ extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_STDOUT #endif -#if defined(__ANDROID__) || defined(__CloudABI__) +#if defined(__ANDROID__) || defined(__CloudABI__) || defined(_LIBCPP_HAS_MUSL_LIBC) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif @@ -767,4 +813,17 @@ extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS #endif -#endif // _LIBCPP_CONFIG +#if __has_feature(cxx_atomic) || __has_extension(c_atomic) +#define _LIBCPP_HAS_C_ATOMIC_IMP +#elif _GNUC_VER > 407 +#define _LIBCPP_HAS_GCC_ATOMIC_IMP +#endif + +#if (!defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP)) \ + || defined(_LIBCPP_HAS_NO_THREADS) +#define _LIBCPP_HAS_NO_ATOMIC_HEADER +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_CONFIG diff --git a/include/__config_site.in b/include/__config_site.in new file mode 100644 index 000000000000..ec64485289fa --- /dev/null +++ b/include/__config_site.in @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_CONFIG_SITE +#define _LIBCPP_CONFIG_SITE + +#cmakedefine _LIBCPP_ABI_VERSION @_LIBCPP_ABI_VERSION@ +#cmakedefine _LIBCPP_ABI_UNSTABLE +#cmakedefine _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE +#cmakedefine _LIBCPP_HAS_NO_STDIN +#cmakedefine _LIBCPP_HAS_NO_STDOUT +#cmakedefine _LIBCPP_HAS_NO_THREADS +#cmakedefine _LIBCPP_HAS_NO_MONOTONIC_CLOCK +#cmakedefine _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS +#cmakedefine _LIBCPP_HAS_MUSL_LIBC + +#endif // _LIBCPP_CONFIG_SITE diff --git a/include/__functional_03 b/include/__functional_03 index 13c38d8548d9..4edbb0996ca0 100644 --- a/include/__functional_03 +++ b/include/__functional_03 @@ -17,218 +17,7 @@ #pragma GCC system_header #endif -template -class __mem_fn - : public __weak_result_type<_Tp> -{ -public: - // types - typedef _Tp type; -private: - type __f_; - -public: - _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} - - // invoke - - typename __invoke_return::type - operator() () const - { - return __invoke(__f_); - } - - template - typename __invoke_return0::type - operator() (_A0& __a0) const - { - return __invoke(__f_, __a0); - } - - template - typename __invoke_return1::type - operator() (_A0& __a0, _A1& __a1) const - { - return __invoke(__f_, __a0, __a1); - } - - template - typename __invoke_return2::type - operator() (_A0& __a0, _A1& __a1, _A2& __a2) const - { - return __invoke(__f_, __a0, __a1, __a2); - } -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp _Tp::*> -mem_fn(_Rp _Tp::* __pm) -{ - return __mem_fn<_Rp _Tp::*>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)()> -mem_fn(_Rp (_Tp::* __pm)()) -{ - return __mem_fn<_Rp (_Tp::*)()>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0)> -mem_fn(_Rp (_Tp::* __pm)(_A0)) -{ - return __mem_fn<_Rp (_Tp::*)(_A0)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1)> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1)) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2)) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2)>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)() const> -mem_fn(_Rp (_Tp::* __pm)() const) -{ - return __mem_fn<_Rp (_Tp::*)() const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0) const> -mem_fn(_Rp (_Tp::* __pm)(_A0) const) -{ - return __mem_fn<_Rp (_Tp::*)(_A0) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1) const> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)() volatile> -mem_fn(_Rp (_Tp::* __pm)() volatile) -{ - return __mem_fn<_Rp (_Tp::*)() volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0) volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)() const volatile> -mem_fn(_Rp (_Tp::* __pm)() const volatile) -{ - return __mem_fn<_Rp (_Tp::*)() const volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0) const volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1) const volatile>(__pm); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_A0, _A1, _A2) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_A0, _A1, _A2) const volatile>(__pm); -} - -// bad_function_call - -class _LIBCPP_EXCEPTION_ABI bad_function_call - : public exception -{ -}; - -template class _LIBCPP_TYPE_VIS_ONLY 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> -{ -}; +namespace __function { template class __base; @@ -662,15 +451,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp()> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)()) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2()>& __p) {return __p;} public: typedef _Rp result_type; @@ -769,7 +549,7 @@ function<_Rp()>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp()> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -796,7 +576,7 @@ function<_Rp()>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp()> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -947,27 +727,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_B0)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)()) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)() const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)() volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)() const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_B0)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1066,7 +825,7 @@ function<_Rp(_A0)>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1093,7 +852,7 @@ function<_Rp(_A0)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_A0)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1244,27 +1003,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_B0, _B1)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1) const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1) volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1) const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_B0, _B1)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1363,7 +1101,7 @@ function<_Rp(_A0, _A1)>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1390,7 +1128,7 @@ function<_Rp(_A0, _A1)>::function(allocator_arg_t, const _Alloc& __a0, _Fp __f, : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1540,27 +1278,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)> aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_B0, _B1, _B2)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_B1, _B2) const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_B0, _B1, _B2)>& __p) {return __p;} public: typedef _Rp result_type; @@ -1660,7 +1377,7 @@ function<_Rp(_A0, _A1, _A2)>::function(_Fp __f, typename enable_if::value>::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_A0, _A1, _A2)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1687,7 +1404,7 @@ function<_Rp(_A0, _A1, _A2)>::function(allocator_arg_t, const _Alloc& __a0, _Fp : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)> _FF; if (sizeof(_FF) <= sizeof(__buf_)) @@ -1856,274 +1573,4 @@ void swap(function<_Fp>& __x, function<_Fp>& __y) {return __x.swap(__y);} -template struct __is_bind_expression : public false_type {}; -template struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression - : public __is_bind_expression::type> {}; - -template struct __is_placeholder : public integral_constant {}; -template struct _LIBCPP_TYPE_VIS_ONLY is_placeholder - : public __is_placeholder::type> {}; - -namespace placeholders -{ - -template struct __ph {}; - -extern __ph<1> _1; -extern __ph<2> _2; -extern __ph<3> _3; -extern __ph<4> _4; -extern __ph<5> _5; -extern __ph<6> _6; -extern __ph<7> _7; -extern __ph<8> _8; -extern __ph<9> _9; -extern __ph<10> _10; - -} // placeholders - -template -struct __is_placeholder > - : public integral_constant {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp& -__mu(reference_wrapper<_Tp> __t, _Uj&) -{ - return __t.get(); -} -/* -template -struct __mu_return1 {}; - -template -struct __mu_return1 -{ - typedef typename result_of<_Ti(_Uj...)>::type type; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __mu_return1::type -__mu_expand(_Ti& __ti, tuple<_Uj...>&& __uj, __tuple_indices<_Indx...>) -{ - __ti(_VSTD::forward::type>(_VSTD::get<_Indx>(__uj))...); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_bind_expression<_Ti>::value, - typename __mu_return1::value, _Ti, _Uj...>::type ->::type -__mu(_Ti& __ti, tuple<_Uj...>& __uj) -{ - typedef typename __make_tuple_indices::type __indices; - return __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; - // compiler bug workaround - typename tuple_element<_Indx, _Uj>::type __t = _VSTD::get<_Indx>(__uj); - return __t; -// 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& __uj) -{ - return __ti; -} - -template -struct ____mu_return; - -template -struct ____mu_return<_Ti, true, false, tuple<_Uj...> > -{ - typedef typename result_of<_Ti(_Uj...)>::type type; -}; - -template -struct ____mu_return<_Ti, false, true, _TupleUj> -{ - typedef typename tuple_element::value - 1, - _TupleUj>::type&& type; -}; - -template -struct ____mu_return<_Ti, false, false, _TupleUj> -{ - typedef _Ti& type; -}; - -template -struct __mu_return - : public ____mu_return<_Ti, - is_bind_expression<_Ti>::value, - 0 < is_placeholder<_Ti>::value, - _TupleUj> -{ -}; - -template -struct __mu_return, _TupleUj> -{ - typedef _Ti& type; -}; - -template -struct __bind_return; - -template -struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> -{ - typedef typename __ref_return - < - _Fp&, - typename __mu_return - < - _BoundArgs, - _TupleUj - >::type... - >::type type; -}; - -template -struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> -{ - typedef typename __ref_return - < - _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 __invoke(__f, __mu(_VSTD::get<_Indx>(__bound_args), __args)...); -} - -template -class __bind -{ - _Fp __f_; - tuple<_BoundArgs...> __bound_args_; - - typedef typename __make_tuple_indices::type __indices; -public: - template - explicit __bind(_Gp&& __f, _BA&& ...__bound_args) - : __f_(_VSTD::forward<_Gp>(__f)), - __bound_args_(_VSTD::forward<_BA>(__bound_args)...) {} - - template - typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type - operator()(_Args&& ...__args) - { - // compiler bug workaround - return __apply_functor(__f_, __bound_args_, __indices(), - tuple<_Args&&...>(__args...)); - } - - template - typename __bind_return<_Fp, tuple<_BoundArgs...>, tuple<_Args&&...> >::type - operator()(_Args&& ...__args) const - { - return __apply_functor(__f_, __bound_args_, __indices(), - tuple<_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; -public: - typedef _Rp result_type; - - template - explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args) - : base(_VSTD::forward<_Gp>(__f), - _VSTD::forward<_BA>(__bound_args)...) {} - - template - result_type - operator()(_Args&& ...__args) - { - typedef __invoke_void_return_wrapper<_Rp> _Invoker; - return _Invoker::__call(static_cast(*this), _VSTD::forward<_Args>(__args)...); - } - - template - result_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 -__bind::type, typename decay<_BoundArgs>::type...> -bind(_Fp&& __f, _BoundArgs&&... __bound_args) -{ - typedef __bind::type, typename decay<_BoundArgs>::type...> type; - return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -__bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> -bind(_Fp&& __f, _BoundArgs&&... __bound_args) -{ - typedef __bind_r<_Rp, typename decay<_Fp>::type, typename decay<_BoundArgs>::type...> type; - return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...); -} -*/ - #endif // _LIBCPP_FUNCTIONAL_03 diff --git a/include/__functional_base b/include/__functional_base index 09424bc025a9..52c535aa3ea1 100644 --- a/include/__functional_base +++ b/include/__functional_base @@ -77,62 +77,6 @@ struct _LIBCPP_TYPE_VIS_ONLY less }; #endif -// addressof - -template -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -addressof(_Tp& __x) _NOEXCEPT -{ - return (_Tp*)&reinterpret_cast(__x); -} - -#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 - -#ifdef _LIBCPP_HAS_NO_VARIADICS - -#include <__functional_base_03> - -#else // _LIBCPP_HAS_NO_VARIADICS - // __weak_result_type template @@ -314,6 +258,8 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> { }; + +#ifndef _LIBCPP_HAS_NO_VARIADICS // 3 or more arguments template @@ -358,8 +304,12 @@ struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> typedef _Rp result_type; }; +#endif // _LIBCPP_HAS_NO_VARIADICS + // __invoke +#ifndef _LIBCPP_HAS_NO_VARIADICS + // bullets 1 and 2 template (__f)(_VSTD::forward<_Args>(__args)...); } - template struct __invoke_return { typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_Args>()...)) type; }; +#else // _LIBCPP_HAS_NO_VARIADICS + +#include <__functional_base_03> + +#endif // _LIBCPP_HAS_NO_VARIADICS + + template struct __invoke_void_return_wrapper { +#ifndef _LIBCPP_HAS_NO_VARIADICS template - static _Ret __call(_Args&&... __args) - { + 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_HAS_NO_VARIADICS template - static void __call(_Args&&... __args) - { + 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 @@ -463,14 +461,120 @@ public: _LIBCPP_INLINE_VISIBILITY operator type& () const _NOEXCEPT {return *__f_;} _LIBCPP_INLINE_VISIBILITY type& get() const _NOEXCEPT {return *__f_;} +#ifndef _LIBCPP_HAS_NO_VARIADICS // invoke template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_of::type - operator() (_ArgTypes&&... __args) const - { - return __invoke(get(), _VSTD::forward<_ArgTypes>(__args)...); - } + _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_HAS_NO_VARIADICS }; template struct __is_reference_wrapper_impl : public false_type {}; @@ -510,6 +614,7 @@ cref(reference_wrapper<_Tp> __t) _NOEXCEPT return cref(__t.get()); } +#ifndef _LIBCPP_HAS_NO_VARIADICS #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS diff --git a/include/__functional_base_03 b/include/__functional_base_03 index 655027786665..8407dcfa39ca 100644 --- a/include/__functional_base_03 +++ b/include/__functional_base_03 @@ -13,943 +13,166 @@ // manual variadic expansion for -// __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 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::type> -{ -}; - -// 0 argument case - -template -struct __weak_result_type<_Rp ()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)()> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)()> -{ - typedef _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 -{ -}; - -// 3 or more arguments - -template -struct __weak_result_type<_Rp (_A1, _A2, _A3)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (&)(_A1, _A2, _A3)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (*)(_A1, _A2, _A3)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2)> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) const> -{ - typedef _Rp result_type; -}; - -template -struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2) volatile> -{ - typedef _Rp result_type; -}; - // __invoke -// __ref_return0 -// -// template -// struct ________ref_return0 // _HasResultType is true -// { -// typedef typename _Tp::result_type type; -// }; -// -// template -// struct ________ref_return0<_Tp, false> -// { -// typedef void type; -// }; -// -// template -// struct ____ref_return0 // _IsClass is true -// : public ________ref_return0<_Tp, __has_result_type::type>::value> -// { -// }; -// -// template -// struct ______ref_return0 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct ______ref_return0<_Tp, false> // pointer to member data -// { -// typedef void type; -// }; -// -// template -// struct ____ref_return0<_Tp, false> -// : public ______ref_return0::type, -// __has_result_type<__callable_type::type> >::value> -// { -// }; -// -// template -// struct __ref_return0 -// : public ____ref_return0::type, -// is_class::type>::value> -// { -// }; -// -// __ref_return1 -// -// template -// struct ____ref_return1 // _IsClass is true -// { -// typedef typename result_of<_Tp(_A0)>::type type; -// }; -// -// template -// struct ______ref_return1 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct __ref_return1_member_data1; -// -// template -// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, true> -// { -// typedef typename __apply_cv<_A0, _Rp>::type& type; -// }; -// -// template -// struct __ref_return1_member_data1<_Rp _Cp::*, _A0, false> -// { -// static _A0 __a; -// typedef typename __apply_cv::type& type; -// }; -// -// template -// struct __ref_return1_member_data; -// -// template -// struct __ref_return1_member_data<_Rp _Cp::*, _A0> -// : public __ref_return1_member_data1<_Rp _Cp::*, _A0, -// is_same::type, -// typename remove_cv::type>::type>::value> -// { -// }; -// -// template -// struct ______ref_return1<_Tp, false, _A0> // pointer to member data -// : public __ref_return1_member_data::type, _A0> -// { -// }; -// -// template -// struct ____ref_return1<_Tp, false, _A0> -// : public ______ref_return1::type, -// __has_result_type<__callable_type::type> >::value, _A0> -// { -// }; -// -// template -// struct __ref_return1 -// : public ____ref_return1::type, -// is_class::type>::value, _A0> -// { -// }; -// -// __ref_return2 -// -// template -// struct ____ref_return2 // _IsClass is true -// { -// typedef typename result_of<_Tp(_A0, _A1)>::type type; -// }; -// -// template -// struct ______ref_return2 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct ______ref_return2<_Tp, false, class _A0, class _A1> // pointer to member data -// { -// static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer" -// " to member data with too many arguments."); -// }; -// -// template -// struct ____ref_return2<_Tp, false, _A0, _A1> -// : public ______ref_return2::type, -// __has_result_type<__callable_type::type> >::value, _A0, _A1> -// { -// }; -// -// template -// struct __ref_return2 -// : public ____ref_return2::type, -// is_class::type>::value, _A0, _A1> -// { -// }; -// -// __ref_return3 -// -// template -// struct ____ref_return3 // _IsClass is true -// { -// typedef typename result_of<_Tp(_A0, _A1, _A2)>::type type; -// }; -// -// template -// struct ______ref_return3 // _HasResultType is true -// { -// typedef typename __callable_type<_Tp>::result_type type; -// }; -// -// template -// struct ______ref_return3<_Tp, false, class _A0, class _A1, class _A2> // pointer to member data -// { -// static_assert(sizeof(_Tp) == 0, "An attempt has been made to `call` a pointer" -// " to member data with too many arguments."); -// }; -// -// template -// struct ____ref_return3<_Tp, false, _A0, _A1, _A2> -// : public ______ref_return3::type, -// __has_result_type<__callable_type::type> >::value, _A0, _A1, _A2> -// { -// }; -// -// template -// struct __ref_return3 -// : public ____ref_return3::type, -// is_class::type>::value, _A0, _A1, _A2> -// { -// }; +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 +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(), _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1) { return (__t1.*__f)(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0), _T1& __t1, _A0& __a0) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { return (__t1.*__f)(__a0); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1& __t1, _A0& __a0, _A1& __a1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { return (__t1.*__f)(__a0, __a1); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet1 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { return (__t1.*__f)(__a0, __a1, __a2); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() volatile, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const volatile, _T1& __t1) -{ - return (__t1.*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1& __t1, _A0& __a0) -{ - return (__t1.*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1& __t1, _A0& __a0, _A1& __a1) -{ - return (__t1.*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return (__t1.*__f)(__a0, __a1, __a2); -} - -// second bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(), _T1 __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1) { return ((*__t1).*__f)(); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0), _T1 __t1, _A0& __a0) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0) { return ((*__t1).*__f)(__a0); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1), _T1 __t1, _A0& __a0, _A1& __a1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1) { return ((*__t1).*__f)(__a0, __a1); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2), _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet2 +__invoke(_Fn __f, _T1& __t1, _A0& __a0, _A1& __a1, _A2& __a2) { return ((*__t1).*__f)(__a0, __a1, __a2); } -template +template inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() volatile, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) volatile, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) volatile, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)() const volatile, _T1 __t1) -{ - return ((*__t1).*__f)(); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0) const volatile, _T1 __t1, _A0& __a0) -{ - return ((*__t1).*__f)(__a0); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1) const volatile, _T1 __t1, _A0& __a0, _A1& __a1) -{ - return ((*__t1).*__f)(__a0, __a1); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - _Rp ->::type -__invoke(_Rp (_Tp::*__f)(_A0, _A1, _A2) const volatile, _T1 __t1, _A0& __a0, _A1& __a1, _A2& __a2) -{ - return ((*__t1).*__f)(__a0, __a1, __a2); -} - -// third bullet - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if -< - is_base_of<_Tp, typename remove_reference<_T1>::type>::value, - typename __apply_cv<_T1, _Rp>::type& ->::type -__invoke(_Rp _Tp::* __f, _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet3 +__invoke(_Fn __f, _T1& __t1) { return __t1.*__f; } -template +template inline _LIBCPP_INLINE_VISIBILITY -void -__invoke(_Rp _Tp::*) -{ -} - -// template -// inline _LIBCPP_INLINE_VISIBILITY -// typename enable_if -// < -// is_base_of<_Tp, typename remove_reference<_T1>::type>::value, -// typename __ref_return1<_Rp _Tp::*, _T1>::type -// >::type -// __invoke(_Rp _Tp::* __f, _T1& __t1) -// { -// return __t1.*__f; -// } - -// forth bullet - -template -struct __4th_helper -{ -}; - -template -struct __4th_helper<_T1, _Rp, true> -{ - typedef typename __apply_cv()), _Rp>::type type; -}; - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __4th_helper<_T1, _Rp, - !is_base_of<_Tp, - typename remove_reference<_T1>::type - >::value - >::type& -__invoke(_Rp _Tp::* __f, _T1& __t1) -{ +typename __enable_invoke<_Fn, _T1>::_Bullet4 +__invoke(_Fn __f, _T1& __t1) { return (*__t1).*__f; } -// template -// inline _LIBCPP_INLINE_VISIBILITY -// typename enable_if -// < -// !is_base_of<_Tp, typename remove_reference<_T1>::type>::value, -// typename __ref_return1<_Rp _Tp::*, _T1>::type -// >::type -// __invoke(_Rp _Tp::* __f, _T1 __t1) -// { -// return (*__t1).*__f; -// } - // fifth bullet template inline _LIBCPP_INLINE_VISIBILITY -decltype(declval<_Fp>()()) -__invoke(_Fp __f) +decltype(_VSTD::declval<_Fp&>()()) +__invoke(_Fp& __f) { return __f(); } template inline _LIBCPP_INLINE_VISIBILITY -decltype(declval<_Fp>()(declval<_A0&>())) -__invoke(_Fp __f, _A0& __a0) +decltype(_VSTD::declval<_Fp&>()(_VSTD::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) +decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::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) +decltype(_VSTD::declval<_Fp&>()(_VSTD::declval<_A0&>(), _VSTD::declval<_A1&>(), _VSTD::declval<_A2&>())) +__invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) { return __f(__a0, __a1, __a2); } -// template -// inline _LIBCPP_INLINE_VISIBILITY -// _Rp -// __invoke(_Fp& __f) -// { -// return __f(); -// } -// -// template -// inline _LIBCPP_INLINE_VISIBILITY -// typename enable_if -// < -// !is_member_pointer<_Fp>::value, -// _Rp -// >::type -// __invoke(_Fp& __f, _A0& __a0) -// { -// return __f(__a0); -// } -// -// template -// inline _LIBCPP_INLINE_VISIBILITY -// _Rp -// __invoke(_Fp& __f, _A0& __a0, _A1& __a1) -// { -// return __f(__a0, __a1); -// } -// -// template -// inline _LIBCPP_INLINE_VISIBILITY -// _Rp -// __invoke(_Fp& __f, _A0& __a0, _A1& __a1, _A2& __a2) -// { -// return __f(__a0, __a1, __a2); -// } - -template -struct __has_type -{ -private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - template >::value> struct __invoke_return { @@ -959,186 +182,43 @@ struct __invoke_return template struct __invoke_return<_Fp, false> { - typedef decltype(__invoke(_VSTD::declval<_Fp>())) type; + typedef decltype(__invoke(_VSTD::declval<_Fp&>())) type; }; template struct __invoke_return0 { - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>())) type; + typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>())) type; }; template struct __invoke_return0<_Rp _Tp::*, _A0> { - typedef typename __apply_cv<_A0, _Rp>::type& type; -}; - -template -struct __invoke_return0<_Rp _Tp::*, _A0*> -{ - typedef typename __apply_cv<_A0, _Rp>::type& type; + typedef typename __enable_invoke<_Rp _Tp::*, _A0>::type type; }; template struct __invoke_return1 { - typedef decltype(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(), - _VSTD::declval<_A1>())) type; + typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), + _VSTD::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(__invoke(_VSTD::declval<_Tp>(), _VSTD::declval<_A0>(), - _VSTD::declval<_A1>(), - _VSTD::declval<_A2>())) type; + typedef decltype(__invoke(_VSTD::declval<_Tp&>(), _VSTD::declval<_A0&>(), + _VSTD::declval<_A1&>(), + _VSTD::declval<_A2&>())) type; }; -template -struct __invoke_void_return_wrapper -{ - 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); - } +template +struct __invoke_return2<_Ret _Class::*, _A0, _A1, _A2> { + typedef typename __enable_invoke<_Ret _Class::*, _A0>::type type; }; - - -template <> -struct __invoke_void_return_wrapper -{ - 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); - } -}; - -template -class _LIBCPP_TYPE_VIS_ONLY 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) : __f_(&__f) {} - - // access - _LIBCPP_INLINE_VISIBILITY operator type& () const {return *__f_;} - _LIBCPP_INLINE_VISIBILITY type& get() const {return *__f_;} - - // invoke - - _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_return1::type - operator() (_A0& __a0, _A1& __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 struct __is_reference_wrapper_impl : public false_type {}; -template struct __is_reference_wrapper_impl > : public true_type {}; -template struct __is_reference_wrapper - : public __is_reference_wrapper_impl::type> {}; - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(_Tp& __t) -{ - return reference_wrapper<_Tp>(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper<_Tp> -ref(reference_wrapper<_Tp> __t) -{ - return ref(__t.get()); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(const _Tp& __t) -{ - return reference_wrapper(__t); -} - -template -inline _LIBCPP_INLINE_VISIBILITY -reference_wrapper -cref(reference_wrapper<_Tp> __t) -{ - return cref(__t.get()); -} - #endif // _LIBCPP_FUNCTIONAL_BASE_03 diff --git a/include/__hash_table b/include/__hash_table index f3a20309df71..cfa763ab217a 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -836,6 +836,7 @@ public: typedef __hash_local_iterator<__node_pointer> local_iterator; typedef __hash_const_local_iterator<__node_pointer> const_local_iterator; + _LIBCPP_INLINE_VISIBILITY __hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value && @@ -843,6 +844,7 @@ public: is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value); + _LIBCPP_INLINE_VISIBILITY __hash_table(const hasher& __hf, const key_equal& __eql); __hash_table(const hasher& __hf, const key_equal& __eql, const allocator_type& __a); @@ -863,6 +865,7 @@ public: __hash_table& operator=(const __hash_table& __u); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __hash_table& operator=(__hash_table&& __u) _NOEXCEPT_( __node_traits::propagate_on_container_move_assignment::value && @@ -934,9 +937,13 @@ public: return __bucket_list_.get_deleter().size(); } + _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY iterator end() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY const_iterator begin() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT; template @@ -965,6 +972,7 @@ public: __node_holder remove(const_iterator __p) _NOEXCEPT; template + _LIBCPP_INLINE_VISIBILITY size_type __count_unique(const _Key& __k) const; template size_type __count_multi(const _Key& __k) const; @@ -984,15 +992,17 @@ public: __equal_range_multi(const _Key& __k) const; void swap(__hash_table& __u) +#if _LIBCPP_STD_VER <= 11 _NOEXCEPT_( __is_nothrow_swappable::value && __is_nothrow_swappable::value -#if _LIBCPP_STD_VER <= 11 && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || __is_nothrow_swappable<__pointer_allocator>::value) && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) -#endif ); +#else + _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value); +#endif _LIBCPP_INLINE_VISIBILITY size_type max_bucket_count() const _NOEXCEPT @@ -1128,11 +1138,12 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() _NOEXCEPT_( is_nothrow_default_constructible<__bucket_list>::value && is_nothrow_default_constructible<__first_node>::value && + is_nothrow_default_constructible<__node_allocator>::value && is_nothrow_default_constructible::value && is_nothrow_default_constructible::value) : __p2_(0), @@ -1141,7 +1152,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table() } template -inline _LIBCPP_INLINE_VISIBILITY +inline __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(const hasher& __hf, const key_equal& __eql) : __bucket_list_(nullptr, __bucket_list_deleter()), @@ -1201,6 +1212,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__hash_table(__hash_table&& __u) _NOEXCEPT_( is_nothrow_move_constructible<__bucket_list>::value && is_nothrow_move_constructible<__first_node>::value && + is_nothrow_move_constructible<__node_allocator>::value && is_nothrow_move_constructible::value && is_nothrow_move_constructible::value) : __bucket_list_(_VSTD::move(__u.__bucket_list_)), @@ -1408,7 +1420,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__move_assign( } template -inline _LIBCPP_INLINE_VISIBILITY +inline __hash_table<_Tp, _Hash, _Equal, _Alloc>& __hash_table<_Tp, _Hash, _Equal, _Alloc>::operator=(__hash_table&& __u) _NOEXCEPT_( @@ -1493,7 +1505,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__assign_multi(_InputIterator __first, } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT { @@ -1505,7 +1517,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT { @@ -1517,7 +1529,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT { @@ -1529,7 +1541,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::begin() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::const_iterator __hash_table<_Tp, _Hash, _Equal, _Alloc>::end() const _NOEXCEPT { @@ -2106,7 +2118,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = hash_function()(__h->__value_); __h->__next_ = nullptr; - return _VSTD::move(__h); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2122,7 +2134,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template @@ -2254,7 +2266,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::remove(const_iterator __p) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename __hash_table<_Tp, _Hash, _Equal, _Alloc>::size_type __hash_table<_Tp, _Hash, _Equal, _Alloc>::__count_unique(const _Key& __k) const { @@ -2351,15 +2363,17 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__equal_range_multi( template void __hash_table<_Tp, _Hash, _Equal, _Alloc>::swap(__hash_table& __u) +#if _LIBCPP_STD_VER <= 11 _NOEXCEPT_( __is_nothrow_swappable::value && __is_nothrow_swappable::value -#if _LIBCPP_STD_VER <= 11 && (!allocator_traits<__pointer_allocator>::propagate_on_container_swap::value || __is_nothrow_swappable<__pointer_allocator>::value) && (!__node_traits::propagate_on_container_swap::value || __is_nothrow_swappable<__node_allocator>::value) -#endif ) +#else + _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) +#endif { { __node_pointer_pointer __npp = __bucket_list_.release(); diff --git a/include/__locale b/include/__locale index 19895582cac8..7bc701dda6e3 100644 --- a/include/__locale +++ b/include/__locale @@ -37,6 +37,8 @@ #elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) \ || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) # include +#elif defined(_LIBCPP_HAS_MUSL_LIBC) +# include #endif // __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -329,7 +331,7 @@ locale::operator()(const basic_string<_CharT, _Traits, _Allocator>& __x, class _LIBCPP_TYPE_VIS ctype_base { public: -#ifdef __GLIBC__ +#if defined(__GLIBC__) typedef unsigned short mask; static const mask space = _ISspace; static const mask print = _ISprint; @@ -359,7 +361,7 @@ public: typedef __uint32_t mask; # elif defined(__FreeBSD__) typedef unsigned long mask; -# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) +# elif defined(__EMSCRIPTEN__) || defined(__NetBSD__) typedef unsigned short mask; # endif static const mask space = _CTYPE_S; diff --git a/include/__mutex_base b/include/__mutex_base index d5ece7c1454c..b019b4760d18 100644 --- a/include/__mutex_base +++ b/include/__mutex_base @@ -14,7 +14,9 @@ #include <__config> #include #include +#ifndef _LIBCPP_HAS_NO_THREADS #include +#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -306,6 +308,7 @@ public: template bool + _LIBCPP_INLINE_VISIBILITY wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); @@ -390,7 +393,7 @@ condition_variable::wait_for(unique_lock& __lk, } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool condition_variable::wait_for(unique_lock& __lk, const chrono::duration<_Rep, _Period>& __d, diff --git a/include/__nullptr b/include/__nullptr new file mode 100644 index 000000000000..95415a6325a3 --- /dev/null +++ b/include/__nullptr @@ -0,0 +1,66 @@ +// -*- C++ -*- +//===--------------------------- __nullptr --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_NULLPTR +#define _LIBCPP_NULLPTR + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#ifdef _LIBCPP_HAS_NO_NULLPTR + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct _LIBCPP_TYPE_VIS_ONLY nullptr_t +{ + void* __lx; + + struct __nat {int __for_bool_;}; + + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} + + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} + + template + _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR + operator _Tp* () const {return 0;} + + template + _LIBCPP_ALWAYS_INLINE + operator _Tp _Up::* () const {return 0;} + + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} + friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} +}; + +inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} + +#define nullptr _VSTD::__get_nullptr_t() + +_LIBCPP_END_NAMESPACE_STD + +#else // _LIBCPP_HAS_NO_NULLPTR + +namespace std +{ + typedef decltype(nullptr) nullptr_t; +} + +#endif // _LIBCPP_HAS_NO_NULLPTR + +#endif // _LIBCPP_NULLPTR diff --git a/include/__split_buffer b/include/__split_buffer index 727b1b6b5674..79d1aa1d7c4a 100644 --- a/include/__split_buffer +++ b/include/__split_buffer @@ -56,9 +56,12 @@ public: _LIBCPP_INLINE_VISIBILITY pointer& __end_cap() _NOEXCEPT {return __end_cap_.first();} _LIBCPP_INLINE_VISIBILITY const pointer& __end_cap() const _NOEXCEPT {return __end_cap_.first();} + _LIBCPP_INLINE_VISIBILITY __split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value); + _LIBCPP_INLINE_VISIBILITY explicit __split_buffer(__alloc_rr& __a); + _LIBCPP_INLINE_VISIBILITY explicit __split_buffer(const __alloc_rr& __a); __split_buffer(size_type __cap, size_type __start, __alloc_rr& __a); ~__split_buffer(); @@ -128,7 +131,9 @@ public: _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin) {__destruct_at_begin(__new_begin, is_trivially_destructible());} + _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin, false_type); + _LIBCPP_INLINE_VISIBILITY void __destruct_at_begin(pointer __new_begin, true_type); _LIBCPP_INLINE_VISIBILITY @@ -266,7 +271,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { @@ -275,7 +280,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_ } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) { @@ -309,7 +314,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta } template -inline _LIBCPP_INLINE_VISIBILITY +inline __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible::value) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) @@ -317,14 +322,14 @@ __split_buffer<_Tp, _Allocator>::__split_buffer() } template -inline _LIBCPP_INLINE_VISIBILITY +inline __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template -inline _LIBCPP_INLINE_VISIBILITY +inline __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { diff --git a/include/__std_stream b/include/__std_stream index 5403adabc343..f867cd23bdd5 100644 --- a/include/__std_stream +++ b/include/__std_stream @@ -276,7 +276,6 @@ __stdoutbuf<_CharT>::overflow(int_type __c) codecvt_base::result __r; char_type* pbase = &__1buf; char_type* pptr = pbase + 1; - char_type* epptr = pptr; do { const char_type* __e; diff --git a/include/__tree b/include/__tree index 574e74baf26b..6391609b3982 100644 --- a/include/__tree +++ b/include/__tree @@ -1118,8 +1118,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp) template __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) - : __pair1_(__node_allocator(__a)), - __begin_node_(__node_pointer()), + : __begin_node_(__node_pointer()), + __pair1_(__node_allocator(__a)), __pair3_(0) { __begin_node() = __end_node(); @@ -1128,8 +1128,8 @@ __tree<_Tp, _Compare, _Allocator>::__tree(const allocator_type& __a) template __tree<_Tp, _Compare, _Allocator>::__tree(const value_compare& __comp, const allocator_type& __a) - : __pair1_(__node_allocator(__a)), - __begin_node_(__node_pointer()), + : __begin_node_(__node_pointer()), + __pair1_(__node_allocator(__a)), __pair3_(0, __comp) { __begin_node() = __end_node(); @@ -1843,7 +1843,7 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(const value_type& __v) __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; - return _VSTD::move(__h); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/include/__tuple b/include/__tuple index 2837ce708f09..8c31759774de 100644 --- a/include/__tuple +++ b/include/__tuple @@ -86,6 +86,11 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, tuple<_Tp...> >::type&& get(tuple<_Tp...>&&) _NOEXCEPT; + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, tuple<_Tp...> >::type&& +get(const tuple<_Tp...>&&) _NOEXCEPT; #endif // pair specializations @@ -109,6 +114,11 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&&) _NOEXCEPT; + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& +get(const pair<_T1, _T2>&&) _NOEXCEPT; #endif // array specializations @@ -132,35 +142,15 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&&) _NOEXCEPT; + +template +_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp&& +get(const array<_Tp, _Size>&&) _NOEXCEPT; #endif #if !defined(_LIBCPP_HAS_NO_VARIADICS) -// __lazy_and - -template -struct __lazy_and_impl; - -template -struct __lazy_and_impl : false_type {}; - -template <> -struct __lazy_and_impl : true_type {}; - -template -struct __lazy_and_impl : integral_constant {}; - -template -struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; - -template -struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; - -// __lazy_not - -template -struct __lazy_not : integral_constant {}; - // __make_tuple_indices template struct __tuple_indices {}; diff --git a/include/algorithm b/include/algorithm index 7b0c53e05a5a..9c051198930d 100644 --- a/include/algorithm +++ b/include/algorithm @@ -851,7 +851,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); - return _VSTD::move(__f); // explicitly moved for (emulated) C++03 + return _LIBCPP_EXPLICIT_MOVE(__f); // explicitly moved for (emulated) C++03 } // find @@ -2330,7 +2330,7 @@ __reverse(_BidirectionalIterator __first, _BidirectionalIterator __last, bidirec { if (__first == --__last) break; - swap(*__first, *__last); + _VSTD::iter_swap(__first, __last); ++__first; } } @@ -2342,7 +2342,7 @@ __reverse(_RandomAccessIterator __first, _RandomAccessIterator __last, random_ac { if (__first != __last) for (; __first < --__last; ++__first) - swap(*__first, *__last); + _VSTD::iter_swap(__first, __last); } template @@ -3037,7 +3037,7 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p if (_Rp == 0) return static_cast(_Eng(__g, _Dt)()); size_t __w = _Dt - __clz(_Rp) - 1; - if ((_Rp & (_UIntType(~0) >> (_Dt - __w))) != 0) + if ((_Rp & (std::numeric_limits<_UIntType>::max() >> (_Dt - __w))) != 0) ++__w; _Eng __e(__g, __w); _UIntType __u; diff --git a/include/array b/include/array index 2e02a43ed524..8866eaf6b463 100644 --- a/include/array +++ b/include/array @@ -89,12 +89,13 @@ template void swap(array& x, array& y) noexcept(noexcept(x.swap(y))); template class tuple_size; -template class tuple_element; +template class tuple_element; template struct tuple_size>; -template struct tuple_element>; -template T& get(array&) noexcept; // constexpr in C++14 -template const T& get(const array&) noexcept; // constexpr in C++14 -template T&& get(array&&) noexcept; // constexpr in C++14 +template struct tuple_element>; +template T& get(array&) noexcept; // constexpr in C++14 +template const T& get(const array&) noexcept; // constexpr in C++14 +template T&& get(array&&) noexcept; // constexpr in C++14 +template const T&& get(const array&&) noexcept; // constexpr in C++14 } // std @@ -324,6 +325,15 @@ get(array<_Tp, _Size>&& __a) _NOEXCEPT return _VSTD::move(__a.__elems_[_Ip]); } +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const _Tp&& +get(const array<_Tp, _Size>&& __a) _NOEXCEPT +{ + static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)"); + return _VSTD::move(__a.__elems_[_Ip]); +} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_END_NAMESPACE_STD diff --git a/include/atomic b/include/atomic index 97a998d33633..abec2a0b565a 100644 --- a/include/atomic +++ b/include/atomic @@ -535,25 +535,35 @@ void atomic_signal_fence(memory_order m) noexcept; #ifdef _LIBCPP_HAS_NO_THREADS #error is not supported on this single threaded system -#else // !_LIBCPP_HAS_NO_THREADS +#endif +#if !defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) +#error is not implemented +#endif _LIBCPP_BEGIN_NAMESPACE_STD -#if !__has_feature(cxx_atomic) && _GNUC_VER < 407 -#error is not implemented -#else - typedef enum memory_order { memory_order_relaxed, memory_order_consume, memory_order_acquire, memory_order_release, memory_order_acq_rel, memory_order_seq_cst } memory_order; -#if _GNUC_VER >= 407 +#if defined(_LIBCPP_HAS_GCC_ATOMIC_IMP) namespace __gcc_atomic { template struct __gcc_atomic_t { - __gcc_atomic_t() _NOEXCEPT {} + +#if _GNUC_VER >= 501 + static_assert(is_trivially_copyable<_Tp>::value, + "std::atomic requires that 'Tp' be a trivially copyable type"); +#endif + + _LIBCPP_INLINE_VISIBILITY +#ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + __gcc_atomic_t() _NOEXCEPT = default; +#else + __gcc_atomic_t() _NOEXCEPT : __a_value() {} +#endif // _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS _LIBCPP_CONSTEXPR explicit __gcc_atomic_t(_Tp value) _NOEXCEPT : __a_value(value) {} _Tp __a_value; @@ -574,7 +584,7 @@ struct __can_assign { sizeof(__test_atomic_assignable<_Tp, _Td>(1)) == sizeof(char); }; -static inline constexpr int __to_gcc_order(memory_order __order) { +static inline _LIBCPP_CONSTEXPR int __to_gcc_order(memory_order __order) { // Avoid switch statement to make this a constexpr. return __order == memory_order_relaxed ? __ATOMIC_RELAXED: (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: @@ -584,7 +594,7 @@ static inline constexpr int __to_gcc_order(memory_order __order) { __ATOMIC_CONSUME)))); } -static inline constexpr int __to_gcc_failure_order(memory_order __order) { +static inline _LIBCPP_CONSTEXPR int __to_gcc_failure_order(memory_order __order) { // Avoid switch statement to make this a constexpr. return __order == memory_order_relaxed ? __ATOMIC_RELAXED: (__order == memory_order_acquire ? __ATOMIC_ACQUIRE: @@ -805,7 +815,7 @@ static inline _Tp __c11_atomic_fetch_xor(_Atomic(_Tp)* __a, _Tp __pattern, return __atomic_fetch_xor(&__a->__a_value, __pattern, __gcc_atomic::__to_gcc_order(__order)); } -#endif // _GNUC_VER >= 407 +#endif // _LIBCPP_HAS_GCC_ATOMIC_IMP template inline _LIBCPP_INLINE_VISIBILITY @@ -825,7 +835,7 @@ struct __atomic_base // false _LIBCPP_INLINE_VISIBILITY bool is_lock_free() const volatile _NOEXCEPT { -#if __has_feature(cxx_atomic) +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) return __c11_atomic_is_lock_free(sizeof(_Tp)); #else return __atomic_is_lock_free(sizeof(_Tp), 0); @@ -1779,8 +1789,6 @@ typedef atomic atomic_uintmax_t; #define ATOMIC_FLAG_INIT {false} #define ATOMIC_VAR_INIT(__v) {__v} -// lock-free property - #define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE #define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE #define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE @@ -1792,10 +1800,6 @@ typedef atomic atomic_uintmax_t; #define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE #define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE -#endif // !__has_feature(cxx_atomic) - _LIBCPP_END_NAMESPACE_STD -#endif // !_LIBCPP_HAS_NO_THREADS - #endif // _LIBCPP_ATOMIC diff --git a/include/bitset b/include/bitset index 8c278cc724f1..87d7afca5a73 100644 --- a/include/bitset +++ b/include/bitset @@ -168,7 +168,9 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT @@ -180,8 +182,11 @@ protected: _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT {return const_iterator(__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} + _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset& __v) _NOEXCEPT; void flip() _NOEXCEPT; @@ -192,22 +197,27 @@ protected: bool all() const _NOEXCEPT; bool any() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT; private: #ifdef _LIBCPP_HAS_NO_CONSTEXPR void __init(unsigned long long __v, false_type) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void __init(unsigned long long __v, true_type) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_CONSTEXPR unsigned long to_ulong(false_type) const; + _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong(true_type) const; unsigned long long to_ullong(false_type) const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong(true_type) const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong(true_type, false_type) const; unsigned long long to_ullong(true_type, true_type) const; }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset() _NOEXCEPT #ifndef _LIBCPP_HAS_NO_CONSTEXPR @@ -245,7 +255,7 @@ __bitset<_N_words, _Size>::__init(unsigned long long __v, true_type) _NOEXCEPT #endif // _LIBCPP_HAS_NO_CONSTEXPR template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_CONSTEXPR @@ -264,7 +274,7 @@ __bitset<_N_words, _Size>::__bitset(unsigned long long __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { @@ -273,7 +283,7 @@ __bitset<_N_words, _Size>::operator&=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { @@ -282,7 +292,7 @@ __bitset<_N_words, _Size>::operator|=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<_N_words, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { @@ -325,7 +335,7 @@ __bitset<_N_words, _Size>::to_ulong(false_type) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long __bitset<_N_words, _Size>::to_ulong(true_type) const { @@ -348,7 +358,7 @@ __bitset<_N_words, _Size>::to_ullong(false_type) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type) const { @@ -356,7 +366,7 @@ __bitset<_N_words, _Size>::to_ullong(true_type) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long __bitset<_N_words, _Size>::to_ullong(true_type, false_type) const { @@ -414,7 +424,7 @@ __bitset<_N_words, _Size>::any() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t __bitset<_N_words, _Size>::__hash_code() const _NOEXCEPT { @@ -450,7 +460,9 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t __pos) _NOEXCEPT @@ -462,23 +474,32 @@ protected: _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_t __pos) const _NOEXCEPT {return const_iterator(&__first_ + __pos / __bits_per_word, __pos % __bits_per_word);} + _LIBCPP_INLINE_VISIBILITY void operator&=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator|=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void operator^=(const __bitset& __v) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void flip() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const; + _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT; }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset() _NOEXCEPT : __first_(0) @@ -486,7 +507,7 @@ __bitset<1, _Size>::__bitset() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT : __first_(static_cast<__storage_type>(__v)) @@ -494,7 +515,7 @@ __bitset<1, _Size>::__bitset(unsigned long long __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT { @@ -502,7 +523,7 @@ __bitset<1, _Size>::operator&=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT { @@ -510,7 +531,7 @@ __bitset<1, _Size>::operator|=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT { @@ -518,7 +539,7 @@ __bitset<1, _Size>::operator^=(const __bitset& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void __bitset<1, _Size>::flip() _NOEXCEPT { @@ -528,7 +549,7 @@ __bitset<1, _Size>::flip() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long __bitset<1, _Size>::to_ulong() const { @@ -536,7 +557,7 @@ __bitset<1, _Size>::to_ulong() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long __bitset<1, _Size>::to_ullong() const { @@ -544,7 +565,7 @@ __bitset<1, _Size>::to_ullong() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool __bitset<1, _Size>::all() const _NOEXCEPT { @@ -553,7 +574,7 @@ __bitset<1, _Size>::all() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool __bitset<1, _Size>::any() const _NOEXCEPT { @@ -562,7 +583,7 @@ __bitset<1, _Size>::any() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t __bitset<1, _Size>::__hash_code() const _NOEXCEPT { @@ -593,7 +614,9 @@ protected: typedef __bit_iterator<__bitset, false> iterator; typedef __bit_iterator<__bitset, true> const_iterator; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR __bitset() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR __bitset(unsigned long long) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY reference __make_ref(size_t) _NOEXCEPT @@ -620,13 +643,13 @@ protected: _LIBCPP_INLINE_VISIBILITY size_t __hash_code() const _NOEXCEPT {return 0;} }; -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset() _NOEXCEPT { } -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT { @@ -663,16 +686,23 @@ public: _CharT __zero = _CharT('0'), _CharT __one = _CharT('1')); // 23.3.5.2 bitset operations: + _LIBCPP_INLINE_VISIBILITY bitset& operator&=(const bitset& __rhs) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& operator|=(const bitset& __rhs) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& operator^=(const bitset& __rhs) _NOEXCEPT; bitset& operator<<=(size_t __pos) _NOEXCEPT; bitset& operator>>=(size_t __pos) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& set() _NOEXCEPT; bitset& set(size_t __pos, bool __val = true); + _LIBCPP_INLINE_VISIBILITY bitset& reset() _NOEXCEPT; bitset& reset(size_t __pos); + _LIBCPP_INLINE_VISIBILITY bitset operator~() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset& flip() _NOEXCEPT; bitset& flip(size_t __pos); @@ -680,28 +710,40 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR const_reference operator[](size_t __p) const {return base::__make_ref(__p);} _LIBCPP_INLINE_VISIBILITY reference operator[](size_t __p) {return base::__make_ref(__p);} + _LIBCPP_INLINE_VISIBILITY unsigned long to_ulong() const; + _LIBCPP_INLINE_VISIBILITY unsigned long long to_ullong() const; template basic_string<_CharT, _Traits, _Allocator> to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; template + _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; template + _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > to_string(_CharT __zero = _CharT('0'), _CharT __one = _CharT('1')) const; + _LIBCPP_INLINE_VISIBILITY basic_string, allocator > to_string(char __zero = '0', char __one = '1') const; + _LIBCPP_INLINE_VISIBILITY size_t count() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR size_t size() const _NOEXCEPT {return _Size;} + _LIBCPP_INLINE_VISIBILITY bool operator==(const bitset& __rhs) const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bool operator!=(const bitset& __rhs) const _NOEXCEPT; bool test(size_t __pos) const; + _LIBCPP_INLINE_VISIBILITY bool all() const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bool any() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY bool none() const _NOEXCEPT {return !any();} + _LIBCPP_INLINE_VISIBILITY bitset operator<<(size_t __pos) const _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY bitset operator>>(size_t __pos) const _NOEXCEPT; private: @@ -774,7 +816,7 @@ bitset<_Size>::bitset(const basic_string<_CharT,_Traits,_Allocator>& __str, } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT { @@ -783,7 +825,7 @@ bitset<_Size>::operator&=(const bitset& __rhs) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT { @@ -792,7 +834,7 @@ bitset<_Size>::operator|=(const bitset& __rhs) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::operator^=(const bitset& __rhs) _NOEXCEPT { @@ -821,7 +863,7 @@ bitset<_Size>::operator>>=(size_t __pos) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::set() _NOEXCEPT { @@ -844,7 +886,7 @@ bitset<_Size>::set(size_t __pos, bool __val) } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::reset() _NOEXCEPT { @@ -867,7 +909,7 @@ bitset<_Size>::reset(size_t __pos) } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size> bitset<_Size>::operator~() const _NOEXCEPT { @@ -877,7 +919,7 @@ bitset<_Size>::operator~() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size>& bitset<_Size>::flip() _NOEXCEPT { @@ -901,7 +943,7 @@ bitset<_Size>::flip(size_t __pos) } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long bitset<_Size>::to_ulong() const { @@ -909,7 +951,7 @@ bitset<_Size>::to_ulong() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline unsigned long long bitset<_Size>::to_ullong() const { @@ -932,7 +974,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, _Traits, allocator<_CharT> > bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -941,7 +983,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, char_traits<_CharT>, allocator<_CharT> > bitset<_Size>::to_string(_CharT __zero, _CharT __one) const { @@ -949,7 +991,7 @@ bitset<_Size>::to_string(_CharT __zero, _CharT __one) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string, allocator > bitset<_Size>::to_string(char __zero, char __one) const { @@ -957,7 +999,7 @@ bitset<_Size>::to_string(char __zero, char __one) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t bitset<_Size>::count() const _NOEXCEPT { @@ -965,7 +1007,7 @@ bitset<_Size>::count() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT { @@ -973,7 +1015,7 @@ bitset<_Size>::operator==(const bitset& __rhs) const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::operator!=(const bitset& __rhs) const _NOEXCEPT { @@ -994,7 +1036,7 @@ bitset<_Size>::test(size_t __pos) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::all() const _NOEXCEPT { @@ -1002,7 +1044,7 @@ bitset<_Size>::all() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool bitset<_Size>::any() const _NOEXCEPT { @@ -1010,7 +1052,7 @@ bitset<_Size>::any() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size> bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT { @@ -1020,7 +1062,7 @@ bitset<_Size>::operator<<(size_t __pos) const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline bitset<_Size> bitset<_Size>::operator>>(size_t __pos) const _NOEXCEPT { diff --git a/include/cctype b/include/cctype index 26c740f7382d..a68c2a06604d 100644 --- a/include/cctype +++ b/include/cctype @@ -37,10 +37,6 @@ int toupper(int c); #include <__config> #include -#if defined(_LIBCPP_MSVCRT) -#include "support/win32/support.h" -#include "support/win32/locale_win32.h" -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -48,117 +44,20 @@ int toupper(int c); _LIBCPP_BEGIN_NAMESPACE_STD -#ifdef isalnum -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalnum(int __c) {return isalnum(__c);} -#undef isalnum -inline _LIBCPP_INLINE_VISIBILITY int isalnum(int __c) {return __libcpp_isalnum(__c);} -#else // isalnum using ::isalnum; -#endif // isalnum - -#ifdef isalpha -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isalpha(int __c) {return isalpha(__c);} -#undef isalpha -inline _LIBCPP_INLINE_VISIBILITY int isalpha(int __c) {return __libcpp_isalpha(__c);} -#else // isalpha using ::isalpha; -#endif // isalpha - -#ifdef isblank -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isblank(int __c) {return isblank(__c);} -#undef isblank -inline _LIBCPP_INLINE_VISIBILITY int isblank(int __c) {return __libcpp_isblank(__c);} -#else // isblank using ::isblank; -#endif // isblank - -#ifdef iscntrl -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iscntrl(int __c) {return iscntrl(__c);} -#undef iscntrl -inline _LIBCPP_INLINE_VISIBILITY int iscntrl(int __c) {return __libcpp_iscntrl(__c);} -#else // iscntrl using ::iscntrl; -#endif // iscntrl - -#ifdef isdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isdigit(int __c) {return isdigit(__c);} -#undef isdigit -inline _LIBCPP_INLINE_VISIBILITY int isdigit(int __c) {return __libcpp_isdigit(__c);} -#else // isdigit using ::isdigit; -#endif // isdigit - -#ifdef isgraph -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isgraph(int __c) {return isgraph(__c);} -#undef isgraph -inline _LIBCPP_INLINE_VISIBILITY int isgraph(int __c) {return __libcpp_isgraph(__c);} -#else // isgraph using ::isgraph; -#endif // isgraph - -#ifdef islower -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_islower(int __c) {return islower(__c);} -#undef islower -inline _LIBCPP_INLINE_VISIBILITY int islower(int __c) {return __libcpp_islower(__c);} -#else // islower using ::islower; -#endif // islower - -#ifdef isprint -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isprint(int __c) {return isprint(__c);} -#undef isprint -inline _LIBCPP_INLINE_VISIBILITY int isprint(int __c) {return __libcpp_isprint(__c);} -#else // isprint using ::isprint; -#endif // isprint - -#ifdef ispunct -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ispunct(int __c) {return ispunct(__c);} -#undef ispunct -inline _LIBCPP_INLINE_VISIBILITY int ispunct(int __c) {return __libcpp_ispunct(__c);} -#else // ispunct using ::ispunct; -#endif // ispunct - -#ifdef isspace -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isspace(int __c) {return isspace(__c);} -#undef isspace -inline _LIBCPP_INLINE_VISIBILITY int isspace(int __c) {return __libcpp_isspace(__c);} -#else // isspace using ::isspace; -#endif // isspace - -#ifdef isupper -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isupper(int __c) {return isupper(__c);} -#undef isupper -inline _LIBCPP_INLINE_VISIBILITY int isupper(int __c) {return __libcpp_isupper(__c);} -#else // isupper using ::isupper; -#endif // isupper - -#ifdef isxdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isxdigit(int __c) {return isxdigit(__c);} -#undef isxdigit -inline _LIBCPP_INLINE_VISIBILITY int isxdigit(int __c) {return __libcpp_isxdigit(__c);} -#else // isxdigit using ::isxdigit; -#endif // isxdigit - -#ifdef tolower -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_tolower(int __c) {return tolower(__c);} -#undef tolower -inline _LIBCPP_INLINE_VISIBILITY int tolower(int __c) {return __libcpp_tolower(__c);} -#else // tolower using ::tolower; -#endif // tolower - -#ifdef toupper -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_toupper(int __c) {return toupper(__c);} -#undef toupper -inline _LIBCPP_INLINE_VISIBILITY int toupper(int __c) {return __libcpp_toupper(__c);} -#else // toupper using ::toupper; -#endif // toupper _LIBCPP_END_NAMESPACE_STD diff --git a/include/cerrno b/include/cerrno index 9804e4e3dcfe..bab13b8aa861 100644 --- a/include/cerrno +++ b/include/cerrno @@ -30,364 +30,4 @@ Macros: #pragma GCC system_header #endif -#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) - -#ifdef ELAST - -const int __elast1 = ELAST+1; -const int __elast2 = ELAST+2; - -#else - -const int __elast1 = 104; -const int __elast2 = 105; - -#endif - -#ifdef ENOTRECOVERABLE - -#define EOWNERDEAD __elast1 - -#ifdef ELAST -#undef ELAST -#define ELAST EOWNERDEAD -#endif - -#elif defined(EOWNERDEAD) - -#define ENOTRECOVERABLE __elast1 -#ifdef ELAST -#undef ELAST -#define ELAST ENOTRECOVERABLE -#endif - -#else // defined(EOWNERDEAD) - -#define EOWNERDEAD __elast1 -#define ENOTRECOVERABLE __elast2 -#ifdef ELAST -#undef ELAST -#define ELAST ENOTRECOVERABLE -#endif - -#endif // defined(EOWNERDEAD) - -#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) - -// supply errno values likely to be missing, particularly on Windows - -#ifndef EAFNOSUPPORT -#define EAFNOSUPPORT 9901 -#endif - -#ifndef EADDRINUSE -#define EADDRINUSE 9902 -#endif - -#ifndef EADDRNOTAVAIL -#define EADDRNOTAVAIL 9903 -#endif - -#ifndef EISCONN -#define EISCONN 9904 -#endif - -#ifndef EBADMSG -#define EBADMSG 9905 -#endif - -#ifndef ECONNABORTED -#define ECONNABORTED 9906 -#endif - -#ifndef EALREADY -#define EALREADY 9907 -#endif - -#ifndef ECONNREFUSED -#define ECONNREFUSED 9908 -#endif - -#ifndef ECONNRESET -#define ECONNRESET 9909 -#endif - -#ifndef EDESTADDRREQ -#define EDESTADDRREQ 9910 -#endif - -#ifndef EHOSTUNREACH -#define EHOSTUNREACH 9911 -#endif - -#ifndef EIDRM -#define EIDRM 9912 -#endif - -#ifndef EMSGSIZE -#define EMSGSIZE 9913 -#endif - -#ifndef ENETDOWN -#define ENETDOWN 9914 -#endif - -#ifndef ENETRESET -#define ENETRESET 9915 -#endif - -#ifndef ENETUNREACH -#define ENETUNREACH 9916 -#endif - -#ifndef ENOBUFS -#define ENOBUFS 9917 -#endif - -#ifndef ENOLINK -#define ENOLINK 9918 -#endif - -#ifndef ENODATA -#define ENODATA 9919 -#endif - -#ifndef ENOMSG -#define ENOMSG 9920 -#endif - -#ifndef ENOPROTOOPT -#define ENOPROTOOPT 9921 -#endif - -#ifndef ENOSR -#define ENOSR 9922 -#endif - -#ifndef ENOTSOCK -#define ENOTSOCK 9923 -#endif - -#ifndef ENOSTR -#define ENOSTR 9924 -#endif - -#ifndef ENOTCONN -#define ENOTCONN 9925 -#endif - -#ifndef ENOTSUP -#define ENOTSUP 9926 -#endif - -#ifndef ECANCELED -#define ECANCELED 9927 -#endif - -#ifndef EINPROGRESS -#define EINPROGRESS 9928 -#endif - -#ifndef EOPNOTSUPP -#define EOPNOTSUPP 9929 -#endif - -#ifndef EWOULDBLOCK -#define EWOULDBLOCK 9930 -#endif - -#ifndef EOWNERDEAD -#define EOWNERDEAD 9931 -#endif - -#ifndef EPROTO -#define EPROTO 9932 -#endif - -#ifndef EPROTONOSUPPORT -#define EPROTONOSUPPORT 9933 -#endif - -#ifndef ENOTRECOVERABLE -#define ENOTRECOVERABLE 9934 -#endif - -#ifndef ETIME -#define ETIME 9935 -#endif - -#ifndef ETXTBSY -#define ETXTBSY 9936 -#endif - -#ifndef ETIMEDOUT -#define ETIMEDOUT 9938 -#endif - -#ifndef ELOOP -#define ELOOP 9939 -#endif - -#ifndef EOVERFLOW -#define EOVERFLOW 9940 -#endif - -#ifndef EPROTOTYPE -#define EPROTOTYPE 9941 -#endif - -#ifndef ENOSYS -#define ENOSYS 9942 -#endif - -#ifndef EINVAL -#define EINVAL 9943 -#endif - -#ifndef ERANGE -#define ERANGE 9944 -#endif - -#ifndef EILSEQ -#define EILSEQ 9945 -#endif - -// Windows Mobile doesn't appear to define these: - -#ifndef E2BIG -#define E2BIG 9946 -#endif - -#ifndef EDOM -#define EDOM 9947 -#endif - -#ifndef EFAULT -#define EFAULT 9948 -#endif - -#ifndef EBADF -#define EBADF 9949 -#endif - -#ifndef EPIPE -#define EPIPE 9950 -#endif - -#ifndef EXDEV -#define EXDEV 9951 -#endif - -#ifndef EBUSY -#define EBUSY 9952 -#endif - -#ifndef ENOTEMPTY -#define ENOTEMPTY 9953 -#endif - -#ifndef ENOEXEC -#define ENOEXEC 9954 -#endif - -#ifndef EEXIST -#define EEXIST 9955 -#endif - -#ifndef EFBIG -#define EFBIG 9956 -#endif - -#ifndef ENAMETOOLONG -#define ENAMETOOLONG 9957 -#endif - -#ifndef ENOTTY -#define ENOTTY 9958 -#endif - -#ifndef EINTR -#define EINTR 9959 -#endif - -#ifndef ESPIPE -#define ESPIPE 9960 -#endif - -#ifndef EIO -#define EIO 9961 -#endif - -#ifndef EISDIR -#define EISDIR 9962 -#endif - -#ifndef ECHILD -#define ECHILD 9963 -#endif - -#ifndef ENOLCK -#define ENOLCK 9964 -#endif - -#ifndef ENOSPC -#define ENOSPC 9965 -#endif - -#ifndef ENXIO -#define ENXIO 9966 -#endif - -#ifndef ENODEV -#define ENODEV 9967 -#endif - -#ifndef ENOENT -#define ENOENT 9968 -#endif - -#ifndef ESRCH -#define ESRCH 9969 -#endif - -#ifndef ENOTDIR -#define ENOTDIR 9970 -#endif - -#ifndef ENOMEM -#define ENOMEM 9971 -#endif - -#ifndef EPERM -#define EPERM 9972 -#endif - -#ifndef EACCES -#define EACCES 9973 -#endif - -#ifndef EROFS -#define EROFS 9974 -#endif - -#ifndef EDEADLK -#define EDEADLK 9975 -#endif - -#ifndef EAGAIN -#define EAGAIN 9976 -#endif - -#ifndef ENFILE -#define ENFILE 9977 -#endif - -#ifndef EMFILE -#define EMFILE 9978 -#endif - -#ifndef EMLINK -#define EMLINK 9979 -#endif - #endif // _LIBCPP_CERRNO diff --git a/include/cfenv b/include/cfenv index dd7db37f8e48..4fc630419bde 100644 --- a/include/cfenv +++ b/include/cfenv @@ -1,5 +1,5 @@ // -*- C++ -*- -//===---------------------------- cctype ----------------------------------===// +//===---------------------------- cfenv -----------------------------------===// // // The LLVM Compiler Infrastructure // diff --git a/include/cfloat b/include/cfloat index 5fa56550fa6a..176fa9de3cec 100644 --- a/include/cfloat +++ b/include/cfloat @@ -67,12 +67,4 @@ Macros: #pragma GCC system_header #endif -#ifndef FLT_EVAL_METHOD -#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ -#endif - -#ifndef DECIMAL_DIG -#define DECIMAL_DIG __DECIMAL_DIG__ -#endif - #endif // _LIBCPP_CFLOAT diff --git a/include/chrono b/include/chrono index 9229234ce55a..68484e982432 100644 --- a/include/chrono +++ b/include/chrono @@ -26,6 +26,9 @@ duration_cast(const duration& fd); template struct treat_as_floating_point : is_floating_point {}; +template constexpr bool treat_as_floating_point_v + = treat_as_floating_point::value; // C++17 + template struct duration_values { @@ -194,6 +197,13 @@ template template ToDuration duration_cast(const duration& d); +template + constexpr ToDuration floor(const duration& d); // C++17 +template + constexpr ToDuration ceil(const duration& d); // C++17 +template + constexpr ToDuration round(const duration& d); // C++17 + // time_point arithmetic (all constexpr in C++14) template time_point>::type> @@ -227,6 +237,20 @@ template template time_point time_point_cast(const time_point& t); +template + constexpr time_point + floor(const time_point& tp); // C++17 + +template + constexpr time_point + ceil(const time_point& tp); // C++17 + +template + constexpr time_point + round(const time_point& tp); // C++17 + +template + constexpr duration abs(duration d); // C++17 // Clocks class system_clock @@ -392,6 +416,11 @@ duration_cast(const duration<_Rep, _Period>& __fd) template struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool treat_as_floating_point_v + = treat_as_floating_point<_Rep>::value; +#endif + template struct _LIBCPP_TYPE_VIS_ONLY duration_values { @@ -401,6 +430,58 @@ public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep min() {return numeric_limits<_Rep>::lowest();} }; +#if _LIBCPP_STD_VER > 14 +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +floor(const duration<_Rep, _Period>& __d) +{ + _ToDuration __t = duration_cast<_ToDuration>(__d); + if (__t > __d) + __t = __t - _ToDuration{1}; + return __t; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +ceil(const duration<_Rep, _Period>& __d) +{ + _ToDuration __t = duration_cast<_ToDuration>(__d); + if (__t < __d) + __t = __t + _ToDuration{1}; + return __t; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + _ToDuration +>::type +round(const duration<_Rep, _Period>& __d) +{ + _ToDuration __lower = floor<_ToDuration>(__d); + _ToDuration __upper = __lower + _ToDuration{1}; + auto __lowerDiff = __d - __lower; + auto __upperDiff = __upper - __d; + if (__lowerDiff < __upperDiff) + return __lower; + if (__lowerDiff > __upperDiff) + return __upper; + return __lower.count() & 1 ? __upper : __lower; +} +#endif + // duration template @@ -807,6 +888,56 @@ time_point_cast(const time_point<_Clock, _Duration>& __t) return time_point<_Clock, _ToDuration>(_VSTD::chrono::duration_cast<_ToDuration>(__t.time_since_epoch())); } +#if _LIBCPP_STD_VER > 14 +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +floor(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{floor<_ToDuration>(__t.time_since_epoch())}; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +ceil(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{ceil<_ToDuration>(__t.time_since_epoch())}; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + __is_duration<_ToDuration>::value, + time_point<_Clock, _ToDuration> +>::type +round(const time_point<_Clock, _Duration>& __t) +{ + return time_point<_Clock, _ToDuration>{round<_ToDuration>(__t.time_since_epoch())}; +} + +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR +typename enable_if +< + numeric_limits<_Rep>::is_signed, + duration<_Rep, _Period> +>::type +abs(duration<_Rep, _Period> __d) +{ + return __d >= __d.zero() ? __d : -__d; +} +#endif + // time_point == template diff --git a/include/cinttypes b/include/cinttypes index cfd763c98f4a..3f61b0634b17 100644 --- a/include/cinttypes +++ b/include/cinttypes @@ -246,10 +246,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int _LIBCPP_BEGIN_NAMESPACE_STD using::imaxdiv_t; - -#undef imaxabs using::imaxabs; -#undef imaxdiv using::imaxdiv; using::strtoimax; using::strtoumax; diff --git a/include/cmath b/include/cmath index 5f9aaedd5afa..ebbde18168ff 100644 --- a/include/cmath +++ b/include/cmath @@ -299,340 +299,11 @@ long double truncl(long double x); #include <__config> #include -#include - -#ifdef _LIBCPP_MSVCRT -#include "support/win32/math_win32.h" -#endif #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -// signbit - -#ifdef signbit - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT -{ - return signbit(__lcpp_x); -} - -#undef signbit - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -signbit(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // signbit - -// fpclassify - -#ifdef fpclassify - -template -_LIBCPP_ALWAYS_INLINE -int -__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ - return fpclassify(__lcpp_x); -} - -#undef fpclassify - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, int>::type -fpclassify(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // fpclassify - -// isfinite - -#ifdef isfinite - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT -{ - return isfinite(__lcpp_x); -} - -#undef isfinite - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isfinite(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isfinite - -// isinf - -#ifdef isinf - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT -{ - return isinf(__lcpp_x); -} - -#undef isinf - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isinf(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isinf - -// isnan - -#ifdef isnan - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT -{ - return isnan(__lcpp_x); -} - -#undef isnan - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnan(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isnan - -// isnormal - -#ifdef isnormal - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT -{ - return isnormal(__lcpp_x); -} - -#undef isnormal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if::value, bool>::type -isnormal(_A1 __lcpp_x) _NOEXCEPT -{ - return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); -} - -#endif // isnormal - -// isgreater - -#ifdef isgreater - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isgreater(__lcpp_x, __lcpp_y); -} - -#undef isgreater - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isgreater - -// isgreaterequal - -#ifdef isgreaterequal - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isgreaterequal(__lcpp_x, __lcpp_y); -} - -#undef isgreaterequal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isgreaterequal - -// isless - -#ifdef isless - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isless(__lcpp_x, __lcpp_y); -} - -#undef isless - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isless - -// islessequal - -#ifdef islessequal - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return islessequal(__lcpp_x, __lcpp_y); -} - -#undef islessequal - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // islessequal - -// islessgreater - -#ifdef islessgreater - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return islessgreater(__lcpp_x, __lcpp_y); -} - -#undef islessgreater - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // islessgreater - -// isunordered - -#ifdef isunordered - -template -_LIBCPP_ALWAYS_INLINE -bool -__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - return isunordered(__lcpp_x, __lcpp_y); -} - -#undef isunordered - -template -inline _LIBCPP_INLINE_VISIBILITY -typename std::enable_if -< - std::is_arithmetic<_A1>::value && - std::is_arithmetic<_A2>::value, - bool ->::type -isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename std::__promote<_A1, _A2>::type type; - return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); -} - -#endif // isunordered - _LIBCPP_BEGIN_NAMESPACE_STD using ::signbit; @@ -652,794 +323,130 @@ using ::isunordered; using ::float_t; using ::double_t; -// abs - -#if defined(__sun__) +#ifndef _AIX using ::abs; #endif -#if !defined(_AIX) && !defined(__sun__) -inline _LIBCPP_INLINE_VISIBILITY -float -abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} - -inline _LIBCPP_INLINE_VISIBILITY -double -abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);} - -inline _LIBCPP_INLINE_VISIBILITY -long double -abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} -#endif // !defined(_AIX) - #ifndef __sun__ - -// acos - using ::acos; using ::acosf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);} - -// asin - using ::asin; using ::asinf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);} - -// atan - using ::atan; using ::atanf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);} - -// atan2 - using ::atan2; using ::atan2f; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); -} - -// ceil - using ::ceil; using ::ceilf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);} - -// cos - using ::cos; using ::cosf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);} - -// cosh - using ::cosh; using ::coshf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);} - #endif // __sun__ -// exp using ::exp; using ::expf; #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);} -#endif - - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);} - -// fabs - using ::fabs; using ::fabsf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);} - -// floor - using ::floor; using ::floorf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);} - -// fmod - #endif //__sun__ + using ::fmod; using ::fmodf; + #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - - -// frexp - using ::frexp; using ::frexpf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);} -inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);} - -// ldexp - using ::ldexp; using ::ldexpf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);} -inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);} - -// log - #endif // __sun__ + using ::log; using ::logf; + #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);} - - -// log10 - using ::log10; using ::log10f; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);} - -// modf - using ::modf; using ::modff; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);} -#endif - -// pow - #endif // __sun__ + using ::pow; using ::powf; #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// sin - using ::sin; using ::sinf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);} - -// sinh - using ::sinh; using ::sinhf; - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);} - -// sqrt - #endif // __sun__ + using ::sqrt; using ::sqrtf; - - -#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);} - -// tan - using ::tan; using ::tanf; + #ifndef __sun__ - -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);} - -// tanh - using ::tanh; using ::tanhf; -#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) -inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);} - -// acosh - #ifndef _LIBCPP_MSVCRT using ::acosh; using ::acoshf; - -inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return acoshf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);} -#endif - -// asinh - -#ifndef _LIBCPP_MSVCRT using ::asinh; using ::asinhf; - -inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return asinhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);} -#endif - -// atanh - -#ifndef _LIBCPP_MSVCRT using ::atanh; using ::atanhf; - -inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return atanhf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);} -#endif - -// cbrt - -#ifndef _LIBCPP_MSVCRT using ::cbrt; using ::cbrtf; - -inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return cbrtf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);} #endif -// copysign - using ::copysign; using ::copysignf; -#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12) -inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, - float __lcpp_y) _NOEXCEPT { - return copysignf(__lcpp_x, __lcpp_y); -} -inline _LIBCPP_INLINE_VISIBILITY long double -copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { - return copysignl(__lcpp_x, __lcpp_y); -} -#endif - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - #ifndef _LIBCPP_MSVCRT - -// erf - using ::erf; using ::erff; - -inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return erff(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);} - -// erfc - using ::erfc; using ::erfcf; - -inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return erfcf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);} - -// exp2 - using ::exp2; using ::exp2f; - -inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return exp2f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);} - -// expm1 - using ::expm1; using ::expm1f; - -inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return expm1f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);} - -// fdim - using ::fdim; using ::fdimf; - -inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fdimf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// fma - using ::fmaf; using ::fma; - -inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);} -inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value && - is_arithmetic<_A3>::value, - __promote<_A1, _A2, _A3> ->::type -fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2, _A3>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value && - is_same<_A3, __result_type>::value)), ""); - return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); -} - -// fmax - using ::fmax; using ::fmaxf; - -inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmaxf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// fmin - using ::fmin; using ::fminf; - -inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fminf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// hypot - using ::hypot; using ::hypotf; - -inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return hypotf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// ilogb - using ::ilogb; using ::ilogbf; - -inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ilogbf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, int>::type -ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);} - -// lgamma - using ::lgamma; using ::lgammaf; - -inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return lgammaf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);} - - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);} - - -// llrint - using ::llrint; using ::llrintf; - -inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return llrintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long long>::type -llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);} - -// llround - using ::llround; using ::llroundf; - -inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return llroundf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long long>::type -llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);} - -// log1p - using ::log1p; using ::log1pf; - -inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return log1pf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);} - -// log2 - using ::log2; using ::log2f; - -inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return log2f(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);} - -// logb - using ::logb; using ::logbf; - -inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return logbf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);} - -// lrint - using ::lrint; using ::lrintf; - -inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return lrintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long>::type -lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);} - -// lround - using ::lround; using ::lroundf; - -inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return lroundf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, long>::type -lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);} - #endif // _LIBCPP_MSVCRT #endif // __sun__ -// nan - #ifndef _LIBCPP_MSVCRT using ::nan; using ::nanf; @@ -1447,183 +454,28 @@ using ::nanf; #ifndef __sun__ #ifndef _LIBCPP_MSVCRT - -// nearbyint - using ::nearbyint; using ::nearbyintf; - -inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return nearbyintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);} - -// nextafter - using ::nextafter; using ::nextafterf; - -inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return nextafterf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// nexttoward - using ::nexttoward; using ::nexttowardf; - -inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);} - -// remainder - using ::remainder; using ::remainderf; - -inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return remainderf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); -} - -// remquo - using ::remquo; using ::remquof; - -inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);} -inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename __lazy_enable_if -< - is_arithmetic<_A1>::value && - is_arithmetic<_A2>::value, - __promote<_A1, _A2> ->::type -remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT -{ - typedef typename __promote<_A1, _A2>::type __result_type; - static_assert((!(is_same<_A1, __result_type>::value && - is_same<_A2, __result_type>::value)), ""); - return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); -} - -// rint - using ::rint; using ::rintf; - -inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return rintf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);} - -// round - using ::round; using ::roundf; - -inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return roundf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);} - -// scalbln - using ::scalbln; using ::scalblnf; - -inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);} - -// scalbn - using ::scalbn; using ::scalbnf; - -inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnf(__lcpp_x, __lcpp_y);} -inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);} - -// tgamma - using ::tgamma; using ::tgammaf; - -inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return tgammaf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);} - -// trunc - using ::trunc; using ::truncf; - -inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return truncf(__lcpp_x);} -inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);} - -template -inline _LIBCPP_INLINE_VISIBILITY -typename enable_if::value, double>::type -trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);} - #endif // !_LIBCPP_MSVCRT using ::acosl; @@ -1647,6 +499,7 @@ using ::sinl; using ::sinhl; using ::sqrtl; using ::tanl; + #ifndef _LIBCPP_MSVCRT using ::tanhl; using ::acoshl; @@ -1654,7 +507,9 @@ using ::asinhl; using ::atanhl; using ::cbrtl; #endif // !_LIBCPP_MSVCRT + using ::copysignl; + #ifndef _LIBCPP_MSVCRT using ::erfl; using ::erfcl; @@ -1692,6 +547,7 @@ using ::truncl; using ::lgamma; using ::lgammaf; #endif // __sun__ + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CMATH diff --git a/include/complex.h b/include/complex.h index 7003d31a89cd..c2359665add5 100644 --- a/include/complex.h +++ b/include/complex.h @@ -18,6 +18,12 @@ */ +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + #ifdef __cplusplus #include @@ -28,8 +34,4 @@ #endif // __cplusplus -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - #endif // _LIBCPP_COMPLEX_H diff --git a/include/condition_variable b/include/condition_variable index 1af2484abd7b..10e007701672 100644 --- a/include/condition_variable +++ b/include/condition_variable @@ -124,14 +124,18 @@ class _LIBCPP_TYPE_VIS condition_variable_any condition_variable __cv_; shared_ptr __mut_; public: + _LIBCPP_INLINE_VISIBILITY condition_variable_any(); + _LIBCPP_INLINE_VISIBILITY void notify_one() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void notify_all() _NOEXCEPT; template void wait(_Lock& __lock); template + _LIBCPP_INLINE_VISIBILITY void wait(_Lock& __lock, _Predicate __pred); template @@ -141,27 +145,30 @@ public: template bool + _LIBCPP_INLINE_VISIBILITY wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, _Predicate __pred); template cv_status + _LIBCPP_INLINE_VISIBILITY wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d); template bool + _LIBCPP_INLINE_VISIBILITY wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred); }; -inline _LIBCPP_INLINE_VISIBILITY +inline condition_variable_any::condition_variable_any() : __mut_(make_shared()) {} -inline _LIBCPP_INLINE_VISIBILITY +inline void condition_variable_any::notify_one() _NOEXCEPT { @@ -169,7 +176,7 @@ condition_variable_any::notify_one() _NOEXCEPT __cv_.notify_one(); } -inline _LIBCPP_INLINE_VISIBILITY +inline void condition_variable_any::notify_all() _NOEXCEPT { @@ -196,7 +203,7 @@ condition_variable_any::wait(_Lock& __lock) } // __mut_.unlock(), __lock.lock() template -inline _LIBCPP_INLINE_VISIBILITY +inline void condition_variable_any::wait(_Lock& __lock, _Predicate __pred) { @@ -218,7 +225,7 @@ condition_variable_any::wait_until(_Lock& __lock, } // __mut_.unlock(), __lock.lock() template -inline _LIBCPP_INLINE_VISIBILITY +inline bool condition_variable_any::wait_until(_Lock& __lock, const chrono::time_point<_Clock, _Duration>& __t, @@ -231,7 +238,7 @@ condition_variable_any::wait_until(_Lock& __lock, } template -inline _LIBCPP_INLINE_VISIBILITY +inline cv_status condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d) @@ -240,7 +247,7 @@ condition_variable_any::wait_for(_Lock& __lock, } template -inline _LIBCPP_INLINE_VISIBILITY +inline bool condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, diff --git a/include/csetjmp b/include/csetjmp index d0b2c078967d..58a9c73ab56f 100644 --- a/include/csetjmp +++ b/include/csetjmp @@ -38,10 +38,6 @@ void longjmp(jmp_buf env, int val); #pragma GCC system_header #endif -#ifndef setjmp -#define setjmp(env) setjmp(env) -#endif - _LIBCPP_BEGIN_NAMESPACE_STD using ::jmp_buf; diff --git a/include/cstddef b/include/cstddef index c3ca64a9c014..edd106c001bc 100644 --- a/include/cstddef +++ b/include/cstddef @@ -35,12 +35,14 @@ Types: #include <__config> -#include - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif +// Don't include our own ; we don't want to declare ::nullptr_t. +#include_next +#include <__nullptr> + _LIBCPP_BEGIN_NAMESPACE_STD using ::ptrdiff_t; @@ -53,50 +55,6 @@ using ::max_align_t; typedef long double max_align_t; #endif -#ifdef _LIBCPP_HAS_NO_NULLPTR - -struct _LIBCPP_TYPE_VIS_ONLY nullptr_t -{ - void* __lx; - - struct __nat {int __for_bool_;}; - - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t() : __lx(0) {} - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t(int __nat::*) : __lx(0) {} - - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR operator int __nat::*() const {return 0;} - - template - _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR - operator _Tp* () const {return 0;} - - template - _LIBCPP_ALWAYS_INLINE - operator _Tp _Up::* () const {return 0;} - - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} -}; - -inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} - -#define nullptr _VSTD::__get_nullptr_t() - -#endif // _LIBCPP_HAS_NO_NULLPTR - _LIBCPP_END_NAMESPACE_STD -#ifndef _LIBCPP_HAS_NO_NULLPTR - -namespace std -{ - typedef decltype(nullptr) nullptr_t; -} - -#endif // _LIBCPP_HAS_NO_NULLPTR - #endif // _LIBCPP_CSTDDEF diff --git a/include/cstdio b/include/cstdio index d8ba6c2ef383..50fdd3457426 100644 --- a/include/cstdio +++ b/include/cstdio @@ -103,41 +103,6 @@ void perror(const char* s); #pragma GCC system_header #endif -// snprintf -#if defined(_LIBCPP_MSVCRT) -#include "support/win32/support.h" -#endif - -#ifdef getc -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);} -#undef getc -inline _LIBCPP_INLINE_VISIBILITY int getc(FILE* __stream) {return __libcpp_getc(__stream);} -#endif // getc - -#ifdef putc -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_putc(int __c, FILE* __stream) {return putc(__c, __stream);} -#undef putc -inline _LIBCPP_INLINE_VISIBILITY int putc(int __c, FILE* __stream) {return __libcpp_putc(__c, __stream);} -#endif // putc - -#ifdef clearerr -inline _LIBCPP_INLINE_VISIBILITY void __libcpp_clearerr(FILE* __stream) { return clearerr(__stream); } -#undef clearerr -inline _LIBCPP_INLINE_VISIBILITY void clearerr(FILE* __stream) { return __libcpp_clearerr(__stream); } -#endif // clearerr - -#ifdef feof -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_feof(FILE* __stream) { return feof(__stream); } -#undef feof -inline _LIBCPP_INLINE_VISIBILITY int feof(FILE* __stream) { return __libcpp_feof(__stream); } -#endif // feof - -#ifdef ferror -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_ferror(FILE* __stream) { return ferror(__stream); } -#undef ferror -inline _LIBCPP_INLINE_VISIBILITY int ferror(FILE* __stream) { return __libcpp_ferror(__stream); } -#endif // ferror - _LIBCPP_BEGIN_NAMESPACE_STD using ::FILE; diff --git a/include/cstdlib b/include/cstdlib index 55e15c82192e..10ed231078d8 100644 --- a/include/cstdlib +++ b/include/cstdlib @@ -84,9 +84,6 @@ void *aligned_alloc(size_t alignment, size_t size); // C11 #include <__config> #include -#ifdef _LIBCPP_MSVCRT -#include "support/win32/locale_win32.h" -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -131,20 +128,14 @@ using ::getenv; using ::system; using ::bsearch; using ::qsort; -#undef abs using ::abs; -#undef labs using ::labs; #ifndef _LIBCPP_HAS_NO_LONG_LONG -#undef llabs using ::llabs; #endif // _LIBCPP_HAS_NO_LONG_LONG -#undef div using ::div; -#undef ldiv using ::ldiv; #ifndef _LIBCPP_HAS_NO_LONG_LONG -#undef lldiv using ::lldiv; #endif // _LIBCPP_HAS_NO_LONG_LONG #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS @@ -162,19 +153,6 @@ using ::quick_exit; using ::aligned_alloc; #endif -// MSVCRT already has the correct prototype in #ifdef __cplusplus -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) -inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);} -#ifndef _LIBCPP_HAS_NO_LONG_LONG -inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);} -#endif // _LIBCPP_HAS_NO_LONG_LONG - -inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);} -#ifndef _LIBCPP_HAS_NO_LONG_LONG -inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);} -#endif // _LIBCPP_HAS_NO_LONG_LONG -#endif // _LIBCPP_MSVCRT - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_CSTDLIB diff --git a/include/ctype.h b/include/ctype.h new file mode 100644 index 000000000000..22d6c49be9e1 --- /dev/null +++ b/include/ctype.h @@ -0,0 +1,69 @@ +// -*- C++ -*- +//===---------------------------- ctype.h ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_CTYPE_H +#define _LIBCPP_CTYPE_H + +/* + ctype.h synopsis + +int isalnum(int c); +int isalpha(int c); +int isblank(int c); // C99 +int iscntrl(int c); +int isdigit(int c); +int isgraph(int c); +int islower(int c); +int isprint(int c); +int ispunct(int c); +int isspace(int c); +int isupper(int c); +int isxdigit(int c); +int tolower(int c); +int toupper(int c); +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#if defined(_LIBCPP_MSVCRT) +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { + #include "support/win32/support.h" + #include "support/win32/locale_win32.h" +} +#endif // _LIBCPP_MSVCRT + +#undef isalnum +#undef isalpha +#undef isblank +#undef iscntrl +#undef isdigit +#undef isgraph +#undef islower +#undef isprint +#undef ispunct +#undef isspace +#undef isupper +#undef isxdigit +#undef tolower +#undef toupper + +#endif + +#endif // _LIBCPP_CTYPE_H diff --git a/include/cwchar b/include/cwchar index 797a1777c22f..ef4806db2bde 100644 --- a/include/cwchar +++ b/include/cwchar @@ -106,9 +106,6 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, #include <__config> #include #include -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -#include // pull in *swprintf defines -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -161,16 +158,13 @@ using ::wcscoll; using ::wcsncmp; using ::wcsxfrm; -#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) - +#ifdef _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS using ::wcschr; using ::wcspbrk; using ::wcsrchr; using ::wcsstr; using ::wmemchr; - #else - inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} @@ -185,7 +179,6 @@ inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsstr( wchar_t* __s1, cons inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} - #endif using ::wcscspn; diff --git a/include/cwctype b/include/cwctype index 4f89b52db27c..25b2489edf2c 100644 --- a/include/cwctype +++ b/include/cwctype @@ -63,150 +63,24 @@ _LIBCPP_BEGIN_NAMESPACE_STD using ::wint_t; using ::wctrans_t; using ::wctype_t; - -#ifdef iswalnum -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalnum(wint_t __wc) {return iswalnum(__wc);} -#undef iswalnum -inline _LIBCPP_INLINE_VISIBILITY int iswalnum(wint_t __wc) {return __libcpp_iswalnum(__wc);} -#else // iswalnum using ::iswalnum; -#endif - -#ifdef iswalpha -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswalpha(wint_t __wc) {return iswalpha(__wc);} -#undef iswalpha -inline _LIBCPP_INLINE_VISIBILITY int iswalpha(wint_t __wc) {return __libcpp_iswalpha(__wc);} -#else // iswalpha using ::iswalpha; -#endif - -#ifdef iswblank -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswblank(wint_t __wc) {return iswblank(__wc);} -#undef iswblank -inline _LIBCPP_INLINE_VISIBILITY int iswblank(wint_t __wc) {return __libcpp_iswblank(__wc);} -#else // iswblank using ::iswblank; -#endif - -#ifdef iswcntrl -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswcntrl(wint_t __wc) {return iswcntrl(__wc);} -#undef iswcntrl -inline _LIBCPP_INLINE_VISIBILITY int iswcntrl(wint_t __wc) {return __libcpp_iswcntrl(__wc);} -#else // iswcntrl using ::iswcntrl; -#endif - -#ifdef iswdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswdigit(wint_t __wc) {return iswdigit(__wc);} -#undef iswdigit -inline _LIBCPP_INLINE_VISIBILITY int iswdigit(wint_t __wc) {return __libcpp_iswdigit(__wc);} -#else // iswdigit using ::iswdigit; -#endif - -#ifdef iswgraph -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswgraph(wint_t __wc) {return iswgraph(__wc);} -#undef iswgraph -inline _LIBCPP_INLINE_VISIBILITY int iswgraph(wint_t __wc) {return __libcpp_iswgraph(__wc);} -#else // iswgraph using ::iswgraph; -#endif - -#ifdef iswlower -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswlower(wint_t __wc) {return iswlower(__wc);} -#undef iswlower -inline _LIBCPP_INLINE_VISIBILITY int iswlower(wint_t __wc) {return __libcpp_iswlower(__wc);} -#else // iswlower using ::iswlower; -#endif - -#ifdef iswprint -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswprint(wint_t __wc) {return iswprint(__wc);} -#undef iswprint -inline _LIBCPP_INLINE_VISIBILITY int iswprint(wint_t __wc) {return __libcpp_iswprint(__wc);} -#else // iswprint using ::iswprint; -#endif - -#ifdef iswpunct -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswpunct(wint_t __wc) {return iswpunct(__wc);} -#undef iswpunct -inline _LIBCPP_INLINE_VISIBILITY int iswpunct(wint_t __wc) {return __libcpp_iswpunct(__wc);} -#else // iswpunct using ::iswpunct; -#endif - -#ifdef iswspace -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswspace(wint_t __wc) {return iswspace(__wc);} -#undef iswspace -inline _LIBCPP_INLINE_VISIBILITY int iswspace(wint_t __wc) {return __libcpp_iswspace(__wc);} -#else // iswspace using ::iswspace; -#endif - -#ifdef iswupper -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswupper(wint_t __wc) {return iswupper(__wc);} -#undef iswupper -inline _LIBCPP_INLINE_VISIBILITY int iswupper(wint_t __wc) {return __libcpp_iswupper(__wc);} -#else // iswupper using ::iswupper; -#endif - -#ifdef iswxdigit -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswxdigit(wint_t __wc) {return iswxdigit(__wc);} -#undef iswxdigit -inline _LIBCPP_INLINE_VISIBILITY int iswxdigit(wint_t __wc) {return __libcpp_iswxdigit(__wc);} -#else // iswxdigit using ::iswxdigit; -#endif - -#ifdef iswctype -inline _LIBCPP_INLINE_VISIBILITY int __libcpp_iswctype(wint_t __w, wctype_t __d) {return iswctype(__w, __d);} -#undef iswctype -inline _LIBCPP_INLINE_VISIBILITY int iswctype(wint_t __w, wctype_t __d) {return __libcpp_iswctype(__w, __d);} -#else // iswctype using ::iswctype; -#endif - -#ifdef wctype -inline _LIBCPP_INLINE_VISIBILITY wctype_t __libcpp_wctype(const char* __p) {return wctype(__p);} -#undef wctype -inline _LIBCPP_INLINE_VISIBILITY wctype_t wctype(const char* __p) {return __libcpp_wctype(__p);} -#else // wctype using ::wctype; -#endif - -#ifdef towlower -inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towlower(wint_t __wc) {return towlower(__wc);} -#undef towlower -inline _LIBCPP_INLINE_VISIBILITY wint_t towlower(wint_t __wc) {return __libcpp_towlower(__wc);} -#else // towlower using ::towlower; -#endif - -#ifdef towupper -inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towupper(wint_t __wc) {return towupper(__wc);} -#undef towupper -inline _LIBCPP_INLINE_VISIBILITY wint_t towupper(wint_t __wc) {return __libcpp_towupper(__wc);} -#else // towupper using ::towupper; -#endif - -#ifdef towctrans -inline _LIBCPP_INLINE_VISIBILITY wint_t __libcpp_towctrans(wint_t __wc, wctype_t __d) {return towctrans(__wc, __d);} -#undef towctrans -inline _LIBCPP_INLINE_VISIBILITY wint_t towctrans(wint_t __wc, wctype_t __d) {return __libcpp_towctrans(__wc, __d);} -#else // towctrans using ::towctrans; -#endif - -#ifdef wctrans -inline _LIBCPP_INLINE_VISIBILITY wctrans_t __libcpp_wctrans(const char* __p) {return wctrans(__p);} -#undef wctrans -inline _LIBCPP_INLINE_VISIBILITY wctrans_t wctrans(const char* __p) {return __libcpp_wctrans(__p);} -#else // wctrans using ::wctrans; -#endif _LIBCPP_END_NAMESPACE_STD diff --git a/include/deque b/include/deque index 5e152e425d0b..c6fbd512a1c6 100644 --- a/include/deque +++ b/include/deque @@ -261,8 +261,21 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __l, __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); +template +struct __deque_block_size { + static const _DiffType value = sizeof(_ValueType) < 256 ? 4096 / sizeof(_ValueType) : 16; +}; + template + class _DiffType, _DiffType _BS = +#ifdef _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +// Keep template parameter to avoid changing all template declarations thoughout +// this file. + 0 +#else + __deque_block_size<_ValueType, _DiffType>::value +#endif + > class _LIBCPP_TYPE_VIS_ONLY __deque_iterator { typedef _MapPointer __map_iterator; @@ -273,7 +286,7 @@ private: __map_iterator __m_iter_; pointer __ptr_; - static const difference_type __block_size = _BlockSize; + static const difference_type __block_size; public: typedef _ValueType value_type; typedef random_access_iterator_tag iterator_category; @@ -287,7 +300,7 @@ public: template _LIBCPP_INLINE_VISIBILITY - __deque_iterator(const __deque_iterator& __it, + __deque_iterator(const __deque_iterator& __it, typename enable_if::value>::type* = 0) _NOEXCEPT : __m_iter_(__it.__m_iter_), __ptr_(__it.__ptr_) {} @@ -520,6 +533,12 @@ private: __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2> __r); }; +template +const _DiffType __deque_iterator<_ValueType, _Pointer, _Reference, _MapPointer, + _DiffType, _BlockSize>::__block_size = + __deque_block_size<_ValueType, _DiffType>::value; + // copy template ::difference_type difference_type; typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size; while (__f != __l) { pointer __rb = __r.__ptr_; - pointer __re = *__r.__m_iter_ + _B2; + pointer __re = *__r.__m_iter_ + __block_size; difference_type __bs = __re - __rb; difference_type __n = __l - __f; _RAIter __m = __l; @@ -560,11 +580,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -587,11 +608,12 @@ copy(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -705,10 +727,11 @@ move(_RAIter __f, { typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::difference_type difference_type; typedef typename __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V2, _P2, _R2, _M2, _D2, _B2>::__block_size; while (__f != __l) { pointer __rb = __r.__ptr_; - pointer __re = *__r.__m_iter_ + _B2; + pointer __re = *__r.__m_iter_ + __block_size; difference_type __bs = __re - __rb; difference_type __n = __l - __f; _RAIter __m = __l; @@ -733,11 +756,12 @@ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -760,11 +784,12 @@ move(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, { typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::difference_type difference_type; typedef typename __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::pointer pointer; + const difference_type __block_size = __deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1>::__block_size; difference_type __n = __l - __f; while (__n > 0) { pointer __fb = __f.__ptr_; - pointer __fe = *__f.__m_iter_ + _B1; + pointer __fe = *__f.__m_iter_ + __block_size; difference_type __bs = __fe - __fb; if (__bs > __n) { @@ -909,7 +934,7 @@ protected: typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; - static const difference_type __block_size = sizeof(value_type) < 256 ? 4096 / sizeof(value_type) : 16; + static const difference_type __block_size; typedef typename __rebind_alloc_helper<__alloc_traits, pointer>::type __pointer_allocator; typedef allocator_traits<__pointer_allocator> __map_traits; @@ -919,9 +944,9 @@ protected: typedef __split_buffer __map; typedef __deque_iterator iterator; + difference_type> iterator; typedef __deque_iterator const_iterator; + difference_type> const_iterator; __map __map_; size_type __start_; @@ -939,8 +964,10 @@ protected: _LIBCPP_INLINE_VISIBILITY const allocator_type& __alloc() const _NOEXCEPT {return __size_.second();} + _LIBCPP_INLINE_VISIBILITY __deque_base() _NOEXCEPT_(is_nothrow_default_constructible::value); + _LIBCPP_INLINE_VISIBILITY explicit __deque_base(const allocator_type& __a); public: ~__deque_base(); @@ -996,6 +1023,11 @@ private: {} }; +template +const typename __deque_base<_Tp, _Allocator>::difference_type + __deque_base<_Tp, _Allocator>::__block_size = + __deque_block_size::value; + template bool __deque_base<_Tp, _Allocator>::__invariants() const @@ -1060,13 +1092,13 @@ __deque_base<_Tp, _Allocator>::end() const _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline __deque_base<_Tp, _Allocator>::__deque_base() _NOEXCEPT_(is_nothrow_default_constructible::value) : __start_(0), __size_(0) {} template -inline _LIBCPP_INLINE_VISIBILITY +inline __deque_base<_Tp, _Allocator>::__deque_base(const allocator_type& __a) : __map_(__pointer_allocator(__a)), __start_(0), __size_(0, __a) {} @@ -1164,6 +1196,9 @@ public: typedef _Tp value_type; typedef _Allocator allocator_type; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + typedef __deque_base __base; typedef typename __base::__alloc_traits __alloc_traits; @@ -1211,8 +1246,11 @@ public: #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value); + _LIBCPP_INLINE_VISIBILITY deque(deque&& __c, const allocator_type& __a); + _LIBCPP_INLINE_VISIBILITY deque& operator=(deque&& __c) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && is_nothrow_move_assignable::value); @@ -1231,6 +1269,7 @@ public: void assign(initializer_list __il) {assign(__il.begin(), __il.end());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY allocator_type get_allocator() const _NOEXCEPT; // iterators: @@ -1283,13 +1322,21 @@ public: bool empty() const _NOEXCEPT {return __base::size() == 0;} // element access: + _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __i); + _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __i) const; + _LIBCPP_INLINE_VISIBILITY reference at(size_type __i); + _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __i) const; + _LIBCPP_INLINE_VISIBILITY reference front(); + _LIBCPP_INLINE_VISIBILITY const_reference front() const; + _LIBCPP_INLINE_VISIBILITY reference back(); + _LIBCPP_INLINE_VISIBILITY const_reference back() const; // 23.2.2.3 modifiers: @@ -1328,6 +1375,7 @@ public: iterator erase(const_iterator __p); iterator erase(const_iterator __f, const_iterator __l); + _LIBCPP_INLINE_VISIBILITY void swap(deque& __c) #if _LIBCPP_STD_VER >= 14 _NOEXCEPT; @@ -1335,6 +1383,7 @@ public: _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable::value); #endif + _LIBCPP_INLINE_VISIBILITY void clear() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -1507,7 +1556,7 @@ deque<_Tp, _Allocator>::operator=(const deque& __c) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline deque<_Tp, _Allocator>::deque(deque&& __c) _NOEXCEPT_(is_nothrow_move_constructible<__base>::value) : __base(_VSTD::move(__c)) @@ -1515,7 +1564,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a) : __base(_VSTD::move(__c), __a) { @@ -1527,7 +1576,7 @@ deque<_Tp, _Allocator>::deque(deque&& __c, const allocator_type& __a) } template -inline _LIBCPP_INLINE_VISIBILITY +inline deque<_Tp, _Allocator>& deque<_Tp, _Allocator>::operator=(deque&& __c) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && @@ -1611,7 +1660,7 @@ deque<_Tp, _Allocator>::assign(size_type __n, const value_type& __v) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Allocator deque<_Tp, _Allocator>::get_allocator() const _NOEXCEPT { @@ -1670,7 +1719,7 @@ deque<_Tp, _Allocator>::shrink_to_fit() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::operator[](size_type __i) { @@ -1679,7 +1728,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::operator[](size_type __i) const { @@ -1688,7 +1737,7 @@ deque<_Tp, _Allocator>::operator[](size_type __i) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::at(size_type __i) { @@ -1699,7 +1748,7 @@ deque<_Tp, _Allocator>::at(size_type __i) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::at(size_type __i) const { @@ -1710,7 +1759,7 @@ deque<_Tp, _Allocator>::at(size_type __i) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::front() { @@ -1719,7 +1768,7 @@ deque<_Tp, _Allocator>::front() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::front() const { @@ -1728,7 +1777,7 @@ deque<_Tp, _Allocator>::front() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::reference deque<_Tp, _Allocator>::back() { @@ -1737,7 +1786,7 @@ deque<_Tp, _Allocator>::back() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename deque<_Tp, _Allocator>::const_reference deque<_Tp, _Allocator>::back() const { @@ -2029,7 +2078,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty if (__n > __front_spare()) __add_front_capacity(__n - __front_spare()); // __n <= __front_spare() - size_type __old_n = __n; iterator __old_begin = __base::begin(); iterator __i = __old_begin; if (__n > __pos) @@ -2054,7 +2102,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, size_type __n, const value_ty if (__n > __back_capacity) __add_back_capacity(__n - __back_capacity); // __n <= __back_capacity - size_type __old_n = __n; iterator __old_end = __base::end(); iterator __i = __old_end; size_type __de = __base::size() - __pos; @@ -2119,7 +2166,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, if (__n > __front_spare()) __add_front_capacity(__n - __front_spare()); // __n <= __front_spare() - size_type __old_n = __n; iterator __old_begin = __base::begin(); iterator __i = __old_begin; _BiIter __m = __f; @@ -2150,7 +2196,6 @@ deque<_Tp, _Allocator>::insert(const_iterator __p, _BiIter __f, _BiIter __l, if (__n > __back_capacity) __add_back_capacity(__n - __back_capacity); // __n <= __back_capacity - size_type __old_n = __n; iterator __old_end = __base::end(); iterator __i = __old_end; _BiIter __m = __l; @@ -2685,7 +2730,6 @@ template typename deque<_Tp, _Allocator>::iterator deque<_Tp, _Allocator>::erase(const_iterator __f) { - difference_type __n = 1; iterator __b = __base::begin(); difference_type __pos = __f - __b; iterator __p = __b + __pos; @@ -2781,7 +2825,7 @@ deque<_Tp, _Allocator>::__erase_to_end(const_iterator __f) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void deque<_Tp, _Allocator>::swap(deque& __c) #if _LIBCPP_STD_VER >= 14 @@ -2795,7 +2839,7 @@ deque<_Tp, _Allocator>::swap(deque& __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void deque<_Tp, _Allocator>::clear() _NOEXCEPT { diff --git a/include/errno.h b/include/errno.h new file mode 100644 index 000000000000..ee6429110cc1 --- /dev/null +++ b/include/errno.h @@ -0,0 +1,398 @@ +// -*- C++ -*- +//===-------------------------- errno.h -----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_ERRNO_H +#define _LIBCPP_ERRNO_H + +/* + errno.h synopsis + +Macros: + + EDOM + EILSEQ // C99 + ERANGE + errno + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#if !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) + +#ifdef ELAST + +static const int __elast1 = ELAST+1; +static const int __elast2 = ELAST+2; + +#else + +static const int __elast1 = 104; +static const int __elast2 = 105; + +#endif + +#ifdef ENOTRECOVERABLE + +#define EOWNERDEAD __elast1 + +#ifdef ELAST +#undef ELAST +#define ELAST EOWNERDEAD +#endif + +#elif defined(EOWNERDEAD) + +#define ENOTRECOVERABLE __elast1 +#ifdef ELAST +#undef ELAST +#define ELAST ENOTRECOVERABLE +#endif + +#else // defined(EOWNERDEAD) + +#define EOWNERDEAD __elast1 +#define ENOTRECOVERABLE __elast2 +#ifdef ELAST +#undef ELAST +#define ELAST ENOTRECOVERABLE +#endif + +#endif // defined(EOWNERDEAD) + +#endif // !defined(EOWNERDEAD) || !defined(ENOTRECOVERABLE) + +// supply errno values likely to be missing, particularly on Windows + +#ifndef EAFNOSUPPORT +#define EAFNOSUPPORT 9901 +#endif + +#ifndef EADDRINUSE +#define EADDRINUSE 9902 +#endif + +#ifndef EADDRNOTAVAIL +#define EADDRNOTAVAIL 9903 +#endif + +#ifndef EISCONN +#define EISCONN 9904 +#endif + +#ifndef EBADMSG +#define EBADMSG 9905 +#endif + +#ifndef ECONNABORTED +#define ECONNABORTED 9906 +#endif + +#ifndef EALREADY +#define EALREADY 9907 +#endif + +#ifndef ECONNREFUSED +#define ECONNREFUSED 9908 +#endif + +#ifndef ECONNRESET +#define ECONNRESET 9909 +#endif + +#ifndef EDESTADDRREQ +#define EDESTADDRREQ 9910 +#endif + +#ifndef EHOSTUNREACH +#define EHOSTUNREACH 9911 +#endif + +#ifndef EIDRM +#define EIDRM 9912 +#endif + +#ifndef EMSGSIZE +#define EMSGSIZE 9913 +#endif + +#ifndef ENETDOWN +#define ENETDOWN 9914 +#endif + +#ifndef ENETRESET +#define ENETRESET 9915 +#endif + +#ifndef ENETUNREACH +#define ENETUNREACH 9916 +#endif + +#ifndef ENOBUFS +#define ENOBUFS 9917 +#endif + +#ifndef ENOLINK +#define ENOLINK 9918 +#endif + +#ifndef ENODATA +#define ENODATA 9919 +#endif + +#ifndef ENOMSG +#define ENOMSG 9920 +#endif + +#ifndef ENOPROTOOPT +#define ENOPROTOOPT 9921 +#endif + +#ifndef ENOSR +#define ENOSR 9922 +#endif + +#ifndef ENOTSOCK +#define ENOTSOCK 9923 +#endif + +#ifndef ENOSTR +#define ENOSTR 9924 +#endif + +#ifndef ENOTCONN +#define ENOTCONN 9925 +#endif + +#ifndef ENOTSUP +#define ENOTSUP 9926 +#endif + +#ifndef ECANCELED +#define ECANCELED 9927 +#endif + +#ifndef EINPROGRESS +#define EINPROGRESS 9928 +#endif + +#ifndef EOPNOTSUPP +#define EOPNOTSUPP 9929 +#endif + +#ifndef EWOULDBLOCK +#define EWOULDBLOCK 9930 +#endif + +#ifndef EOWNERDEAD +#define EOWNERDEAD 9931 +#endif + +#ifndef EPROTO +#define EPROTO 9932 +#endif + +#ifndef EPROTONOSUPPORT +#define EPROTONOSUPPORT 9933 +#endif + +#ifndef ENOTRECOVERABLE +#define ENOTRECOVERABLE 9934 +#endif + +#ifndef ETIME +#define ETIME 9935 +#endif + +#ifndef ETXTBSY +#define ETXTBSY 9936 +#endif + +#ifndef ETIMEDOUT +#define ETIMEDOUT 9938 +#endif + +#ifndef ELOOP +#define ELOOP 9939 +#endif + +#ifndef EOVERFLOW +#define EOVERFLOW 9940 +#endif + +#ifndef EPROTOTYPE +#define EPROTOTYPE 9941 +#endif + +#ifndef ENOSYS +#define ENOSYS 9942 +#endif + +#ifndef EINVAL +#define EINVAL 9943 +#endif + +#ifndef ERANGE +#define ERANGE 9944 +#endif + +#ifndef EILSEQ +#define EILSEQ 9945 +#endif + +// Windows Mobile doesn't appear to define these: + +#ifndef E2BIG +#define E2BIG 9946 +#endif + +#ifndef EDOM +#define EDOM 9947 +#endif + +#ifndef EFAULT +#define EFAULT 9948 +#endif + +#ifndef EBADF +#define EBADF 9949 +#endif + +#ifndef EPIPE +#define EPIPE 9950 +#endif + +#ifndef EXDEV +#define EXDEV 9951 +#endif + +#ifndef EBUSY +#define EBUSY 9952 +#endif + +#ifndef ENOTEMPTY +#define ENOTEMPTY 9953 +#endif + +#ifndef ENOEXEC +#define ENOEXEC 9954 +#endif + +#ifndef EEXIST +#define EEXIST 9955 +#endif + +#ifndef EFBIG +#define EFBIG 9956 +#endif + +#ifndef ENAMETOOLONG +#define ENAMETOOLONG 9957 +#endif + +#ifndef ENOTTY +#define ENOTTY 9958 +#endif + +#ifndef EINTR +#define EINTR 9959 +#endif + +#ifndef ESPIPE +#define ESPIPE 9960 +#endif + +#ifndef EIO +#define EIO 9961 +#endif + +#ifndef EISDIR +#define EISDIR 9962 +#endif + +#ifndef ECHILD +#define ECHILD 9963 +#endif + +#ifndef ENOLCK +#define ENOLCK 9964 +#endif + +#ifndef ENOSPC +#define ENOSPC 9965 +#endif + +#ifndef ENXIO +#define ENXIO 9966 +#endif + +#ifndef ENODEV +#define ENODEV 9967 +#endif + +#ifndef ENOENT +#define ENOENT 9968 +#endif + +#ifndef ESRCH +#define ESRCH 9969 +#endif + +#ifndef ENOTDIR +#define ENOTDIR 9970 +#endif + +#ifndef ENOMEM +#define ENOMEM 9971 +#endif + +#ifndef EPERM +#define EPERM 9972 +#endif + +#ifndef EACCES +#define EACCES 9973 +#endif + +#ifndef EROFS +#define EROFS 9974 +#endif + +#ifndef EDEADLK +#define EDEADLK 9975 +#endif + +#ifndef EAGAIN +#define EAGAIN 9976 +#endif + +#ifndef ENFILE +#define ENFILE 9977 +#endif + +#ifndef EMFILE +#define EMFILE 9978 +#endif + +#ifndef EMLINK +#define EMLINK 9979 +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_ERRNO_H diff --git a/include/exception b/include/exception index 5a905e7e58d8..686e4ecd0578 100644 --- a/include/exception +++ b/include/exception @@ -235,7 +235,7 @@ rethrow_if_nested(const _Ep& __e, typename enable_if< is_polymorphic<_Ep>::value >::type* = 0) { - const nested_exception* __nep = dynamic_cast(&__e); + const nested_exception* __nep = dynamic_cast(_VSTD::addressof(__e)); if (__nep) __nep->rethrow_nested(); } diff --git a/include/experimental/algorithm b/include/experimental/algorithm index a2e956f281a0..ffaa793b6d4e 100644 --- a/include/experimental/algorithm +++ b/include/experimental/algorithm @@ -50,6 +50,12 @@ SampleIterator sample(PopulationIterator first, PopulationIterator last, _LIBCPP_BEGIN_NAMESPACE_LFTS +template +_LIBCPP_INLINE_VISIBILITY +_ForwardIterator search(_ForwardIterator __f, _ForwardIterator __l, const _Searcher &__s) +{ return __s(__f, __l); } + + template _LIBCPP_INLINE_VISIBILITY diff --git a/include/experimental/any b/include/experimental/any new file mode 100644 index 000000000000..603788484dd5 --- /dev/null +++ b/include/experimental/any @@ -0,0 +1,590 @@ +// -*- C++ -*- +//===------------------------------ any -----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_ANY +#define _LIBCPP_EXPERIMENTAL_ANY + +/* + experimental/any synopsis + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + class bad_any_cast : public bad_cast + { + public: + virtual const char* what() const noexcept; + }; + + class any + { + public: + + // 6.3.1 any construct/destruct + any() noexcept; + + any(const any& other); + any(any&& other) noexcept; + + template + any(ValueType&& value); + + ~any(); + + // 6.3.2 any assignments + any& operator=(const any& rhs); + any& operator=(any&& rhs) noexcept; + + template + any& operator=(ValueType&& rhs); + + // 6.3.3 any modifiers + void clear() noexcept; + void swap(any& rhs) noexcept; + + // 6.3.4 any observers + bool empty() const noexcept; + const type_info& type() const noexcept; + }; + + // 6.4 Non-member functions + void swap(any& x, any& y) noexcept; + + template + ValueType any_cast(const any& operand); + template + ValueType any_cast(any& operand); + template + ValueType any_cast(any&& operand); + + template + const ValueType* any_cast(const any* operand) noexcept; + template + ValueType* any_cast(any* operand) noexcept; + +} // namespace fundamentals_v1 +} // namespace experimental +} // namespace std + +*/ + +#include +#include +#include +#include +#include +#include +#include + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +class _LIBCPP_EXCEPTION_ABI bad_any_cast : public bad_cast +{ +public: + virtual const char* what() const _NOEXCEPT; +}; + +#if _LIBCPP_STD_VER > 11 // C++ > 11 + +_LIBCPP_NORETURN _LIBCPP_INLINE_VISIBILITY +inline void __throw_bad_any_cast() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_any_cast(); +#else + assert(!"bad_any_cast"); +#endif +} + +// Forward declarations +class any; + +template +typename add_pointer::type>::type +any_cast(any const *) _NOEXCEPT; + +template +typename add_pointer<_ValueType>::type +any_cast(any *) _NOEXCEPT; + +namespace __any_imp +{ + typedef typename aligned_storage<3*sizeof(void*), alignment_of::value>::type + _Buffer; + + template + struct _IsSmallObject + : public integral_constant::value + % alignment_of<_Tp>::value == 0 + && is_nothrow_move_constructible<_Tp>::value + > + {}; + + enum class _Action + { + _Destroy, + _Copy, + _Move, + _Get, + _TypeInfo + }; + + template + struct _SmallHandler; + + template + struct _LargeHandler; + + template + using _Handler = typename conditional<_IsSmallObject<_Tp>::value + , _SmallHandler<_Tp> + , _LargeHandler<_Tp> + >::type; + template + using _EnableIfNotAny = typename + enable_if< + !is_same::type, any>::value + >::type; + +} // namespace __any_imp + +class any +{ +public: + // 6.3.1 any construct/destruct + _LIBCPP_INLINE_VISIBILITY + any() _NOEXCEPT : __h(nullptr) {} + + _LIBCPP_INLINE_VISIBILITY + any(any const & __other) : __h(nullptr) + { + if (__other.__h) __other.__call(_Action::_Copy, this); + } + + _LIBCPP_INLINE_VISIBILITY + any(any && __other) _NOEXCEPT : __h(nullptr) + { + if (__other.__h) __other.__call(_Action::_Move, this); + } + + template < + class _ValueType + , class = __any_imp::_EnableIfNotAny<_ValueType> + > + any(_ValueType && __value); + + _LIBCPP_INLINE_VISIBILITY + ~any() + { + this->clear(); + } + + // 6.3.2 any assignments + _LIBCPP_INLINE_VISIBILITY + any & operator=(any const & __rhs) + { + any(__rhs).swap(*this); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + any & operator=(any && __rhs) _NOEXCEPT + { + any(_VSTD::move(__rhs)).swap(*this); + return *this; + } + + template < + class _ValueType + , class = __any_imp::_EnableIfNotAny<_ValueType> + > + any & operator=(_ValueType && __rhs); + + // 6.3.3 any modifiers + _LIBCPP_INLINE_VISIBILITY + void clear() _NOEXCEPT + { + if (__h) this->__call(_Action::_Destroy); + } + + void swap(any & __rhs) _NOEXCEPT; + + // 6.3.4 any observers + _LIBCPP_INLINE_VISIBILITY + bool empty() const _NOEXCEPT + { + return __h == nullptr; + } + +#if !defined(_LIBCPP_NO_RTTI) + _LIBCPP_INLINE_VISIBILITY + const type_info & type() const _NOEXCEPT + { + if (__h) { + return *static_cast(this->__call(_Action::_TypeInfo)); + } else { + return typeid(void); + } + } +#endif + +private: + typedef __any_imp::_Action _Action; + + typedef void* (*_HandleFuncPtr)(_Action, any const *, any *, const type_info *); + + union _Storage + { + void * __ptr; + __any_imp::_Buffer __buf; + }; + + _LIBCPP_ALWAYS_INLINE + void * __call(_Action __a, any * __other = nullptr, + type_info const * __info = nullptr) const + { + return __h(__a, this, __other, __info); + } + + _LIBCPP_ALWAYS_INLINE + void * __call(_Action __a, any * __other = nullptr, + type_info const * __info = nullptr) + { + return __h(__a, this, __other, __info); + } + + template + friend struct __any_imp::_SmallHandler; + template + friend struct __any_imp::_LargeHandler; + + template + friend typename add_pointer::type>::type + any_cast(any const *) _NOEXCEPT; + + template + friend typename add_pointer<_ValueType>::type + any_cast(any *) _NOEXCEPT; + + _HandleFuncPtr __h; + _Storage __s; +}; + +namespace __any_imp +{ + + template + struct _LIBCPP_TYPE_VIS_ONLY _SmallHandler + { + _LIBCPP_INLINE_VISIBILITY + static void* __handle(_Action __act, any const * __this, any * __other, + type_info const * __info) + { + switch (__act) + { + case _Action::_Destroy: + __destroy(const_cast(*__this)); + return nullptr; + case _Action::_Copy: + __copy(*__this, *__other); + return nullptr; + case _Action::_Move: + __move(const_cast(*__this), *__other); + return nullptr; + case _Action::_Get: + return __get(const_cast(*__this), __info); + case _Action::_TypeInfo: + return __type_info(); + } + } + + template + _LIBCPP_INLINE_VISIBILITY + static void __create(any & __dest, _Up && __v) + { + ::new (static_cast(&__dest.__s.__buf)) _Tp(_VSTD::forward<_Up>(__v)); + __dest.__h = &_SmallHandler::__handle; + } + + private: + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __destroy(any & __this) + { + _Tp & __value = *static_cast<_Tp *>(static_cast(&__this.__s.__buf)); + __value.~_Tp(); + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __copy(any const & __this, any & __dest) + { + _SmallHandler::__create(__dest, *static_cast<_Tp const *>( + static_cast(&__this.__s.__buf))); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __move(any & __this, any & __dest) + { + _SmallHandler::__create(__dest, _VSTD::move( + *static_cast<_Tp*>(static_cast(&__this.__s.__buf)))); + __destroy(__this); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __get(any & __this, type_info const * __info) + { +#if !defined(_LIBCPP_NO_RTTI) + if (typeid(_Tp) == *__info) { + return static_cast(&__this.__s.__buf); + } + return nullptr; +#else + return static_cast(&__this.__s.__buf); +#endif + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __type_info() + { +#if !defined(_LIBCPP_NO_RTTI) + return const_cast(static_cast(&typeid(_Tp))); +#else + return nullptr; +#endif + } + }; + + template + struct _LIBCPP_TYPE_VIS_ONLY _LargeHandler + { + _LIBCPP_INLINE_VISIBILITY + static void* __handle(_Action __act, any const * __this, any * __other, + type_info const * __info) + { + switch (__act) + { + case _Action::_Destroy: + __destroy(const_cast(*__this)); + return nullptr; + case _Action::_Copy: + __copy(*__this, *__other); + return nullptr; + case _Action::_Move: + __move(const_cast(*__this), *__other); + return nullptr; + case _Action::_Get: + return __get(const_cast(*__this), __info); + case _Action::_TypeInfo: + return __type_info(); + } + } + + template + _LIBCPP_INLINE_VISIBILITY + static void __create(any & __dest, _Up && __v) + { + typedef allocator<_Tp> _Alloc; + typedef __allocator_destructor<_Alloc> _Dp; + _Alloc __a; + unique_ptr<_Tp, _Dp> __hold(__a.allocate(1), _Dp(__a, 1)); + ::new ((void*)__hold.get()) _Tp(_VSTD::forward<_Up>(__v)); + __dest.__s.__ptr = __hold.release(); + __dest.__h = &_LargeHandler::__handle; + } + + private: + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __destroy(any & __this) + { + delete static_cast<_Tp*>(__this.__s.__ptr); + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __copy(any const & __this, any & __dest) + { + _LargeHandler::__create(__dest, *static_cast<_Tp const *>(__this.__s.__ptr)); + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void __move(any & __this, any & __dest) + { + __dest.__s.__ptr = __this.__s.__ptr; + __dest.__h = &_LargeHandler::__handle; + __this.__h = nullptr; + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __get(any & __this, type_info const * __info) + { +#if !defined(_LIBCPP_NO_RTTI) + if (typeid(_Tp) == *__info) { + return static_cast(__this.__s.__ptr); + } + return nullptr; +#else + return static_cast(__this.__s.__ptr); +#endif + } + + _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY + static void* __type_info() + { +#if !defined(_LIBCPP_NO_RTTI) + return const_cast(static_cast(&typeid(_Tp))); +#else + return nullptr; +#endif + } + }; + +} // namespace __any_imp + + +template +_LIBCPP_INLINE_VISIBILITY +any::any(_ValueType && __v) : __h(nullptr) +{ + typedef typename decay<_ValueType>::type _Tp; + static_assert(is_copy_constructible<_Tp>::value, + "_ValueType must be CopyConstructible."); + typedef __any_imp::_Handler<_Tp> _HandlerType; + _HandlerType::__create(*this, _VSTD::forward<_ValueType>(__v)); +} + +template +_LIBCPP_INLINE_VISIBILITY +any & any::operator=(_ValueType && __v) +{ + typedef typename decay<_ValueType>::type _Tp; + static_assert(is_copy_constructible<_Tp>::value, + "_ValueType must be CopyConstructible."); + any(_VSTD::forward<_ValueType>(__v)).swap(*this); + return *this; +} + +inline _LIBCPP_INLINE_VISIBILITY +void any::swap(any & __rhs) _NOEXCEPT +{ + if (__h && __rhs.__h) { + any __tmp; + __rhs.__call(_Action::_Move, &__tmp); + this->__call(_Action::_Move, &__rhs); + __tmp.__call(_Action::_Move, this); + } + else if (__h) { + this->__call(_Action::_Move, &__rhs); + } + else if (__rhs.__h) { + __rhs.__call(_Action::_Move, this); + } +} + +// 6.4 Non-member functions + +inline _LIBCPP_INLINE_VISIBILITY +void swap(any & __lhs, any & __rhs) _NOEXCEPT +{ + __lhs.swap(__rhs); +} + +template +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any const & __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename add_const::type>::type + _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any & __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename remove_reference<_ValueType>::type _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template +_LIBCPP_INLINE_VISIBILITY +_ValueType any_cast(any && __v) +{ + static_assert( + is_reference<_ValueType>::value + || is_copy_constructible<_ValueType>::value, + "_ValueType is required to be a reference or a CopyConstructible type."); + typedef typename remove_reference<_ValueType>::type _Tp; + _Tp * __tmp = any_cast<_Tp>(&__v); + if (__tmp == nullptr) + __throw_bad_any_cast(); + return *__tmp; +} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename add_pointer::type>::type +any_cast(any const * __any) _NOEXCEPT +{ + static_assert(!is_reference<_ValueType>::value, + "_ValueType may not be a reference."); + return any_cast<_ValueType>(const_cast(__any)); +} + +template +_LIBCPP_INLINE_VISIBILITY +typename add_pointer<_ValueType>::type +any_cast(any * __any) _NOEXCEPT +{ + using __any_imp::_Action; + static_assert(!is_reference<_ValueType>::value, + "_ValueType may not be a reference."); + typedef typename add_pointer<_ValueType>::type _ReturnType; + if (__any && __any->__h) { + + return static_cast<_ReturnType>( + __any->__call(_Action::_Get, nullptr, +#if !defined(_LIBCPP_NO_RTTI) + &typeid(_ValueType) +#else + nullptr +#endif + )); + + } + return nullptr; +} + +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_LFTS + +#endif // _LIBCPP_EXPERIMENTAL_ANY diff --git a/include/experimental/dynarray b/include/experimental/dynarray index a0258628dfa6..f40a6ca188b8 100644 --- a/include/experimental/dynarray +++ b/include/experimental/dynarray @@ -137,7 +137,7 @@ public: private: size_t __size_; value_type * __base_; - _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {} + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __size_(0), __base_(nullptr) {} static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) { diff --git a/include/experimental/functional b/include/experimental/functional new file mode 100644 index 000000000000..c7a78695b809 --- /dev/null +++ b/include/experimental/functional @@ -0,0 +1,454 @@ +// -*- C++ -*- +//===-------------------------- functional --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_EXPERIMENTAL_FUNCTIONAL +#define _LIBCPP_EXPERIMENTAL_FUNCTIONAL + +/* + experimental/functional synopsis + +#include + +namespace std { +namespace experimental { +inline namespace fundamentals_v1 { + + // See C++14 20.9.9, Function object binders + template constexpr bool is_bind_expression_v + = is_bind_expression::value; + template constexpr int is_placeholder_v + = is_placeholder::value; + + // 4.2, Class template function + template class function; // undefined + template class function; + + template + void swap(function&, function&); + + template + bool operator==(const function&, nullptr_t) noexcept; + template + bool operator==(nullptr_t, const function&) noexcept; + template + bool operator!=(const function&, nullptr_t) noexcept; + template + bool operator!=(nullptr_t, const function&) noexcept; + + // 4.3, Searchers + template> + class default_searcher; + + template::value_type>, + class BinaryPredicate = equal_to<>> + class boyer_moore_searcher; + + template::value_type>, + class BinaryPredicate = equal_to<>> + class boyer_moore_horspool_searcher; + + template> + default_searcher + make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last, + BinaryPredicate pred = BinaryPredicate()); + + template::value_type>, + class BinaryPredicate = equal_to<>> + boyer_moore_searcher + make_boyer_moore_searcher( + RandomAccessIterator pat_first, RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + + template::value_type>, + class BinaryPredicate = equal_to<>> + boyer_moore_horspool_searcher + make_boyer_moore_horspool_searcher( + RandomAccessIterator pat_first, RandomAccessIterator pat_last, + Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); + + } // namespace fundamentals_v1 + } // namespace experimental + + template + struct uses_allocator, Alloc>; + +} // namespace std + +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include <__undef_min_max> + +#include <__debug> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +#if _LIBCPP_STD_VER > 11 +// default searcher +template> +_LIBCPP_TYPE_VIS +class default_searcher { +public: + _LIBCPP_INLINE_VISIBILITY + default_searcher(_ForwardIterator __f, _ForwardIterator __l, + _BinaryPredicate __p = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__p) {} + + template + _LIBCPP_INLINE_VISIBILITY + _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const + { + return _VSTD::search(__f, __l, __first_, __last_, __pred_); + } + +private: + _ForwardIterator __first_; + _ForwardIterator __last_; + _BinaryPredicate __pred_; + }; + +template> +_LIBCPP_INLINE_VISIBILITY +default_searcher<_ForwardIterator, _BinaryPredicate> +make_default_searcher( _ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate ()) +{ + return default_searcher<_ForwardIterator, _BinaryPredicate>(__f, __l, __p); +} + +template class _BMSkipTable; + +// General case for BM data searching; use a map +template +class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> { +public: // TODO private: + typedef _Value value_type; + typedef _Key key_type; + + const _Value __default_value_; + std::unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(std::size_t __sz, _Value __default, _Hash __hf, _BinaryPredicate __pred) + : __default_value_(__default), __table(__sz, __hf, __pred) {} + + _LIBCPP_INLINE_VISIBILITY + void insert(const key_type &__key, value_type __val) + { + __table [__key] = __val; // Would skip_.insert (val) be better here? + } + + _LIBCPP_INLINE_VISIBILITY + value_type operator [](const key_type & __key) const + { + auto __it = __table.find (__key); + return __it == __table.end() ? __default_value_ : __it->second; + } +}; + + +// Special case small numeric values; use an array +template +class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> { +private: + typedef _Value value_type; + typedef _Key key_type; + + typedef typename std::make_unsigned::type unsigned_key_type; + typedef std::array::max()> skip_map; + skip_map __table; + +public: + _LIBCPP_INLINE_VISIBILITY + _BMSkipTable(std::size_t /*__sz*/, _Value __default, _Hash /*__hf*/, _BinaryPredicate /*__pred*/) + { + std::fill_n(__table.begin(), __table.size(), __default); + } + + _LIBCPP_INLINE_VISIBILITY + void insert(key_type __key, value_type __val) + { + __table[static_cast(__key)] = __val; + } + + _LIBCPP_INLINE_VISIBILITY + value_type operator [](key_type __key) const + { + return __table[static_cast(__key)]; + } +}; + + +template ::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class boyer_moore_searcher { +private: + typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; + typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; + typedef _BMSkipTable::value && // what about enums? + sizeof(value_type) == 1 && + is_same<_Hash, hash>::value && + is_same<_BinaryPredicate, equal_to<>>::value + > skip_table_type; + +public: + boyer_moore_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__pred), + __pattern_length_(_VSTD::distance(__first_, __last_)), + __skip_{make_shared(__pattern_length_, -1, __hf, __pred_)}, + __suffix_{make_shared>(__pattern_length_ + 1)} + { + // build the skip table + for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i ) + __skip_->insert(*__f, __i); + + this->__build_suffix_table ( __first_, __last_, __pred_ ); + } + + template + _RandomAccessIterator2 + operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + static_assert ( std::is_same< + typename std::decay::value_type>::type, + typename std::decay::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + if (__f == __l ) return __l; // empty corpus + if (__first_ == __last_) return __f; // empty pattern + + // If the pattern is larger than the corpus, we can't find it! + if ( __pattern_length_ > _VSTD::distance (__f, __l)) + return __l; + + // Do the search + return this->__search(__f, __l); + } + +public: // TODO private: + _RandomAccessIterator1 __first_; + _RandomAccessIterator1 __last_; + _BinaryPredicate __pred_; + difference_type __pattern_length_; + shared_ptr __skip_; + shared_ptr> __suffix_; + + template + _RandomAccessIterator2 __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + _RandomAccessIterator2 __cur = __f; + const _RandomAccessIterator2 __last = __l - __pattern_length_; + const skip_table_type & __skip = *__skip_.get(); + const vector & __suffix = *__suffix_.get(); + + while (__cur <= __last) + { + + // Do we match right where we are? + difference_type __j = __pattern_length_; + while (__pred_(__first_ [__j-1], __cur [__j-1])) { + __j--; + // We matched - we're done! + if ( __j == 0 ) + return __cur; + } + + // Since we didn't match, figure out how far to skip forward + difference_type __k = __skip[__cur [ __j - 1 ]]; + difference_type __m = __j - __k - 1; + if (__k < __j && __m > __suffix[ __j ]) + __cur += __m; + else + __cur += __suffix[ __j ]; + } + + return __l; // We didn't find anything + } + + + template + void __compute_bm_prefix ( _Iterator __f, _Iterator __l, _BinaryPredicate __pred, _Container &__prefix ) + { + const std::size_t __count = _VSTD::distance(__f, __l); + + __prefix[0] = 0; + std::size_t __k = 0; + for ( std::size_t __i = 1; __i < __count; ++__i ) + { + while ( __k > 0 && !__pred ( __f[__k], __f[__i] )) + __k = __prefix [ __k - 1 ]; + + if ( __pred ( __f[__k], __f[__i] )) + __k++; + __prefix [ __i ] = __k; + } + } + + void __build_suffix_table(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _BinaryPredicate __pred) + { + const std::size_t __count = _VSTD::distance(__f, __l); + vector & __suffix = *__suffix_.get(); + if (__count > 0) + { + _VSTD::vector __scratch(__count); + + __compute_bm_prefix(__f, __l, __pred, __scratch); + for ( std::size_t __i = 0; __i <= __count; __i++ ) + __suffix[__i] = __count - __scratch[__count-1]; + + typedef _VSTD::reverse_iterator<_RandomAccessIterator1> _RevIter; + __compute_bm_prefix(_RevIter(__l), _RevIter(__f), __pred, __scratch); + + for ( std::size_t __i = 0; __i < __count; __i++ ) + { + const std::size_t __j = __count - __scratch[__i]; + const difference_type __k = __i - __scratch[__i] + 1; + + if (__suffix[__j] > __k) + __suffix[__j] = __k; + } + } + } + +}; + +template::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> +make_boyer_moore_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, + _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) +{ + return boyer_moore_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p); +} + +// boyer-moore-horspool +template ::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_TYPE_VIS +class boyer_moore_horspool_searcher { +private: + typedef typename std::iterator_traits<_RandomAccessIterator1>::difference_type difference_type; + typedef typename std::iterator_traits<_RandomAccessIterator1>::value_type value_type; + typedef _BMSkipTable::value && // what about enums? + sizeof(value_type) == 1 && + is_same<_Hash, hash>::value && + is_same<_BinaryPredicate, equal_to<>>::value + > skip_table_type; + +public: + boyer_moore_horspool_searcher(_RandomAccessIterator1 __f, _RandomAccessIterator1 __l, + _Hash __hf = _Hash(), _BinaryPredicate __pred = _BinaryPredicate()) + : __first_(__f), __last_(__l), __pred_(__pred), + __pattern_length_(_VSTD::distance(__first_, __last_)), + __skip_{_VSTD::make_shared(__pattern_length_, __pattern_length_, __hf, __pred_)} + { + // build the skip table + if ( __f != __l ) + { + __l = __l - 1; + for ( difference_type __i = 0; __f != __l; ++__f, (void) ++__i ) + __skip_->insert(*__f, __pattern_length_ - 1 - __i); + } + } + + template + _RandomAccessIterator2 + operator ()(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const + { + static_assert ( std::is_same< + typename std::decay::value_type>::type, + typename std::decay::value_type>::type + >::value, + "Corpus and Pattern iterators must point to the same type" ); + + if (__f == __l ) return __l; // empty corpus + if (__first_ == __last_) return __f; // empty pattern + + // If the pattern is larger than the corpus, we can't find it! + if ( __pattern_length_ > _VSTD::distance (__f, __l)) + return __l; + + // Do the search + return this->__search(__f, __l); + } + +private: + _RandomAccessIterator1 __first_; + _RandomAccessIterator1 __last_; + _BinaryPredicate __pred_; + difference_type __pattern_length_; + shared_ptr __skip_; + + template + _RandomAccessIterator2 __search ( _RandomAccessIterator2 __f, _RandomAccessIterator2 __l ) const { + _RandomAccessIterator2 __cur = __f; + const _RandomAccessIterator2 __last = __l - __pattern_length_; + const skip_table_type & __skip = *__skip_.get(); + + while (__cur <= __last) + { + // Do we match right where we are? + difference_type __j = __pattern_length_; + while (__pred_(__first_[__j-1], __cur[__j-1])) + { + __j--; + // We matched - we're done! + if ( __j == 0 ) + return __cur; + } + __cur += __skip[__cur[__pattern_length_-1]]; + } + + return __l; + } +}; + +template::value_type>, + class _BinaryPredicate = equal_to<>> +_LIBCPP_INLINE_VISIBILITY +boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate> +make_boyer_moore_horspool_searcher( _RandomAccessIterator __f, _RandomAccessIterator __l, + _Hash __hf = _Hash(), _BinaryPredicate __p = _BinaryPredicate ()) +{ + return boyer_moore_horspool_searcher<_RandomAccessIterator, _Hash, _BinaryPredicate>(__f, __l, __hf, __p); +} + +#endif // _LIBCPP_STD_VER > 11 + +_LIBCPP_END_NAMESPACE_LFTS + +#endif /* _LIBCPP_EXPERIMENTAL_FUNCTIONAL */ diff --git a/include/ext/hash_map b/include/ext/hash_map index 31fcedfb9f9e..0e4ab6910eb5 100644 --- a/include/ext/hash_map +++ b/include/ext/hash_map @@ -681,7 +681,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template diff --git a/include/float.h b/include/float.h new file mode 100644 index 000000000000..1acfdc6188f2 --- /dev/null +++ b/include/float.h @@ -0,0 +1,83 @@ +// -*- C++ -*- +//===--------------------------- float.h ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_FLOAT_H +#define _LIBCPP_FLOAT_H + +/* + float.h synopsis + +Macros: + + FLT_ROUNDS + FLT_EVAL_METHOD // C99 + FLT_RADIX + + FLT_MANT_DIG + DBL_MANT_DIG + LDBL_MANT_DIG + + DECIMAL_DIG // C99 + + FLT_DIG + DBL_DIG + LDBL_DIG + + FLT_MIN_EXP + DBL_MIN_EXP + LDBL_MIN_EXP + + FLT_MIN_10_EXP + DBL_MIN_10_EXP + LDBL_MIN_10_EXP + + FLT_MAX_EXP + DBL_MAX_EXP + LDBL_MAX_EXP + + FLT_MAX_10_EXP + DBL_MAX_10_EXP + LDBL_MAX_10_EXP + + FLT_MAX + DBL_MAX + LDBL_MAX + + FLT_EPSILON + DBL_EPSILON + LDBL_EPSILON + + FLT_MIN + DBL_MIN + LDBL_MIN + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#ifndef FLT_EVAL_METHOD +#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ +#endif + +#ifndef DECIMAL_DIG +#define DECIMAL_DIG __DECIMAL_DIG__ +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_FLOAT_H diff --git a/include/forward_list b/include/forward_list index 8a87fc5e1f26..adbc32cf861c 100644 --- a/include/forward_list +++ b/include/forward_list @@ -537,6 +537,9 @@ public: typedef _Tp value_type; typedef _Alloc allocator_type; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + typedef value_type& reference; typedef const value_type& const_reference; typedef typename allocator_traits::pointer pointer; diff --git a/include/functional b/include/functional index 5ee941763020..dbe9b01bbd86 100644 --- a/include/functional +++ b/include/functional @@ -1234,11 +1234,9 @@ 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);} -#ifdef _LIBCPP_HAS_NO_VARIADICS - -#include <__functional_03> - -#else // _LIBCPP_HAS_NO_VARIADICS +//////////////////////////////////////////////////////////////////////////////// +// MEMFUN +//============================================================================== template class __mem_fn @@ -1251,26 +1249,130 @@ private: type __f_; public: - _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) : __f_(__f) {} + _LIBCPP_INLINE_VISIBILITY __mem_fn(type __f) _NOEXCEPT : __f_(__f) {} +#ifndef _LIBCPP_HAS_NO_VARIADICS // invoke template - _LIBCPP_INLINE_VISIBILITY - typename __invoke_return::type - operator() (_ArgTypes&&... __args) const - { - return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); - } + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return::type + operator() (_ArgTypes&&... __args) const { + return __invoke(__f_, _VSTD::forward<_ArgTypes>(__args)...); + } +#else + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0& __a0) const { + return __invoke(__f_, __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return0::type + operator() (_A0 const& __a0) const { + return __invoke(__f_, __a0); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0& __a0, _A1 const& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return1::type + operator() (_A0 const& __a0, _A1 const& __a1) const { + return __invoke(__f_, __a0, __a1); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1 const& __a1, _A2& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0 const& __a0, _A1& __a1, _A2 const& __a2) const { + return __invoke(__f_, __a0, __a1, __a2); + } + + template + _LIBCPP_INLINE_VISIBILITY + typename __invoke_return2::type + operator() (_A0& __a0, _A1 const& __a1, _A2 const& __a2) const { + return __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 __invoke(__f_, __a0, __a1, __a2); + } +#endif }; template inline _LIBCPP_INLINE_VISIBILITY __mem_fn<_Rp _Tp::*> -mem_fn(_Rp _Tp::* __pm) +mem_fn(_Rp _Tp::* __pm) _NOEXCEPT { return __mem_fn<_Rp _Tp::*>(__pm); } +//////////////////////////////////////////////////////////////////////////////// +// FUNCTION +//============================================================================== + // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call @@ -1283,7 +1385,7 @@ template class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { -template +template struct __maybe_derive_from_unary_function { }; @@ -1294,7 +1396,7 @@ struct __maybe_derive_from_unary_function<_Rp(_A1)> { }; -template +template struct __maybe_derive_from_binary_function { }; @@ -1305,6 +1407,28 @@ struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> { }; +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; } + +} // namespace __function + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +namespace __function { + template class __base; template @@ -1440,28 +1564,6 @@ class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> typename aligned_storage<3*sizeof(void*)>::type __buf_; __base* __f_; - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const _Fp&) {return true;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (*__p)(_Ap...)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...)) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...) volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(_R2 (_Cp::*__p)(_Ap...) const volatile) {return __p;} - template - _LIBCPP_INLINE_VISIBILITY - static bool __not_null(const function<_R2(_Ap...)>& __p) {return !!__p;} - template ::value && __invokable<_Fp&, _ArgTypes...>::value> struct __callable; @@ -1626,7 +1728,7 @@ function<_Rp(_ArgTypes...)>::function(_Fp __f, >::type*) : __f_(0) { - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, allocator<_Fp>, _Rp(_ArgTypes...)> _FF; if (sizeof(_FF) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) @@ -1653,7 +1755,7 @@ function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc& __a0, _Fp _ : __f_(0) { typedef allocator_traits<_Alloc> __alloc_traits; - if (__not_null(__f)) + if (__function::__not_null(__f)) { typedef __function::__func<_Fp, _Alloc, _Rp(_ArgTypes...)> _FF; typedef typename __rebind_alloc_helper<__alloc_traits, _FF>::type _Ap; @@ -1848,6 +1950,16 @@ void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {return __x.swap(__y);} +#else // _LIBCPP_HAS_NO_VARIADICS + +#include <__functional_03> + +#endif + +//////////////////////////////////////////////////////////////////////////////// +// BIND +//============================================================================== + template struct __is_bind_expression : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression::type> {}; @@ -1878,6 +1990,9 @@ template struct __is_placeholder > : public integral_constant {}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + template inline _LIBCPP_INLINE_VISIBILITY _Tp& @@ -2402,14 +2517,14 @@ struct _LIBCPP_TYPE_VIS_ONLY hash size_t __b; size_t __c; size_t __d; - }; + } __s; } __u; - __u.__a = 0; - __u.__b = 0; - __u.__c = 0; - __u.__d = 0; + __u.__s.__a = 0; + __u.__s.__b = 0; + __u.__s.__c = 0; + __u.__s.__d = 0; __u.__t = __v; - return __u.__a ^ __u.__b ^ __u.__c ^ __u.__d; + return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d; #elif defined(__x86_64__) // Zero out padding bits union @@ -2419,12 +2534,12 @@ struct _LIBCPP_TYPE_VIS_ONLY hash { size_t __a; size_t __b; - }; + } __s; } __u; - __u.__a = 0; - __u.__b = 0; + __u.__s.__a = 0; + __u.__s.__b = 0; __u.__t = __v; - return __u.__a ^ __u.__b; + return __u.__s.__a ^ __u.__s.__b; #else return __scalar_hash::operator()(__v); #endif diff --git a/include/future b/include/future index 5b5afe6e2771..ce15eafbf7e4 100644 --- a/include/future +++ b/include/future @@ -512,6 +512,16 @@ public: virtual ~future_error() _NOEXCEPT; }; +inline _LIBCPP_ALWAYS_INLINE +void __throw_future_error(future_errc _Ev) +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw future_error(make_error_code(_Ev)); +#else + assert(!"future_error"); +#endif +} + class _LIBCPP_TYPE_VIS __assoc_sub_state : public __shared_count { @@ -566,6 +576,7 @@ public: void wait(); template future_status + _LIBCPP_INLINE_VISIBILITY wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const; template future_status @@ -589,7 +600,7 @@ __assoc_sub_state::wait_until(const chrono::time_point<_Clock, _Duration>& __abs } template -inline _LIBCPP_INLINE_VISIBILITY +inline future_status __assoc_sub_state::wait_for(const chrono::duration<_Rep, _Period>& __rel_time) const { @@ -645,10 +656,8 @@ __assoc_state<_Rp>::set_value(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); @@ -664,10 +673,8 @@ __assoc_state<_Rp>::set_value_at_thread_exit(_Arg& __arg) #endif { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); ::new(&__value_) _Rp(_VSTD::forward<_Arg>(__arg)); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); @@ -725,10 +732,8 @@ void __assoc_state<_Rp&>::set_value(_Rp& __arg) { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; __cv_.notify_all(); @@ -739,10 +744,8 @@ void __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) { unique_lock __lk(this->__mut_); -#ifndef _LIBCPP_NO_EXCEPTIONS if (this->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); -#endif + __throw_future_error(future_errc::promise_already_satisfied); __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); @@ -849,6 +852,7 @@ class __deferred_assoc_state public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif @@ -858,7 +862,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __deferred_assoc_state<_Rp, _Fp>::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -895,6 +899,7 @@ class __deferred_assoc_state public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __deferred_assoc_state(_Fp&& __f); #endif @@ -904,7 +909,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __deferred_assoc_state::__deferred_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -943,6 +948,7 @@ class __async_assoc_state virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif @@ -952,7 +958,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __async_assoc_state<_Rp, _Fp>::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -997,6 +1003,7 @@ class __async_assoc_state virtual void __on_zero_shared() _NOEXCEPT; public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY explicit __async_assoc_state(_Fp&& __f); #endif @@ -1006,7 +1013,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __async_assoc_state::__async_assoc_state(_Fp&& __f) : __func_(_VSTD::forward<_Fp>(__f)) { @@ -1108,6 +1115,7 @@ private: public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); + _LIBCPP_INLINE_VISIBILITY shared_future<_Rp> share(); // retrieving the value @@ -1138,10 +1146,8 @@ template future<_Rp>::future(__assoc_state<_Rp>* __state) : __state_(__state) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_->__has_future_attached()) - throw future_error(make_error_code(future_errc::future_already_retrieved)); -#endif + __throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } @@ -1212,6 +1218,7 @@ private: public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); + _LIBCPP_INLINE_VISIBILITY shared_future<_Rp&> share(); // retrieving the value @@ -1242,10 +1249,8 @@ template future<_Rp&>::future(__assoc_state<_Rp&>* __state) : __state_(__state) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_->__has_future_attached()) - throw future_error(make_error_code(future_errc::future_already_retrieved)); -#endif + __throw_future_error(future_errc::future_already_retrieved); __state_->__add_shared(); __state_->__set_future_attached(); } @@ -1311,6 +1316,7 @@ private: public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~future(); + _LIBCPP_INLINE_VISIBILITY shared_future share(); // retrieving the value @@ -1445,10 +1451,8 @@ template future<_Rp> promise<_Rp>::get_future() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); return future<_Rp>(__state_); } @@ -1456,10 +1460,8 @@ template void promise<_Rp>::set_value(const _Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value(__r); } @@ -1469,10 +1471,8 @@ template void promise<_Rp>::set_value(_Rp&& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value(_VSTD::move(__r)); } @@ -1482,10 +1482,8 @@ template void promise<_Rp>::set_exception(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } @@ -1493,10 +1491,8 @@ template void promise<_Rp>::set_value_at_thread_exit(const _Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } @@ -1506,10 +1502,8 @@ template void promise<_Rp>::set_value_at_thread_exit(_Rp&& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(_VSTD::move(__r)); } @@ -1519,10 +1513,8 @@ template void promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } @@ -1619,10 +1611,8 @@ template future<_Rp&> promise<_Rp&>::get_future() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); return future<_Rp&>(__state_); } @@ -1630,10 +1620,8 @@ template void promise<_Rp&>::set_value(_Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value(__r); } @@ -1641,10 +1629,8 @@ template void promise<_Rp&>::set_exception(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception(__p); } @@ -1652,10 +1638,8 @@ template void promise<_Rp&>::set_value_at_thread_exit(_Rp& __r) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_value_at_thread_exit(__r); } @@ -1663,10 +1647,8 @@ template void promise<_Rp&>::set_exception_at_thread_exit(exception_ptr __p) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); -#endif + __throw_future_error(future_errc::no_state); __state_->set_exception_at_thread_exit(__p); } @@ -1861,6 +1843,7 @@ public: void swap(__packaged_task_function&) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _Rp operator()(_ArgTypes...) const; }; @@ -2000,7 +1983,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::swap(__packaged_task_function& __f) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Rp __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const { @@ -2087,11 +2070,11 @@ template void packaged_task<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2109,11 +2092,11 @@ template void packaged_task<_Rp(_ArgTypes...)>::make_ready_at_thread_exit(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2131,10 +2114,8 @@ template void packaged_task<_Rp(_ArgTypes...)>::reset() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (!valid()) - throw future_error(make_error_code(future_errc::no_state)); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_future_error(future_errc::no_state); __p_ = promise(); } @@ -2218,11 +2199,11 @@ template void packaged_task::operator()(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2241,11 +2222,11 @@ template void packaged_task::make_ready_at_thread_exit(_ArgTypes... __args) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__p_.__state_ == nullptr) - throw future_error(make_error_code(future_errc::no_state)); + __throw_future_error(future_errc::no_state); if (__p_.__state_->__has_value()) - throw future_error(make_error_code(future_errc::promise_already_satisfied)); + __throw_future_error(future_errc::promise_already_satisfied); +#ifndef _LIBCPP_NO_EXCEPTIONS try { #endif // _LIBCPP_NO_EXCEPTIONS @@ -2264,10 +2245,8 @@ template void packaged_task::reset() { -#ifndef _LIBCPP_NO_EXCEPTIONS if (!valid()) - throw future_error(make_error_code(future_errc::no_state)); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_future_error(future_errc::no_state); __p_ = promise(); } @@ -2592,7 +2571,7 @@ swap(shared_future<_Rp>& __x, shared_future<_Rp>& __y) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_future<_Rp> future<_Rp>::share() { @@ -2600,7 +2579,7 @@ future<_Rp>::share() } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_future<_Rp&> future<_Rp&>::share() { @@ -2609,7 +2588,7 @@ future<_Rp&>::share() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -inline _LIBCPP_INLINE_VISIBILITY +inline shared_future future::share() { diff --git a/include/inttypes.h b/include/inttypes.h new file mode 100644 index 000000000000..5c5618bef884 --- /dev/null +++ b/include/inttypes.h @@ -0,0 +1,251 @@ +// -*- C++ -*- +//===--------------------------- inttypes.h -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_INTTYPES_H +#define _LIBCPP_INTTYPES_H + +/* + inttypes.h synopsis + +This entire header is C99 / C++0X + +#include // includes + +Macros: + + PRId8 + PRId16 + PRId32 + PRId64 + + PRIdLEAST8 + PRIdLEAST16 + PRIdLEAST32 + PRIdLEAST64 + + PRIdFAST8 + PRIdFAST16 + PRIdFAST32 + PRIdFAST64 + + PRIdMAX + PRIdPTR + + PRIi8 + PRIi16 + PRIi32 + PRIi64 + + PRIiLEAST8 + PRIiLEAST16 + PRIiLEAST32 + PRIiLEAST64 + + PRIiFAST8 + PRIiFAST16 + PRIiFAST32 + PRIiFAST64 + + PRIiMAX + PRIiPTR + + PRIo8 + PRIo16 + PRIo32 + PRIo64 + + PRIoLEAST8 + PRIoLEAST16 + PRIoLEAST32 + PRIoLEAST64 + + PRIoFAST8 + PRIoFAST16 + PRIoFAST32 + PRIoFAST64 + + PRIoMAX + PRIoPTR + + PRIu8 + PRIu16 + PRIu32 + PRIu64 + + PRIuLEAST8 + PRIuLEAST16 + PRIuLEAST32 + PRIuLEAST64 + + PRIuFAST8 + PRIuFAST16 + PRIuFAST32 + PRIuFAST64 + + PRIuMAX + PRIuPTR + + PRIx8 + PRIx16 + PRIx32 + PRIx64 + + PRIxLEAST8 + PRIxLEAST16 + PRIxLEAST32 + PRIxLEAST64 + + PRIxFAST8 + PRIxFAST16 + PRIxFAST32 + PRIxFAST64 + + PRIxMAX + PRIxPTR + + PRIX8 + PRIX16 + PRIX32 + PRIX64 + + PRIXLEAST8 + PRIXLEAST16 + PRIXLEAST32 + PRIXLEAST64 + + PRIXFAST8 + PRIXFAST16 + PRIXFAST32 + PRIXFAST64 + + PRIXMAX + PRIXPTR + + SCNd8 + SCNd16 + SCNd32 + SCNd64 + + SCNdLEAST8 + SCNdLEAST16 + SCNdLEAST32 + SCNdLEAST64 + + SCNdFAST8 + SCNdFAST16 + SCNdFAST32 + SCNdFAST64 + + SCNdMAX + SCNdPTR + + SCNi8 + SCNi16 + SCNi32 + SCNi64 + + SCNiLEAST8 + SCNiLEAST16 + SCNiLEAST32 + SCNiLEAST64 + + SCNiFAST8 + SCNiFAST16 + SCNiFAST32 + SCNiFAST64 + + SCNiMAX + SCNiPTR + + SCNo8 + SCNo16 + SCNo32 + SCNo64 + + SCNoLEAST8 + SCNoLEAST16 + SCNoLEAST32 + SCNoLEAST64 + + SCNoFAST8 + SCNoFAST16 + SCNoFAST32 + SCNoFAST64 + + SCNoMAX + SCNoPTR + + SCNu8 + SCNu16 + SCNu32 + SCNu64 + + SCNuLEAST8 + SCNuLEAST16 + SCNuLEAST32 + SCNuLEAST64 + + SCNuFAST8 + SCNuFAST16 + SCNuFAST32 + SCNuFAST64 + + SCNuMAX + SCNuPTR + + SCNx8 + SCNx16 + SCNx32 + SCNx64 + + SCNxLEAST8 + SCNxLEAST16 + SCNxLEAST32 + SCNxLEAST64 + + SCNxFAST8 + SCNxFAST16 + SCNxFAST32 + SCNxFAST64 + + SCNxMAX + SCNxPTR + +Types: + + imaxdiv_t + +intmax_t imaxabs(intmax_t j); +imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom); +intmax_t strtoimax(const char* restrict nptr, char** restrict endptr, int base); +uintmax_t strtoumax(const char* restrict nptr, char** restrict endptr, int base); +intmax_t wcstoimax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); +uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#include + +#undef imaxabs +#undef imaxdiv + +#endif // __cplusplus + +#endif // _LIBCPP_INTTYPES_H diff --git a/include/ios b/include/ios index ff79998b0bbf..1deb5f613c8a 100644 --- a/include/ios +++ b/include/ios @@ -114,9 +114,9 @@ class basic_ios public: // types: typedef charT char_type; - typedef typename traits::int_type int_type; - typedef typename traits::pos_type pos_type; - typedef typename traits::off_type off_type; + typedef typename traits::int_type int_type; // removed in C++17 + typedef typename traits::pos_type pos_type; // removed in C++17 + typedef typename traits::off_type off_type; // removed in C++17 typedef traits traits_type; operator unspecified-bool-type() const; @@ -216,7 +216,7 @@ storage-class-specifier const error_category& iostream_category() noexcept; #include <__locale> #include -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) #include // for __xindex_ #endif @@ -254,14 +254,12 @@ public: static const fmtflags floatfield = scientific | fixed; typedef unsigned int iostate; - typedef iostate io_state; static const iostate badbit = 0x1; static const iostate eofbit = 0x2; static const iostate failbit = 0x4; static const iostate goodbit = 0x0; typedef unsigned int openmode; - typedef openmode open_mode; static const openmode app = 0x01; static const openmode ate = 0x02; static const openmode binary = 0x04; @@ -270,10 +268,15 @@ public: static const openmode trunc = 0x20; enum seekdir {beg, cur, end}; - typedef seekdir seek_dir; + +#if _LIBCPP_STD_VER <= 14 + typedef iostate io_state; + typedef openmode open_mode; + typedef seekdir seek_dir; typedef _VSTD::streamoff streamoff; typedef _VSTD::streampos streampos; +#endif class _LIBCPP_TYPE_VIS Init; @@ -367,7 +370,9 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only +// enabled with clang. +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static atomic __xindex_; #else static int __xindex_; diff --git a/include/istream b/include/istream index 168a4d0635f6..c6a272e75ef1 100644 --- a/include/istream +++ b/include/istream @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _ } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf* __sb) : __gc_(0) { @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) : __gc_(__rhs.__gc_) { @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) { @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_istream() } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs) { @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator>>(int& __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&)) { @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream& } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_ios& (*__pf)(basic_ios&)) @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_ios& } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&)) { @@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream& operator>>(basic_istream& __is, unsigned char* __s) { @@ -808,7 +808,7 @@ operator>>(basic_istream& __is, unsigned char* __s) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream& operator>>(basic_istream& __is, signed char* __s) { @@ -843,7 +843,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream& operator>>(basic_istream& __is, unsigned char& __c) { @@ -851,7 +851,7 @@ operator>>(basic_istream& __is, unsigned char& __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream& operator>>(basic_istream& __is, signed char& __c) { @@ -947,7 +947,7 @@ basic_istream<_CharT, _Traits>::get() } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type& __c) { @@ -1006,7 +1006,7 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __ } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n) { @@ -1068,7 +1068,7 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf& __s } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(basic_streambuf& __sb) { @@ -1129,7 +1129,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n) { @@ -1407,6 +1407,7 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) try { #endif // _LIBCPP_NO_EXCEPTIONS + this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) { @@ -1461,7 +1462,7 @@ ws(basic_istream<_CharT, _Traits>& __is) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) { @@ -1503,7 +1504,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf* __sb) : basic_istream<_CharT, _Traits>(__sb) { @@ -1512,14 +1513,14 @@ basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf -inline _LIBCPP_INLINE_VISIBILITY +inline basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) { } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_iostream<_CharT, _Traits>& basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) { @@ -1535,7 +1536,7 @@ basic_iostream<_CharT, _Traits>::~basic_iostream() } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs) { @@ -1644,7 +1645,7 @@ getline(basic_istream<_CharT, _Traits>& __is, } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str) @@ -1655,7 +1656,7 @@ getline(basic_istream<_CharT, _Traits>& __is, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) @@ -1664,7 +1665,7 @@ getline(basic_istream<_CharT, _Traits>&& __is, } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str) diff --git a/include/iterator b/include/iterator index c06ef8f6777d..8dd6bd59c1a8 100644 --- a/include/iterator +++ b/include/iterator @@ -513,12 +513,12 @@ distance(_InputIter __first, _InputIter __last) return __distance(__first, __last, typename iterator_traits<_InputIter>::iterator_category()); } -template +template inline _LIBCPP_INLINE_VISIBILITY -_ForwardIter -next(_ForwardIter __x, - typename iterator_traits<_ForwardIter>::difference_type __n = 1, - typename enable_if<__is_forward_iterator<_ForwardIter>::value>::type* = 0) +_InputIter +next(_InputIter __x, + typename iterator_traits<_InputIter>::difference_type __n = 1, + typename enable_if<__is_input_iterator<_InputIter>::value>::type* = 0) { _VSTD::advance(__x, __n); return __x; diff --git a/include/list b/include/list index 14201a80e348..28d505582c0d 100644 --- a/include/list +++ b/include/list @@ -191,19 +191,10 @@ template struct __list_node; template struct __list_node_base { - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node<_Tp, _VoidPtr> > pointer; -#else - rebind<__list_node<_Tp, _VoidPtr> >::other pointer; -#endif - - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node_base> __base_pointer; -#else - rebind<__list_node_base>::other __base_pointer; -#endif + typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type + pointer; + typedef typename __rebind_pointer<_VoidPtr, __list_node_base>::type + __base_pointer; pointer __prev_; pointer __next_; @@ -232,12 +223,8 @@ template class _LIBCPP_TYPE_VIS_ONLY __list_const_it template class _LIBCPP_TYPE_VIS_ONLY __list_iterator { - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node<_Tp, _VoidPtr> > __node_pointer; -#else - rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer; -#endif + typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type + __node_pointer; __node_pointer __ptr_; @@ -262,13 +249,7 @@ public: typedef bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef value_type& reference; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<_VoidPtr, value_type>::type pointer; typedef typename pointer_traits::difference_type difference_type; _LIBCPP_INLINE_VISIBILITY @@ -365,12 +346,8 @@ public: template class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator { - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__list_node<_Tp, _VoidPtr> > __node_pointer; -#else - rebind<__list_node<_Tp, _VoidPtr> >::other __node_pointer; -#endif + typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type + __node_pointer; __node_pointer __ptr_; @@ -392,13 +369,7 @@ public: typedef bidirectional_iterator_tag iterator_category; typedef _Tp value_type; typedef const value_type& reference; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<_VoidPtr, const value_type>::type pointer; typedef typename pointer_traits::difference_type difference_type; _LIBCPP_INLINE_VISIBILITY diff --git a/include/locale b/include/locale index e683ba33ae9d..84cb5a5ef6cd 100644 --- a/include/locale +++ b/include/locale @@ -1888,6 +1888,9 @@ protected: virtual const string_type& __r() const; virtual const string_type& __x() const; virtual const string_type& __X() const; + + _LIBCPP_ALWAYS_INLINE + ~__time_get_c_storage() {} }; template > @@ -3773,11 +3776,14 @@ private: wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: + _LIBCPP_ALWAYS_INLINE _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); + _LIBCPP_ALWAYS_INLINE wstring_convert(_Codecvt* __pcvt, state_type __state); _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_ALWAYS_INLINE wstring_convert(wstring_convert&& __wc); #endif ~wstring_convert(); @@ -3811,7 +3817,7 @@ public: }; template -inline _LIBCPP_ALWAYS_INLINE +inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(_Codecvt* __pcvt) : __cvtptr_(__pcvt), __cvtstate_(), __cvtcount_(0) @@ -3819,7 +3825,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: } template -inline _LIBCPP_ALWAYS_INLINE +inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(_Codecvt* __pcvt, state_type __state) : __cvtptr_(__pcvt), __cvtstate_(__state), __cvtcount_(0) @@ -3838,7 +3844,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_ALWAYS_INLINE +inline wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: wstring_convert(wstring_convert&& __wc) : __byte_err_string_(_VSTD::move(__wc.__byte_err_string_)), @@ -4313,18 +4319,9 @@ wbuffer_convert<_Codecvt, _Elem, _Tr>::seekoff(off_type __off, ios_base::seekdir int __width = __cv_->encoding(); if (__cv_ == 0 || __bufptr_ == 0 || (__width <= 0 && __off != 0) || sync()) return pos_type(off_type(-1)); - // __width > 0 || __off == 0 - switch (__way) - { - case ios_base::beg: - break; - case ios_base::cur: - break; - case ios_base::end: - break; - default: + // __width > 0 || __off == 0, now check __way + if (__way != ios_base::beg && __way != ios_base::cur && __way != ios_base::end) return pos_type(off_type(-1)); - } pos_type __r = __bufptr_->pubseekoff(__width * __off, __way, __om); __r.state(__st_); return __r; diff --git a/include/map b/include/map index eb6b8ed05308..adfb4cdb5e9e 100644 --- a/include/map +++ b/include/map @@ -840,6 +840,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { @@ -1523,7 +1526,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template @@ -1696,6 +1699,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function { diff --git a/include/math.h b/include/math.h new file mode 100644 index 000000000000..20205544d51d --- /dev/null +++ b/include/math.h @@ -0,0 +1,1419 @@ +// -*- C++ -*- +//===---------------------------- math.h ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_MATH_H +#define _LIBCPP_MATH_H + +/* + math.h synopsis + +Macros: + + HUGE_VAL + HUGE_VALF // C99 + HUGE_VALL // C99 + INFINITY // C99 + NAN // C99 + FP_INFINITE // C99 + FP_NAN // C99 + FP_NORMAL // C99 + FP_SUBNORMAL // C99 + FP_ZERO // C99 + FP_FAST_FMA // C99 + FP_FAST_FMAF // C99 + FP_FAST_FMAL // C99 + FP_ILOGB0 // C99 + FP_ILOGBNAN // C99 + MATH_ERRNO // C99 + MATH_ERREXCEPT // C99 + math_errhandling // C99 + +Types: + + float_t // C99 + double_t // C99 + +// C90 + +floating_point abs(floating_point x); + +floating_point acos (arithmetic x); +float acosf(float x); +long double acosl(long double x); + +floating_point asin (arithmetic x); +float asinf(float x); +long double asinl(long double x); + +floating_point atan (arithmetic x); +float atanf(float x); +long double atanl(long double x); + +floating_point atan2 (arithmetic y, arithmetic x); +float atan2f(float y, float x); +long double atan2l(long double y, long double x); + +floating_point ceil (arithmetic x); +float ceilf(float x); +long double ceill(long double x); + +floating_point cos (arithmetic x); +float cosf(float x); +long double cosl(long double x); + +floating_point cosh (arithmetic x); +float coshf(float x); +long double coshl(long double x); + +floating_point exp (arithmetic x); +float expf(float x); +long double expl(long double x); + +floating_point fabs (arithmetic x); +float fabsf(float x); +long double fabsl(long double x); + +floating_point floor (arithmetic x); +float floorf(float x); +long double floorl(long double x); + +floating_point fmod (arithmetic x, arithmetic y); +float fmodf(float x, float y); +long double fmodl(long double x, long double y); + +floating_point frexp (arithmetic value, int* exp); +float frexpf(float value, int* exp); +long double frexpl(long double value, int* exp); + +floating_point ldexp (arithmetic value, int exp); +float ldexpf(float value, int exp); +long double ldexpl(long double value, int exp); + +floating_point log (arithmetic x); +float logf(float x); +long double logl(long double x); + +floating_point log10 (arithmetic x); +float log10f(float x); +long double log10l(long double x); + +floating_point modf (floating_point value, floating_point* iptr); +float modff(float value, float* iptr); +long double modfl(long double value, long double* iptr); + +floating_point pow (arithmetic x, arithmetic y); +float powf(float x, float y); +long double powl(long double x, long double y); + +floating_point sin (arithmetic x); +float sinf(float x); +long double sinl(long double x); + +floating_point sinh (arithmetic x); +float sinhf(float x); +long double sinhl(long double x); + +floating_point sqrt (arithmetic x); +float sqrtf(float x); +long double sqrtl(long double x); + +floating_point tan (arithmetic x); +float tanf(float x); +long double tanl(long double x); + +floating_point tanh (arithmetic x); +float tanhf(float x); +long double tanhl(long double x); + +// C99 + +bool signbit(arithmetic x); + +int fpclassify(arithmetic x); + +bool isfinite(arithmetic x); +bool isinf(arithmetic x); +bool isnan(arithmetic x); +bool isnormal(arithmetic x); + +bool isgreater(arithmetic x, arithmetic y); +bool isgreaterequal(arithmetic x, arithmetic y); +bool isless(arithmetic x, arithmetic y); +bool islessequal(arithmetic x, arithmetic y); +bool islessgreater(arithmetic x, arithmetic y); +bool isunordered(arithmetic x, arithmetic y); + +floating_point acosh (arithmetic x); +float acoshf(float x); +long double acoshl(long double x); + +floating_point asinh (arithmetic x); +float asinhf(float x); +long double asinhl(long double x); + +floating_point atanh (arithmetic x); +float atanhf(float x); +long double atanhl(long double x); + +floating_point cbrt (arithmetic x); +float cbrtf(float x); +long double cbrtl(long double x); + +floating_point copysign (arithmetic x, arithmetic y); +float copysignf(float x, float y); +long double copysignl(long double x, long double y); + +floating_point erf (arithmetic x); +float erff(float x); +long double erfl(long double x); + +floating_point erfc (arithmetic x); +float erfcf(float x); +long double erfcl(long double x); + +floating_point exp2 (arithmetic x); +float exp2f(float x); +long double exp2l(long double x); + +floating_point expm1 (arithmetic x); +float expm1f(float x); +long double expm1l(long double x); + +floating_point fdim (arithmetic x, arithmetic y); +float fdimf(float x, float y); +long double fdiml(long double x, long double y); + +floating_point fma (arithmetic x, arithmetic y, arithmetic z); +float fmaf(float x, float y, float z); +long double fmal(long double x, long double y, long double z); + +floating_point fmax (arithmetic x, arithmetic y); +float fmaxf(float x, float y); +long double fmaxl(long double x, long double y); + +floating_point fmin (arithmetic x, arithmetic y); +float fminf(float x, float y); +long double fminl(long double x, long double y); + +floating_point hypot (arithmetic x, arithmetic y); +float hypotf(float x, float y); +long double hypotl(long double x, long double y); + +int ilogb (arithmetic x); +int ilogbf(float x); +int ilogbl(long double x); + +floating_point lgamma (arithmetic x); +float lgammaf(float x); +long double lgammal(long double x); + +long long llrint (arithmetic x); +long long llrintf(float x); +long long llrintl(long double x); + +long long llround (arithmetic x); +long long llroundf(float x); +long long llroundl(long double x); + +floating_point log1p (arithmetic x); +float log1pf(float x); +long double log1pl(long double x); + +floating_point log2 (arithmetic x); +float log2f(float x); +long double log2l(long double x); + +floating_point logb (arithmetic x); +float logbf(float x); +long double logbl(long double x); + +long lrint (arithmetic x); +long lrintf(float x); +long lrintl(long double x); + +long lround (arithmetic x); +long lroundf(float x); +long lroundl(long double x); + +double nan (const char* str); +float nanf(const char* str); +long double nanl(const char* str); + +floating_point nearbyint (arithmetic x); +float nearbyintf(float x); +long double nearbyintl(long double x); + +floating_point nextafter (arithmetic x, arithmetic y); +float nextafterf(float x, float y); +long double nextafterl(long double x, long double y); + +floating_point nexttoward (arithmetic x, long double y); +float nexttowardf(float x, long double y); +long double nexttowardl(long double x, long double y); + +floating_point remainder (arithmetic x, arithmetic y); +float remainderf(float x, float y); +long double remainderl(long double x, long double y); + +floating_point remquo (arithmetic x, arithmetic y, int* pquo); +float remquof(float x, float y, int* pquo); +long double remquol(long double x, long double y, int* pquo); + +floating_point rint (arithmetic x); +float rintf(float x); +long double rintl(long double x); + +floating_point round (arithmetic x); +float roundf(float x); +long double roundl(long double x); + +floating_point scalbln (arithmetic x, long ex); +float scalblnf(float x, long ex); +long double scalblnl(long double x, long ex); + +floating_point scalbn (arithmetic x, int ex); +float scalbnf(float x, int ex); +long double scalbnl(long double x, int ex); + +floating_point tgamma (arithmetic x); +float tgammaf(float x); +long double tgammal(long double x); + +floating_point trunc (arithmetic x); +float truncf(float x); +long double truncl(long double x); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +// We support including .h headers inside 'extern "C"' contexts, so switch +// back to C++ linkage before including these C++ headers. +extern "C++" { + +#include + +#ifdef _LIBCPP_MSVCRT +#include "support/win32/math_win32.h" +#endif + +// signbit + +#ifdef signbit + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_signbit(_A1 __lcpp_x) _NOEXCEPT +{ + return signbit(__lcpp_x); +} + +#undef signbit + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +signbit(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_signbit((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // signbit + +// fpclassify + +#ifdef fpclassify + +template +_LIBCPP_ALWAYS_INLINE +int +__libcpp_fpclassify(_A1 __lcpp_x) _NOEXCEPT +{ + return fpclassify(__lcpp_x); +} + +#undef fpclassify + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, int>::type +fpclassify(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_fpclassify((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // fpclassify + +// isfinite + +#ifdef isfinite + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isfinite(_A1 __lcpp_x) _NOEXCEPT +{ + return isfinite(__lcpp_x); +} + +#undef isfinite + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isfinite(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isfinite((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isfinite + +// isinf + +#ifdef isinf + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isinf(_A1 __lcpp_x) _NOEXCEPT +{ + return isinf(__lcpp_x); +} + +#undef isinf + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isinf(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isinf((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isinf + +// isnan + +#ifdef isnan + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isnan(_A1 __lcpp_x) _NOEXCEPT +{ + return isnan(__lcpp_x); +} + +#undef isnan + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isnan(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isnan((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isnan + +// isnormal + +#ifdef isnormal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isnormal(_A1 __lcpp_x) _NOEXCEPT +{ + return isnormal(__lcpp_x); +} + +#undef isnormal + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, bool>::type +isnormal(_A1 __lcpp_x) _NOEXCEPT +{ + return __libcpp_isnormal((typename std::__promote<_A1>::type)__lcpp_x); +} + +#endif // isnormal + +// isgreater + +#ifdef isgreater + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isgreater(__lcpp_x, __lcpp_y); +} + +#undef isgreater + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isgreater((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isgreater + +// isgreaterequal + +#ifdef isgreaterequal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isgreaterequal(__lcpp_x, __lcpp_y); +} + +#undef isgreaterequal + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isgreaterequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isgreaterequal((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isgreaterequal + +// isless + +#ifdef isless + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isless(__lcpp_x, __lcpp_y); +} + +#undef isless + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isless(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isless((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isless + +// islessequal + +#ifdef islessequal + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return islessequal(__lcpp_x, __lcpp_y); +} + +#undef islessequal + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +islessequal(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_islessequal((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // islessequal + +// islessgreater + +#ifdef islessgreater + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return islessgreater(__lcpp_x, __lcpp_y); +} + +#undef islessgreater + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +islessgreater(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_islessgreater((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // islessgreater + +// isunordered + +#ifdef isunordered + +template +_LIBCPP_ALWAYS_INLINE +bool +__libcpp_isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + return isunordered(__lcpp_x, __lcpp_y); +} + +#undef isunordered + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + bool +>::type +isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type type; + return __libcpp_isunordered((type)__lcpp_x, (type)__lcpp_y); +} + +#endif // isunordered + +#ifndef __sun__ + +// abs + +#if !defined(_AIX) +inline _LIBCPP_INLINE_VISIBILITY +float +abs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} + +inline _LIBCPP_INLINE_VISIBILITY +double +abs(double __lcpp_x) _NOEXCEPT {return fabs(__lcpp_x);} + +inline _LIBCPP_INLINE_VISIBILITY +long double +abs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} +#endif // !defined(_AIX) + +// acos + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return acosf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return acosl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +acos(_A1 __lcpp_x) _NOEXCEPT {return acos((double)__lcpp_x);} + +// asin + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return asinf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return asinl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +asin(_A1 __lcpp_x) _NOEXCEPT {return asin((double)__lcpp_x);} + +// atan + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return atanf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return atanl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +atan(_A1 __lcpp_x) _NOEXCEPT {return atan((double)__lcpp_x);} + +// atan2 + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return atan2f(__lcpp_y, __lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return atan2l(__lcpp_y, __lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x); +} + +// ceil + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ceilf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ceill(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +ceil(_A1 __lcpp_x) _NOEXCEPT {return ceil((double)__lcpp_x);} + +// cos + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return cosf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return cosl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +cos(_A1 __lcpp_x) _NOEXCEPT {return cos((double)__lcpp_x);} + +// cosh + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return coshf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return coshl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +cosh(_A1 __lcpp_x) _NOEXCEPT {return cosh((double)__lcpp_x);} + +// exp + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return expf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return expl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +exp(_A1 __lcpp_x) _NOEXCEPT {return exp((double)__lcpp_x);} + +// fabs + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return fabsf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return fabsl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +fabs(_A1 __lcpp_x) _NOEXCEPT {return fabs((double)__lcpp_x);} + +// floor + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return floorf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return floorl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +floor(_A1 __lcpp_x) _NOEXCEPT {return floor((double)__lcpp_x);} + +// fmod + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmodf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmodl(__lcpp_x, __lcpp_y);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// frexp + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpf(__lcpp_x, __lcpp_e);} +inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexpl(__lcpp_x, __lcpp_e);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return frexp((double)__lcpp_x, __lcpp_e);} + +// ldexp + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpf(__lcpp_x, __lcpp_e);} +inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexpl(__lcpp_x, __lcpp_e);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ldexp((double)__lcpp_x, __lcpp_e);} + +// log + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return logf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return logl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log(_A1 __lcpp_x) _NOEXCEPT {return log((double)__lcpp_x);} + +// log10 + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return log10f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return log10l(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log10(_A1 __lcpp_x) _NOEXCEPT {return log10((double)__lcpp_x);} + +// modf + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return modff(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return modfl(__lcpp_x, __lcpp_y);} +#endif + +// pow + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return powf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return powl(__lcpp_x, __lcpp_y);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return pow((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// sin + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return sinf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return sinl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +sin(_A1 __lcpp_x) _NOEXCEPT {return sin((double)__lcpp_x);} + +// sinh + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return sinhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return sinhl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +sinh(_A1 __lcpp_x) _NOEXCEPT {return sinh((double)__lcpp_x);} + +// sqrt + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return sqrtf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return sqrtl(__lcpp_x);} +#endif + +#endif // __sun__ +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +sqrt(_A1 __lcpp_x) _NOEXCEPT {return sqrt((double)__lcpp_x);} +#ifndef __sun__ + +// tan + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return tanf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return tanl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +tan(_A1 __lcpp_x) _NOEXCEPT {return tan((double)__lcpp_x);} + +// tanh + +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) +inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return tanhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return tanhl(__lcpp_x);} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +tanh(_A1 __lcpp_x) _NOEXCEPT {return tanh((double)__lcpp_x);} + +// acosh + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float acosh(float __lcpp_x) _NOEXCEPT {return acoshf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double acosh(long double __lcpp_x) _NOEXCEPT {return acoshl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +acosh(_A1 __lcpp_x) _NOEXCEPT {return acosh((double)__lcpp_x);} +#endif + +// asinh + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float asinh(float __lcpp_x) _NOEXCEPT {return asinhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double asinh(long double __lcpp_x) _NOEXCEPT {return asinhl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +asinh(_A1 __lcpp_x) _NOEXCEPT {return asinh((double)__lcpp_x);} +#endif + +// atanh + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float atanh(float __lcpp_x) _NOEXCEPT {return atanhf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double atanh(long double __lcpp_x) _NOEXCEPT {return atanhl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +atanh(_A1 __lcpp_x) _NOEXCEPT {return atanh((double)__lcpp_x);} +#endif + +// cbrt + +#ifndef _LIBCPP_MSVCRT +inline _LIBCPP_INLINE_VISIBILITY float cbrt(float __lcpp_x) _NOEXCEPT {return cbrtf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double cbrt(long double __lcpp_x) _NOEXCEPT {return cbrtl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +cbrt(_A1 __lcpp_x) _NOEXCEPT {return cbrt((double)__lcpp_x);} +#endif + +// copysign + +#if !defined(_VC_CRT_MAJOR_VERSION) || (_VC_CRT_MAJOR_VERSION < 12) +inline _LIBCPP_INLINE_VISIBILITY float copysign(float __lcpp_x, + float __lcpp_y) _NOEXCEPT { + return copysignf(__lcpp_x, __lcpp_y); +} +inline _LIBCPP_INLINE_VISIBILITY long double +copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT { + return copysignl(__lcpp_x, __lcpp_y); +} +#endif + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +#ifndef _LIBCPP_MSVCRT + +// erf + +inline _LIBCPP_INLINE_VISIBILITY float erf(float __lcpp_x) _NOEXCEPT {return erff(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double erf(long double __lcpp_x) _NOEXCEPT {return erfl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +erf(_A1 __lcpp_x) _NOEXCEPT {return erf((double)__lcpp_x);} + +// erfc + +inline _LIBCPP_INLINE_VISIBILITY float erfc(float __lcpp_x) _NOEXCEPT {return erfcf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double erfc(long double __lcpp_x) _NOEXCEPT {return erfcl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +erfc(_A1 __lcpp_x) _NOEXCEPT {return erfc((double)__lcpp_x);} + +// exp2 + +inline _LIBCPP_INLINE_VISIBILITY float exp2(float __lcpp_x) _NOEXCEPT {return exp2f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double exp2(long double __lcpp_x) _NOEXCEPT {return exp2l(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +exp2(_A1 __lcpp_x) _NOEXCEPT {return exp2((double)__lcpp_x);} + +// expm1 + +inline _LIBCPP_INLINE_VISIBILITY float expm1(float __lcpp_x) _NOEXCEPT {return expm1f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double expm1(long double __lcpp_x) _NOEXCEPT {return expm1l(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +expm1(_A1 __lcpp_x) _NOEXCEPT {return expm1((double)__lcpp_x);} + +// fdim + +inline _LIBCPP_INLINE_VISIBILITY float fdim(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fdimf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fdiml(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// fma + +inline _LIBCPP_INLINE_VISIBILITY float fma(float __lcpp_x, float __lcpp_y, float __lcpp_z) _NOEXCEPT {return fmaf(__lcpp_x, __lcpp_y, __lcpp_z);} +inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long double __lcpp_y, long double __lcpp_z) _NOEXCEPT {return fmal(__lcpp_x, __lcpp_y, __lcpp_z);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value && + std::is_arithmetic<_A3>::value, + std::__promote<_A1, _A2, _A3> +>::type +fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2, _A3>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value && + std::is_same<_A3, __result_type>::value)), ""); + return fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z); +} + +// fmax + +inline _LIBCPP_INLINE_VISIBILITY float fmax(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fmaxf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fmaxl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// fmin + +inline _LIBCPP_INLINE_VISIBILITY float fmin(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return fminf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return fminl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// hypot + +inline _LIBCPP_INLINE_VISIBILITY float hypot(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return hypotf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return hypotl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// ilogb + +inline _LIBCPP_INLINE_VISIBILITY int ilogb(float __lcpp_x) _NOEXCEPT {return ilogbf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY int ilogb(long double __lcpp_x) _NOEXCEPT {return ilogbl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, int>::type +ilogb(_A1 __lcpp_x) _NOEXCEPT {return ilogb((double)__lcpp_x);} + +// lgamma + +inline _LIBCPP_INLINE_VISIBILITY float lgamma(float __lcpp_x) _NOEXCEPT {return lgammaf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double lgamma(long double __lcpp_x) _NOEXCEPT {return lgammal(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +lgamma(_A1 __lcpp_x) _NOEXCEPT {return lgamma((double)__lcpp_x);} + +// llrint + +inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return llrintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long long llrint(long double __lcpp_x) _NOEXCEPT {return llrintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long long>::type +llrint(_A1 __lcpp_x) _NOEXCEPT {return llrint((double)__lcpp_x);} + +// llround + +inline _LIBCPP_INLINE_VISIBILITY long long llround(float __lcpp_x) _NOEXCEPT {return llroundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long long llround(long double __lcpp_x) _NOEXCEPT {return llroundl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long long>::type +llround(_A1 __lcpp_x) _NOEXCEPT {return llround((double)__lcpp_x);} + +// log1p + +inline _LIBCPP_INLINE_VISIBILITY float log1p(float __lcpp_x) _NOEXCEPT {return log1pf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log1p(long double __lcpp_x) _NOEXCEPT {return log1pl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log1p(_A1 __lcpp_x) _NOEXCEPT {return log1p((double)__lcpp_x);} + +// log2 + +inline _LIBCPP_INLINE_VISIBILITY float log2(float __lcpp_x) _NOEXCEPT {return log2f(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double log2(long double __lcpp_x) _NOEXCEPT {return log2l(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +log2(_A1 __lcpp_x) _NOEXCEPT {return log2((double)__lcpp_x);} + +// logb + +inline _LIBCPP_INLINE_VISIBILITY float logb(float __lcpp_x) _NOEXCEPT {return logbf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double logb(long double __lcpp_x) _NOEXCEPT {return logbl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +logb(_A1 __lcpp_x) _NOEXCEPT {return logb((double)__lcpp_x);} + +// lrint + +inline _LIBCPP_INLINE_VISIBILITY long lrint(float __lcpp_x) _NOEXCEPT {return lrintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long lrint(long double __lcpp_x) _NOEXCEPT {return lrintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long>::type +lrint(_A1 __lcpp_x) _NOEXCEPT {return lrint((double)__lcpp_x);} + +// lround + +inline _LIBCPP_INLINE_VISIBILITY long lround(float __lcpp_x) _NOEXCEPT {return lroundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long lround(long double __lcpp_x) _NOEXCEPT {return lroundl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, long>::type +lround(_A1 __lcpp_x) _NOEXCEPT {return lround((double)__lcpp_x);} + +// nan + +// nearbyint + +inline _LIBCPP_INLINE_VISIBILITY float nearbyint(float __lcpp_x) _NOEXCEPT {return nearbyintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double nearbyint(long double __lcpp_x) _NOEXCEPT {return nearbyintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +nearbyint(_A1 __lcpp_x) _NOEXCEPT {return nearbyint((double)__lcpp_x);} + +// nextafter + +inline _LIBCPP_INLINE_VISIBILITY float nextafter(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return nextafterf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nextafterl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// nexttoward + +inline _LIBCPP_INLINE_VISIBILITY float nexttoward(float __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double nexttoward(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttowardl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +nexttoward(_A1 __lcpp_x, long double __lcpp_y) _NOEXCEPT {return nexttoward((double)__lcpp_x, __lcpp_y);} + +// remainder + +inline _LIBCPP_INLINE_VISIBILITY float remainder(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return remainderf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return remainderl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y); +} + +// remquo + +inline _LIBCPP_INLINE_VISIBILITY float remquo(float __lcpp_x, float __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquof(__lcpp_x, __lcpp_y, __lcpp_z);} +inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long double __lcpp_y, int* __lcpp_z) _NOEXCEPT {return remquol(__lcpp_x, __lcpp_y, __lcpp_z);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::__lazy_enable_if +< + std::is_arithmetic<_A1>::value && + std::is_arithmetic<_A2>::value, + std::__promote<_A1, _A2> +>::type +remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT +{ + typedef typename std::__promote<_A1, _A2>::type __result_type; + static_assert((!(std::is_same<_A1, __result_type>::value && + std::is_same<_A2, __result_type>::value)), ""); + return remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z); +} + +// rint + +inline _LIBCPP_INLINE_VISIBILITY float rint(float __lcpp_x) _NOEXCEPT {return rintf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double rint(long double __lcpp_x) _NOEXCEPT {return rintl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +rint(_A1 __lcpp_x) _NOEXCEPT {return rint((double)__lcpp_x);} + +// round + +inline _LIBCPP_INLINE_VISIBILITY float round(float __lcpp_x) _NOEXCEPT {return roundf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double round(long double __lcpp_x) _NOEXCEPT {return roundl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +round(_A1 __lcpp_x) _NOEXCEPT {return round((double)__lcpp_x);} + +// scalbln + +inline _LIBCPP_INLINE_VISIBILITY float scalbln(float __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double scalbln(long double __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalblnl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +scalbln(_A1 __lcpp_x, long __lcpp_y) _NOEXCEPT {return scalbln((double)__lcpp_x, __lcpp_y);} + +// scalbn + +inline _LIBCPP_INLINE_VISIBILITY float scalbn(float __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnf(__lcpp_x, __lcpp_y);} +inline _LIBCPP_INLINE_VISIBILITY long double scalbn(long double __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbnl(__lcpp_x, __lcpp_y);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +scalbn(_A1 __lcpp_x, int __lcpp_y) _NOEXCEPT {return scalbn((double)__lcpp_x, __lcpp_y);} + +// tgamma + +inline _LIBCPP_INLINE_VISIBILITY float tgamma(float __lcpp_x) _NOEXCEPT {return tgammaf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double tgamma(long double __lcpp_x) _NOEXCEPT {return tgammal(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +tgamma(_A1 __lcpp_x) _NOEXCEPT {return tgamma((double)__lcpp_x);} + +// trunc + +inline _LIBCPP_INLINE_VISIBILITY float trunc(float __lcpp_x) _NOEXCEPT {return truncf(__lcpp_x);} +inline _LIBCPP_INLINE_VISIBILITY long double trunc(long double __lcpp_x) _NOEXCEPT {return truncl(__lcpp_x);} + +template +inline _LIBCPP_INLINE_VISIBILITY +typename std::enable_if::value, double>::type +trunc(_A1 __lcpp_x) _NOEXCEPT {return trunc((double)__lcpp_x);} + +#endif // !_LIBCPP_MSVCRT +#endif // __sun__ + +} // extern "C++" + +#endif // __cplusplus + +#endif // _LIBCPP_MATH_H diff --git a/include/memory b/include/memory index 22311aaace92..65369d2632c4 100644 --- a/include/memory +++ b/include/memory @@ -612,7 +612,7 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); #include #endif -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER) # include #endif @@ -932,6 +932,15 @@ public: {return _VSTD::addressof(__r);} }; +template +struct __rebind_pointer { +#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES + typedef typename pointer_traits<_From>::template rebind<_To> type; +#else + typedef typename pointer_traits<_From>::template rebind<_To>::other type; +#endif +}; + // allocator_traits namespace __has_pointer_type_imp @@ -1669,7 +1678,7 @@ private: {return __a.max_size();} _LIBCPP_INLINE_VISIBILITY static size_type __max_size(false_type, const allocator_type&) - {return numeric_limits::max();} + {return numeric_limits::max() / sizeof(value_type);} _LIBCPP_INLINE_VISIBILITY static allocator_type @@ -1900,6 +1909,10 @@ public: _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator*() {return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(const _Tp& __element) {::new(&*__x_) _Tp(__element); return *this;} +#if _LIBCPP_STD_VER >= 14 + _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator=(_Tp&& __element) + {::new(&*__x_) _Tp(_VSTD::move(__element)); return *this;} +#endif _LIBCPP_INLINE_VISIBILITY raw_storage_iterator& operator++() {++__x_; return *this;} _LIBCPP_INLINE_VISIBILITY raw_storage_iterator operator++(int) {raw_storage_iterator __t(*this); ++__x_; return __t;} @@ -2659,10 +2672,17 @@ public: : __ptr_(__u->release(), _VSTD::forward(__u->get_deleter())) {} template - _LIBCPP_INLINE_VISIBILITY unique_ptr& operator=(unique_ptr<_Up, _Ep> __u) + _LIBCPP_INLINE_VISIBILITY + typename enable_if< + !is_array<_Up>::value && + is_convertible::pointer, pointer>::value && + is_assignable::value, + unique_ptr& + >::type + operator=(unique_ptr<_Up, _Ep> __u) { reset(__u.release()); - __ptr_.second() = _VSTD::forward(__u.get_deleter()); + __ptr_.second() = _VSTD::forward<_Ep>(__u.get_deleter()); return *this; } @@ -3420,7 +3440,7 @@ struct __scalar_hash<_Tp, 2> { size_t __a; size_t __b; - }; + } __s; } __u; __u.__t = __v; return __murmur2_or_cityhash()(&__u, sizeof(__u)); @@ -3442,7 +3462,7 @@ struct __scalar_hash<_Tp, 3> size_t __a; size_t __b; size_t __c; - }; + } __s; } __u; __u.__t = __v; return __murmur2_or_cityhash()(&__u, sizeof(__u)); @@ -3465,7 +3485,7 @@ struct __scalar_hash<_Tp, 4> size_t __b; size_t __c; size_t __d; - }; + } __s; } __u; __u.__t = __v; return __murmur2_or_cityhash()(&__u, sizeof(__u)); @@ -3854,7 +3874,9 @@ private: struct __nat {int __for_bool_;}; public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR shared_ptr() _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR shared_ptr(nullptr_t) _NOEXCEPT; template explicit shared_ptr(_Yp* __p, @@ -3867,15 +3889,18 @@ public: typename enable_if::value, __nat>::type = __nat()); template shared_ptr(nullptr_t __p, _Dp __d); template shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a); - template shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; + template _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, element_type* __p) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr& __r) _NOEXCEPT; template + _LIBCPP_INLINE_VISIBILITY shared_ptr(const shared_ptr<_Yp>& __r, typename enable_if::value, __nat>::type = __nat()) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr&& __r) _NOEXCEPT; - template shared_ptr(shared_ptr<_Yp>&& __r, + template _LIBCPP_INLINE_VISIBILITY shared_ptr(shared_ptr<_Yp>&& __r, typename enable_if::value, __nat>::type = __nat()) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -3932,6 +3957,7 @@ public: ~shared_ptr(); + _LIBCPP_INLINE_VISIBILITY shared_ptr& operator=(const shared_ptr& __r) _NOEXCEPT; template typename enable_if @@ -3939,8 +3965,10 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY shared_ptr& operator=(shared_ptr&& __r) _NOEXCEPT; template typename enable_if @@ -3948,6 +3976,7 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr<_Tp>& >::type + _LIBCPP_INLINE_VISIBILITY operator=(shared_ptr<_Yp>&& __r); template typename enable_if @@ -3956,6 +3985,7 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr >::type& + _LIBCPP_INLINE_VISIBILITY operator=(auto_ptr<_Yp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template @@ -3965,6 +3995,7 @@ public: is_convertible<_Yp*, element_type*>::value, shared_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(auto_ptr<_Yp> __r); #endif template @@ -3975,12 +4006,16 @@ public: shared_ptr& >::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY operator=(unique_ptr<_Yp, _Dp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY operator=(unique_ptr<_Yp, _Dp> __r); #endif + _LIBCPP_INLINE_VISIBILITY void swap(shared_ptr& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT; template typename enable_if @@ -3988,6 +4023,7 @@ public: is_convertible<_Yp*, element_type*>::value, void >::type + _LIBCPP_INLINE_VISIBILITY reset(_Yp* __p); template typename enable_if @@ -3995,6 +4031,7 @@ public: is_convertible<_Yp*, element_type*>::value, void >::type + _LIBCPP_INLINE_VISIBILITY reset(_Yp* __p, _Dp __d); template typename enable_if @@ -4002,6 +4039,7 @@ public: is_convertible<_Yp*, element_type*>::value, void >::type + _LIBCPP_INLINE_VISIBILITY reset(_Yp* __p, _Dp __d, _Alloc __a); _LIBCPP_INLINE_VISIBILITY @@ -4103,7 +4141,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR shared_ptr<_Tp>::shared_ptr() _NOEXCEPT : __ptr_(0), @@ -4112,7 +4150,7 @@ shared_ptr<_Tp>::shared_ptr() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR shared_ptr<_Tp>::shared_ptr(nullptr_t) _NOEXCEPT : __ptr_(0), @@ -4235,7 +4273,7 @@ shared_ptr<_Tp>::shared_ptr(nullptr_t __p, _Dp __d, _Alloc __a) template template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEXCEPT : __ptr_(__p), __cntrl_(__r.__cntrl_) @@ -4245,7 +4283,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, element_type *__p) _NOEX } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -4256,7 +4294,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, typename enable_if::value, __nat>::type) _NOEXCEPT @@ -4270,7 +4308,7 @@ shared_ptr<_Tp>::shared_ptr(const shared_ptr<_Yp>& __r, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -4281,7 +4319,7 @@ shared_ptr<_Tp>::shared_ptr(shared_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>::shared_ptr(shared_ptr<_Yp>&& __r, typename enable_if::value, __nat>::type) _NOEXCEPT @@ -4568,7 +4606,7 @@ shared_ptr<_Tp>::~shared_ptr() } template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>& shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT { @@ -4578,7 +4616,7 @@ shared_ptr<_Tp>::operator=(const shared_ptr& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4593,7 +4631,7 @@ shared_ptr<_Tp>::operator=(const shared_ptr<_Yp>& __r) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline shared_ptr<_Tp>& shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT { @@ -4603,7 +4641,7 @@ shared_ptr<_Tp>::operator=(shared_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4617,7 +4655,7 @@ shared_ptr<_Tp>::operator=(shared_ptr<_Yp>&& __r) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < !is_array<_Yp>::value && @@ -4632,7 +4670,7 @@ shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < !is_array<_Yp>::value && @@ -4680,7 +4718,7 @@ shared_ptr<_Tp>::operator=(unique_ptr<_Yp, _Dp> __r) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT { @@ -4689,7 +4727,7 @@ shared_ptr<_Tp>::swap(shared_ptr& __r) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void shared_ptr<_Tp>::reset() _NOEXCEPT { @@ -4698,7 +4736,7 @@ shared_ptr<_Tp>::reset() _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4711,7 +4749,7 @@ shared_ptr<_Tp>::reset(_Yp* __p) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -4724,7 +4762,7 @@ shared_ptr<_Tp>::reset(_Yp* __p, _Dp __d) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5041,23 +5079,27 @@ private: __shared_weak_count* __cntrl_; public: + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR weak_ptr() _NOEXCEPT; - template weak_ptr(shared_ptr<_Yp> const& __r, + template _LIBCPP_INLINE_VISIBILITY weak_ptr(shared_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr const& __r) _NOEXCEPT; - template weak_ptr(weak_ptr<_Yp> const& __r, + template _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr&& __r) _NOEXCEPT; - template weak_ptr(weak_ptr<_Yp>&& __r, + template _LIBCPP_INLINE_VISIBILITY weak_ptr(weak_ptr<_Yp>&& __r, typename enable_if::value, __nat*>::type = 0) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES ~weak_ptr(); + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr const& __r) _NOEXCEPT; template typename enable_if @@ -5065,10 +5107,12 @@ public: is_convertible<_Yp*, element_type*>::value, weak_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY weak_ptr& operator=(weak_ptr&& __r) _NOEXCEPT; template typename enable_if @@ -5076,6 +5120,7 @@ public: is_convertible<_Yp*, element_type*>::value, weak_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -5086,9 +5131,12 @@ public: is_convertible<_Yp*, element_type*>::value, weak_ptr& >::type + _LIBCPP_INLINE_VISIBILITY operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void swap(weak_ptr& __r) _NOEXCEPT; + _LIBCPP_INLINE_VISIBILITY void reset() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY @@ -5112,7 +5160,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR weak_ptr<_Tp>::weak_ptr() _NOEXCEPT : __ptr_(0), @@ -5121,7 +5169,7 @@ weak_ptr<_Tp>::weak_ptr() _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -5132,7 +5180,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr const& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type) _NOEXCEPT @@ -5145,7 +5193,7 @@ weak_ptr<_Tp>::weak_ptr(shared_ptr<_Yp> const& __r, template template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, typename enable_if::value, __nat*>::type) _NOEXCEPT @@ -5159,7 +5207,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp> const& __r, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT : __ptr_(__r.__ptr_), __cntrl_(__r.__cntrl_) @@ -5170,7 +5218,7 @@ weak_ptr<_Tp>::weak_ptr(weak_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>::weak_ptr(weak_ptr<_Yp>&& __r, typename enable_if::value, __nat*>::type) _NOEXCEPT @@ -5191,7 +5239,7 @@ weak_ptr<_Tp>::~weak_ptr() } template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT { @@ -5201,7 +5249,7 @@ weak_ptr<_Tp>::operator=(weak_ptr const& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5216,7 +5264,7 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp> const& __r) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline weak_ptr<_Tp>& weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT { @@ -5226,7 +5274,7 @@ weak_ptr<_Tp>::operator=(weak_ptr&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5242,7 +5290,7 @@ weak_ptr<_Tp>::operator=(weak_ptr<_Yp>&& __r) _NOEXCEPT template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < is_convertible<_Yp*, _Tp*>::value, @@ -5255,7 +5303,7 @@ weak_ptr<_Tp>::operator=(shared_ptr<_Yp> const& __r) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void weak_ptr<_Tp>::swap(weak_ptr& __r) _NOEXCEPT { @@ -5272,7 +5320,7 @@ swap(weak_ptr<_Tp>& __x, weak_ptr<_Tp>& __y) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline void weak_ptr<_Tp>::reset() _NOEXCEPT { @@ -5305,7 +5353,11 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT return __r; } +#if _LIBCPP_STD_VER > 14 +template struct owner_less; +#else template struct owner_less; +#endif template struct _LIBCPP_TYPE_VIS_ONLY owner_less > @@ -5339,6 +5391,30 @@ struct _LIBCPP_TYPE_VIS_ONLY owner_less > {return __x.owner_before(__y);} }; +#if _LIBCPP_STD_VER > 14 +template <> +struct _LIBCPP_TYPE_VIS_ONLY owner_less +{ + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( shared_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( shared_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( weak_ptr<_Tp> const& __x, shared_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + template + _LIBCPP_INLINE_VISIBILITY + bool operator()( weak_ptr<_Tp> const& __x, weak_ptr<_Up> const& __y) const + {return __x.owner_before(__y);} + typedef void is_transparent; +}; +#endif + template class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this { @@ -5381,7 +5457,9 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +// TODO(EricWF): Enable this for both Clang and GCC. Currently it is only +// enabled with clang. +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) class _LIBCPP_TYPE_VIS __sp_mut { @@ -5507,7 +5585,7 @@ atomic_compare_exchange_weak_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v return atomic_compare_exchange_weak(__p, __v, __w); } -#endif // __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) //enum class struct _LIBCPP_TYPE_VIS pointer_safety @@ -5574,6 +5652,15 @@ template _LIBCPP_INLINE_VISIBILITY void __swap_allocator(_Alloc &, _Alloc &, false_type) _NOEXCEPT {} +template > +struct __noexcept_move_assign_container : public integral_constant 14 + || _Traits::is_always_equal::value +#else + && is_nothrow_move_assignable<_Alloc>::value +#endif + > {}; _LIBCPP_END_NAMESPACE_STD diff --git a/include/module.modulemap b/include/module.modulemap index 3c0700eca443..3fb7428411df 100644 --- a/include/module.modulemap +++ b/include/module.modulemap @@ -455,9 +455,13 @@ module std [system] { export * } + // FIXME: We don't have modules for the headers, because they might + // be included from the C library's headers, and that would create a #include + // cycle. For the same reason, we don't have a module for __config. + //module __config { header "__config" export * } + // FIXME: These should be private. module __bit_reference { header "__bit_reference" export * } - module __config { header "__config" export * } module __debug { header "__debug" export * } module __functional_base { header "__functional_base" export * } module __hash_table { header "__hash_table" export * } diff --git a/include/mutex b/include/mutex index 373d75b09789..a0875a568ec6 100644 --- a/include/mutex +++ b/include/mutex @@ -179,7 +179,9 @@ template #ifndef _LIBCPP_HAS_NO_VARIADICS #include #endif +#ifndef _LIBCPP_HAS_NO_THREADS #include +#endif #include <__undef_min_max> diff --git a/include/ostream b/include/ostream index f55fd40856ec..01157b2377db 100644 --- a/include/ostream +++ b/include/ostream @@ -275,7 +275,7 @@ basic_ostream<_CharT, _Traits>::sentry::~sentry() } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf* __sb) { this->init(__sb); @@ -284,14 +284,14 @@ basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) { this->move(__rhs); } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) { @@ -307,7 +307,7 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs) { @@ -315,7 +315,7 @@ basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream&)) { @@ -323,7 +323,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream& } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(basic_ios& (*__pf)(basic_ios&)) @@ -333,7 +333,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_ios& } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(ios_base& (*__pf)(ios_base&)) { @@ -989,7 +989,7 @@ basic_ostream<_CharT, _Traits>::flush() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() { @@ -999,7 +999,7 @@ basic_ostream<_CharT, _Traits>::tellp() } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { @@ -1013,7 +1013,7 @@ basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { @@ -1027,7 +1027,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) { @@ -1037,7 +1037,7 @@ endl(basic_ostream<_CharT, _Traits>& __os) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) { @@ -1046,7 +1046,7 @@ ends(basic_ostream<_CharT, _Traits>& __os) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) { @@ -1057,7 +1057,7 @@ flush(basic_ostream<_CharT, _Traits>& __os) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < !is_lvalue_reference<_Stream>::value && @@ -1081,7 +1081,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) { @@ -1089,7 +1089,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) { diff --git a/include/random b/include/random index 64382a3d9aa6..794bf7b3fd15 100644 --- a/include/random +++ b/include/random @@ -3119,6 +3119,7 @@ public: independent_bits_engine<_Eng, _Wp, _UI>& __x); private: + _LIBCPP_INLINE_VISIBILITY result_type __eval(false_type); result_type __eval(true_type); @@ -3144,7 +3145,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline _UIntType independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) { @@ -3735,7 +3736,7 @@ public: _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} - template result_type operator()(_URNG& __g, const param_type& __p); + template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY @@ -3765,7 +3766,7 @@ public: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename uniform_real_distribution<_RealType>::result_type uniform_real_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { @@ -3851,7 +3852,7 @@ public: _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} - template result_type operator()(_URNG& __g, const param_type& __p); + template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY @@ -3878,7 +3879,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline bernoulli_distribution::result_type bernoulli_distribution::operator()(_URNG& __g, const param_type& __p) { @@ -5522,7 +5523,7 @@ public: _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g) {return (*this)(__g, __p_);} - template result_type operator()(_URNG& __g, const param_type& __p); + template _LIBCPP_INLINE_VISIBILITY result_type operator()(_URNG& __g, const param_type& __p); // property functions _LIBCPP_INLINE_VISIBILITY @@ -5552,7 +5553,7 @@ public: template template -inline _LIBCPP_INLINE_VISIBILITY +inline _RealType cauchy_distribution<_RealType>::operator()(_URNG& __g, const param_type& __p) { @@ -6044,9 +6045,6 @@ basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>& __is, discrete_distribution<_IT>& __x) { - typedef discrete_distribution<_IT> _Eng; - typedef typename _Eng::result_type result_type; - typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; @@ -6358,7 +6356,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is, { typedef piecewise_constant_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; - typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; @@ -6698,7 +6695,6 @@ operator>>(basic_istream<_CharT, _Traits>& __is, { typedef piecewise_linear_distribution<_RT> _Eng; typedef typename _Eng::result_type result_type; - typedef typename _Eng::param_type param_type; __save_flags<_CharT, _Traits> __lx(__is); __is.flags(ios_base::dec | ios_base::skipws); size_t __n; diff --git a/include/ratio b/include/ratio index f623a062f2ce..8f708ce478d3 100644 --- a/include/ratio +++ b/include/ratio @@ -62,6 +62,19 @@ typedef ratio< 1000000000000000000, 1> exa; typedef ratio< 1000000000000000000000, 1> zetta; // not supported typedef ratio<1000000000000000000000000, 1> yotta; // not supported + // 20.11.5, ratio comparison + template constexpr bool ratio_equal_v + = ratio_equal::value; // C++17 + template constexpr bool ratio_not_equal_v + = ratio_not_equal::value; // C++17 + template constexpr bool ratio_less_v + = ratio_less::value; // C++17 + template constexpr bool ratio_less_equal_v + = ratio_less_equal::value; // C++17 + template constexpr bool ratio_greater_v + = ratio_greater::value; // C++17 + template constexpr bool ratio_greater_equal_v + = ratio_greater_equal::value; // C++17 } */ @@ -485,6 +498,26 @@ struct __ratio_gcd __static_lcm<_R1::den, _R2::den>::value> type; }; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool ratio_equal_v + = ratio_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_not_equal_v + = ratio_not_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_less_v + = ratio_less<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_less_equal_v + = ratio_less_equal<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_greater_v + = ratio_greater<_R1, _R2>::value; + +template _LIBCPP_CONSTEXPR bool ratio_greater_equal_v + = ratio_greater_equal<_R1, _R2>::value; +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_RATIO diff --git a/include/regex b/include/regex index bd48fb8da04b..b9dac4765cdf 100644 --- a/include/regex +++ b/include/regex @@ -762,6 +762,7 @@ typedef regex_token_iterator wsregex_token_iterator; #include #include #include +#include #include <__undef_min_max> @@ -955,6 +956,17 @@ public: regex_constants::error_type code() const {return __code_;} }; +template +_LIBCPP_ALWAYS_INLINE +void __throw_regex_error() +{ +#ifndef _LIBCPP_NO_EXCEPTIONS + throw regex_error(_Ev); +#else + assert(!"regex_error"); +#endif +} + template struct _LIBCPP_TYPE_VIS_ONLY regex_traits { @@ -1036,6 +1048,7 @@ private: _LIBCPP_INLINE_VISIBILITY int __regex_traits_value(char __ch, int __radix) const {return __regex_traits_value(static_cast(__ch), __radix);} + _LIBCPP_INLINE_VISIBILITY int __regex_traits_value(wchar_t __ch, int __radix) const; }; @@ -1258,7 +1271,7 @@ regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) } template -inline _LIBCPP_INLINE_VISIBILITY +inline int regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { @@ -1721,6 +1734,8 @@ template void __back_ref<_CharT>::__exec(__state& __s) const { + if (__mexp_ > __s.__sub_matches_.size()) + __throw_regex_error(); sub_match& __sm = __s.__sub_matches_[__mexp_-1]; if (__sm.matched) { @@ -2256,10 +2271,8 @@ public: } else { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__b.size() != 1 || __e.size() != 1) - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (__icase_) { __b[0] = __traits_.translate_nocase(__b[0]); @@ -2952,7 +2965,7 @@ public: _LIBCPP_INLINE_VISIBILITY __lookahead(const basic_regex<_CharT, _Traits>& __exp, bool __invert, __node<_CharT>* __s, unsigned __mexp) - : base(__s), __exp_(__exp), __invert_(__invert), __mexp_(__mexp) {} + : base(__s), __exp_(__exp), __mexp_(__mexp), __invert_(__invert) {} virtual void __exec(__state&) const; }; @@ -3012,10 +3025,8 @@ basic_regex<_CharT, _Traits>::__parse(_ForwardIterator __first, case egrep: __first = __parse_egrep(__first, __last); break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::__re_err_grammar); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } return __first; } @@ -3046,10 +3057,8 @@ basic_regex<_CharT, _Traits>::__parse_basic_reg_exp(_ForwardIterator __first, } } } -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first != __last) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } return __first; } @@ -3062,19 +3071,15 @@ basic_regex<_CharT, _Traits>::__parse_extended_reg_exp(_ForwardIterator __first, { __owns_one_state<_CharT>* __sa = __end_; _ForwardIterator __temp = __parse_ERE_branch(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; while (__first != __last && *__first == '|') { __owns_one_state<_CharT>* __sb = __end_; __temp = __parse_ERE_branch(++__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_alternation(__sa, __sb); __first = __temp; } @@ -3088,10 +3093,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_branch(_ForwardIterator __first, _ForwardIterator __last) { _ForwardIterator __temp = __parse_ERE_expression(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::__re_err_empty); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); do { __first = __temp; @@ -3126,10 +3129,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_expression(_ForwardIterator __first, unsigned __temp_count = __marked_count_; ++__open_count_; __temp = __parse_extended_reg_exp(++__temp, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_end_marked_subexpression(__temp_count); --__open_count_; ++__temp; @@ -3194,10 +3195,8 @@ basic_regex<_CharT, _Traits>::__parse_nondupl_RE(_ForwardIterator __first, unsigned __temp_count = __marked_count_; __first = __parse_RE_expression(__temp, __last); __temp = __parse_Back_close_paren(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_end_marked_subexpression(__temp_count); __first = __temp; } @@ -3511,22 +3510,16 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, int __min = 0; __first = __temp; __temp = __parse_DUP_COUNT(__first, __last, __min); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (*__first != ',') { __temp = __parse_Back_close_brace(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_loop(__min, __min, __s, __mexp_begin, __mexp_end, true); __first = __temp; @@ -3537,18 +3530,14 @@ basic_regex<_CharT, _Traits>::__parse_RE_dupl_symbol(_ForwardIterator __first, int __max = -1; __first = __parse_DUP_COUNT(__first, __last, __max); __temp = __parse_Back_close_brace(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (__max == -1) __push_greedy_inf_repeat(__min, __s, __mexp_begin, __mexp_end); else { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__max < __min) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_loop(__min, __max, __s, __mexp_begin, __mexp_end, true); } @@ -3608,15 +3597,11 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, { int __min; _ForwardIterator __temp = __parse_DUP_COUNT(++__first, __last, __min); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); switch (*__first) { case '}': @@ -3631,10 +3616,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, break; case ',': ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (*__first == '}') { ++__first; @@ -3650,20 +3633,14 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, { int __max = -1; __temp = __parse_DUP_COUNT(__first, __last, __max); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __first) - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = __temp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != '}') - throw regex_error(regex_constants::error_brace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__max < __min) - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (__grammar == ECMAScript && __first != __last && *__first == '?') { ++__first; @@ -3673,10 +3650,8 @@ basic_regex<_CharT, _Traits>::__parse_ERE_dupl_symbol(_ForwardIterator __first, __push_loop(__min, __max, __s, __mexp_begin, __mexp_end); } break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::error_badbrace); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } } break; @@ -3694,10 +3669,8 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs if (__first != __last && *__first == '[') { ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); bool __negate = false; if (*__first == '^') { @@ -3706,29 +3679,23 @@ basic_regex<_CharT, _Traits>::__parse_bracket_expression(_ForwardIterator __firs } __bracket_expression<_CharT, _Traits>* __ml = __start_matching_list(__negate); // __ml owned by *this -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if ((__flags_ & 0x1F0) != ECMAScript && *__first == ']') { __ml->__add_char(']'); ++__first; } __first = __parse_follow_list(__first, __last, __ml); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); if (*__first == '-') { __ml->__add_char('-'); ++__first; } -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != ']') - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); ++__first; } return __first; @@ -3848,10 +3815,8 @@ basic_regex<_CharT, _Traits>::__parse_class_escape(_ForwardIterator __first, basic_string<_CharT>& __str, __bracket_expression<_CharT, _Traits>* __ml) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); switch (*__first) { case 0: @@ -3892,10 +3857,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first, _ForwardIterator __last, basic_string<_CharT>* __str) { -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); switch (*__first) { case '\\': @@ -3963,10 +3926,8 @@ basic_regex<_CharT, _Traits>::__parse_awk_escape(_ForwardIterator __first, else __push_char(_CharT(__val)); } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); return __first; } @@ -3982,18 +3943,14 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first value_type _Equal_close[2] = {'=', ']'}; _ForwardIterator __temp = _VSTD::search(__first, __last, _Equal_close, _Equal_close+2); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); // [__first, __temp) contains all text in [= ... =] typedef typename _Traits::string_type string_type; string_type __collate_name = __traits_.lookup_collatename(__first, __temp); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__collate_name.empty()) - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); string_type __equiv_name = __traits_.transform_primary(__collate_name.begin(), __collate_name.end()); @@ -4009,10 +3966,8 @@ basic_regex<_CharT, _Traits>::__parse_equivalence_class(_ForwardIterator __first case 2: __ml->__add_digraph(__collate_name[0], __collate_name[1]); break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } } __first = _VSTD::next(__temp, 2); @@ -4031,18 +3986,14 @@ basic_regex<_CharT, _Traits>::__parse_character_class(_ForwardIterator __first, value_type _Colon_close[2] = {':', ']'}; _ForwardIterator __temp = _VSTD::search(__first, __last, _Colon_close, _Colon_close+2); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); // [__first, __temp) contains all text in [: ... :] typedef typename _Traits::char_class_type char_class_type; char_class_type __class_type = __traits_.lookup_classname(__first, __temp, __flags_ & icase); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__class_type == 0) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __ml->__add_class(__class_type); __first = _VSTD::next(__temp, 2); return __first; @@ -4060,22 +4011,17 @@ basic_regex<_CharT, _Traits>::__parse_collating_symbol(_ForwardIterator __first, value_type _Dot_close[2] = {'.', ']'}; _ForwardIterator __temp = _VSTD::search(__first, __last, _Dot_close, _Dot_close+2); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last) - throw regex_error(regex_constants::error_brack); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); // [__first, __temp) contains all text in [. ... .] - typedef typename _Traits::string_type string_type; __col_sym = __traits_.lookup_collatename(__first, __temp); switch (__col_sym.size()) { case 1: case 2: break; -#ifndef _LIBCPP_NO_EXCEPTIONS default: - throw regex_error(regex_constants::error_collate); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } __first = _VSTD::next(__temp, 2); return __first; @@ -4219,10 +4165,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, unsigned __mexp = __exp.__marked_count_; __push_lookahead(_VSTD::move(__exp), false, __marked_count_); __marked_count_ += __mexp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = ++__temp; } break; @@ -4234,10 +4178,8 @@ basic_regex<_CharT, _Traits>::__parse_assertion(_ForwardIterator __first, unsigned __mexp = __exp.__marked_count_; __push_lookahead(_VSTD::move(__exp), true, __marked_count_); __marked_count_ += __mexp; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__temp == __last || *__temp != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __first = ++__temp; } break; @@ -4274,19 +4216,15 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, case '(': { ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); _ForwardIterator __temp = _VSTD::next(__first); if (__temp != __last && *__first == '?' && *__temp == ':') { ++__open_count_; __first = __parse_ecma_exp(++__temp, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); --__open_count_; ++__first; } @@ -4296,16 +4234,20 @@ basic_regex<_CharT, _Traits>::__parse_atom(_ForwardIterator __first, unsigned __temp_count = __marked_count_; ++__open_count_; __first = __parse_ecma_exp(__first, __last); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last || *__first != ')') - throw regex_error(regex_constants::error_paren); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_end_marked_subexpression(__temp_count); --__open_count_; ++__first; } } break; + case '*': + case '+': + case '?': + case '{': + __throw_regex_error(); + break; default: __first = __parse_pattern_character(__first, __last); break; @@ -4360,10 +4302,8 @@ basic_regex<_CharT, _Traits>::__parse_decimal_escape(_ForwardIterator __first, unsigned __v = *__first - '0'; for (++__first; '0' <= *__first && *__first <= '9'; ++__first) __v = 10 * __v + *__first - '0'; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__v > mark_count()) - throw regex_error(regex_constants::error_backref); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __push_back_ref(__v); } } @@ -4479,62 +4419,42 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(_CharT(*__t % 32)); __first = ++__t; } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); break; case 'u': ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); // drop through case 'x': ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); ++__first; -#ifndef _LIBCPP_NO_EXCEPTIONS if (__first == __last) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __hd = __traits_.value(*__first, 16); -#ifndef _LIBCPP_NO_EXCEPTIONS if (__hd == -1) - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); __sum = 16 * __sum + static_cast(__hd); if (__str) *__str = _CharT(__sum); @@ -4558,10 +4478,8 @@ basic_regex<_CharT, _Traits>::__parse_character_escape(_ForwardIterator __first, __push_char(*__first); ++__first; } -#ifndef _LIBCPP_NO_EXCEPTIONS else - throw regex_error(regex_constants::error_escape); -#endif // _LIBCPP_NO_EXCEPTIONS + __throw_regex_error(); break; } } @@ -5422,8 +5340,8 @@ match_results<_BidirectionalIterator, _Allocator>::match_results( __unmatched_(), __prefix_(), __suffix_(), - __position_start_(), - __ready_(false) + __ready_(false), + __position_start_() { } @@ -5648,9 +5566,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_ecma( __states.pop_back(); break; default: -#ifndef _LIBCPP_NO_EXCEPTIONS - throw regex_error(regex_constants::__re_err_unknown); -#endif + __throw_regex_error(); break; } @@ -5720,9 +5636,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_nosubs( __states.pop_back(); break; default: -#ifndef _LIBCPP_NO_EXCEPTIONS - throw regex_error(regex_constants::__re_err_unknown); -#endif + __throw_regex_error(); break; } } while (!__states.empty()); @@ -5808,9 +5722,7 @@ basic_regex<_CharT, _Traits>::__match_at_start_posix_subs( __states.pop_back(); break; default: -#ifndef _LIBCPP_NO_EXCEPTIONS - throw regex_error(regex_constants::__re_err_unknown); -#endif + __throw_regex_error(); break; } } while (!__states.empty()); diff --git a/include/scoped_allocator b/include/scoped_allocator index cd4987ad9bb6..9436dac9c199 100644 --- a/include/scoped_allocator +++ b/include/scoped_allocator @@ -58,6 +58,8 @@ public: template scoped_allocator_adaptor(const scoped_allocator_adaptor&& other) noexcept; + scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; + scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; ~scoped_allocator_adaptor(); inner_allocator_type& inner_allocator() noexcept; @@ -457,6 +459,8 @@ public: scoped_allocator_adaptor<_OuterA2, _InnerAllocs...>&& __other) _NOEXCEPT : base(_VSTD::move(__other)) {} + // scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&) = default; + // scoped_allocator_adaptor& operator=(scoped_allocator_adaptor&&) = default; // ~scoped_allocator_adaptor() = default; _LIBCPP_INLINE_VISIBILITY diff --git a/include/set b/include/set index 9d64a521da11..ac69e085241f 100644 --- a/include/set +++ b/include/set @@ -409,6 +409,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + private: typedef __tree __base; typedef allocator_traits __alloc_traits; @@ -819,6 +822,9 @@ public: typedef value_type& reference; typedef const value_type& const_reference; + static_assert((is_same::value), + "Allocator::value_type must be same type as value_type"); + private: typedef __tree __base; typedef allocator_traits __alloc_traits; diff --git a/include/setjmp.h b/include/setjmp.h new file mode 100644 index 000000000000..464b4a540897 --- /dev/null +++ b/include/setjmp.h @@ -0,0 +1,45 @@ +// -*- C++ -*- +//===--------------------------- setjmp.h ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SETJMP_H +#define _LIBCPP_SETJMP_H + +/* + setjmp.h synopsis + +Macros: + + setjmp + +Types: + + jmp_buf + +void longjmp(jmp_buf env, int val); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#ifndef setjmp +#define setjmp(env) setjmp(env) +#endif + +#endif // __cplusplus + +#endif // _LIBCPP_SETJMP_H diff --git a/include/sstream b/include/sstream index 27ae78f9d45f..308c3b62f2bc 100644 --- a/include/sstream +++ b/include/sstream @@ -236,7 +236,7 @@ protected: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch) : __hm_(0), __mode_(__wch) @@ -245,7 +245,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s, ios_base::openmode __wch) : __hm_(0), @@ -425,7 +425,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) @@ -607,7 +607,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off, } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, ios_base::openmode __wch) @@ -654,7 +654,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch) : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) @@ -662,7 +662,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base:: } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s, ios_base::openmode __wch) : basic_istream<_CharT, _Traits>(&__sb_), @@ -673,7 +673,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const stri #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) @@ -693,7 +693,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream& #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs) { @@ -702,7 +702,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rh } template -inline _LIBCPP_INLINE_VISIBILITY +inline void swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<_CharT, _Traits, _Allocator>& __y) @@ -711,7 +711,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringbuf<_CharT, _Traits, _Allocator>* basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const { @@ -719,7 +719,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, _Traits, _Allocator> basic_istringstream<_CharT, _Traits, _Allocator>::str() const { @@ -727,7 +727,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { @@ -773,7 +773,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch) : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) @@ -781,7 +781,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base:: } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s, ios_base::openmode __wch) : basic_ostream<_CharT, _Traits>(&__sb_), @@ -792,7 +792,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const stri #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs) : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) @@ -812,7 +812,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream& #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs) { @@ -821,7 +821,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rh } template -inline _LIBCPP_INLINE_VISIBILITY +inline void swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<_CharT, _Traits, _Allocator>& __y) @@ -830,7 +830,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringbuf<_CharT, _Traits, _Allocator>* basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const { @@ -838,7 +838,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, _Traits, _Allocator> basic_ostringstream<_CharT, _Traits, _Allocator>::str() const { @@ -846,7 +846,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { @@ -892,7 +892,7 @@ public: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch) : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) @@ -900,7 +900,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::op } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s, ios_base::openmode __wch) : basic_iostream<_CharT, _Traits>(&__sb_), @@ -911,7 +911,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs) : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) @@ -931,7 +931,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs) { @@ -940,7 +940,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_CharT, _Traits, _Allocator>& __y) @@ -949,7 +949,7 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_stringbuf<_CharT, _Traits, _Allocator>* basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const { @@ -957,7 +957,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_string<_CharT, _Traits, _Allocator> basic_stringstream<_CharT, _Traits, _Allocator>::str() const { @@ -965,7 +965,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::str() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { diff --git a/include/stddef.h b/include/stddef.h new file mode 100644 index 000000000000..8841bbea2978 --- /dev/null +++ b/include/stddef.h @@ -0,0 +1,62 @@ +// -*- C++ -*- +//===--------------------------- stddef.h ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \ + defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_STDDEF_H) +#define _LIBCPP_STDDEF_H + +/* + stddef.h synopsis + +Macros: + + offsetof(type,member-designator) + NULL + +Types: + + ptrdiff_t + size_t + max_align_t + nullptr_t + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +extern "C++" { +#include <__nullptr> +using std::nullptr_t; +} + +// Re-use the compiler's max_align_t where possible. +#if !defined(__CLANG_MAX_ALIGN_T_DEFINED) && !defined(_GCC_MAX_ALIGN_T) +typedef long double max_align_t; +#endif + +#endif + +#endif // _LIBCPP_STDDEF_H diff --git a/include/stdio.h b/include/stdio.h new file mode 100644 index 000000000000..56fb2d83bb28 --- /dev/null +++ b/include/stdio.h @@ -0,0 +1,127 @@ +// -*- C++ -*- +//===---------------------------- stdio.h ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_FILE) || defined(__need___FILE) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_STDIO_H) +#define _LIBCPP_STDIO_H + +/* + stdio.h synopsis + +Macros: + + BUFSIZ + EOF + FILENAME_MAX + FOPEN_MAX + L_tmpnam + NULL + SEEK_CUR + SEEK_END + SEEK_SET + TMP_MAX + _IOFBF + _IOLBF + _IONBF + stderr + stdin + stdout + +Types: + +FILE +fpos_t +size_t + +int remove(const char* filename); +int rename(const char* old, const char* new); +FILE* tmpfile(void); +char* tmpnam(char* s); +int fclose(FILE* stream); +int fflush(FILE* stream); +FILE* fopen(const char* restrict filename, const char* restrict mode); +FILE* freopen(const char* restrict filename, const char * restrict mode, + FILE * restrict stream); +void setbuf(FILE* restrict stream, char* restrict buf); +int setvbuf(FILE* restrict stream, char* restrict buf, int mode, size_t size); +int fprintf(FILE* restrict stream, const char* restrict format, ...); +int fscanf(FILE* restrict stream, const char * restrict format, ...); +int printf(const char* restrict format, ...); +int scanf(const char* restrict format, ...); +int snprintf(char* restrict s, size_t n, const char* restrict format, ...); // C99 +int sprintf(char* restrict s, const char* restrict format, ...); +int sscanf(const char* restrict s, const char* restrict format, ...); +int vfprintf(FILE* restrict stream, const char* restrict format, va_list arg); +int vfscanf(FILE* restrict stream, const char* restrict format, va_list arg); // C99 +int vprintf(const char* restrict format, va_list arg); +int vscanf(const char* restrict format, va_list arg); // C99 +int vsnprintf(char* restrict s, size_t n, const char* restrict format, // C99 + va_list arg); +int vsprintf(char* restrict s, const char* restrict format, va_list arg); +int vsscanf(const char* restrict s, const char* restrict format, va_list arg); // C99 +int fgetc(FILE* stream); +char* fgets(char* restrict s, int n, FILE* restrict stream); +int fputc(int c, FILE* stream); +int fputs(const char* restrict s, FILE* restrict stream); +int getc(FILE* stream); +int getchar(void); +char* gets(char* s); // removed in C++14 +int putc(int c, FILE* stream); +int putchar(int c); +int puts(const char* s); +int ungetc(int c, FILE* stream); +size_t fread(void* restrict ptr, size_t size, size_t nmemb, + FILE* restrict stream); +size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, + FILE* restrict stream); +int fgetpos(FILE* restrict stream, fpos_t* restrict pos); +int fseek(FILE* stream, long offset, int whence); +int fsetpos(FILE*stream, const fpos_t* pos); +long ftell(FILE* stream); +void rewind(FILE* stream); +void clearerr(FILE* stream); +int feof(FILE* stream); +int ferror(FILE* stream); +void perror(const char* s); +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +// snprintf +#if defined(_LIBCPP_MSVCRT) +extern "C++" { +#include "support/win32/support.h" +} +#endif + +#undef getc +#undef putc +#undef clearerr +#undef feof +#undef ferror + +#endif + +#endif // _LIBCPP_STDIO_H diff --git a/include/stdlib.h b/include/stdlib.h new file mode 100644 index 000000000000..12fd676a15f5 --- /dev/null +++ b/include/stdlib.h @@ -0,0 +1,130 @@ +// -*- C++ -*- +//===--------------------------- stdlib.h ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_malloc_and_calloc) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_STDLIB_H) +#define _LIBCPP_STDLIB_H + +/* + stdlib.h synopsis + +Macros: + + EXIT_FAILURE + EXIT_SUCCESS + MB_CUR_MAX + NULL + RAND_MAX + +Types: + + size_t + div_t + ldiv_t + lldiv_t // C99 + +double atof (const char* nptr); +int atoi (const char* nptr); +long atol (const char* nptr); +long long atoll(const char* nptr); // C99 +double strtod (const char* restrict nptr, char** restrict endptr); +float strtof (const char* restrict nptr, char** restrict endptr); // C99 +long double strtold (const char* restrict nptr, char** restrict endptr); // C99 +long strtol (const char* restrict nptr, char** restrict endptr, int base); +long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99 +unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base); +unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99 +int rand(void); +void srand(unsigned int seed); +void* calloc(size_t nmemb, size_t size); +void free(void* ptr); +void* malloc(size_t size); +void* realloc(void* ptr, size_t size); +void abort(void); +int atexit(void (*func)(void)); +void exit(int status); +void _Exit(int status); +char* getenv(const char* name); +int system(const char* string); +void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); +void qsort(void* base, size_t nmemb, size_t size, + int (*compar)(const void *, const void *)); +int abs( int j); +long abs( long j); +long long abs(long long j); // C++0X +long labs( long j); +long long llabs(long long j); // C99 +div_t div( int numer, int denom); +ldiv_t div( long numer, long denom); +lldiv_t div(long long numer, long long denom); // C++0X +ldiv_t ldiv( long numer, long denom); +lldiv_t lldiv(long long numer, long long denom); // C99 +int mblen(const char* s, size_t n); +int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n); +int wctomb(char* s, wchar_t wchar); +size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n); +size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); +int at_quick_exit(void (*func)(void)) // C++11 +void quick_exit(int status); // C++11 +void *aligned_alloc(size_t alignment, size_t size); // C11 + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +extern "C++" { + +#ifdef _LIBCPP_MSVCRT +#include "support/win32/locale_win32.h" +#endif // _LIBCPP_MSVCRT + +#undef abs +#undef div +#undef labs +#undef ldiv +#ifndef _LIBCPP_HAS_NO_LONG_LONG +#undef llabs +#undef lldiv +#endif + +// MSVCRT already has the correct prototype in if __cplusplus is defined +#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) +inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);} +#ifndef _LIBCPP_HAS_NO_LONG_LONG +inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);} +#endif // _LIBCPP_HAS_NO_LONG_LONG + +inline _LIBCPP_INLINE_VISIBILITY ldiv_t div( long __x, long __y) _NOEXCEPT {return ldiv(__x, __y);} +#ifndef _LIBCPP_HAS_NO_LONG_LONG +inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x, long long __y) _NOEXCEPT {return lldiv(__x, __y);} +#endif // _LIBCPP_HAS_NO_LONG_LONG +#endif // _LIBCPP_MSVCRT / __sun__ / _AIX + +} // extern "C++" + +#endif // __cplusplus + +#endif // _LIBCPP_STDLIB_H diff --git a/include/streambuf b/include/streambuf index 603c68038796..e75e8be2271d 100644 --- a/include/streambuf +++ b/include/streambuf @@ -220,7 +220,7 @@ basic_streambuf<_CharT, _Traits>::~basic_streambuf() } template -inline _LIBCPP_INLINE_VISIBILITY +inline locale basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) { @@ -231,7 +231,7 @@ basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) } template -inline _LIBCPP_INLINE_VISIBILITY +inline locale basic_streambuf<_CharT, _Traits>::getloc() const { @@ -239,7 +239,7 @@ basic_streambuf<_CharT, _Traits>::getloc() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline basic_streambuf<_CharT, _Traits>* basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n) { @@ -247,7 +247,7 @@ basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::pos_type basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off, ios_base::seekdir __way, @@ -257,7 +257,7 @@ basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off, } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::pos_type basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp, ios_base::openmode __which) @@ -266,7 +266,7 @@ basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp, } template -inline _LIBCPP_INLINE_VISIBILITY +inline int basic_streambuf<_CharT, _Traits>::pubsync() { @@ -274,7 +274,7 @@ basic_streambuf<_CharT, _Traits>::pubsync() } template -inline _LIBCPP_INLINE_VISIBILITY +inline streamsize basic_streambuf<_CharT, _Traits>::in_avail() { @@ -284,7 +284,7 @@ basic_streambuf<_CharT, _Traits>::in_avail() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::snextc() { @@ -294,7 +294,7 @@ basic_streambuf<_CharT, _Traits>::snextc() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sbumpc() { @@ -304,7 +304,7 @@ basic_streambuf<_CharT, _Traits>::sbumpc() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sgetc() { @@ -314,7 +314,7 @@ basic_streambuf<_CharT, _Traits>::sgetc() } template -inline _LIBCPP_INLINE_VISIBILITY +inline streamsize basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n) { @@ -322,7 +322,7 @@ basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c) { @@ -332,7 +332,7 @@ basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sungetc() { @@ -342,7 +342,7 @@ basic_streambuf<_CharT, _Traits>::sungetc() } template -inline _LIBCPP_INLINE_VISIBILITY +inline typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sputc(char_type __c) { @@ -353,7 +353,7 @@ basic_streambuf<_CharT, _Traits>::sputc(char_type __c) } template -inline _LIBCPP_INLINE_VISIBILITY +inline streamsize basic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n) { @@ -411,7 +411,7 @@ basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_streambuf<_CharT, _Traits>::gbump(int __n) { @@ -419,7 +419,7 @@ basic_streambuf<_CharT, _Traits>::gbump(int __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) @@ -430,7 +430,7 @@ basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext, } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_streambuf<_CharT, _Traits>::pbump(int __n) { @@ -438,7 +438,7 @@ basic_streambuf<_CharT, _Traits>::pbump(int __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void basic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend) { diff --git a/include/string b/include/string index 6be21955b146..ee5db1aab63b 100644 --- a/include/string +++ b/include/string @@ -115,8 +115,8 @@ public: basic_string& operator=(const basic_string& str); basic_string& operator=(basic_string&& str) noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + allocator_type::propagate_on_container_move_assignment::value || + allocator_type::is_always_equal::value ); // C++17 basic_string& operator=(const value_type* s); basic_string& operator=(value_type c); basic_string& operator=(initializer_list); @@ -517,10 +517,14 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits {return __c1 < __c2;} static int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a); static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -550,7 +554,7 @@ char_traits<_CharT>::compare(const char_type* __s1, const char_type* __s2, size_ } template -inline _LIBCPP_INLINE_VISIBILITY +inline size_t char_traits<_CharT>::length(const char_type* __s) { @@ -561,7 +565,7 @@ char_traits<_CharT>::length(const char_type* __s) } template -inline _LIBCPP_INLINE_VISIBILITY +inline const _CharT* char_traits<_CharT>::find(const char_type* __s, size_t __n, const char_type& __a) { @@ -595,7 +599,7 @@ char_traits<_CharT>::move(char_type* __s1, const char_type* __s2, size_t __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _CharT* char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { @@ -607,7 +611,7 @@ char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline _CharT* char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) { @@ -726,11 +730,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} + _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); + _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a); static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -742,10 +752,10 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static inline _LIBCPP_CONSTEXPR bool eq_int_type(int_type __c1, int_type __c2) _NOEXCEPT {return __c1 == __c2;} static inline _LIBCPP_CONSTEXPR int_type eof() _NOEXCEPT - {return int_type(0xDFFF);} + {return int_type(0xFFFF);} }; -inline _LIBCPP_INLINE_VISIBILITY +inline int char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) { @@ -759,7 +769,7 @@ char_traits::compare(const char_type* __s1, const char_type* __s2, siz return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline size_t char_traits::length(const char_type* __s) { @@ -769,7 +779,7 @@ char_traits::length(const char_type* __s) return __len; } -inline _LIBCPP_INLINE_VISIBILITY +inline const char16_t* char_traits::find(const char_type* __s, size_t __n, const char_type& __a) { @@ -782,7 +792,7 @@ char_traits::find(const char_type* __s, size_t __n, const char_type& _ return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline char16_t* char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) { @@ -802,7 +812,7 @@ char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char16_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) { @@ -813,7 +823,7 @@ char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char16_t* char_traits::assign(char_type* __s, size_t __n, char_type __a) { @@ -839,11 +849,17 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits static inline _LIBCPP_CONSTEXPR bool lt(char_type __c1, char_type __c2) _NOEXCEPT {return __c1 < __c2;} + _LIBCPP_INLINE_VISIBILITY static int compare(const char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static size_t length(const char_type* __s); + _LIBCPP_INLINE_VISIBILITY static const char_type* find(const char_type* __s, size_t __n, const char_type& __a); + _LIBCPP_INLINE_VISIBILITY static char_type* move(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n); + _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a); static inline _LIBCPP_CONSTEXPR int_type not_eof(int_type __c) _NOEXCEPT @@ -858,7 +874,7 @@ struct _LIBCPP_TYPE_VIS_ONLY char_traits {return int_type(0xFFFFFFFF);} }; -inline _LIBCPP_INLINE_VISIBILITY +inline int char_traits::compare(const char_type* __s1, const char_type* __s2, size_t __n) { @@ -872,7 +888,7 @@ char_traits::compare(const char_type* __s1, const char_type* __s2, siz return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline size_t char_traits::length(const char_type* __s) { @@ -882,7 +898,7 @@ char_traits::length(const char_type* __s) return __len; } -inline _LIBCPP_INLINE_VISIBILITY +inline const char32_t* char_traits::find(const char_type* __s, size_t __n, const char_type& __a) { @@ -895,7 +911,7 @@ char_traits::find(const char_type* __s, size_t __n, const char_type& _ return 0; } -inline _LIBCPP_INLINE_VISIBILITY +inline char32_t* char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) { @@ -915,7 +931,7 @@ char_traits::move(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char32_t* char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) { @@ -926,7 +942,7 @@ char_traits::copy(char_type* __s1, const char_type* __s2, size_t __n) return __r; } -inline _LIBCPP_INLINE_VISIBILITY +inline char32_t* char_traits::assign(char_type* __s, size_t __n, char_type __a) { @@ -1185,7 +1201,7 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common) #pragma warning( pop ) #endif // _LIBCPP_MSVC -#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template struct __padding @@ -1198,7 +1214,7 @@ struct __padding<_CharT, 1> { }; -#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template class _LIBCPP_TYPE_VIS_ONLY basic_string @@ -1234,7 +1250,7 @@ public: private: -#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT struct __long { @@ -1294,7 +1310,7 @@ private: value_type __data_[__min_cap]; }; -#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT union __ulx{__long __lx; __short __lxx;}; @@ -1377,8 +1393,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_string& operator=(basic_string&& __str) - _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); #endif _LIBCPP_INLINE_VISIBILITY basic_string& operator=(const value_type* __s) {return assign(__s);} basic_string& operator=(value_type __c); @@ -1445,7 +1460,8 @@ public: _LIBCPP_INLINE_VISIBILITY size_type length() const _NOEXCEPT {return size();} _LIBCPP_INLINE_VISIBILITY size_type max_size() const _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type capacity() const _NOEXCEPT - {return (__is_long() ? __get_long_cap() : __min_cap) - 1;} + {return (__is_long() ? __get_long_cap() + : static_cast(__min_cap)) - 1;} void resize(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY void resize(size_type __n) {resize(__n, value_type());} @@ -1509,6 +1525,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_string& assign(basic_string&& str) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) {*this = _VSTD::move(str); return *this;} #endif basic_string& assign(const basic_string& __str, size_type __pos, size_type __n=npos); @@ -1697,7 +1714,7 @@ private: const allocator_type& __alloc() const _NOEXCEPT {return __r_.second();} -#ifdef _LIBCPP_ALTERNATE_STRING_LAYOUT +#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT @@ -1715,7 +1732,7 @@ private: {return __r_.first().__s.__size_;} # endif -#else // _LIBCPP_ALTERNATE_STRING_LAYOUT +#else // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_short_size(size_type __s) _NOEXCEPT @@ -1733,7 +1750,7 @@ private: {return __r_.first().__s.__size_ >> 1;} # endif -#endif // _LIBCPP_ALTERNATE_STRING_LAYOUT +#endif // _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT _LIBCPP_INLINE_VISIBILITY void __set_long_size(size_type __s) _NOEXCEPT @@ -1785,11 +1802,11 @@ private: template static _LIBCPP_INLINE_VISIBILITY size_type __align_it(size_type __s) _NOEXCEPT - {return __s + (__a-1) & ~(__a-1);} + {return (__s + (__a-1)) & ~(__a-1);} enum {__alignment = 16}; static _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __s) _NOEXCEPT - {return (__s < __min_cap ? __min_cap : + {return (__s < __min_cap ? static_cast(__min_cap) : __align_it (__s+1)) - 1;} @@ -1845,10 +1862,15 @@ private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY - void __move_assign(basic_string& __str, false_type); + void __move_assign(basic_string& __str, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value); _LIBCPP_INLINE_VISIBILITY void __move_assign(basic_string& __str, true_type) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT; +#else _NOEXCEPT_(is_nothrow_move_assignable::value); +#endif #endif _LIBCPP_INLINE_VISIBILITY @@ -1936,7 +1958,12 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string() template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) - : __r_(__a) +#if _LIBCPP_STD_VER <= 14 + _NOEXCEPT_(is_nothrow_copy_constructible::value) +#else + _NOEXCEPT +#endif +: __r_(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -2425,6 +2452,7 @@ template inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value) { if (__alloc() != __str.__alloc()) assign(__str); @@ -2436,7 +2464,11 @@ template inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) +#if _LIBCPP_STD_VER > 14 + _NOEXCEPT +#else _NOEXCEPT_(is_nothrow_move_assignable::value) +#endif { clear(); shrink_to_fit(); @@ -2449,8 +2481,7 @@ template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) - _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__str, integral_constant()); @@ -3782,7 +3813,11 @@ bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT { - return __rhs.compare(__lhs) == 0; + typedef basic_string<_CharT, _Traits, _Allocator> _String; + _LIBCPP_ASSERT(__lhs != nullptr, "operator==(char*, basic_string): received nullptr"); + size_t __lhs_len = _Traits::length(__lhs); + if (__lhs_len != __rhs.size()) return false; + return __rhs.compare(0, _String::npos, __lhs, __lhs_len) == 0; } template @@ -3791,7 +3826,11 @@ bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT { - return __lhs.compare(__rhs) == 0; + typedef basic_string<_CharT, _Traits, _Allocator> _String; + _LIBCPP_ASSERT(__rhs != nullptr, "operator==(basic_string, char*): received nullptr"); + size_t __rhs_len = _Traits::length(__rhs); + if (__rhs_len != __lhs.size()) return false; + return __lhs.compare(0, _String::npos, __rhs, __rhs_len) == 0; } // operator!= diff --git a/include/support/musl/xlocale.h b/include/support/musl/xlocale.h new file mode 100644 index 000000000000..3e31c99596ce --- /dev/null +++ b/include/support/musl/xlocale.h @@ -0,0 +1,58 @@ +// -*- C++ -*- +//===------------------- support/musl/xlocale.h ------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// This adds support for the extended locale functions that are currently +// missing from the Musl C library. +// +// This only works when the specified locale is "C" or "POSIX", but that's +// about as good as we can do without implementing full xlocale support +// in Musl. +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_MUSL_XLOCALE_H +#define _LIBCPP_SUPPORT_MUSL_XLOCALE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +static inline long long strtoll_l(const char *nptr, char **endptr, int base, + locale_t) { + return strtoll(nptr, endptr, base); +} + +static inline unsigned long long strtoull_l(const char *nptr, char **endptr, + int base, locale_t) { + return strtoull(nptr, endptr, base); +} + +static inline long long wcstoll_l(const wchar_t *nptr, wchar_t **endptr, + int base, locale_t) { + return wcstoll(nptr, endptr, base); +} + +static inline unsigned long long wcstoull_l(const wchar_t *nptr, + wchar_t **endptr, int base, + locale_t) { + return wcstoull(nptr, endptr, base); +} + +static inline long double wcstold_l(const wchar_t *nptr, wchar_t **endptr, + locale_t) { + return wcstold(nptr, endptr); +} + +#ifdef __cplusplus +} +#endif + +#endif // _LIBCPP_SUPPORT_MUSL_XLOCALE_H diff --git a/include/system_error b/include/system_error index 66bf6d6c4249..134bb3274031 100644 --- a/include/system_error +++ b/include/system_error @@ -371,7 +371,7 @@ public: error_category() _NOEXCEPT; #else _LIBCPP_ALWAYS_INLINE - _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT; + _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT #endif private: error_category(const error_category&);// = delete; diff --git a/include/thread b/include/thread index 8a30102f427e..6857e9edb68b 100644 --- a/include/thread +++ b/include/thread @@ -113,11 +113,38 @@ void sleep_for(const chrono::duration& rel_time); _LIBCPP_BEGIN_NAMESPACE_STD +template class __thread_specific_ptr; +class _LIBCPP_TYPE_VIS __thread_struct; +class _LIBCPP_HIDDEN __thread_struct_imp; +class __assoc_sub_state; + +_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); + +class _LIBCPP_TYPE_VIS __thread_struct +{ + __thread_struct_imp* __p_; + + __thread_struct(const __thread_struct&); + __thread_struct& operator=(const __thread_struct&); +public: + __thread_struct(); + ~__thread_struct(); + + void notify_all_at_thread_exit(condition_variable*, mutex*); + void __make_ready_at_thread_exit(__assoc_sub_state*); +}; + template class __thread_specific_ptr { pthread_key_t __key_; + // Only __thread_local_data() may construct a __thread_specific_ptr + // and only with _Tp == __thread_struct. + static_assert((is_same<_Tp, __thread_struct>::value), ""); + __thread_specific_ptr(); + friend _LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); + __thread_specific_ptr(const __thread_specific_ptr&); __thread_specific_ptr& operator=(const __thread_specific_ptr&); @@ -125,7 +152,6 @@ class __thread_specific_ptr public: typedef _Tp* pointer; - __thread_specific_ptr(); ~__thread_specific_ptr(); _LIBCPP_INLINE_VISIBILITY @@ -159,7 +185,10 @@ __thread_specific_ptr<_Tp>::__thread_specific_ptr() template __thread_specific_ptr<_Tp>::~__thread_specific_ptr() { - pthread_key_delete(__key_); + // __thread_specific_ptr is only created with a static storage duration + // so this destructor is only invoked during program termination. Invoking + // pthread_key_delete(__key_) may prevent other threads from deleting their + // thread local data. For this reason we leak the key. } template @@ -289,6 +318,7 @@ public: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY thread(thread&& __t) _NOEXCEPT : __t_(__t.__t_) {__t.__t_ = 0;} + _LIBCPP_INLINE_VISIBILITY thread& operator=(thread&& __t) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -307,26 +337,6 @@ public: static unsigned hardware_concurrency() _NOEXCEPT; }; -class __assoc_sub_state; - -class _LIBCPP_HIDDEN __thread_struct_imp; - -class _LIBCPP_TYPE_VIS __thread_struct -{ - __thread_struct_imp* __p_; - - __thread_struct(const __thread_struct&); - __thread_struct& operator=(const __thread_struct&); -public: - __thread_struct(); - ~__thread_struct(); - - void notify_all_at_thread_exit(condition_variable*, mutex*); - void __make_ready_at_thread_exit(__assoc_sub_state*); -}; - -_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); - #ifndef _LIBCPP_HAS_NO_VARIADICS template @@ -390,7 +400,7 @@ thread::thread(_Fp __f) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -inline _LIBCPP_INLINE_VISIBILITY +inline thread& thread::operator=(thread&& __t) _NOEXCEPT { diff --git a/include/tuple b/include/tuple index 3a22aa5ff5ac..cb1e27d93cf2 100644 --- a/include/tuple +++ b/include/tuple @@ -80,28 +80,33 @@ template tuple tuple_cat(Tuples&&... tpls); // cons // 20.4.1.4, tuple helper classes: template class tuple_size; // undefined template class tuple_size>; -template class tuple_element; // undefined -template class tuple_element>; -template - using tuple_element_t = typename tuple_element <_Ip, _Tp...>::type; // C++14 +template class tuple_element; // undefined +template class tuple_element>; +template + using tuple_element_t = typename tuple_element ::type; // C++14 // 20.4.1.5, element access: -template +template typename tuple_element>::type& get(tuple&) noexcept; // constexpr in C++14 -template - typename const tuple_element>::type & +template + const typename tuple_element>::type& get(const tuple&) noexcept; // constexpr in C++14 -template +template typename tuple_element>::type&& get(tuple&&) noexcept; // constexpr in C++14 +template + const typename tuple_element>::type&& + get(const tuple&&) noexcept; // constexpr in C++14 template constexpr T1& get(tuple&) noexcept; // C++14 template - constexpr T1 const& get(const tuple&) noexcept; // C++14 + constexpr const T1& get(const tuple&) noexcept; // C++14 template constexpr T1&& get(tuple&&) noexcept; // C++14 +template + constexpr const T1&& get(const tuple&&) noexcept; // C++14 // 20.4.1.6, relational operators: template bool operator==(const tuple&, const tuple&); // constexpr in C++14 @@ -507,6 +512,8 @@ class _LIBCPP_TYPE_VIS_ONLY tuple const typename tuple_element<_Jp, tuple<_Up...> >::type& get(const tuple<_Up...>&) _NOEXCEPT; template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Jp, tuple<_Up...> >::type&& get(tuple<_Up...>&&) _NOEXCEPT; + template friend _LIBCPP_CONSTEXPR_AFTER_CXX11 + const typename tuple_element<_Jp, tuple<_Up...> >::type&& get(const tuple<_Up...>&&) _NOEXCEPT; public: template && __t) _NOEXCEPT static_cast<__tuple_leaf<_Ip, type>&&>(__t.base_).get()); } +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, tuple<_Tp...> >::type&& +get(const tuple<_Tp...>&& __t) _NOEXCEPT +{ + typedef typename tuple_element<_Ip, tuple<_Tp...> >::type type; + return static_cast( + static_cast&&>(__t.base_).get()); +} + #if _LIBCPP_STD_VER > 11 // get by type template @@ -822,6 +839,13 @@ constexpr _T1&& get(tuple<_Args...>&& __tup) noexcept return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const&& get(tuple<_Args...> const&& __tup) noexcept +{ + return _VSTD::get<__find_exactly_one_t<_T1, _Args...>::value>(_VSTD::move(__tup)); +} + #endif // tie diff --git a/include/type_traits b/include/type_traits index a0c1bc565c04..b7adfebceeb9 100644 --- a/include/type_traits +++ b/include/type_traits @@ -203,8 +203,160 @@ namespace std using result_of_t = typename result_of::type; // C++14 template - using void_t = void; -} // C++17 + using void_t = void; // C++17 + + // See C++14 20.10.4.1, primary type categories + template constexpr bool is_void_v + = is_void::value; // C++17 + template constexpr bool is_null_pointer_v + = is_null_pointer::value; // C++17 + template constexpr bool is_integral_v + = is_integral::value; // C++17 + template constexpr bool is_floating_point_v + = is_floating_point::value; // C++17 + template constexpr bool is_array_v + = is_array::value; // C++17 + template constexpr bool is_pointer_v + = is_pointer::value; // C++17 + template constexpr bool is_lvalue_reference_v + = is_lvalue_reference::value; // C++17 + template constexpr bool is_rvalue_reference_v + = is_rvalue_reference::value; // C++17 + template constexpr bool is_member_object_pointer_v + = is_member_object_pointer::value; // C++17 + template constexpr bool is_member_function_pointer_v + = is_member_function_pointer::value; // C++17 + template constexpr bool is_enum_v + = is_enum::value; // C++17 + template constexpr bool is_union_v + = is_union::value; // C++17 + template constexpr bool is_class_v + = is_class::value; // C++17 + template constexpr bool is_function_v + = is_function::value; // C++17 + + // See C++14 20.10.4.2, composite type categories + template constexpr bool is_reference_v + = is_reference::value; // C++17 + template constexpr bool is_arithmetic_v + = is_arithmetic::value; // C++17 + template constexpr bool is_fundamental_v + = is_fundamental::value; // C++17 + template constexpr bool is_object_v + = is_object::value; // C++17 + template constexpr bool is_scalar_v + = is_scalar::value; // C++17 + template constexpr bool is_compound_v + = is_compound::value; // C++17 + template constexpr bool is_member_pointer_v + = is_member_pointer::value; // C++17 + + // See C++14 20.10.4.3, type properties + template constexpr bool is_const_v + = is_const::value; // C++17 + template constexpr bool is_volatile_v + = is_volatile::value; // C++17 + template constexpr bool is_trivial_v + = is_trivial::value; // C++17 + template constexpr bool is_trivially_copyable_v + = is_trivially_copyable::value; // C++17 + template constexpr bool is_standard_layout_v + = is_standard_layout::value; // C++17 + template constexpr bool is_pod_v + = is_pod::value; // C++17 + template constexpr bool is_literal_type_v + = is_literal_type::value; // C++17 + template constexpr bool is_empty_v + = is_empty::value; // C++17 + template constexpr bool is_polymorphic_v + = is_polymorphic::value; // C++17 + template constexpr bool is_abstract_v + = is_abstract::value; // C++17 + template constexpr bool is_final_v + = is_final::value; // C++17 + template constexpr bool is_signed_v + = is_signed::value; // C++17 + template constexpr bool is_unsigned_v + = is_unsigned::value; // C++17 + template constexpr bool is_constructible_v + = is_constructible::value; // C++17 + template constexpr bool is_default_constructible_v + = is_default_constructible::value; // C++17 + template constexpr bool is_copy_constructible_v + = is_copy_constructible::value; // C++17 + template constexpr bool is_move_constructible_v + = is_move_constructible::value; // C++17 + template constexpr bool is_assignable_v + = is_assignable::value; // C++17 + template constexpr bool is_copy_assignable_v + = is_copy_assignable::value; // C++17 + template constexpr bool is_move_assignable_v + = is_move_assignable::value; // C++17 + template constexpr bool is_destructible_v + = is_destructible::value; // C++17 + template constexpr bool is_trivially_constructible_v + = is_trivially_constructible::value; // C++17 + template constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible::value; // C++17 + template constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible::value; // C++17 + template constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible::value; // C++17 + template constexpr bool is_trivially_assignable_v + = is_trivially_assignable::value; // C++17 + template constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable::value; // C++17 + template constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable::value; // C++17 + template constexpr bool is_trivially_destructible_v + = is_trivially_destructible::value; // C++17 + template constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible::value; // C++17 + template constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible::value; // C++17 + template constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible::value; // C++17 + template constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible::value; // C++17 + template constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable::value; // C++17 + template constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable::value; // C++17 + template constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable::value; // C++17 + template constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible::value; // C++17 + template constexpr bool has_virtual_destructor_v + = has_virtual_destructor::value; // C++17 + + // See C++14 20.10.5, type property queries + template constexpr size_t alignment_of_v + = alignment_of::value; // C++17 + template constexpr size_t rank_v + = rank::value; // C++17 + template constexpr size_t extent_v + = extent::value; // C++17 + + // See C++14 20.10.6, type relations + template constexpr bool is_same_v + = is_same::value; // C++17 + template constexpr bool is_base_of_v + = is_base_of::value; // C++17 + template constexpr bool is_convertible_v + = is_convertible::value; // C++17 + + // [meta.logical], logical operator traits: + template struct conjunction; // C++17 + template + constexpr bool conjunction_v = conjunction::value; // C++17 + template struct disjunction; // C++17 + template + constexpr bool disjunction_v = disjunction::value; // C++17 + template struct negation; // C++17 + template + constexpr bool negation_v = negation::value; // C++17 + +} */ #include <__config> @@ -244,6 +396,55 @@ template struct _LIBCPP_TYPE_VIS_ONLY enable_if {typedef template using enable_if_t = typename enable_if<_Bp, _Tp>::type; #endif +// addressof + +template +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return (_Tp*)&reinterpret_cast(__x); +} + +#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 struct __two {char __lx[2];}; @@ -269,24 +470,111 @@ _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; #if _LIBCPP_STD_VER > 14 template using bool_constant = integral_constant; -#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> +#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> #else -#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant +#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant #endif typedef _LIBCPP_BOOL_CONSTANT(true) true_type; typedef _LIBCPP_BOOL_CONSTANT(false) false_type; +#if !defined(_LIBCPP_HAS_NO_VARIADICS) + +// __lazy_and + +template +struct __lazy_and_impl; + +template +struct __lazy_and_impl : false_type {}; + +template <> +struct __lazy_and_impl : true_type {}; + +template +struct __lazy_and_impl : integral_constant {}; + +template +struct __lazy_and_impl : __lazy_and_impl<_Hp::type::value, _Tp...> {}; + +template +struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; + +// __lazy_or + +template +struct __lazy_or_impl; + +template +struct __lazy_or_impl : true_type {}; + +template <> +struct __lazy_or_impl : false_type {}; + +template +struct __lazy_or_impl + : __lazy_or_impl<_Hp::type::value, _Tp...> {}; + +template +struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {}; + +// __lazy_not + +template +struct __lazy_not : integral_constant {}; + +// __and_ +template struct __and_; +template<> struct __and_<> : true_type {}; + +template struct __and_<_B0> : _B0 {}; + +template +struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {}; + +template +struct __and_<_B0, _B1, _B2, _Bn...> + : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {}; + +// __or_ +template struct __or_; +template<> struct __or_<> : false_type {}; + +template struct __or_<_B0> : _B0 {}; + +template +struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {}; + +template +struct __or_<_B0, _B1, _B2, _Bn...> + : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {}; + +// __not_ +template +struct __not_ : conditional<_Tp::value, false_type, true_type>::type {}; + +#endif // !defined(_LIBCPP_HAS_NO_VARIADICS) + // is_const template struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; +#endif + // is_volatile template struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; +#endif + // remove_const template struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; @@ -319,6 +607,11 @@ template <> struct __libcpp_is_void : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_void : public __libcpp_is_void::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; +#endif + // __is_nullptr_t template struct __is_nullptr_t_impl : public false_type {}; @@ -330,6 +623,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t #if _LIBCPP_STD_VER > 11 template struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer : public __is_nullptr_t_impl::type> {}; + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; +#endif #endif // is_integral @@ -360,6 +658,11 @@ template <> struct __libcpp_is_integral<__uint128_t> : public tr template struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; +#endif + // is_floating_point template struct __libcpp_is_floating_point : public false_type {}; @@ -370,6 +673,11 @@ template <> struct __libcpp_is_floating_point : public tru template struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __libcpp_is_floating_point::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; +#endif + // is_array template struct _LIBCPP_TYPE_VIS_ONLY is_array @@ -379,6 +687,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> template struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; +#endif + // is_pointer template struct __libcpp_is_pointer : public false_type {}; @@ -387,6 +700,11 @@ template struct __libcpp_is_pointer<_Tp*> : public true_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __libcpp_is_pointer::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; +#endif + // is_reference template struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; @@ -403,6 +721,16 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public t template struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; +#endif // is_union #if __has_feature(is_union) || (_GNUC_VER >= 403) @@ -418,6 +746,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_union #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; +#endif + // is_class #if __has_feature(is_class) || (_GNUC_VER >= 403) @@ -438,11 +771,21 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_class #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; +#endif + // is_same template struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; template struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; +#endif + // is_function namespace __libcpp_is_function_imp @@ -468,13 +811,18 @@ template struct __libcpp_is_function<_Tp, true> : public false_type template struct _LIBCPP_TYPE_VIS_ONLY is_function : public __libcpp_is_function<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; +#endif + // is_member_function_pointer // template struct __libcpp_is_member_function_pointer : public false_type {}; // template struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; // -template +template struct __member_pointer_traits_imp { // forward declaration; specializations later }; @@ -490,6 +838,11 @@ struct __libcpp_is_member_function_pointer<_Ret _Class::*> template struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer::type>::type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; +#endif + // is_member_pointer template struct __libcpp_is_member_pointer : public false_type {}; @@ -498,12 +851,22 @@ template struct __libcpp_is_member_pointer<_Tp _Up::*> : template struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __libcpp_is_member_pointer::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; +#endif + // is_member_object_pointer template struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant::value && !is_member_function_pointer<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; +#endif + // is_enum #if __has_feature(is_enum) || (_GNUC_VER >= 403) @@ -527,12 +890,22 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_enum #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; +#endif + // is_arithmetic template struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant::value || is_floating_point<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; +#endif + // is_fundamental template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental @@ -540,6 +913,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_fundamental __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; +#endif + // is_scalar template struct _LIBCPP_TYPE_VIS_ONLY is_scalar @@ -551,6 +929,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_scalar template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; +#endif + // is_object template struct _LIBCPP_TYPE_VIS_ONLY is_object @@ -559,11 +942,21 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_object is_union<_Tp>::value || is_class<_Tp>::value > {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; +#endif + // is_compound template struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; +#endif + // add_const template ::value || @@ -701,6 +1094,11 @@ template struct __libcpp_is_signed<_Tp, false> : public false_type { template struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; +#endif + // is_unsigned template ::value> @@ -716,6 +1114,11 @@ template struct __libcpp_is_unsigned<_Tp, false> : public false_type template struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; +#endif + // rank template struct _LIBCPP_TYPE_VIS_ONLY rank @@ -725,6 +1128,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> template struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant::value + 1> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; +#endif + // extent template struct _LIBCPP_TYPE_VIS_ONLY extent @@ -738,6 +1146,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0 template struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Ip>::value; +#endif + // remove_extent template struct _LIBCPP_TYPE_VIS_ONLY remove_extent @@ -804,6 +1217,11 @@ template struct __libcpp_abstract<_Tp, false> : public false_type {} template struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; +#endif + // is_final #if defined(_LIBCPP_HAS_IS_FINAL) @@ -819,6 +1237,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_final : public integral_constant {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; +#endif + // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF @@ -854,6 +1277,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of #endif // _LIBCPP_HAS_IS_BASE_OF +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Bp, _Dp>::value; +#endif + // is_convertible #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) @@ -981,6 +1409,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_convertible #endif // __has_feature(is_convertible_to) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_convertible_v + = is_convertible<_From, _To>::value; +#endif + // is_empty #if __has_feature(is_empty) || (_GNUC_VER >= 407) @@ -1012,6 +1445,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_emp #endif // __has_feature(is_empty) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; +#endif + // is_polymorphic #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC) @@ -1032,6 +1470,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic #endif // __has_feature(is_polymorphic) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; +#endif + // has_virtual_destructor #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403) @@ -1046,11 +1489,21 @@ template struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; +#endif + // alignment_of template struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; +#endif + // aligned_storage template @@ -1143,7 +1596,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage union type { _Aligner __align; - unsigned char __data[_Len]; + unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; }; }; @@ -1158,7 +1611,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ - unsigned char __lx[_Len];\ + unsigned char __lx[(_Len + n - 1)/n * n];\ };\ } @@ -1290,18 +1743,6 @@ public: template class __promote : public __promote_imp<_A1, _A2, _A3> {}; -#ifdef _LIBCPP_STORE_AS_OPTIMIZATION - -// __transform - -template ::value> struct __transform {typedef _Tp type;}; -template struct __transform<_Tp, 1, true> {typedef unsigned char type;}; -template struct __transform<_Tp, 2, true> {typedef unsigned short type;}; -template struct __transform<_Tp, 4, true> {typedef unsigned int type;}; -template struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; - -#endif // _LIBCPP_STORE_AS_OPTIMIZATION - // make_signed / make_unsigned typedef @@ -1482,21 +1923,19 @@ public: template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { -private: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - static _Tp&& __t(); - static _Up&& __u(); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - static _Tp __t(); - static _Up __u(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -public: - typedef typename remove_reference::type type; + typedef typename decay() : _VSTD::declval<_Up>() + )>::type type; }; #else // _LIBCPP_HAS_NO_VARIADICS -template struct common_type; +// bullet 1 - sizeof...(Tp) == 0 + +template +struct _LIBCPP_TYPE_VIS_ONLY common_type {}; + +// bullet 2 - sizeof...(Tp) == 1 template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> @@ -1504,22 +1943,45 @@ struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> typedef typename decay<_Tp>::type type; }; +// bullet 3 - sizeof...(Tp) == 2 + +template +struct __common_type2 {}; + +template +struct __common_type2<_Tp, _Up, + typename __void_t() : _VSTD::declval<_Up>() + )>::type> +{ + typedef typename decay() : _VSTD::declval<_Up>() + )>::type type; +}; + template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> + : __common_type2<_Tp, _Up> {}; + +// bullet 4 - sizeof...(Tp) > 2 + +template struct __common_types; + +template +struct __common_type_impl {}; + +template +struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>, + typename __void_t::type>::type> { -private: - static _Tp&& __t(); - static _Up&& __u(); - static bool __f(); -public: - typedef typename decay::type type; + typedef typename common_type< + typename common_type<_Tp, _Up>::type, _Vp... + >::type type; }; template struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> -{ - typedef typename common_type::type, _Vp...>::type type; -}; + : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {}; #if _LIBCPP_STD_VER > 11 template using common_type_t = typename common_type<_Tp...>::type; @@ -1564,12 +2026,22 @@ template struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Arg>::value; +#endif + // is_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable::type, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; +#endif + // is_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable @@ -1580,6 +2052,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable : public is_copy_assignable<_Tp> {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; +#endif + // is_destructible // if it's a reference, return true @@ -1638,6 +2115,11 @@ template <> struct is_destructible : public _VSTD::false_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; +#endif + // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2672,6 +3154,11 @@ struct __is_constructible2_imp #endif // _LIBCPP_HAS_NO_VARIADICS #endif // __has_feature(is_constructible) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Args...>::value; +#endif + // is_default_constructible template @@ -2679,6 +3166,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; +#endif + // is_copy_constructible template @@ -2686,6 +3178,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; +#endif + // is_move_constructible template @@ -2697,6 +3194,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; +#endif + // is_trivially_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2824,18 +3326,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, #endif // _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Args...>::value; +#endif + // is_trivially_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; +#endif + // is_trivially_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible : public is_trivially_constructible<_Tp, typename add_lvalue_reference::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; +#endif + // is_trivially_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible @@ -2846,6 +3363,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; +#endif + // is_trivially_assignable #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 @@ -2884,12 +3406,22 @@ struct is_trivially_assignable<_Tp&, _Tp&&> #endif // !__has_feature(is_trivially_assignable) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Arg>::value; +#endif + // is_trivially_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable::type, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; +#endif + // is_trivially_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable @@ -2901,6 +3433,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; +#endif + // is_trivially_destructible #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) @@ -2917,6 +3454,14 @@ template struct __libcpp_trivial_destructor template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor::type> {}; +template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]> + : public false_type {}; + +#endif + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; #endif // is_nothrow_constructible @@ -3079,18 +3624,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, #endif // _LIBCPP_HAS_NO_VARIADICS #endif // __has_feature(is_nothrow_constructible) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Args...>::value; +#endif + // is_nothrow_default_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; +#endif + // is_nothrow_copy_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; +#endif + // is_nothrow_move_constructible template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible @@ -3101,6 +3661,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; +#endif + // is_nothrow_assignable #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) @@ -3169,12 +3734,22 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> #endif // __has_feature(cxx_noexcept) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Arg>::value; +#endif + // is_nothrow_copy_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable::type, typename add_lvalue_reference::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; +#endif + // is_nothrow_move_assignable template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable @@ -3186,6 +3761,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; +#endif + // is_nothrow_destructible #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) @@ -3241,6 +3821,15 @@ template struct __libcpp_nothrow_destructor template struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor::type> {}; +template +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]> + : public false_type {}; + +#endif + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; #endif // is_pod @@ -3260,6 +3849,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_pod #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; +#endif + // is_literal_type; template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type @@ -3271,6 +3865,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; +#endif + // is_standard_layout; template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout @@ -3281,6 +3880,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; +#endif + // is_trivially_copyable; template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable @@ -3293,6 +3897,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; +#endif + // is_trivial; template struct _LIBCPP_TYPE_VIS_ONLY is_trivial @@ -3304,6 +3913,11 @@ template struct _LIBCPP_TYPE_VIS_ONLY is_trivial #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; +#endif + #ifndef _LIBCPP_HAS_NO_VARIADICS // Check for complete types @@ -3692,34 +4306,34 @@ struct __sfinae_underlying_type template struct __sfinae_underlying_type<_Tp, false> {}; -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY int __convert_to_integral(int __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned __convert_to_integral(unsigned __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY long __convert_to_integral(long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned long __convert_to_integral(unsigned long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY long long __convert_to_integral(long long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } #ifndef _LIBCPP_HAS_NO_INT128 -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY __int128_t __convert_to_integral(__int128_t __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } #endif template -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY typename __sfinae_underlying_type<_Tp>::__promoted_type __convert_to_integral(_Tp __val) { return __val; } @@ -3759,7 +4373,21 @@ struct __has_operator_addressof #if _LIBCPP_STD_VER > 14 template using void_t = void; -#endif + +# ifndef _LIBCPP_HAS_NO_VARIADICS +template +struct conjunction : __and_<_Args...> {}; +template constexpr bool conjunction_v = conjunction<_Args...>::value; + +template +struct disjunction : __or_<_Args...> {}; +template constexpr bool disjunction_v = disjunction<_Args...>::value; + +template +struct negation : __not_<_Tp> {}; +template constexpr bool negation_v = negation<_Tp>::value; +# endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/include/unordered_map b/include/unordered_map index cf70ab62f69e..3c774d4094e0 100644 --- a/include/unordered_map +++ b/include/unordered_map @@ -1511,7 +1511,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); // explicitly moved for C++03 + return _LIBCPP_EXPLICIT_MOVE(__h); // explicitly moved for C++03 } template diff --git a/include/utility b/include/utility index 54cfc8bc1592..c9f5785b3d4e 100644 --- a/include/utility +++ b/include/utility @@ -52,6 +52,9 @@ template >::type move_if_noexcept(T& x) noexcept; // constexpr in C++14 +template constexpr add_const_t& as_const(T& t) noexcept; // C++17 +template void as_const(const T&&) = delete; // C++17 + template typename add_rvalue_reference::type declval() noexcept; template @@ -110,22 +113,41 @@ template get(pair&) noexcept; // constexpr in C++14 template - const typename const tuple_element >::type& + const typename tuple_element >::type& get(const pair&) noexcept; // constexpr in C++14 template typename tuple_element >::type&& get(pair&&) noexcept; // constexpr in C++14 +template + const typename tuple_element >::type&& + get(const pair&&) noexcept; // constexpr in C++14 + template constexpr T1& get(pair&) noexcept; // C++14 -template - constexpr T1 const& get(pair const &) noexcept; // C++14 +template + constexpr const T1& get(const pair&) noexcept; // C++14 -template +template constexpr T1&& get(pair&&) noexcept; // C++14 +template + constexpr const T1&& get(const pair&&) noexcept; // C++14 + +template + constexpr T1& get(pair&) noexcept; // C++14 + +template + constexpr const T1& get(const pair&) noexcept; // C++14 + +template + constexpr T1&& get(pair&&) noexcept; // C++14 + +template + constexpr const T1&& get(const pair&&) noexcept; // C++14 + // C++14 template @@ -242,6 +264,11 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT return _VSTD::move(__x); } +#if _LIBCPP_STD_VER > 14 +template constexpr add_const_t<_Tp>& as_const(_Tp& __t) noexcept { return __t; } +template void as_const(const _Tp&&) = delete; +#endif + struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { }; #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY) extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); @@ -261,6 +288,12 @@ struct _LIBCPP_TYPE_VIS_ONLY pair // pair(const pair&) = default; // pair(pair&&) = default; +#ifndef _LIBCPP_HAS_NO_DEFAULT_FUNCTION_TEMPLATE_ARGS + template , _Dummy>::value && + __dependent_type, _Dummy>::value + >::type> +#endif _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR pair() : first(), second() {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 @@ -388,8 +421,9 @@ struct _LIBCPP_TYPE_VIS_ONLY pair swap(pair& __p) _NOEXCEPT_(__is_nothrow_swappable::value && __is_nothrow_swappable::value) { - _VSTD::iter_swap(&first, &__p.first); - _VSTD::iter_swap(&second, &__p.second); + using _VSTD::swap; + swap(first, __p.first); + swap(second, __p.second); } private: @@ -551,6 +585,12 @@ struct __get_pair<0> _T1&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T1>(__p.first);} + template + static + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _T1&& + get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward(__p.first);} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }; @@ -577,6 +617,12 @@ struct __get_pair<1> _T2&& get(pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward<_T2>(__p.second);} + template + static + _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _T2&& + get(const pair<_T1, _T2>&& __p) _NOEXCEPT {return _VSTD::forward(__p.second);} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES }; @@ -606,6 +652,14 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT return __get_pair<_Ip>::get(_VSTD::move(__p)); } +template +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 +const typename tuple_element<_Ip, pair<_T1, _T2> >::type&& +get(const pair<_T1, _T2>&& __p) _NOEXCEPT +{ + return __get_pair<_Ip>::get(_VSTD::move(__p)); +} + #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #if _LIBCPP_STD_VER > 11 @@ -630,6 +684,13 @@ constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT return __get_pair<0>::get(_VSTD::move(__p)); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const && get(pair<_T1, _T2> const&& __p) _NOEXCEPT +{ + return __get_pair<0>::get(_VSTD::move(__p)); +} + template inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT @@ -651,6 +712,13 @@ constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT return __get_pair<1>::get(_VSTD::move(__p)); } +template +inline _LIBCPP_INLINE_VISIBILITY +constexpr _T1 const && get(pair<_T2, _T1> const&& __p) _NOEXCEPT +{ + return __get_pair<1>::get(_VSTD::move(__p)); +} + #endif #if _LIBCPP_STD_VER > 11 @@ -671,6 +739,16 @@ struct _LIBCPP_TYPE_VIS_ONLY integer_sequence template using index_sequence = integer_sequence; +#if __has_builtin(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) + +template +struct __make_integer_sequence +{ + typedef __make_integer_seq type; +}; + +#else + namespace __detail { template struct __repeat; @@ -724,10 +802,14 @@ struct __make_integer_sequence { static_assert(is_integral<_Tp>::value, "std::make_integer_sequence can only be instantiated with an integral type" ); - static_assert(0 <= _Ep, "std::make_integer_sequence input shall not be negative"); - typedef __make_integer_sequence_unchecked<_Tp, _Ep> type; + static_assert(0 <= _Ep, "std::make_integer_sequence must have a non-negative sequence length"); + // Workaround GCC bug by preventing bad installations when 0 <= _Ep + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68929 + typedef __make_integer_sequence_unchecked<_Tp, 0 <= _Ep ? _Ep : 0> type; }; +#endif + template using make_integer_sequence = typename __make_integer_sequence<_Tp, _Np>::type; diff --git a/include/valarray b/include/valarray index bdaa58836f39..bde644e8719b 100644 --- a/include/valarray +++ b/include/valarray @@ -802,11 +802,14 @@ public: // construct/destroy: _LIBCPP_INLINE_VISIBILITY valarray() : __begin_(0), __end_(0) {} - explicit valarray(size_t __n); + _LIBCPP_INLINE_VISIBILITY + inline explicit valarray(size_t __n); + _LIBCPP_INLINE_VISIBILITY valarray(const value_type& __x, size_t __n); valarray(const value_type* __p, size_t __n); valarray(const valarray& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY valarray(valarray&& __v) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -816,22 +819,31 @@ public: valarray(const gslice_array& __ga); valarray(const mask_array& __ma); valarray(const indirect_array& __ia); + inline _LIBCPP_INLINE_VISIBILITY ~valarray(); // assignment: valarray& operator=(const valarray& __v); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY valarray& operator=(valarray&& __v) _NOEXCEPT; #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY valarray& operator=(initializer_list); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const slice_array& __sa); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const gslice_array& __ga); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const mask_array& __ma); + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const indirect_array& __ia); template + _LIBCPP_INLINE_VISIBILITY valarray& operator=(const __val_expr<_ValExpr>& __v); // element access: @@ -842,24 +854,38 @@ public: value_type& operator[](size_t __i) {return __begin_[__i];} // subset operations: + _LIBCPP_INLINE_VISIBILITY __val_expr<__slice_expr > operator[](slice __s) const; + _LIBCPP_INLINE_VISIBILITY slice_array operator[](slice __s); + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](const gslice& __gs) const; + _LIBCPP_INLINE_VISIBILITY gslice_array operator[](const gslice& __gs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](gslice&& __gs) const; + _LIBCPP_INLINE_VISIBILITY gslice_array operator[](gslice&& __gs); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr > operator[](const valarray& __vb) const; + _LIBCPP_INLINE_VISIBILITY mask_array operator[](const valarray& __vb); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__mask_expr > operator[](valarray&& __vb) const; + _LIBCPP_INLINE_VISIBILITY mask_array operator[](valarray&& __vb); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](const valarray& __vs) const; + _LIBCPP_INLINE_VISIBILITY indirect_array operator[](const valarray& __vs); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY __val_expr<__indirect_expr > operator[](valarray&& __vs) const; + _LIBCPP_INLINE_VISIBILITY indirect_array operator[](valarray&& __vs); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -870,15 +896,25 @@ public: valarray operator!() const; // computed assignment: + _LIBCPP_INLINE_VISIBILITY valarray& operator*= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator/= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator%= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator+= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator-= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator^= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator&= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator|= (const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator<<=(const value_type& __x); + _LIBCPP_INLINE_VISIBILITY valarray& operator>>=(const value_type& __x); template @@ -887,6 +923,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator*= (const _Expr& __v); template @@ -895,6 +932,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator/= (const _Expr& __v); template @@ -903,6 +941,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator%= (const _Expr& __v); template @@ -911,6 +950,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator+= (const _Expr& __v); template @@ -919,6 +959,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator-= (const _Expr& __v); template @@ -927,6 +968,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator^= (const _Expr& __v); template @@ -935,6 +977,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator|= (const _Expr& __v); template @@ -943,6 +986,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator&= (const _Expr& __v); template @@ -951,6 +995,7 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator<<= (const _Expr& __v); template @@ -959,16 +1004,21 @@ public: __is_val_expr<_Expr>::value, valarray& >::type + _LIBCPP_INLINE_VISIBILITY operator>>= (const _Expr& __v); // member functions: + _LIBCPP_INLINE_VISIBILITY void swap(valarray& __v) _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_t size() const {return static_cast(__end_ - __begin_);} + _LIBCPP_INLINE_VISIBILITY value_type sum() const; + _LIBCPP_INLINE_VISIBILITY value_type min() const; + _LIBCPP_INLINE_VISIBILITY value_type max() const; valarray shift (int __i) const; @@ -1114,6 +1164,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -1122,6 +1173,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -1130,6 +1182,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -1138,6 +1191,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -1146,6 +1200,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -1154,6 +1209,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -1162,6 +1218,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -1170,6 +1227,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -1178,6 +1236,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -1186,6 +1245,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -1194,10 +1254,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const slice_array& operator=(const slice_array& __sa) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; private: @@ -1213,7 +1276,7 @@ private: }; template -inline _LIBCPP_INLINE_VISIBILITY +inline const slice_array<_Tp>& slice_array<_Tp>::operator=(const slice_array& __sa) const { @@ -1226,7 +1289,7 @@ slice_array<_Tp>::operator=(const slice_array& __sa) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1241,7 +1304,7 @@ slice_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1256,7 +1319,7 @@ slice_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1271,7 +1334,7 @@ slice_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1286,7 +1349,7 @@ slice_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1301,7 +1364,7 @@ slice_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1316,7 +1379,7 @@ slice_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1331,7 +1394,7 @@ slice_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1346,7 +1409,7 @@ slice_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1361,7 +1424,7 @@ slice_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1376,7 +1439,7 @@ slice_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1390,7 +1453,7 @@ slice_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void slice_array<_Tp>::operator=(const value_type& __x) const { @@ -1484,6 +1547,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -1492,6 +1556,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -1500,6 +1565,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -1508,6 +1574,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -1516,6 +1583,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -1524,6 +1592,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -1532,6 +1601,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -1540,6 +1610,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -1548,6 +1619,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -1556,6 +1628,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -1564,10 +1637,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const gslice_array& operator=(const gslice_array& __ga) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; // gslice_array(const gslice_array&) = default; @@ -1576,20 +1652,16 @@ public: // gslice_array& operator=(gslice_array&&) = default; private: - _LIBCPP_INLINE_VISIBILITY gslice_array(const gslice& __gs, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(__gs.__1d_) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - - _LIBCPP_INLINE_VISIBILITY gslice_array(gslice&& __gs, const valarray& __v) : __vp_(const_cast(__v.__begin_)), __1d_(move(__gs.__1d_)) {} - #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template friend class valarray; @@ -1597,7 +1669,7 @@ private: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1613,7 +1685,7 @@ gslice_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1629,7 +1701,7 @@ gslice_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1645,7 +1717,7 @@ gslice_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1661,7 +1733,7 @@ gslice_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1677,7 +1749,7 @@ gslice_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1693,7 +1765,7 @@ gslice_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1709,7 +1781,7 @@ gslice_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1725,7 +1797,7 @@ gslice_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1741,7 +1813,7 @@ gslice_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1757,7 +1829,7 @@ gslice_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1772,7 +1844,7 @@ gslice_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline const gslice_array<_Tp>& gslice_array<_Tp>::operator=(const gslice_array& __ga) const { @@ -1785,7 +1857,7 @@ gslice_array<_Tp>::operator=(const gslice_array& __ga) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void gslice_array<_Tp>::operator=(const value_type& __x) const { @@ -1813,6 +1885,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -1821,6 +1894,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -1829,6 +1903,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -1837,6 +1912,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -1845,6 +1921,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -1853,6 +1930,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -1861,6 +1939,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -1869,6 +1948,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -1877,6 +1957,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -1885,6 +1966,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -1893,10 +1975,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const mask_array& operator=(const mask_array& __ma) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; // mask_array(const mask_array&) = default; @@ -1921,7 +2006,7 @@ private: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1936,7 +2021,7 @@ mask_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1951,7 +2036,7 @@ mask_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1966,7 +2051,7 @@ mask_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1981,7 +2066,7 @@ mask_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -1996,7 +2081,7 @@ mask_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2011,7 +2096,7 @@ mask_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2026,7 +2111,7 @@ mask_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2041,7 +2126,7 @@ mask_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2056,7 +2141,7 @@ mask_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2071,7 +2156,7 @@ mask_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2085,7 +2170,7 @@ mask_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline const mask_array<_Tp>& mask_array<_Tp>::operator=(const mask_array& __ma) const { @@ -2096,7 +2181,7 @@ mask_array<_Tp>::operator=(const mask_array& __ma) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void mask_array<_Tp>::operator=(const value_type& __x) const { @@ -2158,6 +2243,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator=(const _Expr& __v) const; template @@ -2166,6 +2252,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator*=(const _Expr& __v) const; template @@ -2174,6 +2261,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator/=(const _Expr& __v) const; template @@ -2182,6 +2270,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator%=(const _Expr& __v) const; template @@ -2190,6 +2279,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator+=(const _Expr& __v) const; template @@ -2198,6 +2288,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator-=(const _Expr& __v) const; template @@ -2206,6 +2297,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator^=(const _Expr& __v) const; template @@ -2214,6 +2306,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator&=(const _Expr& __v) const; template @@ -2222,6 +2315,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator|=(const _Expr& __v) const; template @@ -2230,6 +2324,7 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator<<=(const _Expr& __v) const; template @@ -2238,10 +2333,13 @@ public: __is_val_expr<_Expr>::value, void >::type + _LIBCPP_INLINE_VISIBILITY operator>>=(const _Expr& __v) const; + _LIBCPP_INLINE_VISIBILITY const indirect_array& operator=(const indirect_array& __ia) const; + _LIBCPP_INLINE_VISIBILITY void operator=(const value_type& __x) const; // indirect_array(const indirect_array&) = default; @@ -2271,7 +2369,7 @@ private: template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2286,7 +2384,7 @@ indirect_array<_Tp>::operator=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2301,7 +2399,7 @@ indirect_array<_Tp>::operator*=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2316,7 +2414,7 @@ indirect_array<_Tp>::operator/=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2331,7 +2429,7 @@ indirect_array<_Tp>::operator%=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2346,7 +2444,7 @@ indirect_array<_Tp>::operator+=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2361,7 +2459,7 @@ indirect_array<_Tp>::operator-=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2376,7 +2474,7 @@ indirect_array<_Tp>::operator^=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2391,7 +2489,7 @@ indirect_array<_Tp>::operator&=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2406,7 +2504,7 @@ indirect_array<_Tp>::operator|=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2421,7 +2519,7 @@ indirect_array<_Tp>::operator<<=(const _Expr& __v) const template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -2435,7 +2533,7 @@ indirect_array<_Tp>::operator>>=(const _Expr& __v) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline const indirect_array<_Tp>& indirect_array<_Tp>::operator=(const indirect_array& __ia) const { @@ -2448,7 +2546,7 @@ indirect_array<_Tp>::operator=(const indirect_array& __ia) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline void indirect_array<_Tp>::operator=(const value_type& __x) const { @@ -2650,7 +2748,7 @@ __val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const // valarray template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::valarray(size_t __n) : __begin_(0), __end_(0) @@ -2659,7 +2757,7 @@ valarray<_Tp>::valarray(size_t __n) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::valarray(const value_type& __x, size_t __n) : __begin_(0), __end_(0) @@ -2720,7 +2818,7 @@ valarray<_Tp>::valarray(const valarray& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::valarray(valarray&& __v) _NOEXCEPT : __begin_(__v.__begin_), __end_(__v.__end_) @@ -2874,7 +2972,7 @@ valarray<_Tp>::valarray(const indirect_array& __ia) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>::~valarray() { resize(0); @@ -2896,7 +2994,7 @@ valarray<_Tp>::operator=(const valarray& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT { @@ -2913,7 +3011,7 @@ valarray<_Tp>::operator=(valarray&& __v) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(initializer_list __il) { @@ -2926,7 +3024,7 @@ valarray<_Tp>::operator=(initializer_list __il) #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const value_type& __x) { @@ -2935,7 +3033,7 @@ valarray<_Tp>::operator=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const slice_array& __sa) { @@ -2947,7 +3045,7 @@ valarray<_Tp>::operator=(const slice_array& __sa) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const gslice_array& __ga) { @@ -2961,7 +3059,7 @@ valarray<_Tp>::operator=(const gslice_array& __ga) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const mask_array& __ma) { @@ -2975,7 +3073,7 @@ valarray<_Tp>::operator=(const mask_array& __ma) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const indirect_array& __ia) { @@ -2990,7 +3088,7 @@ valarray<_Tp>::operator=(const indirect_array& __ia) template template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) { @@ -3004,7 +3102,7 @@ valarray<_Tp>::operator=(const __val_expr<_ValExpr>& __v) } template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__slice_expr&> > valarray<_Tp>::operator[](slice __s) const { @@ -3012,7 +3110,7 @@ valarray<_Tp>::operator[](slice __s) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline slice_array<_Tp> valarray<_Tp>::operator[](slice __s) { @@ -3020,7 +3118,7 @@ valarray<_Tp>::operator[](slice __s) } template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](const gslice& __gs) const { @@ -3028,7 +3126,7 @@ valarray<_Tp>::operator[](const gslice& __gs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline gslice_array<_Tp> valarray<_Tp>::operator[](const gslice& __gs) { @@ -3038,7 +3136,7 @@ valarray<_Tp>::operator[](const gslice& __gs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](gslice&& __gs) const { @@ -3046,7 +3144,7 @@ valarray<_Tp>::operator[](gslice&& __gs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline gslice_array<_Tp> valarray<_Tp>::operator[](gslice&& __gs) { @@ -3056,7 +3154,7 @@ valarray<_Tp>::operator[](gslice&& __gs) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__mask_expr&> > valarray<_Tp>::operator[](const valarray& __vb) const { @@ -3064,7 +3162,7 @@ valarray<_Tp>::operator[](const valarray& __vb) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline mask_array<_Tp> valarray<_Tp>::operator[](const valarray& __vb) { @@ -3074,7 +3172,7 @@ valarray<_Tp>::operator[](const valarray& __vb) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__mask_expr&> > valarray<_Tp>::operator[](valarray&& __vb) const { @@ -3082,7 +3180,7 @@ valarray<_Tp>::operator[](valarray&& __vb) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline mask_array<_Tp> valarray<_Tp>::operator[](valarray&& __vb) { @@ -3092,7 +3190,7 @@ valarray<_Tp>::operator[](valarray&& __vb) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](const valarray& __vs) const { @@ -3100,7 +3198,7 @@ valarray<_Tp>::operator[](const valarray& __vs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline indirect_array<_Tp> valarray<_Tp>::operator[](const valarray& __vs) { @@ -3110,7 +3208,7 @@ valarray<_Tp>::operator[](const valarray& __vs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline __val_expr<__indirect_expr&> > valarray<_Tp>::operator[](valarray&& __vs) const { @@ -3118,7 +3216,7 @@ valarray<_Tp>::operator[](valarray&& __vs) const } template -inline _LIBCPP_INLINE_VISIBILITY +inline indirect_array<_Tp> valarray<_Tp>::operator[](valarray&& __vs) { @@ -3196,7 +3294,7 @@ valarray<_Tp>::operator!() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator*=(const value_type& __x) { @@ -3206,7 +3304,7 @@ valarray<_Tp>::operator*=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator/=(const value_type& __x) { @@ -3216,7 +3314,7 @@ valarray<_Tp>::operator/=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator%=(const value_type& __x) { @@ -3226,7 +3324,7 @@ valarray<_Tp>::operator%=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator+=(const value_type& __x) { @@ -3236,7 +3334,7 @@ valarray<_Tp>::operator+=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator-=(const value_type& __x) { @@ -3246,7 +3344,7 @@ valarray<_Tp>::operator-=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator^=(const value_type& __x) { @@ -3256,7 +3354,7 @@ valarray<_Tp>::operator^=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator&=(const value_type& __x) { @@ -3266,7 +3364,7 @@ valarray<_Tp>::operator&=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator|=(const value_type& __x) { @@ -3276,7 +3374,7 @@ valarray<_Tp>::operator|=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator<<=(const value_type& __x) { @@ -3286,7 +3384,7 @@ valarray<_Tp>::operator<<=(const value_type& __x) } template -inline _LIBCPP_INLINE_VISIBILITY +inline valarray<_Tp>& valarray<_Tp>::operator>>=(const value_type& __x) { @@ -3297,7 +3395,7 @@ valarray<_Tp>::operator>>=(const value_type& __x) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3313,7 +3411,7 @@ valarray<_Tp>::operator*=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3329,7 +3427,7 @@ valarray<_Tp>::operator/=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3345,7 +3443,7 @@ valarray<_Tp>::operator%=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3361,7 +3459,7 @@ valarray<_Tp>::operator+=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3377,7 +3475,7 @@ valarray<_Tp>::operator-=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3393,7 +3491,7 @@ valarray<_Tp>::operator^=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3409,7 +3507,7 @@ valarray<_Tp>::operator|=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3425,7 +3523,7 @@ valarray<_Tp>::operator&=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3441,7 +3539,7 @@ valarray<_Tp>::operator<<=(const _Expr& __v) template template -inline _LIBCPP_INLINE_VISIBILITY +inline typename enable_if < __is_val_expr<_Expr>::value, @@ -3456,7 +3554,7 @@ valarray<_Tp>::operator>>=(const _Expr& __v) } template -inline _LIBCPP_INLINE_VISIBILITY +inline void valarray<_Tp>::swap(valarray& __v) _NOEXCEPT { @@ -3465,7 +3563,7 @@ valarray<_Tp>::swap(valarray& __v) _NOEXCEPT } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Tp valarray<_Tp>::sum() const { @@ -3479,7 +3577,7 @@ valarray<_Tp>::sum() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Tp valarray<_Tp>::min() const { @@ -3489,7 +3587,7 @@ valarray<_Tp>::min() const } template -inline _LIBCPP_INLINE_VISIBILITY +inline _Tp valarray<_Tp>::max() const { diff --git a/include/vector b/include/vector index c168c8ea60ad..dbc0dd321824 100644 --- a/include/vector +++ b/include/vector @@ -51,8 +51,8 @@ public: vector& operator=(const vector& x); vector& operator=(vector&& x) noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + allocator_type::propagate_on_container_move_assignment::value || + allocator_type::is_always_equal::value); // C++17 vector& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); @@ -175,8 +175,8 @@ public: vector& operator=(const vector& x); vector& operator=(vector&& x) noexcept( - allocator_type::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + allocator_type::propagate_on_container_move_assignment::value || + allocator_type::is_always_equal::value); // C++17 vector& operator=(initializer_list il); template void assign(InputIterator first, InputIterator last); @@ -562,9 +562,7 @@ public: vector(vector&& __x, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __x) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY @@ -687,9 +685,11 @@ public: _LIBCPP_INLINE_VISIBILITY void push_back(value_type&& __x); #ifndef _LIBCPP_HAS_NO_VARIADICS template + _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args); #endif // _LIBCPP_HAS_NO_VARIADICS #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + _LIBCPP_INLINE_VISIBILITY void pop_back(); iterator insert(const_iterator __position, const_reference __x); @@ -768,6 +768,7 @@ private: void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; void __construct_at_end(size_type __n); + _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, const_reference __x); template typename enable_if @@ -787,7 +788,8 @@ private: void __move_range(pointer __from_s, pointer __from_e, pointer __to); void __move_assign(vector& __c, true_type) _NOEXCEPT_(is_nothrow_move_assignable::value); - void __move_assign(vector& __c, false_type); + void __move_assign(vector& __c, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value); _LIBCPP_INLINE_VISIBILITY void __destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -991,7 +993,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template -inline _LIBCPP_INLINE_VISIBILITY +inline void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { @@ -1303,9 +1305,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__x, integral_constant()); @@ -1315,6 +1315,7 @@ vector<_Tp, _Allocator>::operator=(vector&& __x) template void vector<_Tp, _Allocator>::__move_assign(vector& __c, false_type) + _NOEXCEPT_(__alloc_traits::is_always_equal::value) { if (__base::__alloc() != __c.__alloc()) { @@ -1629,7 +1630,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) template template -inline _LIBCPP_INLINE_VISIBILITY +inline void vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -1650,7 +1651,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline _LIBCPP_INLINE_VISIBILITY +inline void vector<_Tp, _Allocator>::pop_back() { @@ -1897,9 +1898,11 @@ vector<_Tp, _Allocator>::insert(const_iterator __position, _InputIterator __firs pointer __old_last = this->__end_; for (; this->__end_ != this->__end_cap() && __first != __last; ++__first) { + __RAII_IncreaseAnnotator __annotator(*this); __alloc_traits::construct(__a, _VSTD::__to_raw_pointer(this->__end_), *__first); ++this->__end_; + __annotator.__done(); } __split_buffer __v(__a); if (__first != __last) @@ -2211,9 +2214,7 @@ public: vector(vector&& __v, const allocator_type& __a); _LIBCPP_INLINE_VISIBILITY vector& operator=(vector&& __v) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value); + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)); #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY @@ -2836,9 +2837,7 @@ template inline _LIBCPP_INLINE_VISIBILITY vector& vector::operator=(vector&& __v) - _NOEXCEPT_( - __alloc_traits::propagate_on_container_move_assignment::value && - is_nothrow_move_assignable::value) + _NOEXCEPT_((__noexcept_move_assign_container<_Allocator, __alloc_traits>::value)) { __move_assign(__v, integral_constant()); diff --git a/include/wchar.h b/include/wchar.h new file mode 100644 index 000000000000..da34f735edf3 --- /dev/null +++ b/include/wchar.h @@ -0,0 +1,136 @@ +// -*- C++ -*- +//===--------------------------- wchar.h ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#if defined(__need_wint_t) || defined(__need_mbstate_t) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#elif !defined(_LIBCPP_WCHAR_H) +#define _LIBCPP_WCHAR_H + +/* + wchar.h synopsis + +Macros: + + NULL + WCHAR_MAX + WCHAR_MIN + WEOF + +Types: + + mbstate_t + size_t + tm + wint_t + +int fwprintf(FILE* restrict stream, const wchar_t* restrict format, ...); +int fwscanf(FILE* restrict stream, const wchar_t* restrict format, ...); +int swprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, ...); +int swscanf(const wchar_t* restrict s, const wchar_t* restrict format, ...); +int vfwprintf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); +int vfwscanf(FILE* restrict stream, const wchar_t* restrict format, va_list arg); // C99 +int vswprintf(wchar_t* restrict s, size_t n, const wchar_t* restrict format, va_list arg); +int vswscanf(const wchar_t* restrict s, const wchar_t* restrict format, va_list arg); // C99 +int vwprintf(const wchar_t* restrict format, va_list arg); +int vwscanf(const wchar_t* restrict format, va_list arg); // C99 +int wprintf(const wchar_t* restrict format, ...); +int wscanf(const wchar_t* restrict format, ...); +wint_t fgetwc(FILE* stream); +wchar_t* fgetws(wchar_t* restrict s, int n, FILE* restrict stream); +wint_t fputwc(wchar_t c, FILE* stream); +int fputws(const wchar_t* restrict s, FILE* restrict stream); +int fwide(FILE* stream, int mode); +wint_t getwc(FILE* stream); +wint_t getwchar(); +wint_t putwc(wchar_t c, FILE* stream); +wint_t putwchar(wchar_t c); +wint_t ungetwc(wint_t c, FILE* stream); +double wcstod(const wchar_t* restrict nptr, wchar_t** restrict endptr); +float wcstof(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99 +long double wcstold(const wchar_t* restrict nptr, wchar_t** restrict endptr); // C99 +long wcstol(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); +long long wcstoll(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99 +unsigned long wcstoul(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); +unsigned long long wcstoull(const wchar_t* restrict nptr, wchar_t** restrict endptr, int base); // C99 +wchar_t* wcscpy(wchar_t* restrict s1, const wchar_t* restrict s2); +wchar_t* wcsncpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +wchar_t* wcscat(wchar_t* restrict s1, const wchar_t* restrict s2); +wchar_t* wcsncat(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +int wcscmp(const wchar_t* s1, const wchar_t* s2); +int wcscoll(const wchar_t* s1, const wchar_t* s2); +int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t n); +size_t wcsxfrm(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +const wchar_t* wcschr(const wchar_t* s, wchar_t c); + wchar_t* wcschr( wchar_t* s, wchar_t c); +size_t wcscspn(const wchar_t* s1, const wchar_t* s2); +size_t wcslen(const wchar_t* s); +const wchar_t* wcspbrk(const wchar_t* s1, const wchar_t* s2); + wchar_t* wcspbrk( wchar_t* s1, const wchar_t* s2); +const wchar_t* wcsrchr(const wchar_t* s, wchar_t c); + wchar_t* wcsrchr( wchar_t* s, wchar_t c); +size_t wcsspn(const wchar_t* s1, const wchar_t* s2); +const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2); + wchar_t* wcsstr( wchar_t* s1, const wchar_t* s2); +wchar_t* wcstok(wchar_t* restrict s1, const wchar_t* restrict s2, wchar_t** restrict ptr); +const wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); + wchar_t* wmemchr( wchar_t* s, wchar_t c, size_t n); +int wmemcmp(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +wchar_t* wmemcpy(wchar_t* restrict s1, const wchar_t* restrict s2, size_t n); +wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n); +wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n); +size_t wcsftime(wchar_t* restrict s, size_t maxsize, const wchar_t* restrict format, + const tm* restrict timeptr); +wint_t btowc(int c); +int wctob(wint_t c); +int mbsinit(const mbstate_t* ps); +size_t mbrlen(const char* restrict s, size_t n, mbstate_t* restrict ps); +size_t mbrtowc(wchar_t* restrict pwc, const char* restrict s, size_t n, mbstate_t* restrict ps); +size_t wcrtomb(char* restrict s, wchar_t wc, mbstate_t* restrict ps); +size_t mbsrtowcs(wchar_t* restrict dst, const char** restrict src, size_t len, + mbstate_t* restrict ps); +size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, + mbstate_t* restrict ps); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#ifdef __cplusplus +#define __CORRECT_ISO_CPP_WCHAR_H_PROTO +#endif + +#include_next + +// Let know if we have const-correct overloads for wcschr and friends. +#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) +# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 +#elif defined(__GLIBC_PREREQ) +# if __GLIBC_PREREQ(2, 10) +# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 +# endif +#endif + +#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)) +extern "C++" { +#include // pull in *swprintf defines +} // extern "C++" +#endif // __cplusplus && _LIBCPP_MSVCRT + +#endif // _LIBCPP_WCHAR_H diff --git a/include/wctype.h b/include/wctype.h new file mode 100644 index 000000000000..f9c5a47754bb --- /dev/null +++ b/include/wctype.h @@ -0,0 +1,79 @@ +// -*- C++ -*- +//===--------------------------- wctype.h ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_WCTYPE_H +#define _LIBCPP_WCTYPE_H + +/* + wctype.h synopsis + +Macros: + + WEOF + +Types: + + wint_t + wctrans_t + wctype_t + +int iswalnum(wint_t wc); +int iswalpha(wint_t wc); +int iswblank(wint_t wc); // C99 +int iswcntrl(wint_t wc); +int iswdigit(wint_t wc); +int iswgraph(wint_t wc); +int iswlower(wint_t wc); +int iswprint(wint_t wc); +int iswpunct(wint_t wc); +int iswspace(wint_t wc); +int iswupper(wint_t wc); +int iswxdigit(wint_t wc); +int iswctype(wint_t wc, wctype_t desc); +wctype_t wctype(const char* property); +wint_t towlower(wint_t wc); +wint_t towupper(wint_t wc); +wint_t towctrans(wint_t wc, wctrans_t desc); +wctrans_t wctrans(const char* property); + +*/ + +#include <__config> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next + +#ifdef __cplusplus + +#undef iswalnum +#undef iswalpha +#undef iswblank +#undef iswcntrl +#undef iswdigit +#undef iswgraph +#undef iswlower +#undef iswprint +#undef iswpunct +#undef iswspace +#undef iswupper +#undef iswxdigit +#undef iswctype +#undef wctype +#undef towlower +#undef towupper +#undef towctrans +#undef wctrans + +#endif // __cplusplus + +#endif // _LIBCPP_WCTYPE_H diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index d3d5f381d815..d6a35f8eba2e 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -11,7 +11,7 @@ elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS") endif() # Add all the headers to the project for IDEs. -if (MSVC_IDE OR XCODE) +if (LIBCXX_CONFIGURE_IDE) file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*) if(WIN32) file( GLOB LIBCXX_WIN32_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/support/win32/*.h) @@ -24,54 +24,65 @@ if (MSVC_IDE OR XCODE) endif() endif() -if (LIBCXX_ENABLE_SHARED) - add_library(cxx SHARED - ${LIBCXX_SOURCES} - ${LIBCXX_HEADERS} - ) -else() - add_library(cxx STATIC - ${LIBCXX_SOURCES} - ${LIBCXX_HEADERS} - ) +if(NOT LIBCXX_INSTALL_LIBRARY) + set(exclude_from_all EXCLUDE_FROM_ALL) endif() -#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path. -if (DEFINED LIBCXX_CXX_ABI_LIBRARY_PATH) - target_link_libraries(cxx "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") +if (LIBCXX_ENABLE_SHARED) + add_library(cxx SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) +else() + add_library(cxx STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) endif() if (DEFINED LIBCXX_CXX_ABI_DEPS) add_dependencies(cxx LIBCXX_CXX_ABI_DEPS) endif() -set(libraries "") -if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) - # TODO(ericwf): Remove these GNU specific linker flags and let CMake do the - # configuration. This will be more portable. - list(APPEND libraries "-Wl,--whole-archive" "-Wl,-Bstatic") - list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}") - list(APPEND libraries "-Wl,-Bdynamic" "-Wl,--no-whole-archive") -else() - list(APPEND libraries "${LIBCXX_CXX_ABI_LIBRARY}") +#if LIBCXX_CXX_ABI_LIBRARY_PATH is defined we want to add it to the search path. +add_link_flags_if(LIBCXX_CXX_ABI_LIBRARY_PATH "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}") + +add_library_flags_if(LIBCXX_COVERAGE_LIBRARY "${LIBCXX_COVERAGE_LIBRARY}") + +add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,--whole-archive" "-Wl,-Bstatic") +add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}") +add_library_flags_if(LIBCXX_ENABLE_STATIC_ABI_LIBRARY "-Wl,-Bdynamic" "-Wl,--no-whole-archive") + +if (APPLE AND LLVM_USE_SANITIZER) + if ("${LLVM_USE_SANITIZER}" STREQUAL "Address") + set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib") + elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined") + set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib") + else() + message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X") + endif() + if (LIBFILE) + execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=lib OUTPUT_VARIABLE LIBDIR RESULT_VARIABLE Result) + if (NOT ${Result} EQUAL "0") + message(FATAL "Failed to find library resource directory") + endif() + string(STRIP "${LIBDIR}" LIBDIR) + set(LIBDIR "${LIBDIR}/darwin/") + if (NOT IS_DIRECTORY "${LIBDIR}") + message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER") + endif() + set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}") + set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE) + message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}") + add_library_flags("${LIBCXX_SANITIZER_LIBRARY}") + add_link_flags("-Wl,-rpath,${LIBDIR}") + endif() endif() # Generate library list. -append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread) -append_if(libraries LIBCXX_HAS_C_LIB c) -append_if(libraries LIBCXX_HAS_M_LIB m) -append_if(libraries LIBCXX_HAS_RT_LIB rt) -append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s) - -if (LIBCXX_COVERAGE_LIBRARY) - target_link_libraries(cxx ${LIBCXX_COVERAGE_LIBRARY}) -endif() -target_link_libraries(cxx ${libraries}) - +add_library_flags_if(LIBCXX_HAS_PTHREAD_LIB pthread) +add_library_flags_if(LIBCXX_HAS_C_LIB c) +add_library_flags_if(LIBCXX_HAS_M_LIB m) +add_library_flags_if(LIBCXX_HAS_RT_LIB rt) +add_library_flags_if(LIBCXX_HAS_GCC_S_LIB gcc_s) # Setup flags. -append_if(LIBCXX_COMPILE_FLAGS LIBCXX_HAS_FPIC_FLAG -fPIC) -append_if(LIBCXX_LINK_FLAGS LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) +add_flags_if_supported(-fPIC) +add_link_flags_if_supported(-nodefaultlibs) if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR LIBCXX_CXX_ABI_LIBNAME STREQUAL "none")) @@ -80,8 +91,8 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR endif() if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) - list(APPEND LIBCXX_COMPILE_FLAGS "-U__STRICT_ANSI__") - list(APPEND LIBCXX_LINK_FLAGS + add_definitions(-D__STRICT_ANSI__) + add_link_flags( "-compatibility_version 1" "-current_version 1" "-install_name /usr/lib/libc++.1.dylib" @@ -100,10 +111,10 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR "-Wl,-reexport_library,${CMAKE_OSX_SYSROOT}/usr/lib/libc++abi.dylib") endif() else() - set (OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") + set(OSX_RE_EXPORT_LINE "/usr/lib/libc++abi.dylib -Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++abi${LIBCXX_LIBCPPABI_VERSION}.exp") endif() - list(APPEND LIBCXX_LINK_FLAGS + add_link_flags( "-compatibility_version 1" "-install_name /usr/lib/libc++.1.dylib" "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR}/libc++unexp.exp" @@ -113,19 +124,64 @@ if ( APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR endif() endif() -string(REPLACE ";" " " LIBCXX_COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}") -string(REPLACE ";" " " LIBCXX_LINK_FLAGS "${LIBCXX_LINK_FLAGS}") +target_link_libraries(cxx ${LIBCXX_LIBRARIES}) +split_list(LIBCXX_COMPILE_FLAGS) +split_list(LIBCXX_LINK_FLAGS) set_target_properties(cxx PROPERTIES COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" LINK_FLAGS "${LIBCXX_LINK_FLAGS}" OUTPUT_NAME "c++" - VERSION "1.0" - SOVERSION "1" + VERSION "${LIBCXX_ABI_VERSION}.0" + SOVERSION "${LIBCXX_ABI_VERSION}" ) -install(TARGETS cxx - LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} - ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} +# Generate a linker script inplace of a libc++.so symlink. Rerun this command +# after cxx builds. +if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) + # Get the name of the ABI library and handle the case where CXXABI_LIBNAME + # is a target name and not a library. Ex cxxabi_shared. + set(SCRIPT_ABI_LIBNAME "${LIBCXX_CXX_ABI_LIBRARY}") + if (SCRIPT_ABI_LIBNAME STREQUAL "cxxabi_shared") + set(SCRIPT_ABI_LIBNAME "c++abi") + endif() + # Generate a linker script inplace of a libc++.so symlink. Rerun this command + # after cxx builds. + add_custom_command(TARGET cxx POST_BUILD + COMMAND + ${PYTHON_EXECUTABLE} ${LIBCXX_SOURCE_DIR}/utils/gen_link_script/gen_link_script.py + ARGS + "$" + "${SCRIPT_ABI_LIBNAME}" + WORKING_DIRECTORY ${LIBCXX_BUILD_DIR} ) +endif() + +if (LIBCXX_INSTALL_LIBRARY) + install(TARGETS cxx + LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx + ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx + ) + # NOTE: This install command must go after the cxx install command otherwise + # it will not be executed after the library symlinks are installed. + if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) + # Replace the libc++ filename with $ + # after we required CMake 3.0. + install(FILES "${LIBCXX_LIBRARY_DIR}/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}" + DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} + COMPONENT libcxx) + endif() +endif() + +if (NOT CMAKE_CONFIGURATION_TYPES AND (LIBCXX_INSTALL_LIBRARY OR + LIBCXX_INSTALL_HEADERS)) + if(LIBCXX_INSTALL_LIBRARY) + set(deps DEPENDS cxx) + endif() + add_custom_target(install-libcxx + ${deps} + COMMAND "${CMAKE_COMMAND}" + -DCMAKE_INSTALL_COMPONENT=libcxx + -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake") +endif() diff --git a/lib/libc++abi2.exp b/lib/libc++abi2.exp index bdfe99c3456e..47dcbbb88fcd 100644 --- a/lib/libc++abi2.exp +++ b/lib/libc++abi2.exp @@ -290,6 +290,16 @@ __ZTISt16invalid_argument __ZTSSt16invalid_argument __ZTVSt16invalid_argument +__ZNKSt16bad_array_length4whatEv +__ZNSt16bad_array_lengthC1Ev +__ZNSt16bad_array_lengthC2Ev +__ZNSt16bad_array_lengthD0Ev +__ZNSt16bad_array_lengthD1Ev +__ZNSt16bad_array_lengthD2Ev +__ZTISt16bad_array_length +__ZTSSt16bad_array_length +__ZTVSt16bad_array_length + __ZTSDi __ZTSDn __ZTSDs diff --git a/src/any.cpp b/src/any.cpp new file mode 100644 index 000000000000..f77684578905 --- /dev/null +++ b/src/any.cpp @@ -0,0 +1,18 @@ +//===---------------------------- any.cpp ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "experimental/any" + +_LIBCPP_BEGIN_NAMESPACE_LFTS + +const char* bad_any_cast::what() const _NOEXCEPT { + return "bad any cast"; +} + +_LIBCPP_END_NAMESPACE_LFTS diff --git a/src/exception.cpp b/src/exception.cpp index 2c16060a7583..e172f642d483 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -12,10 +12,6 @@ #include "exception" #include "new" -#ifndef __has_include -#define __has_include(inc) 0 -#endif - #if defined(__APPLE__) && !defined(LIBCXXRT) #include @@ -29,16 +25,16 @@ #define __terminate_handler __cxxabiapple::__cxa_terminate_handler #define __unexpected_handler __cxxabiapple::__cxa_unexpected_handler #endif // _LIBCPPABI_VERSION -#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) || __has_include() +#elif defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) #include using namespace __cxxabiv1; #if defined(LIBCXXRT) || defined(_LIBCPPABI_VERSION) #define HAVE_DEPENDENT_EH_ABI 1 #endif -#elif !defined(__GLIBCXX__) // __has_include() +#elif !defined(__GLIBCXX__) // defined(LIBCXX_BUILDING_LIBCXXABI) static std::terminate_handler __terminate_handler; static std::unexpected_handler __unexpected_handler; -#endif // __has_include() +#endif // defined(LIBCXX_BUILDING_LIBCXXABI) namespace std { diff --git a/src/future.cpp b/src/future.cpp index 3132b1861af2..e1758f39df3a 100644 --- a/src/future.cpp +++ b/src/future.cpp @@ -221,10 +221,12 @@ promise::~promise() { if (__state_) { +#ifndef _LIBCPP_NO_EXCEPTIONS if (!__state_->__has_value() && __state_->use_count() > 1) __state_->set_exception(make_exception_ptr( future_error(make_error_code(future_errc::broken_promise)) )); +#endif // _LIBCPP_NO_EXCEPTIONS __state_->__release_shared(); } } diff --git a/src/support/atomic_support.h b/src/include/atomic_support.h similarity index 96% rename from src/support/atomic_support.h rename to src/include/atomic_support.h index e738a5154cd3..dbf3b9c81ea4 100644 --- a/src/support/atomic_support.h +++ b/src/include/atomic_support.h @@ -103,6 +103,13 @@ void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, *__dest = __val; } +template +inline _LIBCPP_INLINE_VISIBILITY +void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val) +{ + *__dest = __val; +} + template inline _LIBCPP_INLINE_VISIBILITY _ValueType __libcpp_atomic_load(_ValueType const* __val, diff --git a/src/config_elast.h b/src/include/config_elast.h similarity index 100% rename from src/config_elast.h rename to src/include/config_elast.h diff --git a/src/ios.cpp b/src/ios.cpp index 90972c407d79..23e3ee0ca044 100644 --- a/src/ios.cpp +++ b/src/ios.cpp @@ -15,7 +15,7 @@ #include "__locale" #include "algorithm" -#include "config_elast.h" +#include "include/config_elast.h" #include "istream" #include "limits" #include "memory" @@ -152,7 +152,7 @@ ios_base::getloc() const } // xalloc -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) atomic ios_base::__xindex_ = ATOMIC_VAR_INIT(0); #else int ios_base::__xindex_ = 0; diff --git a/src/locale.cpp b/src/locale.cpp index bdc73e1d5379..6b04e7881764 100644 --- a/src/locale.cpp +++ b/src/locale.cpp @@ -812,7 +812,8 @@ ctype::do_toupper(char_type c) const { #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c; -#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ + defined(__NetBSD__) return isascii(c) ? ctype::__classic_upper_table()[c] : c; #else return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c; @@ -825,7 +826,8 @@ ctype::do_toupper(char_type* low, const char_type* high) const for (; low != high; ++low) #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low; -#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ + defined(__NetBSD__) *low = isascii(*low) ? ctype::__classic_upper_table()[*low] : *low; #else @@ -839,7 +841,8 @@ ctype::do_tolower(char_type c) const { #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c; -#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ + defined(__NetBSD__) return isascii(c) ? ctype::__classic_lower_table()[c] : c; #else return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c; @@ -852,7 +855,8 @@ ctype::do_tolower(char_type* low, const char_type* high) const for (; low != high; ++low) #ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low; -#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \ + defined(__NetBSD__) *low = isascii(*low) ? ctype::__classic_lower_table()[*low] : *low; #else @@ -922,7 +926,7 @@ ctype::do_toupper(char_type c) const #elif defined(__NetBSD__) return static_cast(__classic_upper_table()[static_cast(c)]); #elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) - return isascii(c) ? + return isascii(c) ? static_cast(__classic_upper_table()[static_cast(c)]) : c; #else return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c; @@ -955,7 +959,7 @@ ctype::do_tolower(char_type c) const static_cast(_DefaultRuneLocale.__maplower[static_cast(c)]) : c; #elif defined(__NetBSD__) return static_cast(__classic_lower_table()[static_cast(c)]); -#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) +#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) return isascii(c) ? static_cast(__classic_lower_table()[static_cast(c)]) : c; #else @@ -1012,7 +1016,7 @@ ctype::do_narrow(const char_type* low, const char_type* high, char dfault, return low; } -#ifdef __EMSCRIPTEN__ +#if defined(__EMSCRIPTEN__) extern "C" const unsigned short ** __ctype_b_loc(); extern "C" const int ** __ctype_tolower_loc(); extern "C" const int ** __ctype_toupper_loc(); @@ -1169,7 +1173,7 @@ ctype::__classic_upper_table() _NOEXCEPT { return *__ctype_toupper_loc(); } -#endif // __GLIBC__ || __EMSCRIPTEN__ || __NETBSD__ +#endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ // template <> class ctype_byname diff --git a/src/memory.cpp b/src/memory.cpp index 66fb143c6a62..5b81f26e3dc0 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -13,7 +13,7 @@ #include "mutex" #include "thread" #endif -#include "support/atomic_support.h" +#include "include/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD @@ -124,7 +124,7 @@ __shared_weak_count::__get_deleter(const type_info&) const _NOEXCEPT #endif // _LIBCPP_NO_RTTI -#if __has_feature(cxx_atomic) && !defined(_LIBCPP_HAS_NO_THREADS) +#if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) static const std::size_t __sp_mut_count = 16; static pthread_mutex_t mut_back_imp[__sp_mut_count] = @@ -177,7 +177,7 @@ __get_sp_mut(const void* p) return muts[hash()(p) & (__sp_mut_count-1)]; } -#endif // __has_feature(cxx_atomic) && !_LIBCPP_HAS_NO_THREADS +#endif // defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS) void declare_reachable(void*) diff --git a/src/mutex.cpp b/src/mutex.cpp index 5f8ba0a08266..127e67a2627e 100644 --- a/src/mutex.cpp +++ b/src/mutex.cpp @@ -12,7 +12,7 @@ #include "limits" #include "system_error" #include "cassert" -#include "support/atomic_support.h" +#include "include/atomic_support.h" _LIBCPP_BEGIN_NAMESPACE_STD #ifndef _LIBCPP_HAS_NO_THREADS diff --git a/src/new.cpp b/src/new.cpp index c28fcb5917cf..f4f73d86803d 100644 --- a/src/new.cpp +++ b/src/new.cpp @@ -13,10 +13,6 @@ #include "new" -#ifndef __has_include -#define __has_include(inc) 0 -#endif - #if defined(__APPLE__) && !defined(LIBCXXRT) #include @@ -27,9 +23,9 @@ #define __new_handler __cxxabiapple::__cxa_new_handler #endif #else // __APPLE__ - #if defined(LIBCXXRT) || __has_include() + #if defined(LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI) #include - #endif // __has_include() + #endif // defined(LIBCXX_BUILDING_LIBCXXABI) #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION @@ -38,7 +34,7 @@ #ifndef __GLIBCXX__ // Implement all new and delete operators as weak definitions -// in this shared library, so that they can be overriden by programs +// in this shared library, so that they can be overridden by programs // that define non-weak copies of the functions. _LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS diff --git a/src/stdexcept.cpp b/src/stdexcept.cpp index aff4b1850d36..0a08bfec27ec 100644 --- a/src/stdexcept.cpp +++ b/src/stdexcept.cpp @@ -13,12 +13,8 @@ #include "string" #include "system_error" -#ifndef __has_include -#define __has_include(inc) 0 -#endif - /* For _LIBCPPABI_VERSION */ -#if __has_include() || defined(__APPLE_) || defined(LIBCXXRT) +#if defined(LIBCXX_BUILDING_LIBCXXABI) || defined(__APPLE__) || defined(LIBCXXRT) #include #endif diff --git a/src/system_error.cpp b/src/system_error.cpp index 18f668f071cd..3023e200aa34 100644 --- a/src/system_error.cpp +++ b/src/system_error.cpp @@ -12,7 +12,7 @@ #define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" -#include "config_elast.h" +#include "include/config_elast.h" #include "cstring" #include "string" diff --git a/src/typeinfo.cpp b/src/typeinfo.cpp index b4281209170c..5c0a609b5e5c 100644 --- a/src/typeinfo.cpp +++ b/src/typeinfo.cpp @@ -8,13 +8,8 @@ //===----------------------------------------------------------------------===// #include -#ifndef __has_include -#define __has_include(inc) 0 -#endif - -#ifdef __APPLE__ -#include -#elif defined(LIBCXXRT) || __has_include() +#if defined(__APPLE__) || defined(LIBCXXRT) || \ + defined(LIBCXX_BUILDING_LIBCXXABI) #include #endif diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ca937a8dba9a..b67b3b43f83e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -6,84 +6,43 @@ macro(pythonize_bool var) endif() endmacro() -set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's llvm-lit.") +set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING + "Configuration variant to use for LIT.") -if(LIBCXX_BUILT_STANDALONE) - # Make sure we can use the console pool for recent cmake and ninja > 1.5 - if(CMAKE_VERSION VERSION_LESS 3.1.20141117) - set(cmake_3_2_USES_TERMINAL) - else() - set(cmake_3_2_USES_TERMINAL USES_TERMINAL) - endif() -else() - include(FindPythonInterp) - if(PYTHONINTERP_FOUND) - set(LIT_EXECUTABLE - ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/utils/lit/lit.py) - else() - message(WARNING "Could not find Python, cannot set LIT_EXECUTABLE.") - endif() +pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS) +pythonize_bool(LIBCXX_ENABLE_RTTI) +pythonize_bool(LIBCXX_ENABLE_SHARED) +pythonize_bool(LIBCXX_BUILD_32_BITS) +pythonize_bool(LIBCXX_GENERATE_COVERAGE) +pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) + +# The tests shouldn't link to any ABI library when it has been linked into +# libc++ statically or via a linker script. +if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY OR LIBCXX_ENABLE_ABI_LINKER_SCRIPT) + set(LIBCXX_CXX_ABI_LIBNAME "none") endif() -if (LIT_EXECUTABLE) - set(LIT_ARGS_DEFAULT "-sv --show-unsupported --show-xfail") - if (MSVC OR XCODE) - set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar") - endif() - set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" - CACHE STRING "Default options for lit") - set(LIT_ARGS "${LLVM_LIT_ARGS}") - separate_arguments(LIT_ARGS) +set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING + "TargetInfo to use when setting up test environment.") +set(LIBCXX_EXECUTOR "None" CACHE STRING + "Executor to use when running tests.") - set(LIBCXX_LIT_VARIANT "libcxx" CACHE STRING - "Configuration variant to use for LIT.") +set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") - pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS) - pythonize_bool(LIBCXX_ENABLE_RTTI) - pythonize_bool(LIBCXX_ENABLE_SHARED) - pythonize_bool(LIBCXX_BUILD_32_BITS) - pythonize_bool(LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE) - pythonize_bool(LIBCXX_ENABLE_STDIN) - pythonize_bool(LIBCXX_ENABLE_STDOUT) - pythonize_bool(LIBCXX_ENABLE_THREADS) - pythonize_bool(LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS) - pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK) - pythonize_bool(LIBCXX_GENERATE_COVERAGE) - pythonize_bool(LIBCXXABI_USE_LLVM_UNWINDER) +configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + @ONLY) - # The tests shouldn't link to any ABI library when it has been linked into - # libc++ statically. - if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) - set(LIBCXX_CXX_ABI_LIBNAME "none") - endif() - set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING - "TargetInfo to use when setting up test environment.") - set(LIBCXX_EXECUTOR "None" CACHE STRING - "Executor to use when running tests.") +add_lit_testsuite(check-libcxx + "Running libcxx tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS cxx) - set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!") - - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - @ONLY) - - add_custom_target(check-libcxx - COMMAND ${LIT_EXECUTABLE} - ${LIT_ARGS} - ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS cxx - COMMENT "Running libcxx tests" - ${cmake_3_2_USES_TERMINAL}) - - if (LIBCXX_GENERATE_COVERAGE) - include(CodeCoverage) - set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage") - set(capture_dirs "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${CMAKE_CURRENT_BINARY_DIR}") - set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src") - setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}") - endif() -else() - message(WARNING - "LIT_EXECUTABLE not set, no check-libcxx target will be available!") +if (LIBCXX_GENERATE_COVERAGE) + include(CodeCoverage) + set(output_dir "${CMAKE_CURRENT_BINARY_DIR}/coverage") + set(capture_dirs "${LIBCXX_LIB_CMAKEFILES_DIR}/cxx.dir/;${CMAKE_CURRENT_BINARY_DIR}") + set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src") + setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}") endif() diff --git a/test/std/atomics/libcpp-has-no-threads.fail.cpp b/test/libcxx/atomics/libcpp-has-no-threads.fail.cpp similarity index 100% rename from test/std/atomics/libcpp-has-no-threads.fail.cpp rename to test/libcxx/atomics/libcpp-has-no-threads.fail.cpp diff --git a/test/std/atomics/libcpp-has-no-threads.pass.cpp b/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp similarity index 87% rename from test/std/atomics/libcpp-has-no-threads.pass.cpp rename to test/libcxx/atomics/libcpp-has-no-threads.pass.cpp index 9c0cccbda380..e587e6b4317a 100644 --- a/test/std/atomics/libcpp-has-no-threads.pass.cpp +++ b/test/libcxx/atomics/libcpp-has-no-threads.pass.cpp @@ -10,7 +10,7 @@ #ifdef _LIBCPP_HAS_NO_THREADS #error This should be XFAIL'd for the purpose of detecting that the LIT feature\ - 'libcpp-has-no-threads' is available iff _LIBCPP_HAS_NO_THREADS is defined + 'libcpp-has-no-threads' is available iff _LIBCPP_HAS_NO_THREADS is defined #endif int main() diff --git a/test/libcxx/compiler.py b/test/libcxx/compiler.py index 7afbed461e31..4962038cbbed 100644 --- a/test/libcxx/compiler.py +++ b/test/libcxx/compiler.py @@ -150,3 +150,39 @@ def hasCompileFlag(self, flag): cmd, out, err, rc = self.compile(os.devnull, out=os.devnull, flags=flags) return rc == 0 + + def addCompileFlagIfSupported(self, flag): + if isinstance(flag, list): + flags = list(flag) + else: + flags = [flag] + if self.hasCompileFlag(flags): + self.compile_flags += flags + return True + else: + return False + + def addWarningFlagIfSupported(self, flag): + """ + addWarningFlagIfSupported - Add a warning flag if the compiler + supports it. Unlike addCompileFlagIfSupported, this function detects + when "-Wno-" flags are unsupported. If flag is a + "-Wno-" GCC will not emit an unknown option diagnostic unless + another error is triggered during compilation. + """ + assert isinstance(flag, str) + if not flag.startswith('-Wno-'): + return self.addCompileFlagIfSupported(flag) + flags = ['-Werror', flag] + cmd = self.compileCmd('-', os.devnull, flags) + # Remove '-v' because it will cause the command line invocation + # to be printed as part of the error output. + # TODO(EricWF): Are there other flags we need to worry about? + if '-v' in cmd: + cmd.remove('-v') + out, err, rc = lit.util.executeCommand(cmd, input='#error\n') + assert rc != 0 + if flag in err: + return False + self.compile_flags += [flag] + return True diff --git a/test/libcxx/containers/sequences/deque/incomplete.pass.cpp b/test/libcxx/containers/sequences/deque/incomplete.pass.cpp new file mode 100644 index 000000000000..dbeea5f9aefb --- /dev/null +++ b/test/libcxx/containers/sequences/deque/incomplete.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// deque() +// deque::iterator() + +#define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +#include +#include + +struct A { + std::deque d; + std::deque::iterator it; + std::deque::reverse_iterator it2; +}; + +int main() +{ + A a; + assert(a.d.size() == 0); + a.it = a.d.begin(); + a.it2 = a.d.rend(); +} diff --git a/test/std/containers/sequences/vector/asan.pass.cpp b/test/libcxx/containers/sequences/vector/asan.pass.cpp similarity index 66% rename from test/std/containers/sequences/vector/asan.pass.cpp rename to test/libcxx/containers/sequences/vector/asan.pass.cpp index 86c02b295624..b102fc08dafb 100644 --- a/test/std/containers/sequences/vector/asan.pass.cpp +++ b/test/libcxx/containers/sequences/vector/asan.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: clang-3.3, clang-3.4, clang-3.5 + // // reference operator[](size_type n); @@ -15,15 +17,21 @@ #include #include -#include "min_allocator.h" #include "asan_testing.h" +#include "min_allocator.h" +#include "test_iterators.h" +#include "test_macros.h" #ifndef _LIBCPP_HAS_NO_ASAN -extern "C" void __asan_set_error_exit_code(int); +extern "C" void __sanitizer_set_death_callback(void (*callback)(void)); + +void do_exit() { + exit(0); +} int main() { -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector> C; @@ -33,15 +41,26 @@ int main() T foo = c[c.size()]; // bad, but not caught by ASAN } #endif - - __asan_set_error_exit_code(0); + + { + typedef input_iterator MyInputIter; + // Sould not trigger ASan. + std::vector v; + v.reserve(1); + int i[] = {42}; + v.insert(v.begin(), MyInputIter(i), MyInputIter(i + 1)); + assert(v[0] == 42); + assert(is_contiguous_container_asan_correct(v)); + } + + __sanitizer_set_death_callback(do_exit); { typedef int T; typedef std::vector C; const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; C c(std::begin(t), std::end(t)); c.reserve(2*c.size()); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity())); T foo = c[c.size()]; // should trigger ASAN assert(false); // if we got here, ASAN didn't trigger diff --git a/test/std/containers/sequences/vector/asan_throw.pass.cpp b/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp similarity index 99% rename from test/std/containers/sequences/vector/asan_throw.pass.cpp rename to test/libcxx/containers/sequences/vector/asan_throw.pass.cpp index c100da1aade7..9af3f6be53e8 100644 --- a/test/std/containers/sequences/vector/asan_throw.pass.cpp +++ b/test/libcxx/containers/sequences/vector/asan_throw.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // Test asan vector annotations with a class that throws in a CTOR. #include diff --git a/test/libcxx/double_include.sh.cpp b/test/libcxx/double_include.sh.cpp index 5620e5b35c2b..99767cf1bbc8 100644 --- a/test/libcxx/double_include.sh.cpp +++ b/test/libcxx/double_include.sh.cpp @@ -15,6 +15,12 @@ // RUN: %cxx -o %t.exe %t.first.o %t.second.o %flags %link_flags // RUN: %run + +// Prevent from generating deprecated warnings for this test. +#if defined(__DEPRECATED) +#undef __DEPRECATED +#endif + #include #include #include @@ -50,6 +56,7 @@ #include #include #include +#include #include #include #include diff --git a/test/libcxx/experimental/any/size_and_alignment.pass.cpp b/test/libcxx/experimental/any/size_and_alignment.pass.cpp new file mode 100644 index 000000000000..b7db54020478 --- /dev/null +++ b/test/libcxx/experimental/any/size_and_alignment.pass.cpp @@ -0,0 +1,23 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// Check that the size and alignment of any are what we expect. + +#include + +int main() +{ + using std::experimental::any; + static_assert(sizeof(any) == sizeof(void*)*4, ""); + static_assert(alignof(any) == alignof(void*), ""); +} diff --git a/test/libcxx/experimental/any/small_type.pass.cpp b/test/libcxx/experimental/any/small_type.pass.cpp new file mode 100644 index 000000000000..e6595d4a4ab3 --- /dev/null +++ b/test/libcxx/experimental/any/small_type.pass.cpp @@ -0,0 +1,114 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// Check that the size and alignment of any are what we expect. + +#include +#include "any_helpers.h" + +constexpr std::size_t BufferSize = (sizeof(void*) * 3); +constexpr std::size_t BufferAlignment = alignof(void*); +// Clang doesn't like "alignof(BufferAlignment * 2)" due to PR13986. +// So we create "DoubleBufferAlignment" instead. +constexpr std::size_t DoubleBufferAlignment = BufferAlignment * 2; + +class SmallThrowsDtor +{ +public: + SmallThrowsDtor() {} + SmallThrowsDtor(SmallThrowsDtor const &) noexcept {} + SmallThrowsDtor(SmallThrowsDtor &&) noexcept {} + ~SmallThrowsDtor() noexcept(false) {} +}; + + +struct alignas(1) MaxSizeType { + char buff[BufferSize]; +}; + +struct alignas(BufferAlignment) MaxAlignType { +}; + +struct alignas(BufferAlignment) MaxSizeAndAlignType { + char buff[BufferSize]; +}; + + +struct alignas(1) OverSizeType { + char buff[BufferSize + 1]; +}; + +struct alignas(DoubleBufferAlignment) OverAlignedType { +}; + +struct alignas(DoubleBufferAlignment) OverSizeAndAlignedType { + char buff[BufferSize + 1]; +}; + +int main() +{ + using std::experimental::any; + using std::experimental::__any_imp::_IsSmallObject; + static_assert(_IsSmallObject::value, ""); + static_assert(_IsSmallObject::value, ""); + static_assert(!_IsSmallObject::value, ""); + static_assert(!_IsSmallObject::value, ""); + { + // Check a type that meets the size requirement *exactly* and has + // a lesser alignment requirement is considered small. + typedef MaxSizeType T; + static_assert(sizeof(T) == BufferSize, ""); + static_assert(alignof(T) < BufferAlignment, ""); + static_assert(_IsSmallObject::value, ""); + } + { + // Check a type that meets the alignment requirement *exactly* and has + // a lesser size is considered small. + typedef MaxAlignType T; + static_assert(sizeof(T) < BufferSize, ""); + static_assert(alignof(T) == BufferAlignment, ""); + static_assert(_IsSmallObject::value, ""); + } + { + // Check a type that meets the size and alignment requirements *exactly* + // is considered small. + typedef MaxSizeAndAlignType T; + static_assert(sizeof(T) == BufferSize, ""); + static_assert(alignof(T) == BufferAlignment, ""); + static_assert(_IsSmallObject::value, ""); + } + { + // Check a type that meets the alignment requirements but is over-sized + // is not considered small. + typedef OverSizeType T; + static_assert(sizeof(T) > BufferSize, ""); + static_assert(alignof(T) < BufferAlignment, ""); + static_assert(!_IsSmallObject::value, ""); + } + { + // Check a type that meets the size requirements but is over-aligned + // is not considered small. + typedef OverAlignedType T; + static_assert(sizeof(T) < BufferSize, ""); + static_assert(alignof(T) > BufferAlignment, ""); + static_assert(!_IsSmallObject::value, ""); + } + { + // Check a type that exceeds both the size an alignment requirements + // is not considered small. + typedef OverSizeAndAlignedType T; + static_assert(sizeof(T) > BufferSize, ""); + static_assert(alignof(T) > BufferAlignment, ""); + static_assert(!_IsSmallObject::value, ""); + } +} diff --git a/test/libcxx/experimental/any/version.pass.cpp b/test/libcxx/experimental/any/version.pass.cpp new file mode 100644 index 000000000000..611d65027b19 --- /dev/null +++ b/test/libcxx/experimental/any/version.pass.cpp @@ -0,0 +1,20 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +#include + +#ifndef _LIBCPP_VERSION +#error _LIBCPP_VERSION not defined +#endif + +int main() +{ +} diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp index 0effac2fc142..738c0c72592e 100644 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default.pass.cpp @@ -7,6 +7,9 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: c++98, c++03, c++11 + // dynarray.cons // explicit dynarray(size_type c); @@ -16,22 +19,21 @@ // ~dynarray(); - -#include <__config> - -#if _LIBCPP_STD_VER > 11 #include #include #include #include +#include +#include #include + using std::experimental::dynarray; template -void test ( const std::initializer_list &vals ) { +void testInitList( const std::initializer_list &vals ) { typedef dynarray dynA; dynA d1 ( vals ); @@ -41,12 +43,14 @@ void test ( const std::initializer_list &vals ) { template -void test ( const T &val ) { +void test ( const T &val, bool DefaultValueIsIndeterminate = false) { typedef dynarray dynA; dynA d1 ( 4 ); assert ( d1.size () == 4 ); - assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } )); + if (!DefaultValueIsIndeterminate) { + assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } )); + } dynA d2 ( 7, val ); assert ( d2.size () == 7 ); @@ -60,27 +64,23 @@ void test ( const T &val ) { void test_bad_length () { try { dynarray ( std::numeric_limits::max() / sizeof ( int ) + 1 ); } catch ( std::bad_array_length & ) { return ; } + catch (...) { assert(false); } assert ( false ); - } +} -void test_bad_alloc () { - try { dynarray ( std::numeric_limits::max() / sizeof ( int ) - 1 ); } - catch ( std::bad_alloc & ) { return ; } - assert ( false ); - } int main() { -// test ( 14 ); // ints don't get default initialized - test ( 0 ); - test ( 14.0 ); + test ( 14, /* DefaultValueIsIndeterminate */ true ); // ints don't get default initialized + test ( 0, true); + test ( 14.0, true ); test> ( std::complex ( 14, 0 )); test ( "fourteen" ); - test ( { 1, 1, 2, 3, 5, 8 } ); - test ( { 1., 1., 2., 3., 5., 8. } ); - test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), - std::string("5"), std::string("8")} ); + testInitList( { 1, 1, 2, 3, 5, 8 } ); + testInitList( { 1., 1., 2., 3., 5., 8. } ); + testInitList( { std::string("1"), std::string("1"), std::string("2"), std::string("3"), + std::string("5"), std::string("8")} ); // Make sure we don't pick up the Allocator version here dynarray d1 ( 20, 3 ); @@ -88,8 +88,4 @@ int main() assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } )); test_bad_length (); - test_bad_alloc (); } -#else -int main() {} -#endif diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp new file mode 100644 index 000000000000..612e661ea6db --- /dev/null +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// XFAIL: libcpp-no-exceptions +// dynarray.cons + +// explicit dynarray(size_type c); + +// UNSUPPORTED: c++98, c++03, c++11 + +// The sanitizers replace new/delete with versions that do not throw bad_alloc. +// UNSUPPORTED: sanitizer-new-delete, ubsan + + +#include +#include +#include +#include + + +using std::experimental::dynarray; + +int main() { + try { dynarray((std::numeric_limits::max() / sizeof(int)) - 1); } + catch (std::bad_alloc &) { return 0; } + catch (...) { assert(false); } + assert(false); +} diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp index b669f25948ed..1bbd8cde92fe 100644 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.data/default.pass.cpp @@ -7,15 +7,13 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 + // dynarray.data // T* data() noexcept; // const T* data() const noexcept; - -#include <__config> - -#if _LIBCPP_STD_VER > 11 #include #include @@ -27,41 +25,44 @@ using std::experimental::dynarray; template -void dyn_test_const ( const dynarray &dyn ) { +void dyn_test_const(const dynarray &dyn, bool CheckEquals = true) { const T *data = dyn.data (); assert ( data != NULL ); - assert ( std::equal ( dyn.begin(), dyn.end(), data )); + if (CheckEquals) { + assert ( std::equal ( dyn.begin(), dyn.end(), data )); } +} template -void dyn_test ( dynarray &dyn ) { +void dyn_test( dynarray &dyn, bool CheckEquals = true) { T *data = dyn.data (); assert ( data != NULL ); - assert ( std::equal ( dyn.begin(), dyn.end(), data )); + if (CheckEquals) { + assert ( std::equal ( dyn.begin(), dyn.end(), data )); } +} template -void test ( const T &val ) { +void test(const T &val, bool DefaultValueIsIndeterminate = false) { typedef dynarray dynA; + + const bool CheckDefaultValues = !DefaultValueIsIndeterminate; + + dynA d1(4); + dyn_test(d1, CheckDefaultValues); + dyn_test_const(d1, CheckDefaultValues); - dynA d1 ( 4 ); - dyn_test ( d1 ); - dyn_test_const ( d1 ); - - dynA d2 ( 7, val ); + dynA d2 (7, val); dyn_test ( d2 ); dyn_test_const ( d2 ); - } +} int main() { - test ( 14 ); - test ( 14.0 ); + test(14, /* DefaultValueIsIndeterminate */ true); + test(14.0, true); test> ( std::complex ( 14, 0 )); test ( "fourteen" ); } -#else -int main() {} -#endif diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp index 4d77cf732758..8c0d08538716 100644 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/at.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // dynarray.overview // const_reference at(size_type n) const; diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp index e82aa64b98b6..2af862a5530f 100644 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 + // dynarray.overview // reference front(); @@ -14,10 +16,6 @@ // reference back(); // const_reference back() const; - -#include <__config> - -#if _LIBCPP_STD_VER > 11 #include #include @@ -29,40 +27,47 @@ using std::experimental::dynarray; template -void dyn_test_const ( const dynarray &dyn ) { +void dyn_test_const ( const dynarray &dyn, bool CheckValues = true ) { const T *data = dyn.data (); - assert ( *data == dyn.front ()); - assert ( *(data + dyn.size() - 1 ) == dyn.back ()); + assert(data == &dyn.front()); + assert((data + dyn.size() - 1) == &dyn.back()); + if (CheckValues) { + assert ( *data == dyn.front ()); + assert ( *(data + dyn.size() - 1 ) == dyn.back ()); } +} template -void dyn_test ( dynarray &dyn ) { +void dyn_test ( dynarray &dyn, bool CheckValues = true ) { T *data = dyn.data (); - assert ( *data == dyn.front ()); - assert ( *(data + dyn.size() - 1 ) == dyn.back ()); + assert(data == &dyn.front()); + assert((data + dyn.size() - 1) == &dyn.back()); + if (CheckValues) { + assert ( *data == dyn.front ()); + assert ( *(data + dyn.size() - 1 ) == dyn.back ()); } +} template -void test ( const T &val ) { +void test ( const T &val, bool DefaultValueIsIndeterminate = false) { typedef dynarray dynA; - + + const bool CheckDefaultValues = ! DefaultValueIsIndeterminate; + dynA d1 ( 4 ); - dyn_test ( d1 ); - dyn_test_const ( d1 ); + dyn_test ( d1, CheckDefaultValues ); + dyn_test_const ( d1, CheckDefaultValues ); dynA d2 ( 7, val ); dyn_test ( d2 ); dyn_test_const ( d2 ); - } +} int main() { - test ( 14 ); - test ( 14.0 ); + test ( 14, /* DefaultValueIsIndeterminate */ true); + test ( 14.0, true ); test> ( std::complex ( 14, 0 )); test ( "fourteen" ); } -#else -int main() {} -#endif diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py index 09fbf66dbba0..fefbf01ad450 100644 --- a/test/libcxx/test/config.py +++ b/test/libcxx/test/config.py @@ -1,4 +1,3 @@ -import importlib import locale import os import platform @@ -12,6 +11,7 @@ from libcxx.test.format import LibcxxTestFormat from libcxx.compiler import CXXCompiler +from libcxx.test.target_info import make_target_info from libcxx.test.executor import * from libcxx.test.tracing import * @@ -42,13 +42,13 @@ def prevent_reload_fn(*args, **kwargs): ld_fn(config, site_cfg) lit_config.load_config = ld_fn - class Configuration(object): # pylint: disable=redefined-outer-name def __init__(self, lit_config, config): self.lit_config = lit_config self.config = config self.cxx = None + self.project_obj_root = None self.libcxx_src_root = None self.libcxx_obj_root = None self.cxx_library_root = None @@ -141,13 +141,7 @@ def configure_executor(self): self.executor = te def configure_target_info(self): - default = "libcxx.test.target_info.LocalTI" - info_str = self.get_lit_conf('target_info', default) - mod_path, _, info = info_str.rpartition('.') - mod = importlib.import_module(mod_path) - self.target_info = getattr(mod, info)() - if info_str != default: - self.lit_config.note("inferred target_info as: %r" % info_str) + self.target_info = make_target_info(self) def configure_cxx(self): # Gather various compiler parameters. @@ -179,7 +173,14 @@ def configure_src_root(self): 'libcxx_src_root', os.path.dirname(self.config.test_source_root)) def configure_obj_root(self): + self.project_obj_root = self.get_lit_conf('project_obj_root') self.libcxx_obj_root = self.get_lit_conf('libcxx_obj_root') + if not self.libcxx_obj_root and self.project_obj_root is not None: + possible_root = os.path.join(self.project_obj_root, 'projects', 'libcxx') + if os.path.isdir(possible_root): + self.libcxx_obj_root = possible_root + else: + self.libcxx_obj_root = self.project_obj_root def configure_cxx_library_root(self): self.cxx_library_root = self.get_lit_conf('cxx_library_root', @@ -211,13 +212,12 @@ def configure_use_clang_verify(self): def configure_execute_external(self): # Choose between lit's internal shell pipeline runner and a real shell. # If LIT_USE_INTERNAL_SHELL is in the environment, we use that as the - # default value. Otherwise we default to internal on Windows and - # external elsewhere, as bash on Windows is usually very slow. + # default value. Otherwise we ask the target_info. use_lit_shell_default = os.environ.get('LIT_USE_INTERNAL_SHELL') if use_lit_shell_default is not None: use_lit_shell_default = use_lit_shell_default != '0' else: - use_lit_shell_default = sys.platform == 'win32' + use_lit_shell_default = self.target_info.use_lit_shell_default() # Check for the command line parameter using the default value if it is # not present. use_lit_shell = self.get_lit_bool('use_lit_shell', @@ -236,63 +236,10 @@ def configure_features(self): if additional_features: for f in additional_features.split(','): self.config.available_features.add(f.strip()) + self.target_info.add_locale_features(self.config.available_features) - # Figure out which of the required locales we support - locales = { - 'Darwin': { - 'en_US.UTF-8': 'en_US.UTF-8', - 'cs_CZ.ISO8859-2': 'cs_CZ.ISO8859-2', - 'fr_FR.UTF-8': 'fr_FR.UTF-8', - 'fr_CA.ISO8859-1': 'fr_CA.ISO8859-1', - 'ru_RU.UTF-8': 'ru_RU.UTF-8', - 'zh_CN.UTF-8': 'zh_CN.UTF-8', - }, - 'FreeBSD': { - 'en_US.UTF-8': 'en_US.UTF-8', - 'cs_CZ.ISO8859-2': 'cs_CZ.ISO8859-2', - 'fr_FR.UTF-8': 'fr_FR.UTF-8', - 'fr_CA.ISO8859-1': 'fr_CA.ISO8859-1', - 'ru_RU.UTF-8': 'ru_RU.UTF-8', - 'zh_CN.UTF-8': 'zh_CN.UTF-8', - }, - 'Linux': { - 'en_US.UTF-8': 'en_US.UTF-8', - 'cs_CZ.ISO8859-2': 'cs_CZ.ISO-8859-2', - 'fr_FR.UTF-8': 'fr_FR.UTF-8', - 'fr_CA.ISO8859-1': 'fr_CA.ISO-8859-1', - 'ru_RU.UTF-8': 'ru_RU.UTF-8', - 'zh_CN.UTF-8': 'zh_CN.UTF-8', - }, - 'Windows': { - 'en_US.UTF-8': 'English_United States.1252', - 'cs_CZ.ISO8859-2': 'Czech_Czech Republic.1250', - 'fr_FR.UTF-8': 'French_France.1252', - 'fr_CA.ISO8859-1': 'French_Canada.1252', - 'ru_RU.UTF-8': 'Russian_Russia.1251', - 'zh_CN.UTF-8': 'Chinese_China.936', - }, - } - - target_system = self.target_info.system() target_platform = self.target_info.platform() - if target_system in locales: - default_locale = locale.setlocale(locale.LC_ALL) - for feature, loc in locales[target_system].items(): - try: - locale.setlocale(locale.LC_ALL, loc) - self.config.available_features.add( - 'locale.{0}'.format(feature)) - except locale.Error: - self.lit_config.warning('The locale {0} is not supported by ' - 'your platform. Some tests will be ' - 'unsupported.'.format(loc)) - locale.setlocale(locale.LC_ALL, default_locale) - else: - # Warn that the user doesn't get any free XFAILs for locale issues - self.lit_config.warning("No locales entry for target_system: %s" % - target_system) - # Write an "available feature" that combines the triple when # use_system_cxx_lib is enabled. This is so that we can easily write # XFAIL markers for tests that are known to fail with versions of @@ -304,17 +251,6 @@ def configure_features(self): # Insert the platform name into the available features as a lower case. self.config.available_features.add(target_platform) - # Some linux distributions have different locale data than others. - # Insert the distributions name and name-version into the available - # features to allow tests to XFAIL on them. - if target_platform == 'linux': - name = self.target_info.platform_name() - ver = self.target_info.platform_ver() - if name: - self.config.available_features.add(name) - if name and ver: - self.config.available_features.add('%s-%s' % (name, ver)) - # Simulator testing can take a really long time for some of these tests # so add a feature check so we can REQUIRES: long_tests in them self.long_tests = self.get_lit_bool('long_tests') @@ -344,38 +280,33 @@ def configure_default_compile_flags(self): # Try and get the std version from the command line. Fall back to # default given in lit.site.cfg is not present. If default is not # present then force c++11. - std = self.get_lit_conf('std', 'c++11') + std = self.get_lit_conf('std') + if not std: + # Choose the newest possible language dialect if none is given. + possible_stds = ['c++1z', 'c++14', 'c++11', 'c++03'] + for s in possible_stds: + if self.cxx.hasCompileFlag('-std=%s' % s): + std = s + self.lit_config.note( + 'inferred language dialect as: %s' % std) + break + if not std: + self.lit_config.fatal( + 'Failed to infer a supported language dialect from one of %r' + % possible_stds) self.cxx.compile_flags += ['-std={0}'.format(std)] self.config.available_features.add(std) # Configure include paths self.cxx.compile_flags += ['-nostdinc++'] self.configure_compile_flags_header_includes() - if self.target_info.platform() == 'linux': - self.cxx.compile_flags += ['-D__STDC_FORMAT_MACROS', - '-D__STDC_LIMIT_MACROS', - '-D__STDC_CONSTANT_MACROS'] + self.target_info.add_cxx_compile_flags(self.cxx.compile_flags) # Configure feature flags. self.configure_compile_flags_exceptions() self.configure_compile_flags_rtti() - self.configure_compile_flags_no_global_filesystem_namespace() - self.configure_compile_flags_no_stdin() - self.configure_compile_flags_no_stdout() + self.configure_compile_flags_abi_version() enable_32bit = self.get_lit_bool('enable_32bit', False) if enable_32bit: self.cxx.flags += ['-m32'] - # Configure threading features. - enable_threads = self.get_lit_bool('enable_threads', True) - enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock', - True) - if not enable_threads: - self.configure_compile_flags_no_threads() - if not enable_monotonic_clock: - self.configure_compile_flags_no_monotonic_clock() - elif not enable_monotonic_clock: - self.lit_config.fatal('enable_monotonic_clock cannot be false when' - ' enable_threads is true.') - self.configure_compile_flags_no_thread_unsafe_c_functions() - # Use verbose output for better errors self.cxx.flags += ['-v'] sysroot = self.get_lit_conf('sysroot') @@ -391,6 +322,7 @@ def configure_compile_flags_header_includes(self): support_path = os.path.join(self.libcxx_src_root, 'test/support') self.cxx.compile_flags += ['-I' + support_path] self.cxx.compile_flags += ['-include', os.path.join(support_path, 'nasty_macros.hpp')] + self.configure_config_site_header() libcxx_headers = self.get_lit_conf( 'libcxx_headers', os.path.join(self.libcxx_src_root, 'include')) if not os.path.isdir(libcxx_headers): @@ -398,6 +330,56 @@ def configure_compile_flags_header_includes(self): % libcxx_headers) self.cxx.compile_flags += ['-I' + libcxx_headers] + def configure_config_site_header(self): + # Check for a possible __config_site in the build directory. We + # use this if it exists. + if self.libcxx_obj_root is None: + return + config_site_header = os.path.join(self.libcxx_obj_root, '__config_site') + if not os.path.isfile(config_site_header): + return + contained_macros = self.parse_config_site_and_add_features( + config_site_header) + self.lit_config.note('Using __config_site header %s with macros: %r' + % (config_site_header, contained_macros)) + # FIXME: This must come after the call to + # 'parse_config_site_and_add_features(...)' in order for it to work. + self.cxx.compile_flags += ['-include', config_site_header] + + def parse_config_site_and_add_features(self, header): + """ parse_config_site_and_add_features - Deduce and add the test + features that that are implied by the #define's in the __config_site + header. Return a dictionary containing the macros found in the + '__config_site' header. + """ + # Parse the macro contents of __config_site by dumping the macros + # using 'c++ -dM -E' and filtering the predefines. + predefines = self.cxx.dumpMacros() + macros = self.cxx.dumpMacros(header) + feature_macros_keys = set(macros.keys()) - set(predefines.keys()) + feature_macros = {} + for k in feature_macros_keys: + feature_macros[k] = macros[k] + # We expect the header guard to be one of the definitions + assert '_LIBCPP_CONFIG_SITE' in feature_macros + del feature_macros['_LIBCPP_CONFIG_SITE'] + # The __config_site header should be non-empty. Otherwise it should + # have never been emitted by CMake. + assert len(feature_macros) > 0 + # Transform each macro name into the feature name used in the tests. + # Ex. _LIBCPP_HAS_NO_THREADS -> libcpp-has-no-threads + for m in feature_macros: + if m == '_LIBCPP_ABI_VERSION': + self.config.available_features.add('libcpp-abi-version-v%s' + % feature_macros[m]) + continue + assert m.startswith('_LIBCPP_HAS_') or m == '_LIBCPP_ABI_UNSTABLE' + m = m.lower()[1:].replace('_', '-') + self.config.available_features.add(m) + return feature_macros + + + def configure_compile_flags_exceptions(self): enable_exceptions = self.get_lit_bool('enable_exceptions', True) if not enable_exceptions: @@ -410,43 +392,16 @@ def configure_compile_flags_rtti(self): self.config.available_features.add('libcpp-no-rtti') self.cxx.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI'] - def configure_compile_flags_no_global_filesystem_namespace(self): - enable_global_filesystem_namespace = self.get_lit_bool( - 'enable_global_filesystem_namespace', True) - if not enable_global_filesystem_namespace: - self.config.available_features.add( - 'libcpp-has-no-global-filesystem-namespace') - self.cxx.compile_flags += [ - '-D_LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE'] - - def configure_compile_flags_no_stdin(self): - enable_stdin = self.get_lit_bool('enable_stdin', True) - if not enable_stdin: - self.config.available_features.add('libcpp-has-no-stdin') - self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_STDIN'] - - def configure_compile_flags_no_stdout(self): - enable_stdout = self.get_lit_bool('enable_stdout', True) - if not enable_stdout: - self.config.available_features.add('libcpp-has-no-stdout') - self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_STDOUT'] - - def configure_compile_flags_no_threads(self): - self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_THREADS'] - self.config.available_features.add('libcpp-has-no-threads') - - def configure_compile_flags_no_thread_unsafe_c_functions(self): - enable_thread_unsafe_c_functions = self.get_lit_bool( - 'enable_thread_unsafe_c_functions', True) - if not enable_thread_unsafe_c_functions: - self.cxx.compile_flags += [ - '-D_LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS'] - self.config.available_features.add( - 'libcpp-has-no-thread-unsafe-c-functions') - - def configure_compile_flags_no_monotonic_clock(self): - self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_MONOTONIC_CLOCK'] - self.config.available_features.add('libcpp-has-no-monotonic-clock') + def configure_compile_flags_abi_version(self): + abi_version = self.get_lit_conf('abi_version', '').strip() + abi_unstable = self.get_lit_bool('abi_unstable') + # Only add the ABI version when it is non-default. + # FIXME(EricWF): Get the ABI version from the "__config_site". + if abi_version and abi_version != '1': + self.cxx.compile_flags += ['-D_LIBCPP_ABI_VERSION=' + abi_version] + if abi_unstable: + self.config.available_features.add('libcpp-abi-unstable') + self.cxx.compile_flags += ['-D_LIBCPP_ABI_UNSTABLE'] def configure_link_flags(self): no_default_flags = self.get_lit_bool('no_default_flags', False) @@ -505,9 +460,7 @@ def configure_link_flags_abi_library(self): elif cxx_abi == 'libsupc++': self.cxx.link_flags += ['-lsupc++'] elif cxx_abi == 'libcxxabi': - # Don't link libc++abi explicitly on OS X because the symbols - # should be available in libc++ directly. - if self.target_info.platform() != 'darwin': + if self.target_info.allow_cxxabi_link(): self.cxx.link_flags += ['-lc++abi'] elif cxx_abi == 'libcxxrt': self.cxx.link_flags += ['-lcxxrt'] @@ -518,26 +471,7 @@ def configure_link_flags_abi_library(self): 'C++ ABI setting %s unsupported for tests' % cxx_abi) def configure_extra_library_flags(self): - enable_threads = self.get_lit_bool('enable_threads', True) - llvm_unwinder = self.get_lit_bool('llvm_unwinder', False) - target_platform = self.target_info.platform() - if target_platform == 'darwin': - self.cxx.link_flags += ['-lSystem'] - elif target_platform == 'linux': - if not llvm_unwinder: - self.cxx.link_flags += ['-lgcc_eh'] - self.cxx.link_flags += ['-lc', '-lm'] - if enable_threads: - self.cxx.link_flags += ['-lpthread'] - self.cxx.link_flags += ['-lrt'] - if llvm_unwinder: - self.cxx.link_flags += ['-lunwind', '-ldl'] - else: - self.cxx.link_flags += ['-lgcc_s'] - elif target_platform.startswith('freebsd'): - self.cxx.link_flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt'] - else: - self.lit_config.fatal("unrecognized system: %r" % target_platform) + self.target_info.add_cxx_link_flags(self.cxx.link_flags) def configure_color_diagnostics(self): use_color = self.get_lit_conf('color_diagnostics') @@ -570,14 +504,28 @@ def configure_debug_mode(self): def configure_warnings(self): enable_warnings = self.get_lit_bool('enable_warnings', False) if enable_warnings: - self.cxx.compile_flags += ['-Wsystem-headers', '-Wall', '-Werror'] - if ('clang' in self.config.available_features or - 'apple-clang' in self.config.available_features): - self.cxx.compile_flags += ['-Wno-user-defined-literals'] + self.cxx.compile_flags += [ + '-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', + '-Wall', '-Werror' + ] + self.cxx.addWarningFlagIfSupported('-Wno-attributes') + self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move') + self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions') + self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals') + # TODO(EricWF) Remove the unused warnings once the test suite + # compiles clean with them. + self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef') + self.cxx.addWarningFlagIfSupported('-Wno-unused-variable') + std = self.get_lit_conf('std', None) + if std in ['c++98', 'c++03']: + # The '#define static_assert' provided by libc++ in C++03 mode + # causes an unused local typedef whenever it is used. + self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef') def configure_sanitizer(self): san = self.get_lit_conf('use_sanitizer', '').strip() if san: + self.target_info.add_sanitizer_features(san, self.config.available_features) # Search for llvm-symbolizer along the compiler path first # and then along the PATH env variable. symbolizer_search_paths = os.environ.get('PATH', '') @@ -590,8 +538,6 @@ def configure_sanitizer(self): symbolizer_search_paths) # Setup the sanitizer compile flags self.cxx.flags += ['-g', '-fno-omit-frame-pointer'] - if self.target_info.platform() == 'linux': - self.cxx.link_flags += ['-ldl'] if san == 'Address': self.cxx.flags += ['-fsanitize=address'] if llvm_symbolizer is not None: @@ -620,6 +566,10 @@ def configure_sanitizer(self): else: self.lit_config.fatal('unsupported value for ' 'use_sanitizer: {0}'.format(san)) + san_lib = self.get_lit_conf('sanitizer_library') + if san_lib: + self.cxx.link_flags += [ + san_lib, '-Wl,-rpath,%s' % os.path.dirname(san_lib)] def configure_coverage(self): self.generate_coverage = self.get_lit_bool('generate_coverage', False) @@ -692,18 +642,4 @@ def configure_triple(self): "inferred target_triple as: %r" % self.config.target_triple) def configure_env(self): - if self.target_info.platform() == 'darwin': - library_paths = [] - # Configure the library path for libc++ - libcxx_library = self.get_lit_conf('libcxx_library') - if self.use_system_cxx_lib: - pass - elif libcxx_library: - library_paths += [os.path.dirname(libcxx_library)] - elif self.cxx_library_root: - library_paths += [self.cxx_library_root] - # Configure the abi library path - if self.abi_library_root: - library_paths += [self.abi_library_root] - if library_paths: - self.env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths) + self.target_info.configure_env(self.env) diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py index 238dcdb29af7..19c9fc742a49 100644 --- a/test/libcxx/test/format.py +++ b/test/libcxx/test/format.py @@ -64,20 +64,24 @@ def _execute(self, test, lit_config): return (lit.Test.UNSUPPORTED, "A lit.local.cfg marked this unsupported") - res = lit.TestRunner.parseIntegratedTestScript( + script = lit.TestRunner.parseIntegratedTestScript( test, require_script=is_sh_test) # Check if a result for the test was returned. If so return that # result. - if isinstance(res, lit.Test.Result): - return res + if isinstance(script, lit.Test.Result): + return script if lit_config.noExecute: return lit.Test.Result(lit.Test.PASS) - # res is not an instance of lit.test.Result. Expand res into its parts. - script, tmpBase, execDir = res + # Check that we don't have run lines on tests that don't support them. if not is_sh_test and len(script) != 0: lit_config.fatal('Unsupported RUN line found in test %s' % name) + tmpDir, tmpBase = lit.TestRunner.getTempPaths(test) + substitutions = lit.TestRunner.getDefaultSubstitutions(test, tmpDir, + tmpBase) + script = lit.TestRunner.applySubstitutions(script, substitutions) + # Dispatch the test based on its suffix. if is_sh_test: if not isinstance(self.executor, LocalExecutor): @@ -86,11 +90,11 @@ def _execute(self, test, lit_config): return lit.Test.UNSUPPORTED, 'ShTest format not yet supported' return lit.TestRunner._runShTest(test, lit_config, self.execute_external, script, - tmpBase, execDir) + tmpBase) elif is_fail_test: return self._evaluate_fail_test(test) elif is_pass_test: - return self._evaluate_pass_test(test, tmpBase, execDir, lit_config) + return self._evaluate_pass_test(test, tmpBase, lit_config) else: # No other test type is supported assert False @@ -98,7 +102,8 @@ def _execute(self, test, lit_config): def _clean(self, exec_path): # pylint: disable=no-self-use libcxx.util.cleanFile(exec_path) - def _evaluate_pass_test(self, test, tmpBase, execDir, lit_config): + def _evaluate_pass_test(self, test, tmpBase, lit_config): + execDir = os.path.dirname(test.getExecPath()) source_path = test.getSourcePath() exec_path = tmpBase + '.exe' object_path = tmpBase + '.o' diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py index a61737786896..667644d2fec6 100644 --- a/test/libcxx/test/target_info.py +++ b/test/libcxx/test/target_info.py @@ -1,55 +1,202 @@ +import importlib +import lit.util # pylint: disable=import-error,no-name-in-module import locale +import os import platform import sys -class TargetInfo(object): +class DefaultTargetInfo(object): + def __init__(self, full_config): + self.full_config = full_config + def platform(self): - raise NotImplementedError + return sys.platform.lower().strip() - def system(self): - raise NotImplementedError + def add_locale_features(self, features): + self.full_config.lit_config.warning( + "No locales entry for target_system: %s" % self.platform()) - def platform_ver(self): - raise NotImplementedError - - def platform_name(self): - raise NotImplementedError - - def supports_locale(self, loc): - raise NotImplementedError + def add_cxx_compile_flags(self, flags): pass + def add_cxx_link_flags(self, flags): pass + def configure_env(self, env): pass + def allow_cxxabi_link(self): return True + def add_sanitizer_features(self, sanitizer_type, features): pass + def use_lit_shell_default(self): return False -class LocalTI(TargetInfo): - def platform(self): - platform_name = sys.platform.lower().strip() - # Strip the '2' from linux2. - if platform_name.startswith('linux'): - platform_name = 'linux' - return platform_name +def test_locale(loc): + assert loc is not None + default_locale = locale.setlocale(locale.LC_ALL) + try: + locale.setlocale(locale.LC_ALL, loc) + return True + except locale.Error: + return False + finally: + locale.setlocale(locale.LC_ALL, default_locale) - def system(self): - return platform.system() - def platform_name(self): - if self.platform() == 'linux': - name, _, _ = platform.linux_distribution() - name = name.lower().strip() - if name: - return name - return None +def add_common_locales(features, lit_config): + # A list of locales needed by the test-suite. + # The list uses the canonical name for the locale used in the test-suite + # TODO: On Linux ISO8859 *may* needs to hyphenated. + locales = [ + 'en_US.UTF-8', + 'fr_FR.UTF-8', + 'ru_RU.UTF-8', + 'zh_CN.UTF-8', + 'fr_CA.ISO8859-1', + 'cs_CZ.ISO8859-2' + ] + for loc in locales: + if test_locale(loc): + features.add('locale.{0}'.format(loc)) + else: + lit_config.warning('The locale {0} is not supported by ' + 'your platform. Some tests will be ' + 'unsupported.'.format(loc)) - def platform_ver(self): - if self.platform() == 'linux': - _, ver, _ = platform.linux_distribution() - ver = ver.lower().strip() - if ver: - return ver - return None - def supports_locale(self, loc): +class DarwinLocalTI(DefaultTargetInfo): + def __init__(self, full_config): + super(DarwinLocalTI, self).__init__(full_config) + + def add_locale_features(self, features): + add_common_locales(feature, self.full_config.lit_config) + + def add_cxx_compile_flags(self, flags): try: - locale.setlocale(locale.LC_ALL, loc) - return True - except locale.Error: - return False + out = lit.util.capture(['xcrun', '--show-sdk-path']).strip() + res = 0 + except OSError: + res = -1 + if res == 0 and out: + sdk_path = out + self.full_config.lit_config.note('using SDKROOT: %r' % sdk_path) + flags += ["-isysroot", sdk_path] + + def add_cxx_link_flags(self, flags): + flags += ['-lSystem'] + + def configure_env(self, env): + library_paths = [] + # Configure the library path for libc++ + libcxx_library = self.full_config.get_lit_conf('libcxx_library') + if self.full_config.use_system_cxx_lib: + pass + elif libcxx_library: + library_paths += [os.path.dirname(libcxx_library)] + elif self.full_config.cxx_library_root: + library_paths += [self.full_config.cxx_library_root] + # Configure the abi library path + if self.full_config.abi_library_root: + library_paths += [self.full_config.abi_library_root] + if library_paths: + env['DYLD_LIBRARY_PATH'] = ':'.join(library_paths) + + def allow_cxxabi_link(self): + # Don't link libc++abi explicitly on OS X because the symbols + # should be available in libc++ directly. + return False + + def add_sanitizer_features(self, sanitizer_type, features): + if san == 'Undefined': + features.add('sanitizer-new-delete') + + +class FreeBSDLocalTI(DefaultTargetInfo): + def __init__(self, full_config): + super(FreeBSDLocalTI, self).__init__(full_config) + + def add_locale_features(self, features): + add_common_locales(features, self.full_config.lit_config) + + def add_cxx_link_flags(self, flags): + flags += ['-lc', '-lm', '-lpthread', '-lgcc_s', '-lcxxrt'] + + +class LinuxLocalTI(DefaultTargetInfo): + def __init__(self, full_config): + super(LinuxLocalTI, self).__init__(full_config) + + def platform(self): + return 'linux' + + def platform_name(self): + name, _, _ = platform.linux_distribution() + name = name.lower().strip() + return name # Permitted to be None + + def platform_ver(self): + _, ver, _ = platform.linux_distribution() + ver = ver.lower().strip() + return ver # Permitted to be None. + + def add_locale_features(self, features): + add_common_locales(features, self.full_config.lit_config) + # Some linux distributions have different locale data than others. + # Insert the distributions name and name-version into the available + # features to allow tests to XFAIL on them. + name = self.platform_name() + ver = self.platform_ver() + if name: + features.add(name) + if name and ver: + features.add('%s-%s' % (name, ver)) + + def add_cxx_compile_flags(self, flags): + flags += ['-D__STDC_FORMAT_MACROS', + '-D__STDC_LIMIT_MACROS', + '-D__STDC_CONSTANT_MACROS'] + + def add_cxx_link_flags(self, flags): + enable_threads = ('libcpp-has-no-threads' not in + self.full_config.config.available_features) + llvm_unwinder = self.full_config.get_lit_bool('llvm_unwinder', False) + flags += ['-lm'] + if not llvm_unwinder: + flags += ['-lgcc_s', '-lgcc'] + if enable_threads: + flags += ['-lpthread'] + flags += ['-lc'] + if llvm_unwinder: + flags += ['-lunwind', '-ldl'] + else: + flags += ['-lgcc_s', '-lgcc'] + san = self.full_config.get_lit_conf('use_sanitizer', '').strip() + if san: + # The libraries and their order are taken from the + # linkSanitizerRuntimeDeps function in + # clang/lib/Driver/Tools.cpp + flags += ['-lpthread', '-lrt', '-lm', '-ldl'] + + +class WindowsLocalTI(DefaultTargetInfo): + def __init__(self, full_config): + super(WindowsLocalTI, self).__init__(full_config) + + def add_locale_features(self, features): + add_common_locales(features, self.full_config.lit_config) + + def use_lit_shell_default(self): + # Default to the internal shell on Windows, as bash on Windows is + # usually very slow. + return True + + +def make_target_info(full_config): + default = "libcxx.test.target_info.LocalTI" + info_str = full_config.get_lit_conf('target_info', default) + if info_str != default: + mod_path, _, info = info_str.rpartition('.') + mod = importlib.import_module(mod_path) + target_info = getattr(mod, info)(full_config) + full_config.lit_config.note("inferred target_info as: %r" % info_str) + return target_info + target_system = platform.system() + if target_system == 'Darwin': return DarwinLocalTI(full_config) + if target_system == 'FreeBSD': return FreeBSDLocalTI(full_config) + if target_system == 'Linux': return LinuxLocalTI(full_config) + if target_system == 'Windows': return WindowsLocalTI(full_config) + return DefaultTargetInfo(full_config) diff --git a/test/libcxx/test/tracing.py b/test/libcxx/test/tracing.py index efef158160c5..766fc192f9f5 100644 --- a/test/libcxx/test/tracing.py +++ b/test/libcxx/test/tracing.py @@ -11,14 +11,14 @@ def wrapper(*args, **kwargs): # Perform the call itself, logging before, after, and anything thrown. try: if log_calls: - print '{}: Calling {}'.format(label, call_str) + print('{}: Calling {}'.format(label, call_str)) res = function(*args, **kwargs) if log_results: - print '{}: {} -> {}'.format(label, call_str, res) + print('{}: {} -> {}'.format(label, call_str, res)) return res except Exception as ex: if log_results: - print '{}: {} raised {}'.format(label, call_str, type(ex)) + print('{}: {} raised {}'.format(label, call_str, type(ex))) raise ex return wrapper diff --git a/test/std/thread/futures/version.pass.cpp b/test/libcxx/thread/futures/version.pass.cpp similarity index 100% rename from test/std/thread/futures/version.pass.cpp rename to test/libcxx/thread/futures/version.pass.cpp diff --git a/test/libcxx/type_traits/convert_to_integral.pass.cpp b/test/libcxx/type_traits/convert_to_integral.pass.cpp index b97832b5e6d7..3fdc98f5468f 100644 --- a/test/libcxx/type_traits/convert_to_integral.pass.cpp +++ b/test/libcxx/type_traits/convert_to_integral.pass.cpp @@ -1,7 +1,22 @@ - +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // TODO: Make this test pass for all standards. // XFAIL: c++98, c++03 +// + +// __convert_to_integral(Tp) + +// Test that the __convert_to_integral functions properly converts Tp to the +// correct type and value for integral, enum and user defined types. + #include #include #include diff --git a/test/libcxx/type_traits/lazy_metafunctions.pass.cpp b/test/libcxx/type_traits/lazy_metafunctions.pass.cpp new file mode 100644 index 000000000000..8f75080ab956 --- /dev/null +++ b/test/libcxx/type_traits/lazy_metafunctions.pass.cpp @@ -0,0 +1,137 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03 + +// + +// __lazy_enable_if, __lazy_not, __lazy_and and __lazy_or + +// Test the libc++ lazy meta-programming helpers in + +#include + +template +struct Identity { + typedef Type type; +}; + +typedef std::true_type TrueT; +typedef std::false_type FalseT; + +typedef Identity LazyTrueT; +typedef Identity LazyFalseT; + +// A type that cannot be instantiated +template +struct CannotInst { + typedef T type; + static_assert(std::is_same::value == false, ""); +}; + + +template +struct NextInt { + typedef NextInt type; + static const int value = Value; +}; + +template +const int NextInt::value; + + +template +struct HasTypeImp { + template + static TrueT test(int); + template + static FalseT test(...); + + typedef decltype(test(0)) type; +}; + +// A metafunction that returns True if Type has a nested 'type' typedef +// and false otherwise. +template +struct HasType : HasTypeImp::type {}; + +void LazyEnableIfTest() { + { + typedef std::__lazy_enable_if > Result; + static_assert(HasType::value, ""); + static_assert(Result::type::value == 1, ""); + } + { + typedef std::__lazy_enable_if > Result; + static_assert(!HasType::value, ""); + } +} + +void LazyNotTest() { + { + typedef std::__lazy_not NotT; + static_assert(std::is_same::value, ""); + static_assert(NotT::value == false, ""); + } + { + typedef std::__lazy_not NotT; + static_assert(std::is_same::value, ""); + static_assert(NotT::value == true, ""); + } + { + // Check that CannotInst is not instantiated. + typedef std::__lazy_not > NotT; + + static_assert(std::is_same::value, ""); + + } +} + +void LazyAndTest() { + { // Test that it acts as the identity function for a single value + static_assert(std::__lazy_and::value == false, ""); + static_assert(std::__lazy_and::value == true, ""); + } + { + static_assert(std::__lazy_and::value == true, ""); + static_assert(std::__lazy_and::value == false, ""); + static_assert(std::__lazy_and::value == false, ""); + static_assert(std::__lazy_and::value == false, ""); + } + { // Test short circuiting - CannotInst should never be instantiated. + static_assert(std::__lazy_and>::value == false, ""); + static_assert(std::__lazy_and>::value == false, ""); + } +} + + +void LazyOrTest() { + { // Test that it acts as the identity function for a single value + static_assert(std::__lazy_or::value == false, ""); + static_assert(std::__lazy_or::value == true, ""); + } + { + static_assert(std::__lazy_or::value == true, ""); + static_assert(std::__lazy_or::value == true, ""); + static_assert(std::__lazy_or::value == true, ""); + static_assert(std::__lazy_or::value == false, ""); + } + { // Test short circuiting - CannotInst should never be instantiated. + static_assert(std::__lazy_or>::value == true, ""); + static_assert(std::__lazy_or>::value == true, ""); + } +} + + +int main() { + LazyEnableIfTest(); + LazyNotTest(); + LazyAndTest(); + LazyOrTest(); +} \ No newline at end of file diff --git a/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp b/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp index 25dd31190685..fce8443ebd0c 100644 --- a/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp +++ b/test/libcxx/utilities/memory/util.smartptr/race_condition.pass.cpp @@ -87,7 +87,8 @@ int main() { } { // Test with in-place shared_count. - Ptr p = std::make_shared(42); + int val = 42; + Ptr p = std::make_shared(val); run_test(p); assert(p.use_count() == 1); } diff --git a/test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp b/test/libcxx/utilities/time/date.time/asctime.thread-unsafe.fail.cpp similarity index 100% rename from test/std/utilities/date.time/asctime.thread-unsafe.fail.cpp rename to test/libcxx/utilities/time/date.time/asctime.thread-unsafe.fail.cpp diff --git a/test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp b/test/libcxx/utilities/time/date.time/ctime.thread-unsafe.fail.cpp similarity index 100% rename from test/std/utilities/date.time/ctime.thread-unsafe.fail.cpp rename to test/libcxx/utilities/time/date.time/ctime.thread-unsafe.fail.cpp diff --git a/test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp b/test/libcxx/utilities/time/date.time/gmtime.thread-unsafe.fail.cpp similarity index 100% rename from test/std/utilities/date.time/gmtime.thread-unsafe.fail.cpp rename to test/libcxx/utilities/time/date.time/gmtime.thread-unsafe.fail.cpp diff --git a/test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp b/test/libcxx/utilities/time/date.time/localtime.thread-unsafe.fail.cpp similarity index 100% rename from test/std/utilities/date.time/localtime.thread-unsafe.fail.cpp rename to test/libcxx/utilities/time/date.time/localtime.thread-unsafe.fail.cpp diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 17f0686add6e..fa25834d1110 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -1,6 +1,6 @@ @AUTO_GEN_COMMENT@ config.cxx_under_test = "@LIBCXX_COMPILER@" -config.std = "@LIBCXX_STD_VERSION@" +config.project_obj_root = "@CMAKE_BINARY_DIR@" config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@" config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@" config.cxx_library_root = "@LIBCXX_LIBRARY_DIR@" @@ -8,14 +8,9 @@ config.enable_exceptions = "@LIBCXX_ENABLE_EXCEPTIONS@" config.enable_rtti = "@LIBCXX_ENABLE_RTTI@" config.enable_shared = "@LIBCXX_ENABLE_SHARED@" config.enable_32bit = "@LIBCXX_BUILD_32_BITS@" -config.enable_global_filesystem_namespace = "@LIBCXX_ENABLE_GLOBAL_FILESYSTEM_NAMESPACE@" -config.enable_stdin = "@LIBCXX_ENABLE_STDIN@" -config.enable_stdout = "@LIBCXX_ENABLE_STDOUT@" -config.enable_threads = "@LIBCXX_ENABLE_THREADS@" -config.enable_thread_unsafe_c_functions = "@LIBCXX_ENABLE_THREAD_UNSAFE_C_FUNCTIONS@" -config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@" config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@" config.use_sanitizer = "@LLVM_USE_SANITIZER@" +config.sanitizer_library = "@LIBCXX_SANITIZER_LIBRARY@" config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@" config.configuration_variant = "@LIBCXX_LIT_VARIANT@" config.target_triple = "@LIBCXX_TARGET_TRIPLE@" diff --git a/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp b/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp index 7810dec2fe1b..cf23c7743996 100644 --- a/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp +++ b/test/std/algorithms/alg.modifying.operations/alg.partitions/stable_partition.pass.cpp @@ -17,10 +17,9 @@ #include #include -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES #include -#endif +#include "test_macros.h" #include "test_iterators.h" struct is_odd @@ -283,7 +282,7 @@ test() } } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 struct is_null { @@ -298,9 +297,10 @@ test1() const unsigned size = 5; std::unique_ptr array[size]; Iter r = std::stable_partition(Iter(array), Iter(array+size), is_null()); + assert(r == Iter(array+size)); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif // TEST_STD_VER >= 11 int main() { @@ -308,7 +308,7 @@ int main() test*> >(); test*>(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 test1*> >(); #endif } diff --git a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp index abc89dc56097..eb37ccac5779 100644 --- a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch.pass.cpp @@ -17,18 +17,16 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" -#if _LIBCPP_STD_VER > 11 -#define HAS_FOUR_ITERATOR_VERSION -#endif int main() { int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[] = {0, 1, 2, 3, 0, 1, 2, 3}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); + const unsigned sb = sizeof(ib)/sizeof(ib[0]); ((void)sb); // unused in c++11 typedef input_iterator II; typedef random_access_iterator RAI; @@ -39,7 +37,7 @@ int main() assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib)) == (std::pair(RAI(ia+3), RAI(ib+3)))); -#ifdef HAS_FOUR_ITERATOR_VERSION +#if TEST_STD_VER > 11 // We have the four iteration version assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+sb)) == (std::pair(II(ia+3), II(ib+3)))); diff --git a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp index 8d85d993cd61..3e1dfd17c3ff 100644 --- a/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp +++ b/test/std/algorithms/alg.nonmodifying/mismatch/mismatch_pred.pass.cpp @@ -19,10 +19,11 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" #include "counting_predicates.hpp" -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 #define HAS_FOUR_ITERATOR_VERSION #endif @@ -31,7 +32,7 @@ int main() int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; const unsigned sa = sizeof(ia)/sizeof(ia[0]); int ib[] = {0, 1, 2, 3, 0, 1, 2, 3}; - const unsigned sb = sizeof(ib)/sizeof(ib[0]); + const unsigned sb = sizeof(ib)/sizeof(ib[0]); ((void)sb); // unused in c++11 typedef input_iterator II; typedef random_access_iterator RAI; diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp index 8db8177fb9c8..70abd1809753 100644 --- a/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes.pass.cpp @@ -29,9 +29,9 @@ test() int ib[] = {2, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); int ic[] = {1, 2}; - const unsigned sc = sizeof(ic)/sizeof(ic[0]); + const unsigned sc = sizeof(ic)/sizeof(ic[0]); ((void)sc); int id[] = {3, 3, 3, 3}; - const unsigned sd = sizeof(id)/sizeof(id[0]); + const unsigned sd = sizeof(id)/sizeof(id[0]); ((void)sd); assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib))); assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1))); diff --git a/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp index 7e1aef4749a5..299dc893560f 100644 --- a/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp +++ b/test/std/algorithms/alg.sorting/alg.set.operations/includes/includes_comp.pass.cpp @@ -30,9 +30,9 @@ test() int ib[] = {2, 4}; const unsigned sb = sizeof(ib)/sizeof(ib[0]); int ic[] = {1, 2}; - const unsigned sc = sizeof(ic)/sizeof(ic[0]); + const unsigned sc = sizeof(ic)/sizeof(ic[0]); ((void)sc); int id[] = {3, 3, 3, 3}; - const unsigned sd = sizeof(id)/sizeof(id[0]); + const unsigned sd = sizeof(id)/sizeof(id[0]); ((void)sd); assert(std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib), std::less())); assert(!std::includes(Iter1(ia), Iter1(ia), Iter2(ib), Iter2(ib+1), std::less())); diff --git a/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp index 8a60f8196dab..3a74e13faf19 100644 --- a/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp +++ b/test/std/atomics/atomics.flag/atomic_flag_clear.pass.cpp @@ -22,13 +22,13 @@ int main() { { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear(&f); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear(&f); assert(f.test_and_set() == 0); diff --git a/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp b/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp index 92e57ecc03f8..0467384455cc 100644 --- a/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp +++ b/test/std/atomics/atomics.flag/atomic_flag_clear_explicit.pass.cpp @@ -22,37 +22,37 @@ int main() { { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_relaxed); assert(f.test_and_set() == 0); } { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_release); assert(f.test_and_set() == 0); } { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_seq_cst); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_relaxed); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_release); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); atomic_flag_clear_explicit(&f, std::memory_order_seq_cst); assert(f.test_and_set() == 0); diff --git a/test/std/atomics/atomics.flag/clear.pass.cpp b/test/std/atomics/atomics.flag/clear.pass.cpp index 7c9362680bba..ea5ae45ae99a 100644 --- a/test/std/atomics/atomics.flag/clear.pass.cpp +++ b/test/std/atomics/atomics.flag/clear.pass.cpp @@ -22,49 +22,49 @@ int main() { { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); f.clear(); assert(f.test_and_set() == 0); } { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); f.clear(std::memory_order_relaxed); assert(f.test_and_set() == 0); } { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); f.clear(std::memory_order_release); assert(f.test_and_set() == 0); } { - std::atomic_flag f = ATOMIC_FLAG_INIT; + std::atomic_flag f(false); f.test_and_set(); f.clear(std::memory_order_seq_cst); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); f.clear(); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); f.clear(std::memory_order_relaxed); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); f.clear(std::memory_order_release); assert(f.test_and_set() == 0); } { - volatile std::atomic_flag f = ATOMIC_FLAG_INIT; + volatile std::atomic_flag f(false); f.test_and_set(); f.clear(std::memory_order_seq_cst); assert(f.test_and_set() == 0); diff --git a/test/std/atomics/atomics.flag/default.pass.cpp b/test/std/atomics/atomics.flag/default.pass.cpp index 45f5e709245b..11c08f50266a 100644 --- a/test/std/atomics/atomics.flag/default.pass.cpp +++ b/test/std/atomics/atomics.flag/default.pass.cpp @@ -22,7 +22,8 @@ int main() { std::atomic_flag f; - + f.clear(); + assert(f.test_and_set() == 0); { typedef std::atomic_flag A; _ALIGNAS_TYPE(A) char storage[sizeof(A)] = {1}; diff --git a/test/std/atomics/atomics.flag/init.pass.cpp b/test/std/atomics/atomics.flag/init.pass.cpp index c90509d8fbb5..c4a121b094a4 100644 --- a/test/std/atomics/atomics.flag/init.pass.cpp +++ b/test/std/atomics/atomics.flag/init.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// XFAIL: c++98, c++03 // diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp b/test/std/atomics/atomics.flag/init03.pass.cpp similarity index 66% rename from test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp rename to test/std/atomics/atomics.flag/init03.pass.cpp index 7099c45fab81..0910bc5ceccb 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/no-variadics.pass.cpp +++ b/test/std/atomics/atomics.flag/init03.pass.cpp @@ -6,19 +6,20 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads -// +// -// class function +// struct atomic_flag -// template function(F); +// TESTING EXTENSION atomic_flag(bool) -#define _LIBCPP_HAS_NO_VARIADICS -#include +#include #include int main() { - std::function f(static_cast(0)); - assert(!f); + std::atomic_flag f(false); + assert(f.test_and_set() == 0); } diff --git a/test/std/atomics/atomics.types.generic/address.pass.cpp b/test/std/atomics/atomics.types.generic/address.pass.cpp index 3b9f3ce76cad..eceac25c9d94 100644 --- a/test/std/atomics/atomics.types.generic/address.pass.cpp +++ b/test/std/atomics/atomics.types.generic/address.pass.cpp @@ -81,12 +81,13 @@ do_test() { typedef typename std::remove_pointer::type X; A obj(T(0)); + bool b0 = obj.is_lock_free(); + ((void)b0); // mark as unused assert(obj == T(0)); std::atomic_init(&obj, T(1)); assert(obj == T(1)); std::atomic_init(&obj, T(2)); assert(obj == T(2)); - bool b0 = obj.is_lock_free(); obj.store(T(0)); assert(obj == T(0)); obj.store(T(1), std::memory_order_release); diff --git a/test/std/atomics/atomics.types.generic/bool.pass.cpp b/test/std/atomics/atomics.types.generic/bool.pass.cpp index dd851e86530c..8eb04ee577cf 100644 --- a/test/std/atomics/atomics.types.generic/bool.pass.cpp +++ b/test/std/atomics/atomics.types.generic/bool.pass.cpp @@ -60,7 +60,6 @@ int main() { { - volatile std::atomic _; volatile std::atomic obj(true); assert(obj == true); std::atomic_init(&obj, false); @@ -116,7 +115,6 @@ int main() assert(obj == true); } { - std::atomic _; std::atomic obj(true); assert(obj == true); std::atomic_init(&obj, false); @@ -172,7 +170,6 @@ int main() assert(obj == true); } { - std::atomic_bool _; std::atomic_bool obj(true); assert(obj == true); std::atomic_init(&obj, false); diff --git a/test/std/atomics/atomics.types.generic/integral.pass.cpp b/test/std/atomics/atomics.types.generic/integral.pass.cpp index f9c758336099..802a37c30a93 100644 --- a/test/std/atomics/atomics.types.generic/integral.pass.cpp +++ b/test/std/atomics/atomics.types.generic/integral.pass.cpp @@ -103,6 +103,7 @@ do_test() std::atomic_init(&obj, T(2)); assert(obj == T(2)); bool b0 = obj.is_lock_free(); + ((void)b0); // mark as unused obj.store(T(0)); assert(obj == T(0)); obj.store(T(1), std::memory_order_release); diff --git a/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp b/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp index f2bf4db0de48..d940980e32f0 100644 --- a/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp +++ b/test/std/atomics/atomics.types.generic/trivially_copyable.fail.cpp @@ -57,12 +57,12 @@ struct NotTriviallyCopyable { NotTriviallyCopyable ( int i ) : i_(i) {} NotTriviallyCopyable ( const NotTriviallyCopyable &rhs) : i_(rhs.i_) {} int i_; - }; +}; -template +template void test ( T t ) { std::atomic t0(t); - } +} int main() { diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp index f1cc993ed33e..7b221dc6eff8 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong.pass.cpp @@ -24,10 +24,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A a; @@ -52,37 +53,10 @@ test() assert(a == T(2)); assert(t == T(2)); } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp index f667ab7f139b..27de5bec4928 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_strong_explicit.pass.cpp @@ -27,10 +27,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A a; @@ -59,37 +60,10 @@ test() assert(a == T(2)); assert(t == T(2)); } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp index 175c445d4560..8c12715647e8 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak.pass.cpp @@ -25,11 +25,11 @@ #include #include +#include "atomic_helpers.h" template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A a; @@ -54,37 +54,10 @@ test() assert(a == T(2)); assert(t == T(2)); } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp index 46f80bfbcb7b..90a93f02b978 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_compare_exchange_weak_explicit.pass.cpp @@ -29,10 +29,11 @@ #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A a; @@ -61,37 +62,10 @@ test() assert(a == T(2)); assert(t == T(2)); } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp index 525e74aa6374..035d974427a4 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange.pass.cpp @@ -24,10 +24,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_init(&t, T(1)); @@ -37,37 +38,11 @@ test() std::atomic_init(&vt, T(3)); assert(std::atomic_exchange(&vt, T(4)) == T(3)); assert(vt == T(4)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp index 9fe4ac816448..4d66bb5f3b81 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_exchange_explicit.pass.cpp @@ -24,10 +24,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_init(&t, T(1)); @@ -39,37 +40,11 @@ test() assert(std::atomic_exchange_explicit(&vt, T(4), std::memory_order_seq_cst) == T(3)); assert(vt == T(4)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp index 3408def9058a..48ff601539cf 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.pass.cpp @@ -32,10 +32,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -50,62 +51,33 @@ test() assert(std::atomic_fetch_add(&t, T(2)) == T(1)); assert(t == T(3)); } -} - -template -void -testp() -{ - { - typedef std::atomic A; - typedef typename std::remove_pointer::type X; - A t; - std::atomic_init(&t, T(1*sizeof(X))); - assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X))); - assert(t == T(3*sizeof(X))); - } - { - typedef std::atomic A; - typedef typename std::remove_pointer::type X; - volatile A t; - std::atomic_init(&t, T(1*sizeof(X))); - assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X))); - assert(t == T(3*sizeof(X))); - } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - A(const A& a) : i(a.i) {} - A(const volatile A& a) : i(a.i) {} - - void operator=(const volatile A& a) volatile {i = a.i;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; +template +void testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::type X; + A t; + std::atomic_init(&t, T(1*sizeof(X))); + assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X))); + assert(t == T(3*sizeof(X))); + } + { + typedef std::atomic A; + typedef typename std::remove_pointer::type X; + volatile A t; + std::atomic_init(&t, T(1*sizeof(X))); + assert(std::atomic_fetch_add(&t, 2) == T(1*sizeof(X))); + assert(t == T(3*sizeof(X))); + } +} + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); testp(); testp(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp index 9977bd491e7a..2dc90c9aca68 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.pass.cpp @@ -32,10 +32,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -52,7 +53,8 @@ test() std::memory_order_seq_cst) == T(1)); assert(t == T(3)); } -} + } +}; template void @@ -78,38 +80,9 @@ testp() } } -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - A(const A& a) : i(a.i) {} - A(const volatile A& a) : i(a.i) {} - - void operator=(const volatile A& a) volatile {i = a.i;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} -}; - int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); testp(); testp(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp index 4c7c0432efc9..57355d30411e 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and.pass.cpp @@ -23,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -41,24 +42,10 @@ test() assert(std::atomic_fetch_and(&t, T(2)) == T(3)); assert(t == T(2)); } -} + } +}; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp index d83bbf264de5..26ff5f65e7db 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_and_explicit.pass.cpp @@ -23,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -43,24 +44,10 @@ test() std::memory_order_seq_cst) == T(3)); assert(t == T(2)); } -} + } +}; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp index acf6d439de43..ca44fdc3217d 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or.pass.cpp @@ -23,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -41,24 +42,10 @@ test() assert(std::atomic_fetch_or(&t, T(2)) == T(3)); assert(t == T(3)); } -} + } +}; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp index 72685e4d9408..72bbde798cb9 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_or_explicit.pass.cpp @@ -23,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -43,24 +44,10 @@ test() std::memory_order_seq_cst) == T(3)); assert(t == T(3)); } -} + } +}; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp index ed8b541291af..2743040428c5 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.pass.cpp @@ -32,10 +32,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -50,62 +51,33 @@ test() assert(std::atomic_fetch_sub(&t, T(2)) == T(3)); assert(t == T(1)); } -} - -template -void -testp() -{ - { - typedef std::atomic A; - typedef typename std::remove_pointer::type X; - A t; - std::atomic_init(&t, T(3*sizeof(X))); - assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X))); - assert(t == T(1*sizeof(X))); - } - { - typedef std::atomic A; - typedef typename std::remove_pointer::type X; - volatile A t; - std::atomic_init(&t, T(3*sizeof(X))); - assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X))); - assert(t == T(1*sizeof(X))); - } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - A(const A& a) : i(a.i) {} - A(const volatile A& a) : i(a.i) {} - - void operator=(const volatile A& a) volatile {i = a.i;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; +template +void testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::type X; + A t; + std::atomic_init(&t, T(3*sizeof(X))); + assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X))); + assert(t == T(1*sizeof(X))); + } + { + typedef std::atomic A; + typedef typename std::remove_pointer::type X; + volatile A t; + std::atomic_init(&t, T(3*sizeof(X))); + assert(std::atomic_fetch_sub(&t, 2) == T(3*sizeof(X))); + assert(t == T(1*sizeof(X))); + } +} + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); testp(); testp(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp index e6c92eada6df..6e94c505fd8c 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.pass.cpp @@ -33,10 +33,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -53,64 +54,35 @@ test() std::memory_order_seq_cst) == T(3)); assert(t == T(1)); } -} - -template -void -testp() -{ - { - typedef std::atomic A; - typedef typename std::remove_pointer::type X; - A t; - std::atomic_init(&t, T(3*sizeof(X))); - assert(std::atomic_fetch_sub_explicit(&t, 2, - std::memory_order_seq_cst) == T(3*sizeof(X))); - assert(t == T(1*sizeof(X))); - } - { - typedef std::atomic A; - typedef typename std::remove_pointer::type X; - volatile A t; - std::atomic_init(&t, T(3*sizeof(X))); - assert(std::atomic_fetch_sub_explicit(&t, 2, - std::memory_order_seq_cst) == T(3*sizeof(X))); - assert(t == T(1*sizeof(X))); - } -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - A(const A& a) : i(a.i) {} - A(const volatile A& a) : i(a.i) {} - - void operator=(const volatile A& a) volatile {i = a.i;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; +template +void testp() +{ + { + typedef std::atomic A; + typedef typename std::remove_pointer::type X; + A t; + std::atomic_init(&t, T(3*sizeof(X))); + assert(std::atomic_fetch_sub_explicit(&t, 2, + std::memory_order_seq_cst) == T(3*sizeof(X))); + assert(t == T(1*sizeof(X))); + } + { + typedef std::atomic A; + typedef typename std::remove_pointer::type X; + volatile A t; + std::atomic_init(&t, T(3*sizeof(X))); + assert(std::atomic_fetch_sub_explicit(&t, 2, + std::memory_order_seq_cst) == T(3*sizeof(X))); + assert(t == T(1*sizeof(X))); + } +} + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); testp(); testp(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp index fc6b97b7db45..42d57dedbd11 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor.pass.cpp @@ -23,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -41,24 +42,10 @@ test() assert(std::atomic_fetch_xor(&t, T(2)) == T(3)); assert(t == T(1)); } -} + } +}; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp index 58772aa4d152..8f388fee6325 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_xor_explicit.pass.cpp @@ -23,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { { typedef std::atomic A; A t; @@ -43,24 +44,10 @@ test() std::memory_order_seq_cst) == T(3)); assert(t == T(1)); } -} + } +}; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS + TestEachIntegralType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h new file mode 100644 index 000000000000..e31420b156c6 --- /dev/null +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h @@ -0,0 +1,51 @@ +#ifndef ATOMIC_HELPERS_H +#define ATOMIC_HELPERS_H + +#include + +#include "test_macros.h" + +struct UserAtomicType +{ + int i; + + explicit UserAtomicType(int d = 0) TEST_NOEXCEPT : i(d) {} + + friend bool operator==(const UserAtomicType& x, const UserAtomicType& y) + { return x.i == y.i; } +}; + +template < template class TestFunctor > +struct TestEachIntegralType { + void operator()() const { + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor(); +#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS + TestFunctor()(); + TestFunctor()(); +#endif + } +}; + +template < template class TestFunctor > +struct TestEachAtomicType { + void operator()() const { + TestEachIntegralType()(); + TestFunctor()(); + TestFunctor()(); + TestFunctor()(); + } +}; + + +#endif // ATOMIC_HELPER_H diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp index 137b6f60f746..884c02dfe7ea 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_init.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// ... assertion fails line 34 +// ... assertion fails line 36 // @@ -24,10 +24,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_init(&t, T(1)); @@ -35,37 +36,10 @@ test() volatile A vt; std::atomic_init(&vt, T(2)); assert(vt == T(2)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp index 18a1605e2092..5d50016ed32c 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_is_lock_free.pass.cpp @@ -20,17 +20,21 @@ // atomic_is_lock_free(const atomic* obj); #include +#include + +#include "atomic_helpers.h" template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; bool b1 = std::atomic_is_lock_free(static_cast(&t)); volatile A vt; bool b2 = std::atomic_is_lock_free(static_cast(&vt)); -} + assert(b1 == b2); + } +}; struct A { @@ -39,23 +43,6 @@ struct A int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestFn()(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp index 66918c71f1f6..e7b8e64b434f 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load.pass.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// ... assertion fails line 34 +// ... assertion fails line 35 // @@ -24,10 +24,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_init(&t, T(1)); @@ -35,37 +36,10 @@ test() volatile A vt; std::atomic_init(&vt, T(2)); assert(std::atomic_load(&vt) == T(2)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp index 5f402a9f139f..56533fa871e5 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_load_explicit.pass.cpp @@ -24,10 +24,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_init(&t, T(1)); @@ -35,37 +36,10 @@ test() volatile A vt; std::atomic_init(&vt, T(2)); assert(std::atomic_load_explicit(&vt, std::memory_order_seq_cst) == T(2)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp index 2b9582b3c522..e61dae904116 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// ... assertion fails line 31 // @@ -24,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_store(&t, T(1)); @@ -35,37 +35,11 @@ test() volatile A vt; std::atomic_store(&vt, T(2)); assert(vt == T(2)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp index 8fe0c7d88421..e57cf8b1b323 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_store_explicit.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads -// ... assertion fails line 31 // @@ -24,10 +23,11 @@ #include #include +#include "atomic_helpers.h" + template -void -test() -{ +struct TestFn { + void operator()() const { typedef std::atomic A; A t; std::atomic_store_explicit(&t, T(1), std::memory_order_seq_cst); @@ -35,37 +35,11 @@ test() volatile A vt; std::atomic_store_explicit(&vt, T(2), std::memory_order_seq_cst); assert(vt == T(2)); -} - -struct A -{ - int i; - - explicit A(int d = 0) noexcept {i=d;} - - friend bool operator==(const A& x, const A& y) - {return x.i == y.i;} + } }; + int main() { - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); - test(); -#ifndef _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); -#endif // _LIBCPP_HAS_NO_UNICODE_CHARS - test(); - test(); + TestEachAtomicType()(); } diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp index 5fed691da268..9f25807fbcde 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_var_init.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// XFAIL: c++98, c++03 // diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp index 0eda2338d257..f6944c7255bc 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/ctor.pass.cpp @@ -10,6 +10,10 @@ // UNSUPPORTED: libcpp-has-no-threads // UNSUPPORTED: c++98, c++03 +// NOTE: atomic<> of a TriviallyCopyable class is wrongly rejected by older +// clang versions. It was fixed right before the llvm 3.5 release. See PR18097. +// XFAIL: apple-clang-6.0, clang-3.4, clang-3.3 + // // constexpr atomic::atomic(T value) @@ -18,6 +22,8 @@ #include #include +#include "atomic_helpers.h" + struct UserType { int i; @@ -30,27 +36,29 @@ struct UserType { }; template -void test() { - typedef std::atomic Atomic; - static_assert(std::is_literal_type::value, ""); - constexpr Tp t(42); - { - constexpr Atomic a(t); - assert(a == t); +struct TestFunc { + void operator()() const { + typedef std::atomic Atomic; + static_assert(std::is_literal_type::value, ""); + constexpr Tp t(42); + { + constexpr Atomic a(t); + assert(a == t); + } + { + constexpr Atomic a{t}; + assert(a == t); + } + { + constexpr Atomic a = ATOMIC_VAR_INIT(t); + assert(a == t); + } } - { - constexpr Atomic a{t}; - assert(a == t); - } - { - constexpr Atomic a = ATOMIC_VAR_INIT(t); - assert(a == t); - } -} +}; int main() { - test(); - test(); + TestFunc()(); + TestEachIntegralType()(); } diff --git a/test/std/containers/associative/map/allocator_mismatch.fail.cpp b/test/std/containers/associative/map/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..f5da14539c47 --- /dev/null +++ b/test/std/containers/associative/map/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::map, std::allocator > m; +} diff --git a/test/std/containers/associative/map/compare.pass.cpp b/test/std/containers/associative/map/compare.pass.cpp index aa4d5999ff46..26ac7af7d908 100644 --- a/test/std/containers/associative/map/compare.pass.cpp +++ b/test/std/containers/associative/map/compare.pass.cpp @@ -17,16 +17,36 @@ // http://llvm.org/bugs/show_bug.cgi?id=16549 #include +#include +#include struct Key { template Key(const T&) {} bool operator< (const Key&) const { return false; } }; -int -main() +int main() { - std::map::iterator it = std::map().find(Key(0)); - std::pair::iterator, bool> result = - std::map().insert(std::make_pair(Key(0), 0)); + typedef std::map MapT; + typedef MapT::iterator Iter; + typedef std::pair IterBool; + { + MapT m_empty; + MapT m_contains; + m_contains[Key(0)] = 42; + + Iter it = m_empty.find(Key(0)); + assert(it == m_empty.end()); + it = m_contains.find(Key(0)); + assert(it != m_contains.end()); + } + { + MapT map; + IterBool result = map.insert(std::make_pair(Key(0), 42)); + assert(result.second); + assert(result.first->second = 42); + IterBool result2 = map.insert(std::make_pair(Key(0), 43)); + assert(!result2.second); + assert(map[Key(0)] == 42); + } } diff --git a/test/std/containers/associative/map/map.access/at.pass.cpp b/test/std/containers/associative/map/map.access/at.pass.cpp index 86b1e3d2dfa6..0da28507fce3 100644 --- a/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/test/std/containers/associative/map/map.access/at.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class map diff --git a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index d14603e1a281..6511dcc85f53 100644 --- a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -16,14 +16,14 @@ #include #include +#include "test_macros.h" #include "MoveOnly.h" #include "min_allocator.h" int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { - typedef std::pair V; std::map m; assert(m.size() == 0); assert(m[1] == 0.0); @@ -37,10 +37,8 @@ int main() assert(m[6] == 6.5); assert(m.size() == 2); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { - typedef std::pair V; + typedef std::pair V; std::map, min_allocator> m; assert(m.size() == 0); assert(m[1] == 0.0); diff --git a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp index 1f11fc9582ed..dedc89bd435e 100644 --- a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } { diff --git a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index eed26d3a6136..9baa19b53d05 100644 --- a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { diff --git a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp index f80b1d323178..3b28118b5b1e 100644 --- a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_move_assignable::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_move_assignable::value, ""); } { diff --git a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp index 9347b8329ae3..0f1fd396639e 100644 --- a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { diff --git a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index 4598e9945d4e..f25dff2c86da 100644 --- a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -94,18 +94,19 @@ struct some_alloc3 int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::map C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::map, test_allocator> C; + typedef std::map, test_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::map, other_allocator> C; + typedef std::map, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } @@ -117,28 +118,28 @@ int main() #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp - typedef std::map, some_alloc > C; + typedef std::map, some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for comp - typedef std::map, some_alloc2> C; + typedef std::map, some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for comp - typedef std::map, some_alloc > C; + typedef std::map, some_alloc > C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for comp - typedef std::map, some_alloc2> C; + typedef std::map, some_alloc2> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // NOT always equal allocator, nothrow swap for comp - typedef std::map, some_alloc3> C; + typedef std::map, some_alloc3> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } diff --git a/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp b/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..18823212f409 --- /dev/null +++ b/test/std/containers/associative/multimap/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::multimap, std::allocator > m; +} diff --git a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp index d1db40b1fc7a..5f05a0dca28e 100644 --- a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(std::is_nothrow_default_constructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(!std::is_nothrow_default_constructible::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp index cb55e3fb33ec..dd1701240c63 100644 --- a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_destructible::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp index 8ad9e8b82fd1..635a8dca0357 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -33,16 +33,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_move_assignable::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_move_assignable::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp index 66ea8737fb75..0f31f04ff829 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -31,16 +31,17 @@ struct some_comp int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; static_assert(std::is_nothrow_move_constructible::value, ""); } { diff --git a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index 1013c62804b8..e70ee1fae565 100644 --- a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -94,18 +94,19 @@ struct some_alloc3 int main() { #if __has_feature(cxx_noexcept) + typedef std::pair V; { typedef std::multimap C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::multimap, test_allocator> C; + typedef std::multimap, test_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { - typedef std::multimap, other_allocator> C; + typedef std::multimap, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } @@ -117,28 +118,28 @@ int main() #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for comp - typedef std::multimap, some_alloc > C; + typedef std::multimap, some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for comp - typedef std::multimap, some_alloc2> C; + typedef std::multimap, some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for comp - typedef std::multimap, some_alloc > C; + typedef std::multimap, some_alloc > C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for comp - typedef std::multimap, some_alloc2> C; + typedef std::multimap, some_alloc2> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // NOT always equal allocator, nothrow swap for comp - typedef std::map, some_alloc3> C; + typedef std::map, some_alloc3> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } diff --git a/test/std/containers/associative/multimap/scary.pass.cpp b/test/std/containers/associative/multimap/scary.pass.cpp index b99d9bc2df91..e6dc5aaca953 100644 --- a/test/std/containers/associative/multimap/scary.pass.cpp +++ b/test/std/containers/associative/multimap/scary.pass.cpp @@ -21,4 +21,5 @@ int main() typedef std::multimap M2; M2::iterator i; M1::iterator j = i; + ((void)j); } diff --git a/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp b/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..b2b30d6fdc1d --- /dev/null +++ b/test/std/containers/associative/multiset/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::multiset, std::allocator > ms; +} diff --git a/test/std/containers/associative/multiset/scary.pass.cpp b/test/std/containers/associative/multiset/scary.pass.cpp index f5ee32714e86..bc4328b5332b 100644 --- a/test/std/containers/associative/multiset/scary.pass.cpp +++ b/test/std/containers/associative/multiset/scary.pass.cpp @@ -21,4 +21,5 @@ int main() typedef std::multiset M2; M2::iterator i; M1::iterator j = i; + ((void)j); } diff --git a/test/std/containers/associative/set/allocator_mismatch.fail.cpp b/test/std/containers/associative/set/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..6905d9344864 --- /dev/null +++ b/test/std/containers/associative/set/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::set, std::allocator > s; +} diff --git a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp index b9775eef0673..5e429adb6fc9 100644 --- a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.data/data.pass.cpp b/test/std/containers/sequences/array/array.data/data.pass.cpp index 08e4fd39d377..d7aed70c98ad 100644 --- a/test/std/containers/sequences/array/array.data/data.pass.cpp +++ b/test/std/containers/sequences/array/array.data/data.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.data/data_const.pass.cpp b/test/std/containers/sequences/array/array.data/data_const.pass.cpp index 8eb9762dcb89..58840e940899 100644 --- a/test/std/containers/sequences/array/array.data/data_const.pass.cpp +++ b/test/std/containers/sequences/array/array.data/data_const.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.fill/fill.pass.cpp b/test/std/containers/sequences/array/array.fill/fill.pass.cpp index 675f49500627..5bc42ceb89f3 100644 --- a/test/std/containers/sequences/array/array.fill/fill.pass.cpp +++ b/test/std/containers/sequences/array/array.fill/fill.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.size/size.pass.cpp b/test/std/containers/sequences/array/array.size/size.pass.cpp index fe5a0d5c8db0..a833fdc04715 100644 --- a/test/std/containers/sequences/array/array.size/size.pass.cpp +++ b/test/std/containers/sequences/array/array.size/size.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.special/swap.pass.cpp b/test/std/containers/sequences/array/array.special/swap.pass.cpp index 08e437739ee6..c1b0b235ab34 100644 --- a/test/std/containers/sequences/array/array.special/swap.pass.cpp +++ b/test/std/containers/sequences/array/array.special/swap.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/test/std/containers/sequences/array/array.swap/swap.pass.cpp index c7a4cb8df38c..651798e1e790 100644 --- a/test/std/containers/sequences/array/array.swap/swap.pass.cpp +++ b/test/std/containers/sequences/array/array.swap/swap.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { diff --git a/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/test/std/containers/sequences/array/array.tuple/get.fail.cpp index 4f4fbcf93af6..13323dd8e519 100644 --- a/test/std/containers/sequences/array/array.tuple/get.fail.cpp +++ b/test/std/containers/sequences/array/array.tuple/get.fail.cpp @@ -11,15 +11,31 @@ // template T& get(array& a); +// Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Warray-bounds" +#endif + #include #include +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { typedef double T; typedef std::array C; C c = {1, 2, 3.5}; - std::get<3>(c) = 5.5; // Can't get element 3! + std::get<3>(c) = 5.5; // expected-note {{requested here}} +#if TEST_STD_VER >= 11 + // expected-error@array:* {{static_assert failed "Index out of bounds in std::get<> (std::array)"}} +#else + // expected-error@array:* {{implicit instantiation of undefined template '__static_assert_test'}} +#endif } } diff --git a/test/std/containers/sequences/array/array.tuple/get.pass.cpp b/test/std/containers/sequences/array/array.tuple/get.pass.cpp index d9e242cd420b..4f210c4f762e 100644 --- a/test/std/containers/sequences/array/array.tuple/get.pass.cpp +++ b/test/std/containers/sequences/array/array.tuple/get.pass.cpp @@ -14,12 +14,19 @@ #include #include -#if __cplusplus > 201103L +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + + +#if TEST_STD_VER > 11 struct S { std::array a; int k; constexpr S() : a{1,2,3}, k(std::get<2>(a)) {} - }; +}; constexpr std::array getArr () { return { 3, 4 }; } #endif @@ -35,7 +42,7 @@ int main() assert(c[1] == 5.5); assert(c[2] == 3.5); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef double T; typedef std::array C; diff --git a/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp b/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp index 1cbdfa4ff393..04606bf6cf73 100644 --- a/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp +++ b/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp @@ -14,6 +14,12 @@ #include #include +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { @@ -24,7 +30,7 @@ int main() assert(std::get<1>(c) == 2); assert(std::get<2>(c) == 3.5); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef double T; typedef std::array C; diff --git a/test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp b/test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp new file mode 100644 index 000000000000..a22c91a4de47 --- /dev/null +++ b/test/std/containers/sequences/array/array.tuple/get_const_rv.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template const T&& get(const array&& a); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include +#include + +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + +int main() +{ + + { + typedef std::unique_ptr T; + typedef std::array C; + const C c = {std::unique_ptr(new double(3.5))}; + static_assert(std::is_same(std::move(c)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(c))), ""); + const T&& t = std::get<0>(std::move(c)); + assert(*t == 3.5); + } + +#if TEST_STD_VER > 11 + { + typedef double T; + typedef std::array C; + constexpr const C c = {1, 2, 3.5}; + static_assert(std::get<0>(std::move(c)) == 1, ""); + static_assert(std::get<1>(std::move(c)) == 2, ""); + static_assert(std::get<2>(std::move(c)) == 3.5, ""); + } +#endif +} diff --git a/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp b/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp index 8eec3ceff514..72ef49b157f6 100644 --- a/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp +++ b/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp @@ -11,14 +11,20 @@ // template T&& get(array&& a); +// UNSUPPORTED: c++98, c++03 + #include #include #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { typedef std::unique_ptr T; typedef std::array C; @@ -26,5 +32,4 @@ int main() T t = std::get<0>(std::move(c)); assert(*t == 3.5); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp index b5cf8a5aaa8f..5cb89dfeeb9a 100644 --- a/test/std/containers/sequences/array/at.pass.cpp +++ b/test/std/containers/sequences/array/at.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // reference operator[] (size_type) @@ -17,6 +18,12 @@ #include #include +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { @@ -27,7 +34,7 @@ int main() assert(r1 == 1); r1 = 5.5; assert(c.front() == 5.5); - + C::reference r2 = c.at(2); assert(r2 == 3.5); r2 = 7.5; @@ -50,7 +57,7 @@ int main() catch (const std::out_of_range &) {} } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef double T; typedef std::array C; diff --git a/test/std/containers/sequences/array/begin.pass.cpp b/test/std/containers/sequences/array/begin.pass.cpp index 9cba0d6fceb0..b12ffc851b84 100644 --- a/test/std/containers/sequences/array/begin.pass.cpp +++ b/test/std/containers/sequences/array/begin.pass.cpp @@ -14,6 +14,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { @@ -27,6 +31,4 @@ int main() *i = 5.5; assert(c[0] == 5.5); } - { - } } diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp index 45a963b9947d..bccaade986ea 100644 --- a/test/std/containers/sequences/array/front_back.pass.cpp +++ b/test/std/containers/sequences/array/front_back.pass.cpp @@ -17,6 +17,12 @@ #include #include +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { @@ -45,12 +51,12 @@ int main() assert(r2 == 3.5); } -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef double T; typedef std::array C; constexpr C c = {1, 2, 3.5}; - + constexpr T t1 = c.front(); static_assert (t1 == 1, ""); diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp index e4dda0dc5cfd..5ccb0b487b95 100644 --- a/test/std/containers/sequences/array/indexing.pass.cpp +++ b/test/std/containers/sequences/array/indexing.pass.cpp @@ -17,6 +17,12 @@ #include #include +#include "test_macros.h" + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int main() { { @@ -42,13 +48,13 @@ int main() C::const_reference r2 = c[2]; assert(r2 == 3.5); } - -#if _LIBCPP_STD_VER > 11 + +#if TEST_STD_VER > 11 { typedef double T; typedef std::array C; constexpr C c = {1, 2, 3.5}; - + constexpr T t1 = c[0]; static_assert (t1 == 1, ""); diff --git a/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp b/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..9223c1ecddcb --- /dev/null +++ b/test/std/containers/sequences/deque/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::deque > d; +} diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp index 522f839973db..84f04f9d52da 100644 --- a/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template @@ -58,7 +59,6 @@ template void testN(int start, int N, int M) { - typedef typename C::const_iterator CI; C c1 = make(N, start); test(c1, M); } @@ -73,7 +73,7 @@ int main() for (int k = 0; k < N; ++k) testN >(rng[i], rng[j], rng[k]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp index 9eb514ba92f7..2bf2423fb9af 100644 --- a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template @@ -58,7 +59,6 @@ template void testN(int start, int N, int M) { - typedef typename C::const_iterator CI; C c1 = make(N, start); test(c1, M, -10); } @@ -73,7 +73,7 @@ int main() for (int k = 0; k < N; ++k) testN >(rng[i], rng[j], rng[k]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp index fb00069f33b6..0cf0387211d3 100644 --- a/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template @@ -51,7 +52,6 @@ template void testN(int start, int N) { - typedef typename C::const_iterator CI; C c1 = make(N, start); test(c1); } @@ -65,7 +65,7 @@ int main() for (int j = 0; j < N; ++j) testN >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp index 51a37cc33b7a..6507f58e1194 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -44,7 +45,6 @@ template void test(C& c1, const C& c2) { - std::size_t c1_osize = c1.size(); c1.assign(c2.begin(), c2.end()); assert(distance(c1.begin(), c1.end()) == c1.size()); assert(c1 == c2); @@ -54,8 +54,6 @@ template void testN(int start, int N, int M) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; C c1 = make(N, start); C c2 = make(M); test(c1, c2); @@ -67,7 +65,6 @@ testI(C& c1, const C& c2) { typedef typename C::const_iterator CI; typedef input_iterator ICI; - std::size_t c1_osize = c1.size(); c1.assign(ICI(c2.begin()), ICI(c2.end())); assert(distance(c1.begin(), c1.end()) == c1.size()); assert(c1 == c2); @@ -77,8 +74,6 @@ template void testNI(int start, int N, int M) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; C c1 = make(N, start); C c2 = make(M); testI(c1, c2); @@ -95,7 +90,7 @@ int main() testN >(rng[i], rng[j], rng[k]); testNI >(1500, 2000, 1000); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp index 3ab79a095fce..e00e0442d22e 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -44,7 +45,6 @@ void test(C& c1, int size, int v) { typedef typename C::const_iterator CI; - std::size_t c1_osize = c1.size(); c1.assign(size, v); assert(c1.size() == size); assert(distance(c1.begin(), c1.end()) == c1.size()); @@ -56,8 +56,6 @@ template void testN(int start, int N, int M) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; C c1 = make(N, start); test(c1, M, -10); } @@ -72,7 +70,7 @@ int main() for (int k = 0; k < N; ++k) testN >(rng[i], rng[j], rng[k]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp index 7a0a2512ee2f..713f2159e598 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp @@ -11,13 +11,14 @@ // template iterator emplace(const_iterator p, Args&&... args); +// UNSUPPORTED: c++98, c++03 + #include #include #include "../../../Emplaceable.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template C @@ -45,7 +46,6 @@ template void test(int P, C& c1) { - typedef typename C::iterator I; typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5)); @@ -59,8 +59,6 @@ template void testN(int start, int N) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) @@ -87,11 +85,9 @@ testN(int start, int N) } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -99,7 +95,6 @@ int main() for (int j = 0; j < N; ++j) testN >(rng[i], rng[j]); } -#if __cplusplus >= 201103L { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -107,6 +102,4 @@ int main() for (int j = 0; j < N; ++j) testN> >(rng[i], rng[j]); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp index ecb95d72a21e..fbe3cb69ccdd 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" #include "MoveOnly.h" #include "../../../stack_allocator.h" @@ -49,7 +50,6 @@ void test(int P, const C& c0, const C& c2) { { - typedef typename C::iterator I; typedef typename C::const_iterator CI; typedef input_iterator BCI; C c1 = c0; @@ -67,7 +67,6 @@ test(int P, const C& c0, const C& c2) assert(*i == j); } { - typedef typename C::iterator I; typedef typename C::const_iterator CI; typedef forward_iterator BCI; C c1 = c0; @@ -85,7 +84,6 @@ test(int P, const C& c0, const C& c2) assert(*i == j); } { - typedef typename C::iterator I; typedef typename C::const_iterator CI; typedef bidirectional_iterator BCI; C c1 = c0; @@ -108,8 +106,6 @@ template void testN(int start, int N, int M) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) @@ -170,7 +166,6 @@ template void testI(int P, C& c1, const C& c2) { - typedef typename C::iterator I; typedef typename C::const_iterator CI; typedef input_iterator ICI; std::size_t c1_osize = c1.size(); @@ -191,8 +186,6 @@ template void testNI(int start, int N, int M) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) @@ -244,7 +237,7 @@ template void test_move() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 C c; typedef typename C::const_iterator CI; { @@ -263,7 +256,7 @@ test_move() j = 0; for (CI i = c.begin(); i != c.end(); ++i, ++j) assert(*i == MoveOnly(j)); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } int main() @@ -276,11 +269,11 @@ int main() for (int k = 0; k < N; ++k) testN >(rng[i], rng[j], rng[k]); testNI >(1500, 2000, 1000); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 test_move > >(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp index b7e73f265028..3c7b0fef28b4 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp @@ -11,13 +11,14 @@ // iterator insert (const_iterator p, value_type&& v); +// UNSUPPORTED: c++98, c++03 + #include #include #include "MoveOnly.h" #include "min_allocator.h" -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template C @@ -45,7 +46,6 @@ template void test(int P, C& c1, int x) { - typedef typename C::iterator I; typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, MoveOnly(x)); @@ -65,8 +65,6 @@ template void testN(int start, int N) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) @@ -93,11 +91,8 @@ testN(int start, int N) } } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -105,7 +100,6 @@ int main() for (int j = 0; j < N; ++j) testN >(rng[i], rng[j]); } -#if __cplusplus >= 201103L { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -113,6 +107,4 @@ int main() for (int j = 0; j < N; ++j) testN> >(rng[i], rng[j]); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp index 2737dfba7739..0efe3b44c604 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template @@ -44,7 +45,6 @@ template void test(int P, C& c1, int size, int x) { - typedef typename C::iterator I; typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, size, x); @@ -64,8 +64,6 @@ template void testN(int start, int N, int M) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) @@ -145,7 +143,7 @@ int main() testN >(rng[i], rng[j], rng[k]); self_reference_test >(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp index fbbaad4f89e5..04c4ca4f7b26 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp @@ -14,6 +14,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template @@ -42,7 +43,6 @@ template void test(int P, C& c1, int x) { - typedef typename C::iterator I; typedef typename C::const_iterator CI; std::size_t c1_osize = c1.size(); CI i = c1.insert(c1.begin() + P, x); @@ -62,8 +62,6 @@ template void testN(int start, int N) { - typedef typename C::iterator I; - typedef typename C::const_iterator CI; for (int i = 0; i <= 3; ++i) { if (0 <= i && i <= N) @@ -126,7 +124,7 @@ int main() testN >(rng[i], rng[j]); self_reference_test >(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp index 8ad6b53f1b5f..b37e961e442f 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void push_back(const value_type& x); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp index e01b2a224ffd..b4caa947aed8 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void push_front(const value_type& x); diff --git a/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp b/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..b53075d033bc --- /dev/null +++ b/test/std/containers/sequences/forwardlist/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::forward_list > fl; +} diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index 8341f7ba0cb2..88ecb7540951 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -24,7 +24,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; - typedef test_allocator A; + typedef test_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -39,7 +39,7 @@ int main() } { typedef MoveOnly T; - typedef other_allocator A; + typedef other_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -55,7 +55,7 @@ int main() #if __cplusplus >= 201103L { typedef MoveOnly T; - typedef min_allocator A; + typedef min_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp index 6bb575ef80f1..3f0e45af1f0b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp @@ -24,7 +24,7 @@ int main() #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef MoveOnly T; - typedef test_allocator A; + typedef test_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -39,7 +39,7 @@ int main() } { typedef MoveOnly T; - typedef test_allocator A; + typedef test_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; @@ -55,7 +55,7 @@ int main() #if __cplusplus >= 201103L { typedef MoveOnly T; - typedef min_allocator A; + typedef min_allocator A; typedef std::forward_list C; T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; typedef std::move_iterator I; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp index 43c62eb00cbf..b501347e7893 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void push_front(const value_type& x); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp index 296ffcd6955d..349a3872d754 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" typedef int T; @@ -44,7 +45,6 @@ tests(const C& c, int p, int f) { typename C::const_iterator i = c.begin(); int n = 0; - int d = 1; if (p == f || p == f+1) { for (n = 0; n < size_t1; ++n, ++i) @@ -106,7 +106,7 @@ int main() } } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { // splicing different containers typedef std::forward_list> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp index ca673b583683..9f01fed66465 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp @@ -22,12 +22,12 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template void test(int N, int M) { - typedef typename C::value_type T; C c1; for (int i = 0; i < N; ++i) c1.push_front(i); @@ -52,7 +52,7 @@ int main() for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) test >(i, j); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) test> >(i, j); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp index 42e245d007b0..e65e064ffdaf 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp @@ -30,12 +30,12 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" template void test(int N, int M) { - typedef typename C::value_type T; C c1; for (int i = 0; i < N; ++i) c1.push_front(i); @@ -57,7 +57,7 @@ int main() for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) test >(i, j); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) test> >(i, j); diff --git a/test/std/containers/sequences/list/allocator_mismatch.fail.cpp b/test/std/containers/sequences/list/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..3490d106a60c --- /dev/null +++ b/test/std/containers/sequences/list/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::list > l; +} diff --git a/test/std/containers/sequences/list/incomplete_type.pass.cpp b/test/std/containers/sequences/list/incomplete_type.pass.cpp new file mode 100644 index 000000000000..adfb4d45fc81 --- /dev/null +++ b/test/std/containers/sequences/list/incomplete_type.pass.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// Check that std::list and it's iterators can be instantiated with an incomplete +// type. + +#include + +struct A { + std::list l; + std::list::iterator it; + std::list::const_iterator cit; + std::list::reverse_iterator rit; + std::list::const_reverse_iterator crit; +}; + +int main() { + A a; +} diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp index a7f1917ab856..736b9baae746 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp index eeb74b83e509..c0f6ed198751 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // iterator insert(const_iterator position, size_type n, const value_type& x); diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp index 406e93a376a1..1aacb63e4a70 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // iterator insert(const_iterator position, const value_type& x); diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp index 9d3c05e26b1c..8d16142defc0 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void push_back(const value_type& x); diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp index 6609005262eb..aafcceecd471 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void push_front(const value_type& x); diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp index b580eb4ae3b0..4dd871c9447e 100644 --- a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp @@ -28,6 +28,32 @@ struct some_alloc some_alloc(const some_alloc&); }; +template +struct some_alloc2 +{ + typedef T value_type; + + some_alloc2() {} + some_alloc2(const some_alloc2&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_move_assignment; + typedef std::true_type is_always_equal; +}; + +template +struct some_alloc3 +{ + typedef T value_type; + + some_alloc3() {} + some_alloc3(const some_alloc3&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_move_assignment; + typedef std::false_type is_always_equal; +}; + int main() { #if __has_feature(cxx_noexcept) @@ -45,7 +71,22 @@ int main() } { typedef std::vector> C; +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_move_assignable::value, ""); +#else + static_assert(!std::is_nothrow_move_assignable::value, ""); +#endif + } +#if TEST_STD_VER > 14 + { // POCMA false, is_always_equal true + typedef std::vector> C; + static_assert( std::is_nothrow_move_assignable::value, ""); + } + { // POCMA false, is_always_equal false + typedef std::vector> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } #endif + +#endif } diff --git a/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp b/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..65fdb63ee6a0 --- /dev/null +++ b/test/std/containers/sequences/vector/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::vector > v; +} diff --git a/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp index 1c4a4f7c9282..c09224497966 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp @@ -29,6 +29,33 @@ struct some_alloc some_alloc(const some_alloc&); }; +template +struct some_alloc2 +{ + typedef T value_type; + + some_alloc2() {} + some_alloc2(const some_alloc2&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_move_assignment; + typedef std::true_type is_always_equal; +}; + +template +struct some_alloc3 +{ + typedef T value_type; + + some_alloc3() {} + some_alloc3(const some_alloc3&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_move_assignment; + typedef std::false_type is_always_equal; +}; + + int main() { #if __has_feature(cxx_noexcept) @@ -46,7 +73,24 @@ int main() } { typedef std::vector> C; + // In C++17, move assignment for allocators are not allowed to throw +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_move_assignable::value, ""); +#else + static_assert(!std::is_nothrow_move_assignable::value, ""); +#endif + } + +#if TEST_STD_VER > 14 + { // POCMA false, is_always_equal true + typedef std::vector> C; + static_assert( std::is_nothrow_move_assignable::value, ""); + } + { // POCMA false, is_always_equal false + typedef std::vector> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } #endif + +#endif } diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp index 6615a25a620f..785225357d4b 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void push_back(const value_type& x); diff --git a/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..39fcb11add40 --- /dev/null +++ b/test/std/containers/unord/unord.map/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_map, std::less, std::allocator > m; +} diff --git a/test/std/containers/unord/unord.map/bucket_count.pass.cpp b/test/std/containers/unord/unord.map/bucket_count.pass.cpp index d3e80d86379a..bc3733742600 100644 --- a/test/std/containers/unord/unord.map/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.map/bucket_count.pass.cpp @@ -19,20 +19,18 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() { { typedef std::unordered_map C; - typedef C::const_iterator I; - typedef std::pair P; const C c; assert(c.bucket_count() == 0); } { typedef std::unordered_map C; - typedef C::const_iterator I; typedef std::pair P; P a[] = { @@ -48,19 +46,16 @@ int main() const C c(std::begin(a), std::end(a)); assert(c.bucket_count() >= 11); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; - typedef C::const_iterator I; - typedef std::pair P; const C c; assert(c.bucket_count() == 0); } { typedef std::unordered_map, std::equal_to, min_allocator>> C; - typedef C::const_iterator I; typedef std::pair P; P a[] = { diff --git a/test/std/containers/unord/unord.map/compare.pass.cpp b/test/std/containers/unord/unord.map/compare.pass.cpp index 8979a3a34ad6..ea6d02f5fcbc 100644 --- a/test/std/containers/unord/unord.map/compare.pass.cpp +++ b/test/std/containers/unord/unord.map/compare.pass.cpp @@ -17,6 +17,7 @@ // http://llvm.org/bugs/show_bug.cgi?id=16549 #include +#include struct Key { template Key(const T&) {} @@ -35,8 +36,12 @@ namespace std int main() { - std::unordered_map::iterator it = - std::unordered_map().find(Key(0)); - std::pair::iterator, bool> result = - std::unordered_map().insert(std::make_pair(Key(0), 0)); + typedef std::unordered_map MapT; + typedef MapT::iterator Iter; + MapT map; + Iter it = map.find(Key(0)); + assert(it == map.end()); + std::pair result = map.insert(std::make_pair(Key(0), 42)); + assert(result.second); + assert(result.first->second == 42); } diff --git a/test/std/containers/unord/unord.map/load_factor.pass.cpp b/test/std/containers/unord/unord.map/load_factor.pass.cpp index 472e41abf6e0..b25c019688a6 100644 --- a/test/std/containers/unord/unord.map/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.map/load_factor.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() @@ -43,11 +44,10 @@ int main() } { typedef std::unordered_map C; - typedef std::pair P; const C c; assert(c.load_factor() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -69,7 +69,6 @@ int main() { typedef std::unordered_map, std::equal_to, min_allocator>> C; - typedef std::pair P; const C c; assert(c.load_factor() == 0); } diff --git a/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp index b4ca8eb04472..08f014da2f49 100644 --- a/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp @@ -19,23 +19,20 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" int main() { { typedef std::unordered_map C; - typedef C::const_iterator I; - typedef std::pair P; const C c; assert(c.max_bucket_count() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; - typedef C::const_iterator I; - typedef std::pair P; const C c; assert(c.max_bucket_count() > 0); } diff --git a/test/std/containers/unord/unord.map/max_load_factor.pass.cpp b/test/std/containers/unord/unord.map/max_load_factor.pass.cpp index 69fd70d2a172..b19a6e6cfa08 100644 --- a/test/std/containers/unord/unord.map/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.map/max_load_factor.pass.cpp @@ -16,44 +16,37 @@ // float max_load_factor() const; // void max_load_factor(float mlf); -#ifdef _LIBCPP_DEBUG -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include #include #include +#include "test_macros.h" #include "min_allocator.h" int main() { { typedef std::unordered_map C; - typedef std::pair P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_map C; - typedef std::pair P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; - typedef std::pair P; const C c; assert(c.max_load_factor() == 1); } { typedef std::unordered_map, std::equal_to, min_allocator>> C; - typedef std::pair P; C c; assert(c.max_load_factor() == 1); c.max_load_factor(2.5); diff --git a/test/std/containers/unord/unord.map/rehash.pass.cpp b/test/std/containers/unord/unord.map/rehash.pass.cpp index 84ece2355511..e1a882c69ffd 100644 --- a/test/std/containers/unord/unord.map/rehash.pass.cpp +++ b/test/std/containers/unord/unord.map/rehash.pass.cpp @@ -21,6 +21,12 @@ #include "min_allocator.h" +template +void rehash_postcondition(const C& c, size_t n) +{ + assert(c.bucket_count() >= c.size() / c.max_load_factor() && c.bucket_count() >= n); +} + template void test(const C& c) { @@ -49,13 +55,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } @@ -77,13 +86,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } diff --git a/test/std/containers/unord/unord.map/reserve.pass.cpp b/test/std/containers/unord/unord.map/reserve.pass.cpp index 48667cdc7f92..bef237f960af 100644 --- a/test/std/containers/unord/unord.map/reserve.pass.cpp +++ b/test/std/containers/unord/unord.map/reserve.pass.cpp @@ -31,6 +31,21 @@ void test(const C& c) assert(c.at(4) == "four"); } +void reserve_invariant(size_t n) // LWG #2156 +{ + for (size_t i = 0; i < n; ++i) + { + std::unordered_map c; + c.reserve(n); + size_t buckets = c.bucket_count(); + for (size_t j = 0; j < i; ++j) + { + c[i] = i; + assert(buckets == c.bucket_count()); + } + } +} + int main() { { @@ -88,4 +103,5 @@ int main() test(c); } #endif + reserve_invariant(20); } diff --git a/test/std/containers/unord/unord.map/swap_member.pass.cpp b/test/std/containers/unord/unord.map/swap_member.pass.cpp index 8ab1eb6211b8..0f98b66aa401 100644 --- a/test/std/containers/unord/unord.map/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.map/swap_member.pass.cpp @@ -21,6 +21,7 @@ #include "../../test_compare.h" #include "../../test_hash.h" +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -31,7 +32,6 @@ int main() typedef test_compare > Compare; typedef test_allocator > Alloc; typedef std::unordered_map C; - typedef std::pair P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -212,7 +212,6 @@ int main() typedef test_compare > Compare; typedef other_allocator > Alloc; typedef std::unordered_map C; - typedef std::pair P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -387,13 +386,12 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash > Hash; typedef test_compare > Compare; typedef min_allocator > Alloc; typedef std::unordered_map C; - typedef std::pair P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp index 18e6683011c8..1420204c5f76 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp @@ -15,6 +15,8 @@ // unordered_map(unordered_map&& u); +// UNSUPPORTED: c++98, c++03 + #include #include #include @@ -27,23 +29,12 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map >, test_compare >, test_allocator > > C; - typedef std::pair P; - P a[] = - { - P(1, "one"), - P(2, "two"), - P(3, "three"), - P(4, "four"), - P(1, "four"), - P(2, "four"), - }; C c0(7, test_hash >(8), test_compare >(9), @@ -105,23 +96,12 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L { typedef std::unordered_map >, test_compare >, min_allocator > > C; - typedef std::pair P; - P a[] = - { - P(1, "one"), - P(2, "two"), - P(3, "three"), - P(4, "four"), - P(1, "four"), - P(2, "four"), - }; C c0(7, test_hash >(8), test_compare >(9), @@ -183,7 +163,6 @@ int main() assert(c0.empty()); } -#endif #if _LIBCPP_DEBUG >= 1 { std::unordered_map s1 = {{1, 1}, {2, 2}, {3, 3}}; @@ -195,5 +174,4 @@ int main() assert(s2.size() == 2); } #endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp index 5fd9f9d6114a..04ce91f69917 100644 --- a/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template , class Pred = equal_to, diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp similarity index 95% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp index dbb812974d46..803ecb5adfcb 100644 --- a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_const_iter.pass.cpp @@ -19,6 +19,7 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" struct TemplateConstructor @@ -46,13 +47,13 @@ int main() }; C c(a, a + sizeof(a)/sizeof(a[0])); C::const_iterator i = c.find(2); - C::iterator j = c.erase(i); + c.erase(i); assert(c.size() == 3); assert(c.at(1) == "one"); assert(c.at(3) == "three"); assert(c.at(4) == "four"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -68,14 +69,14 @@ int main() }; C c(a, a + sizeof(a)/sizeof(a[0])); C::const_iterator i = c.find(2); - C::iterator j = c.erase(i); + c.erase(i); assert(c.size() == 3); assert(c.at(1) == "one"); assert(c.at(3) == "three"); assert(c.at(4) == "four"); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db1.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_db2.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db1.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db2.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db3.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_iter_iter_db4.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp similarity index 97% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp index 0e8ef8b895a7..cdd19eb3459d 100644 --- a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_key.pass.cpp @@ -19,15 +19,16 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 template bool only_deletions ( const Unordered &whole, const Unordered &part ) { typename Unordered::const_iterator w = whole.begin(); typename Unordered::const_iterator p = part.begin(); - - while ( w != whole.end () && p != part.end()) { + + while ( w != whole.end () && p != part.end()) { if ( *w == *p ) p++; w++; @@ -96,7 +97,7 @@ int main() assert(c.erase(3) == 0); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -161,7 +162,7 @@ int main() m[i] = i; m2[i] = i; } - + C::iterator i = m2.begin(); int ctr = 0; while (i != m2.end()) { diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp similarity index 96% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp index 89929c856ec9..a4d8abc7d317 100644 --- a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_or_assign.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_or_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: c++03, c++11, c++14 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // @@ -22,12 +22,10 @@ // template // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 -#include <__config> #include #include #include -#include class Moveable { @@ -53,7 +51,7 @@ class Moveable bool operator<(const Moveable& x) const {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);} size_t hash () const { return std::hash()(int_) + std::hash()(double_); } - + int get() const {return int_;} bool moved() const {return int_ == -1;} }; @@ -66,8 +64,6 @@ namespace std { int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -#ifndef _LIBCPP_HAS_NO_VARIADICS { // pair insert_or_assign(const key_type& k, M&& obj); typedef std::unordered_map M; @@ -193,6 +189,4 @@ int main() assert(r->second.get() == 5); // value } -#endif // _LIBCPP_HAS_NO_VARIADICS -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } \ No newline at end of file diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp similarity index 100% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp diff --git a/test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp similarity index 97% rename from test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp rename to test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp index e6964ce947b5..eabcf2e85db2 100644 --- a/test/std/containers/unord/unord.map/unorder.map.modifiers/try.emplace.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: c++03, c++11, c++14 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // @@ -64,8 +64,6 @@ namespace std { int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -#ifndef _LIBCPP_HAS_NO_VARIADICS { // pair try_emplace(const key_type& k, Args&&... args); typedef std::unordered_map M; @@ -110,7 +108,7 @@ int main() assert(r.first->second.get() == -1); // value } - { // pair try_emplace(key_type&& k, Args&&... args); + { // pair try_emplace(key_type&& k, Args&&... args); typedef std::unordered_map M; typedef std::pair R; M m; @@ -146,7 +144,7 @@ int main() m.try_emplace ( i, Moveable(i, (double) i)); assert(m.size() == 10); M::const_iterator it = m.find(2); - + Moveable mv1(3, 3.0); for (int i=0; i < 20; i += 2) { @@ -189,7 +187,4 @@ int main() assert(r->first.get() == 3); // key assert(r->second.get() == 4); // value } - -#endif // _LIBCPP_HAS_NO_VARIADICS -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp index 7e04b8db117c..f3d51f6da275 100644 --- a/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp @@ -21,6 +21,7 @@ #include "../../../test_compare.h" #include "../../../test_hash.h" +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -31,7 +32,6 @@ int main() typedef test_compare > Compare; typedef test_allocator > Alloc; typedef std::unordered_map C; - typedef std::pair P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -212,7 +212,6 @@ int main() typedef test_compare > Compare; typedef other_allocator > Alloc; typedef std::unordered_map C; - typedef std::pair P; C c1(0, Hash(1), Compare(1), Alloc(1)); C c2(0, Hash(2), Compare(2), Alloc(2)); c2.max_load_factor(2); @@ -387,13 +386,12 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash > Hash; typedef test_compare > Compare; typedef min_allocator > Alloc; typedef std::unordered_map C; - typedef std::pair P; C c1(0, Hash(1), Compare(1), Alloc()); C c2(0, Hash(2), Compare(2), Alloc()); c2.max_load_factor(2); diff --git a/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..3c740950d04e --- /dev/null +++ b/test/std/containers/unord/unord.multimap/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_multimap, std::less, std::allocator > m; +} diff --git a/test/std/containers/unord/unord.multimap/rehash.pass.cpp b/test/std/containers/unord/unord.multimap/rehash.pass.cpp index 1d99208596c1..d36dc42e262d 100644 --- a/test/std/containers/unord/unord.multimap/rehash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/rehash.pass.cpp @@ -22,6 +22,12 @@ #include "min_allocator.h" +template +void rehash_postcondition(const C& c, size_t n) +{ + assert(c.bucket_count() >= c.size() / c.max_load_factor() && c.bucket_count() >= n); +} + template void test(const C& c) { @@ -77,13 +83,16 @@ int main() test(c); assert(c.bucket_count() >= 7); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 7); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } @@ -105,13 +114,16 @@ int main() test(c); assert(c.bucket_count() >= 7); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 7); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } diff --git a/test/std/containers/unord/unord.multimap/reserve.pass.cpp b/test/std/containers/unord/unord.multimap/reserve.pass.cpp index 801c74457d74..388b1f67e450 100644 --- a/test/std/containers/unord/unord.multimap/reserve.pass.cpp +++ b/test/std/containers/unord/unord.multimap/reserve.pass.cpp @@ -33,6 +33,21 @@ void test(const C& c) assert(c.find(4)->second == "four"); } +void reserve_invariant(size_t n) // LWG #2156 +{ + for (size_t i = 0; i < n; ++i) + { + std::unordered_multimap c; + c.reserve(n); + size_t buckets = c.bucket_count(); + for (size_t j = 0; j < i; ++j) + { + c.insert(std::unordered_multimap::value_type(i,i)); + assert(buckets == c.bucket_count()); + } + } +} + int main() { { @@ -90,4 +105,5 @@ int main() test(c); } #endif + reserve_invariant(20); } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp index 37c8119060b7..7c912e01d572 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -116,7 +116,7 @@ struct some_alloc3 int main() { #if __has_feature(cxx_noexcept) - typedef std::pair MapType; + typedef std::pair V; { typedef std::unordered_multimap C; C c1, c2; @@ -124,13 +124,13 @@ int main() } { typedef std::unordered_multimap, - std::equal_to, test_allocator> C; + std::equal_to, test_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } { typedef std::unordered_multimap, - std::equal_to, other_allocator> C; + std::equal_to, other_allocator> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } @@ -148,47 +148,47 @@ int main() #if TEST_STD_VER >= 14 { // POCS allocator, throwable swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc > C; + typedef std::unordered_multimap, some_comp , some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc2> C; + typedef std::unordered_multimap, some_comp , some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, throwable swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc > C; + typedef std::unordered_multimap, some_comp2, some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, throwable swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc2> C; + typedef std::unordered_multimap, some_comp2, some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc > C; + typedef std::unordered_multimap, some_comp , some_alloc > C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for hash, throwable swap for comp - typedef std::unordered_multimap, some_comp , some_alloc2> C; + typedef std::unordered_multimap, some_comp , some_alloc2> C; C c1, c2; static_assert(!noexcept(swap(c1, c2)), ""); } { // POCS allocator, nothrow swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc > C; + typedef std::unordered_multimap, some_comp2, some_alloc > C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // always equal allocator, nothrow swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc2> C; + typedef std::unordered_multimap, some_comp2, some_alloc2> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } { // NOT always equal allocator, nothrow swap for hash, nothrow swap for comp - typedef std::unordered_multimap, some_comp2, some_alloc3> C; + typedef std::unordered_multimap, some_comp2, some_alloc3> C; C c1, c2; static_assert( noexcept(swap(c1, c2)), ""); } diff --git a/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..5836cb366159 --- /dev/null +++ b/test/std/containers/unord/unord.multiset/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_multiset, std::less, std::allocator > v; +} diff --git a/test/std/containers/unord/unord.multiset/rehash.pass.cpp b/test/std/containers/unord/unord.multiset/rehash.pass.cpp index bc8d461c60bf..5c7c6aa8aad3 100644 --- a/test/std/containers/unord/unord.multiset/rehash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/rehash.pass.cpp @@ -20,6 +20,12 @@ #include "min_allocator.h" +template +void rehash_postcondition(const C& c, size_t n) +{ + assert(c.bucket_count() >= c.size() / c.max_load_factor() && c.bucket_count() >= n); +} + template void test(const C& c) { @@ -48,13 +54,16 @@ int main() test(c); assert(c.bucket_count() >= 7); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 7); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } @@ -76,13 +85,16 @@ int main() test(c); assert(c.bucket_count() >= 7); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 7); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } diff --git a/test/std/containers/unord/unord.multiset/reserve.pass.cpp b/test/std/containers/unord/unord.multiset/reserve.pass.cpp index 0c17583d371d..1d393a09cde2 100644 --- a/test/std/containers/unord/unord.multiset/reserve.pass.cpp +++ b/test/std/containers/unord/unord.multiset/reserve.pass.cpp @@ -30,6 +30,21 @@ void test(const C& c) assert(c.count(4) == 1); } +void reserve_invariant(size_t n) // LWG #2156 +{ + for (size_t i = 0; i < n; ++i) + { + std::unordered_multiset c; + c.reserve(n); + size_t buckets = c.bucket_count(); + for (size_t j = 0; j < i; ++j) + { + c.insert(i); + assert(buckets == c.bucket_count()); + } + } +} + int main() { { @@ -87,4 +102,5 @@ int main() test(c); } #endif + reserve_invariant(20); } diff --git a/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp b/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..b87c9a24d3a5 --- /dev/null +++ b/test/std/containers/unord/unord.set/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::unordered_set, std::less, std::allocator > v; +} diff --git a/test/std/containers/unord/unord.set/rehash.pass.cpp b/test/std/containers/unord/unord.set/rehash.pass.cpp index 30fffa561f78..e28c25dc8197 100644 --- a/test/std/containers/unord/unord.set/rehash.pass.cpp +++ b/test/std/containers/unord/unord.set/rehash.pass.cpp @@ -20,6 +20,12 @@ #include "min_allocator.h" +template +void rehash_postcondition(const C& c, size_t n) +{ + assert(c.bucket_count() >= c.size() / c.max_load_factor() && c.bucket_count() >= n); +} + template void test(const C& c) { @@ -48,13 +54,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } @@ -76,13 +85,16 @@ int main() test(c); assert(c.bucket_count() >= 5); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 5); test(c); c.max_load_factor(2); c.rehash(3); + rehash_postcondition(c, 3); assert(c.bucket_count() == 3); test(c); c.rehash(31); + rehash_postcondition(c, 31); assert(c.bucket_count() == 31); test(c); } diff --git a/test/std/containers/unord/unord.set/reserve.pass.cpp b/test/std/containers/unord/unord.set/reserve.pass.cpp index 7d6656a18674..078b886b267e 100644 --- a/test/std/containers/unord/unord.set/reserve.pass.cpp +++ b/test/std/containers/unord/unord.set/reserve.pass.cpp @@ -30,6 +30,21 @@ void test(const C& c) assert(c.count(4) == 1); } +void reserve_invariant(size_t n) // LWG #2156 +{ + for (size_t i = 0; i < n; ++i) + { + std::unordered_set c; + c.reserve(n); + size_t buckets = c.bucket_count(); + for (size_t j = 0; j < i; ++j) + { + c.insert(i); + assert(buckets == c.bucket_count()); + } + } +} + int main() { { @@ -87,4 +102,5 @@ int main() test(c); } #endif + reserve_invariant(20); } diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp index f61a28e84d4c..a5db81e6c632 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/auto.ptr.conv/convert_to_auto_ptr_ref.pass.cpp @@ -24,6 +24,10 @@ test() B* p1 = new B(1); std::auto_ptr ap1(p1); std::auto_ptr_ref apr = ap1; + std::auto_ptr ap2(apr); + assert(ap1.get() == nullptr); + assert(ap2.get() == p1); + ap2.release(); delete p1; } diff --git a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp index 2d1c2af8062d..256563439a17 100644 --- a/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp +++ b/test/std/depr/depr.auto.ptr/auto.ptr/element_type.pass.cpp @@ -25,6 +25,8 @@ void test() { static_assert((std::is_same::element_type, T>::value), ""); + std::auto_ptr p; + ((void)p); } int main() @@ -32,5 +34,4 @@ int main() test(); test(); test(); - std::auto_ptr p; } diff --git a/test/std/depr/depr.c.headers/extern_c.pass.cpp b/test/std/depr/depr.c.headers/extern_c.pass.cpp new file mode 100644 index 000000000000..d4d8b5fafdde --- /dev/null +++ b/test/std/depr/depr.c.headers/extern_c.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// Sometimes C++'s headers get included within extern "C" contexts. This +// is ill-formed (no diagnostic required), per [using.headers]p3, but we permit +// it as an extension. + +extern "C" { +#include +// complex.h is not supported in extern "C". +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +// tgmath.h is not supported in extern "C". +#include +// FIXME: #include +#include +#include +} + +int main() {} diff --git a/test/std/depr/depr.c.headers/inttypes_h.pass.cpp b/test/std/depr/depr.c.headers/inttypes_h.pass.cpp index 4adf82da95ec..637cf72287b8 100644 --- a/test/std/depr/depr.c.headers/inttypes_h.pass.cpp +++ b/test/std/depr/depr.c.headers/inttypes_h.pass.cpp @@ -12,6 +12,250 @@ #include #include +#ifndef INT8_MIN +#error INT8_MIN not defined +#endif + +#ifndef INT16_MIN +#error INT16_MIN not defined +#endif + +#ifndef INT32_MIN +#error INT32_MIN not defined +#endif + +#ifndef INT64_MIN +#error INT64_MIN not defined +#endif + +#ifndef INT8_MAX +#error INT8_MAX not defined +#endif + +#ifndef INT16_MAX +#error INT16_MAX not defined +#endif + +#ifndef INT32_MAX +#error INT32_MAX not defined +#endif + +#ifndef INT64_MAX +#error INT64_MAX not defined +#endif + +#ifndef UINT8_MAX +#error UINT8_MAX not defined +#endif + +#ifndef UINT16_MAX +#error UINT16_MAX not defined +#endif + +#ifndef UINT32_MAX +#error UINT32_MAX not defined +#endif + +#ifndef UINT64_MAX +#error UINT64_MAX not defined +#endif + +#ifndef INT_LEAST8_MIN +#error INT_LEAST8_MIN not defined +#endif + +#ifndef INT_LEAST16_MIN +#error INT_LEAST16_MIN not defined +#endif + +#ifndef INT_LEAST32_MIN +#error INT_LEAST32_MIN not defined +#endif + +#ifndef INT_LEAST64_MIN +#error INT_LEAST64_MIN not defined +#endif + +#ifndef INT_LEAST8_MAX +#error INT_LEAST8_MAX not defined +#endif + +#ifndef INT_LEAST16_MAX +#error INT_LEAST16_MAX not defined +#endif + +#ifndef INT_LEAST32_MAX +#error INT_LEAST32_MAX not defined +#endif + +#ifndef INT_LEAST64_MAX +#error INT_LEAST64_MAX not defined +#endif + +#ifndef UINT_LEAST8_MAX +#error UINT_LEAST8_MAX not defined +#endif + +#ifndef UINT_LEAST16_MAX +#error UINT_LEAST16_MAX not defined +#endif + +#ifndef UINT_LEAST32_MAX +#error UINT_LEAST32_MAX not defined +#endif + +#ifndef UINT_LEAST64_MAX +#error UINT_LEAST64_MAX not defined +#endif + +#ifndef INT_FAST8_MIN +#error INT_FAST8_MIN not defined +#endif + +#ifndef INT_FAST16_MIN +#error INT_FAST16_MIN not defined +#endif + +#ifndef INT_FAST32_MIN +#error INT_FAST32_MIN not defined +#endif + +#ifndef INT_FAST64_MIN +#error INT_FAST64_MIN not defined +#endif + +#ifndef INT_FAST8_MAX +#error INT_FAST8_MAX not defined +#endif + +#ifndef INT_FAST16_MAX +#error INT_FAST16_MAX not defined +#endif + +#ifndef INT_FAST32_MAX +#error INT_FAST32_MAX not defined +#endif + +#ifndef INT_FAST64_MAX +#error INT_FAST64_MAX not defined +#endif + +#ifndef UINT_FAST8_MAX +#error UINT_FAST8_MAX not defined +#endif + +#ifndef UINT_FAST16_MAX +#error UINT_FAST16_MAX not defined +#endif + +#ifndef UINT_FAST32_MAX +#error UINT_FAST32_MAX not defined +#endif + +#ifndef UINT_FAST64_MAX +#error UINT_FAST64_MAX not defined +#endif + +#ifndef INTPTR_MIN +#error INTPTR_MIN not defined +#endif + +#ifndef INTPTR_MAX +#error INTPTR_MAX not defined +#endif + +#ifndef UINTPTR_MAX +#error UINTPTR_MAX not defined +#endif + +#ifndef INTMAX_MIN +#error INTMAX_MIN not defined +#endif + +#ifndef INTMAX_MAX +#error INTMAX_MAX not defined +#endif + +#ifndef UINTMAX_MAX +#error UINTMAX_MAX not defined +#endif + +#ifndef PTRDIFF_MIN +#error PTRDIFF_MIN not defined +#endif + +#ifndef PTRDIFF_MAX +#error PTRDIFF_MAX not defined +#endif + +#ifndef SIG_ATOMIC_MIN +#error SIG_ATOMIC_MIN not defined +#endif + +#ifndef SIG_ATOMIC_MAX +#error SIG_ATOMIC_MAX not defined +#endif + +#ifndef SIZE_MAX +#error SIZE_MAX not defined +#endif + +#ifndef WCHAR_MIN +#error WCHAR_MIN not defined +#endif + +#ifndef WCHAR_MAX +#error WCHAR_MAX not defined +#endif + +#ifndef WINT_MIN +#error WINT_MIN not defined +#endif + +#ifndef WINT_MAX +#error WINT_MAX not defined +#endif + +#ifndef INT8_C +#error INT8_C not defined +#endif + +#ifndef INT16_C +#error INT16_C not defined +#endif + +#ifndef INT32_C +#error INT32_C not defined +#endif + +#ifndef INT64_C +#error INT64_C not defined +#endif + +#ifndef UINT8_C +#error UINT8_C not defined +#endif + +#ifndef UINT16_C +#error UINT16_C not defined +#endif + +#ifndef UINT32_C +#error UINT32_C not defined +#endif + +#ifndef UINT64_C +#error UINT64_C not defined +#endif + +#ifndef INTMAX_C +#error INTMAX_C not defined +#endif + +#ifndef UINTMAX_C +#error UINTMAX_C not defined +#endif + #ifndef PRId8 #error PRId8 not defined #endif @@ -630,6 +874,48 @@ int main() { + { + int8_t i1 = 0; + int16_t i2 = 0; + int32_t i3 = 0; + int64_t i4 = 0; + } + { + uint8_t i1 = 0; + uint16_t i2 = 0; + uint32_t i3 = 0; + uint64_t i4 = 0; + } + { + int_least8_t i1 = 0; + int_least16_t i2 = 0; + int_least32_t i3 = 0; + int_least64_t i4 = 0; + } + { + uint_least8_t i1 = 0; + uint_least16_t i2 = 0; + uint_least32_t i3 = 0; + uint_least64_t i4 = 0; + } + { + int_fast8_t i1 = 0; + int_fast16_t i2 = 0; + int_fast32_t i3 = 0; + int_fast64_t i4 = 0; + } + { + uint_fast8_t i1 = 0; + uint_fast16_t i2 = 0; + uint_fast32_t i3 = 0; + uint_fast64_t i4 = 0; + } + { + intptr_t i1 = 0; + uintptr_t i2 = 0; + intmax_t i3 = 0; + uintmax_t i4 = 0; + } { imaxdiv_t i1 = {0}; } diff --git a/test/std/depr/depr.c.headers/locale_h.pass.cpp b/test/std/depr/depr.c.headers/locale_h.pass.cpp index 6ecf5a82e8dd..f5735b6ea19d 100644 --- a/test/std/depr/depr.c.headers/locale_h.pass.cpp +++ b/test/std/depr/depr.c.headers/locale_h.pass.cpp @@ -42,7 +42,7 @@ int main() { - lconv lc; + lconv lc; ((void)lc); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); } diff --git a/test/std/depr/depr.c.headers/math_h.pass.cpp b/test/std/depr/depr.c.headers/math_h.pass.cpp index b03a61b15e11..ed12fcf73a8c 100644 --- a/test/std/depr/depr.c.headers/math_h.pass.cpp +++ b/test/std/depr/depr.c.headers/math_h.pass.cpp @@ -9,7 +9,8 @@ // -// XFAIL: linux +// NOTE: isinf and isnan are tested separately because they are expected to fail +// on linux. We don't want their expected failure to hide other failures in this file. #include #include @@ -17,498 +18,1168 @@ #include "hexfloat.h" +// convertible to int/float/double/etc +template +struct Value { + operator T () { return T(N); } +}; + +// See PR21083 +// Ambiguous is a user-defined type that defines its own overloads of cmath +// functions. When the std overloads are candidates too (by using or adl), +// they should not interfere. +struct Ambiguous : std::true_type { // ADL + operator float () { return 0.f; } + operator double () { return 0.; } +}; +Ambiguous abs(Ambiguous){ return Ambiguous(); } +Ambiguous acos(Ambiguous){ return Ambiguous(); } +Ambiguous asin(Ambiguous){ return Ambiguous(); } +Ambiguous atan(Ambiguous){ return Ambiguous(); } +Ambiguous atan2(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous ceil(Ambiguous){ return Ambiguous(); } +Ambiguous cos(Ambiguous){ return Ambiguous(); } +Ambiguous cosh(Ambiguous){ return Ambiguous(); } +Ambiguous exp(Ambiguous){ return Ambiguous(); } +Ambiguous fabs(Ambiguous){ return Ambiguous(); } +Ambiguous floor(Ambiguous){ return Ambiguous(); } +Ambiguous fmod(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous frexp(Ambiguous, int*){ return Ambiguous(); } +Ambiguous ldexp(Ambiguous, int){ return Ambiguous(); } +Ambiguous log(Ambiguous){ return Ambiguous(); } +Ambiguous log10(Ambiguous){ return Ambiguous(); } +Ambiguous modf(Ambiguous, Ambiguous*){ return Ambiguous(); } +Ambiguous pow(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous sin(Ambiguous){ return Ambiguous(); } +Ambiguous sinh(Ambiguous){ return Ambiguous(); } +Ambiguous sqrt(Ambiguous){ return Ambiguous(); } +Ambiguous tan(Ambiguous){ return Ambiguous(); } +Ambiguous tanh(Ambiguous){ return Ambiguous(); } +Ambiguous signbit(Ambiguous){ return Ambiguous(); } +Ambiguous fpclassify(Ambiguous){ return Ambiguous(); } +Ambiguous isfinite(Ambiguous){ return Ambiguous(); } +Ambiguous isnormal(Ambiguous){ return Ambiguous(); } +Ambiguous isgreater(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous isgreaterequal(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous isless(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous islessequal(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous islessgreater(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous isunordered(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous acosh(Ambiguous){ return Ambiguous(); } +Ambiguous asinh(Ambiguous){ return Ambiguous(); } +Ambiguous atanh(Ambiguous){ return Ambiguous(); } +Ambiguous cbrt(Ambiguous){ return Ambiguous(); } +Ambiguous copysign(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous erf(Ambiguous){ return Ambiguous(); } +Ambiguous erfc(Ambiguous){ return Ambiguous(); } +Ambiguous exp2(Ambiguous){ return Ambiguous(); } +Ambiguous expm1(Ambiguous){ return Ambiguous(); } +Ambiguous fdim(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous fma(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous fmax(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous fmin(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous hypot(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous ilogb(Ambiguous){ return Ambiguous(); } +Ambiguous lgamma(Ambiguous){ return Ambiguous(); } +Ambiguous llrint(Ambiguous){ return Ambiguous(); } +Ambiguous llround(Ambiguous){ return Ambiguous(); } +Ambiguous log1p(Ambiguous){ return Ambiguous(); } +Ambiguous log2(Ambiguous){ return Ambiguous(); } +Ambiguous logb(Ambiguous){ return Ambiguous(); } +Ambiguous lrint(Ambiguous){ return Ambiguous(); } +Ambiguous lround(Ambiguous){ return Ambiguous(); } +Ambiguous nearbyint(Ambiguous){ return Ambiguous(); } +Ambiguous nextafter(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous nexttoward(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous remainder(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous remquo(Ambiguous, Ambiguous, int*){ return Ambiguous(); } +Ambiguous rint(Ambiguous){ return Ambiguous(); } +Ambiguous round(Ambiguous){ return Ambiguous(); } +Ambiguous scalbln(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous scalbn(Ambiguous, Ambiguous){ return Ambiguous(); } +Ambiguous tgamma(Ambiguous){ return Ambiguous(); } +Ambiguous trunc(Ambiguous){ return Ambiguous(); } + +void test_abs() +{ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(abs(-1.) == 1); +} + void test_acos() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(acos(1) == 0); } void test_asin() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(asin(0) == 0); } void test_atan() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(atan(0) == 0); } void test_atan2() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(atan2(0,1) == 0); } void test_ceil() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(ceil(0) == 0); } void test_cos() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(cos(0) == 1); } void test_cosh() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(cosh(0) == 1); } void test_exp() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(exp(0) == 1); } void test_fabs() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - assert(fabs(-1.f) == 1); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(fabs(-1) == 1); } void test_floor() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(floor(1) == 1); } void test_fmod() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(fmod(1.5,1) == .5); } void test_frexp() { int ip; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(frexp(0, &ip) == 0); } void test_ldexp() { int ip = 1; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(ldexp(1, ip) == 2); } void test_log() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(log(1) == 0); } void test_log10() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(log10(1) == 0); } void test_modf() { + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); double i; assert(modf(1., &i) == 0); } void test_pow() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +// static_assert((std::is_same(), (int)0)), double>::value), ""); +// static_assert((std::is_same(), (float)0)), long double>::value), ""); +// static_assert((std::is_same())), float>::value), ""); + static_assert((std::is_same::value), ""); assert(pow(1,1) == 1); +// assert(pow(Value(), Value()) == 1); +// assert(pow(1.0f, Value()) == 1); +// assert(pow(1.0, Value()) == 1); +// assert(pow(Value(), 1LL) == 1); } void test_sin() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(sin(0) == 0); } void test_sinh() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(sinh(0) == 0); } void test_sqrt() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(sqrt(4) == 2); } void test_tan() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(tan(0) == 0); } void test_tanh() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(tanh(0) == 0); } void test_signbit() { +#ifdef signbit +#error signbit defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(signbit(-1.0) == true); } void test_fpclassify() { +#ifdef fpclassify +#error fpclassify defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(fpclassify(-1.0) == FP_NORMAL); } void test_isfinite() { +#ifdef isfinite +#error isfinite defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isfinite(-1.0) == true); } -void test_isinf() -{ - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - assert(isinf(-1.0) == false); -} - -void test_isnan() -{ - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - assert(isnan(-1.0) == false); -} - void test_isnormal() { +#ifdef isnormal +#error isnormal defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isnormal(-1.0) == true); } void test_isgreater() { +#ifdef isgreater +#error isgreater defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isgreater(-1.0, 0.F) == false); } void test_isgreaterequal() { +#ifdef isgreaterequal +#error isgreaterequal defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isgreaterequal(-1.0, 0.F) == false); } void test_isless() { +#ifdef isless +#error isless defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isless(-1.0, 0.F) == true); } void test_islessequal() { +#ifdef islessequal +#error islessequal defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(islessequal(-1.0, 0.F) == true); } void test_islessgreater() { +#ifdef islessgreater +#error islessgreater defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(islessgreater(-1.0, 0.F) == true); } void test_isunordered() { +#ifdef isunordered +#error isunordered defined +#endif static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(isunordered(-1.0, 0.F) == false); } void test_acosh() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(acosh(1) == 0); } void test_asinh() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(asinh(0) == 0); } void test_atanh() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(atanh(0) == 0); } void test_cbrt() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(cbrt(1) == 1); } void test_copysign() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(copysign(1,1) == 1); } void test_erf() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(erf(0) == 0); } void test_erfc() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(erfc(0) == 1); } void test_exp2() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(exp2(1) == 2); } void test_expm1() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(expm1(0) == 0); } void test_fdim() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(fdim(1,0) == 1); } void test_fma() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(fma(1,1,1) == 2); } void test_fmax() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(fmax(1,0) == 1); } void test_fmin() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(fmin(1,0) == 0); } void test_hypot() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(hypot(3,4) == 5); } void test_ilogb() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(ilogb(1) == 0); } void test_lgamma() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(lgamma(1) == 0); } void test_llrint() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(llrint(1) == 1LL); } void test_llround() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(llround(1) == 1LL); } void test_log1p() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(log1p(0) == 0); } void test_log2() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(log2(1) == 0); } void test_logb() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(logb(1) == 0); } void test_lrint() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(lrint(1) == 1L); } void test_lround() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(lround(1) == 1L); } @@ -521,96 +1192,229 @@ void test_nan() void test_nearbyint() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(nearbyint(1) == 1); } void test_nextafter() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(nextafter(0,1) == hexfloat(0x1, 0, -1074)); } void test_nexttoward() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(nexttoward(0, 1) == hexfloat(0x1, 0, -1074)); } void test_remainder() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(remainder(0.5,1) == 0.5); } void test_remquo() { int ip; + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(remquo(0.5,1, &ip) == 0.5); } void test_rint() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(rint(1) == 1); } void test_round() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(round(1) == 1); } void test_scalbln() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(scalbln(1, 1) == 2); } void test_scalbn() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(scalbn(1, 1) == 2); } void test_tgamma() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(tgamma(1) == 1); } void test_trunc() { + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); assert(trunc(1) == 1); } int main() { + test_abs(); test_acos(); test_asin(); test_atan(); @@ -636,8 +1440,6 @@ int main() test_signbit(); test_fpclassify(); test_isfinite(); - test_isinf(); - test_isnan(); test_isnormal(); test_isgreater(); test_isgreaterequal(); diff --git a/test/std/depr/depr.c.headers/math_h_isinf.pass.cpp b/test/std/depr/depr.c.headers/math_h_isinf.pass.cpp new file mode 100644 index 000000000000..cc7eaac7de62 --- /dev/null +++ b/test/std/depr/depr.c.headers/math_h_isinf.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// isinf + +// XFAIL: linux + +#include +#include +#include + +int main() +{ +#ifdef isinf +#error isinf defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isinf(-1.0) == false); +} diff --git a/test/std/depr/depr.c.headers/math_h_isnan.pass.cpp b/test/std/depr/depr.c.headers/math_h_isnan.pass.cpp new file mode 100644 index 000000000000..118f96bdd434 --- /dev/null +++ b/test/std/depr/depr.c.headers/math_h_isnan.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// isnan + +// XFAIL: linux + +#include +#include +#include + +int main() +{ +#ifdef isnan +#error isnan defined +#endif + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + assert(isnan(-1.0) == false); +} diff --git a/test/std/depr/depr.c.headers/setjmp_h.pass.cpp b/test/std/depr/depr.c.headers/setjmp_h.pass.cpp index 36f425390694..9bc35b747493 100644 --- a/test/std/depr/depr.c.headers/setjmp_h.pass.cpp +++ b/test/std/depr/depr.c.headers/setjmp_h.pass.cpp @@ -12,6 +12,10 @@ #include #include +#ifndef setjmp +#error setjmp not defined +#endif + int main() { jmp_buf jb; diff --git a/test/std/depr/depr.c.headers/signal_h.pass.cpp b/test/std/depr/depr.c.headers/signal_h.pass.cpp index a8ef5f993fe6..83f45c9b142e 100644 --- a/test/std/depr/depr.c.headers/signal_h.pass.cpp +++ b/test/std/depr/depr.c.headers/signal_h.pass.cpp @@ -50,7 +50,7 @@ int main() { - sig_atomic_t sig; + sig_atomic_t sig; ((void)sig); typedef void (*func)(int); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/test/std/depr/depr.c.headers/stdarg_h.pass.cpp b/test/std/depr/depr.c.headers/stdarg_h.pass.cpp index 7a60902529ea..f7d12b1ad551 100644 --- a/test/std/depr/depr.c.headers/stdarg_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdarg_h.pass.cpp @@ -32,4 +32,5 @@ int main() { va_list va; + ((void)va); } diff --git a/test/std/depr/depr.c.headers/stddef_h.pass.cpp b/test/std/depr/depr.c.headers/stddef_h.pass.cpp index 140c91b53e6e..0c08c782a3e4 100644 --- a/test/std/depr/depr.c.headers/stddef_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stddef_h.pass.cpp @@ -10,6 +10,7 @@ // #include +#include #include #ifndef NULL @@ -22,6 +23,9 @@ int main() { + void *p = NULL; + assert(!p); + static_assert(sizeof(size_t) == sizeof(void*), "sizeof(size_t) == sizeof(void*)"); static_assert(std::is_unsigned::value, @@ -34,4 +38,22 @@ int main() "std::is_signed::value"); static_assert(std::is_integral::value, "std::is_integral::value"); + static_assert((std::is_same::value), + "decltype(nullptr) == nullptr_t"); + static_assert(sizeof(nullptr_t) == sizeof(void*), + "sizeof(nullptr_t) == sizeof(void*)"); + static_assert(std::is_pod::value, + "std::is_pod::value"); + static_assert((std::alignment_of::value >= + std::alignment_of::value), + "std::alignment_of::value >= " + "std::alignment_of::value"); + static_assert(std::alignment_of::value >= + std::alignment_of::value, + "std::alignment_of::value >= " + "std::alignment_of::value"); + static_assert(std::alignment_of::value >= + std::alignment_of::value, + "std::alignment_of::value >= " + "std::alignment_of::value"); } diff --git a/test/std/depr/depr.c.headers/stdint_h.pass.cpp b/test/std/depr/depr.c.headers/stdint_h.pass.cpp index 3861ee509753..92bb04e558bb 100644 --- a/test/std/depr/depr.c.headers/stdint_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdint_h.pass.cpp @@ -223,10 +223,10 @@ int main() assert(UINTMAX_MAX == std::numeric_limits::max()); // PTRDIFF_MIN - assert(PTRDIFF_MIN == std::numeric_limits::min()); + assert(PTRDIFF_MIN == std::numeric_limits::min()); // PTRDIFF_MAX - assert(PTRDIFF_MAX == std::numeric_limits::max()); + assert(PTRDIFF_MAX == std::numeric_limits::max()); // SIG_ATOMIC_MIN assert(SIG_ATOMIC_MIN == std::numeric_limits::min()); diff --git a/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/test/std/depr/depr.c.headers/stdio_h.pass.cpp index d4cfbc80a5ce..3c5dd0ebf0e0 100644 --- a/test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -11,6 +11,27 @@ #include #include +#include "test_macros.h" + +#ifdef getc +#error getc is defined +#endif + +#ifdef putc +#error putc is defined +#endif + +#ifdef clearerr +#error clearerr is defined +#endif + +#ifdef feof +#error feof is defined +#endif + +#ifdef ferror +#error ferror is defined +#endif #ifndef BUFSIZ #error BUFSIZ not defined @@ -78,14 +99,16 @@ #include -#pragma clang diagnostic ignored "-Wformat-zero-length" +#pragma GCC diagnostic ignored "-Wformat-zero-length" +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // for tmpnam int main() { FILE* fp = 0; fpos_t fpos = {0}; - size_t s = 0; + size_t s = 0; ((void)s); char* cp = 0; + char arr[] = {'a', 'b'}; va_list va; static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); @@ -117,7 +140,7 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); -#if _LIBCPP_STD_VER < 14 +#if TEST_STD_VER < 14 static_assert((std::is_same::value), ""); #endif static_assert((std::is_same::value), ""); @@ -125,7 +148,7 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/test/std/depr/depr.c.headers/stdlib_h.pass.cpp b/test/std/depr/depr.c.headers/stdlib_h.pass.cpp index 47e1527fb175..96d1143d4de6 100644 --- a/test/std/depr/depr.c.headers/stdlib_h.pass.cpp +++ b/test/std/depr/depr.c.headers/stdlib_h.pass.cpp @@ -12,6 +12,36 @@ #include #include +// As of 1/10/2015 clang emits a -Wnonnull warnings even if the warning occurs +// in an unevaluated context. For this reason we manually suppress the warning. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnonnull" +#endif + +#ifdef abs +#error abs is defined +#endif + +#ifdef labs +#error labs is defined +#endif + +#ifdef llabs +#error llabs is defined +#endif + +#ifdef div +#error div is defined +#endif + +#ifdef ldiv +#error ldiv is defined +#endif + +#ifdef lldiv +#error lldiv is defined +#endif + #ifndef EXIT_FAILURE #error EXIT_FAILURE not defined #endif @@ -34,10 +64,10 @@ int main() { - size_t s = 0; - div_t d; - ldiv_t ld; - lldiv_t lld; + size_t s = 0; ((void)s); + div_t d; ((void)d); + ldiv_t ld; ((void)ld); + lldiv_t lld; ((void)lld); char** endptr = 0; static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/test/std/depr/depr.c.headers/time_h.pass.cpp b/test/std/depr/depr.c.headers/time_h.pass.cpp index c468693ccb26..0d229af409bd 100644 --- a/test/std/depr/depr.c.headers/time_h.pass.cpp +++ b/test/std/depr/depr.c.headers/time_h.pass.cpp @@ -22,7 +22,7 @@ int main() { - clock_t c = 0; + clock_t c = 0; ((void)c); size_t s = 0; time_t t = 0; tm tmv = {0}; diff --git a/test/std/depr/depr.c.headers/wchar_h.pass.cpp b/test/std/depr/depr.c.headers/wchar_h.pass.cpp index 68bea49cfe03..e561b3e5a724 100644 --- a/test/std/depr/depr.c.headers/wchar_h.pass.cpp +++ b/test/std/depr/depr.c.headers/wchar_h.pass.cpp @@ -9,6 +9,7 @@ // + #include #include @@ -30,7 +31,15 @@ int main() { +// mbstate_t comes from the underlying C library; it is defined (in C99) as: +// a complete object type other than an array type that can hold the conversion +// state information necessary to convert between sequences of multibyte +// characters and wide characters +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wmissing-braces" mbstate_t mb = {0}; +#pragma clang diagnostic pop + size_t s = 0; tm *tm = 0; wint_t w = 0; @@ -50,19 +59,13 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); @@ -79,14 +82,19 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + // const wchar_t* wcschr((const wchar_t*)0, L' ') - See below static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + // const wchar_t* wcspbrk((const wchar_t*)0, L"") - See below static_assert((std::is_same::value), ""); + // const wchar_t* wcsrchr((const wchar_t*)0, L' ') - See below static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + // const wchar_t* wcsstr((const wchar_t*)0, L"") - See below static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + // const wchar_t* wmemchr((const wchar_t*)0, L' ', s) - See below static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); @@ -101,4 +109,27 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); + +// This test fails on systems whose C library doesn't provide a correct overload +// set for wcschr, wcspbrk, wcsrchr, wcsstr, and wmemchr. There's no way for +// libc++ to fix that on the C library's behalf. +#ifndef __APPLE__ + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDIN + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); +#endif } diff --git a/test/std/depr/depr.ios.members/io_state.pass.cpp b/test/std/depr/depr.ios.members/io_state.pass.cpp index 15bfbf197802..6b362d016036 100644 --- a/test/std/depr/depr.ios.members/io_state.pass.cpp +++ b/test/std/depr/depr.ios.members/io_state.pass.cpp @@ -15,11 +15,16 @@ // typedef T1 io_state; // }; +// These members were removed for C++17 + +#include "test_macros.h" #include #include int main() { +#if TEST_STD_VER <= 14 std::strstream::io_state b = std::strstream::eofbit; assert(b == std::ios::eofbit); +#endif } diff --git a/test/std/depr/depr.ios.members/open_mode.pass.cpp b/test/std/depr/depr.ios.members/open_mode.pass.cpp index 12a8e9458809..cf91e7c9d1d5 100644 --- a/test/std/depr/depr.ios.members/open_mode.pass.cpp +++ b/test/std/depr/depr.ios.members/open_mode.pass.cpp @@ -15,11 +15,16 @@ // typedef T2 open_mode; // }; +// These members were removed for C++17 + +#include "test_macros.h" #include #include int main() { +#if TEST_STD_VER <= 14 std::strstream::open_mode b = std::strstream::app; assert(b == std::ios::app); +#endif } diff --git a/test/std/depr/depr.ios.members/seek_dir.pass.cpp b/test/std/depr/depr.ios.members/seek_dir.pass.cpp index 891a7a345638..0dd70c101858 100644 --- a/test/std/depr/depr.ios.members/seek_dir.pass.cpp +++ b/test/std/depr/depr.ios.members/seek_dir.pass.cpp @@ -15,11 +15,16 @@ // typedef T3 seek_dir; // }; +// These members were removed for C++17 + +#include "test_macros.h" #include #include int main() { +#if TEST_STD_VER <= 14 std::strstream::seek_dir b = std::strstream::cur; assert(b == std::ios::cur); +#endif } diff --git a/test/std/depr/depr.ios.members/streamoff.pass.cpp b/test/std/depr/depr.ios.members/streamoff.pass.cpp index 4ccfd1f7d225..0c237b3547d6 100644 --- a/test/std/depr/depr.ios.members/streamoff.pass.cpp +++ b/test/std/depr/depr.ios.members/streamoff.pass.cpp @@ -15,11 +15,16 @@ // typedef OFF_T streamoff; // }; +// These members were removed for C++17 + +#include "test_macros.h" #include #include int main() { +#if TEST_STD_VER <= 14 static_assert((std::is_integral::value), ""); static_assert((std::is_signed::value), ""); +#endif } diff --git a/test/std/depr/depr.ios.members/streampos.pass.cpp b/test/std/depr/depr.ios.members/streampos.pass.cpp index 315118cb3e3d..863905f710eb 100644 --- a/test/std/depr/depr.ios.members/streampos.pass.cpp +++ b/test/std/depr/depr.ios.members/streampos.pass.cpp @@ -15,10 +15,15 @@ // typedef POS_T streampos; // }; +// These members were removed for C++17 + +#include "test_macros.h" #include #include int main() { +#if TEST_STD_VER <= 14 static_assert((std::is_same::value), ""); +#endif } diff --git a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp index 7fab50081d2a..5879529317ef 100644 --- a/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp +++ b/test/std/depr/exception.unexpected/unexpected.handler/unexpected_handler.pass.cpp @@ -16,4 +16,5 @@ void f() {} int main() { std::unexpected_handler p = f; + ((void)p); } diff --git a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp index 235305878390..79162ddaa8fd 100644 --- a/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp +++ b/test/std/diagnostics/syserr/syserr.errcat/syserr.errcat.overview/error_category.pass.cpp @@ -16,4 +16,5 @@ int main() { std::error_category* p = 0; + ((void)p); } diff --git a/test/std/experimental/algorithms/alg.search/search.pass.cpp b/test/std/experimental/algorithms/alg.search/search.pass.cpp new file mode 100644 index 000000000000..60a44e4c26a2 --- /dev/null +++ b/test/std/experimental/algorithms/alg.search/search.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// ForwardIterator search(ForwardIterator first, ForwardIterator last, +// const Searcher& searcher); +// +// returns searcher.operator(first, last) +// + +#include +#include + +#include "test_iterators.h" + +int searcher_called = 0; + +struct MySearcher { + template + Iterator operator() ( Iterator b, Iterator /*e*/) const + { + ++searcher_called; + return b; + } +}; + + +int main() { + typedef int * RI; + static_assert((std::is_same::value), "" ); + + RI it(nullptr); + assert(it == std::experimental::search(it, it, MySearcher())); + assert(searcher_called == 1); +} diff --git a/test/std/experimental/any/any.class/any.assign/copy.pass.cpp b/test/std/experimental/any/any.class/any.assign/copy.pass.cpp new file mode 100644 index 000000000000..8ee575c408f9 --- /dev/null +++ b/test/std/experimental/any/any.class/any.assign/copy.pass.cpp @@ -0,0 +1,197 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any& operator=(any const &); + +// Test copy assignment + +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; + +template +void test_copy_assign() { + assert(LHS::count == 0); + assert(RHS::count == 0); + LHS::reset(); + RHS::reset(); + { + any lhs(LHS(1)); + any const rhs(RHS(2)); + + assert(LHS::count == 1); + assert(RHS::count == 1); + assert(RHS::copied == 0); + + lhs = rhs; + + assert(RHS::copied == 1); + assert(LHS::count == 0); + assert(RHS::count == 2); + + assertContains(lhs, 2); + assertContains(rhs, 2); + } + assert(LHS::count == 0); + assert(RHS::count == 0); +} + +template +void test_copy_assign_empty() { + assert(LHS::count == 0); + LHS::reset(); + { + any lhs; + any const rhs(LHS(42)); + + assert(LHS::count == 1); + assert(LHS::copied == 0); + + lhs = rhs; + + assert(LHS::copied == 1); + assert(LHS::count == 2); + + assertContains(lhs, 42); + assertContains(rhs, 42); + } + assert(LHS::count == 0); + LHS::reset(); + { + any lhs(LHS(1)); + any const rhs; + + assert(LHS::count == 1); + assert(LHS::copied == 0); + + lhs = rhs; + + assert(LHS::copied == 0); + assert(LHS::count == 0); + + assertEmpty(lhs); + assertEmpty(rhs); + } + assert(LHS::count == 0); +} + +void test_copy_assign_self() { + // empty + { + any a; + a = a; + assertEmpty(a); + assert(globalMemCounter.checkOutstandingNewEq(0)); + } + assert(globalMemCounter.checkOutstandingNewEq(0)); + // small + { + any a((small(1))); + assert(small::count == 1); + + a = a; + + assert(small::count == 1); + assertContains(a, 1); + assert(globalMemCounter.checkOutstandingNewEq(0)); + } + assert(small::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); + // large + { + any a(large(1)); + assert(large::count == 1); + + a = a; + + assert(large::count == 1); + assertContains(a, 1); + assert(globalMemCounter.checkOutstandingNewEq(1)); + } + assert(large::count == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); +} + +template +void test_copy_assign_throws() +{ +#if !defined(TEST_HAS_NO_EXCEPTIONS) + auto try_throw = + [](any& lhs, any const& rhs) { + try { + lhs = rhs; + assert(false); + } catch (my_any_exception const &) { + // do nothing + } catch (...) { + assert(false); + } + }; + // const lvalue to empty + { + any lhs; + any const rhs((Tp(1))); + assert(Tp::count == 1); + + try_throw(lhs, rhs); + + assert(Tp::count == 1); + assertEmpty(lhs); + assertContains(rhs); + } + { + any lhs((small(2))); + any const rhs((Tp(1))); + assert(small::count == 1); + assert(Tp::count == 1); + + try_throw(lhs, rhs); + + assert(small::count == 1); + assert(Tp::count == 1); + assertContains(lhs, 2); + assertContains(rhs); + } + { + any lhs((large(2))); + any const rhs((Tp(1))); + assert(large::count == 1); + assert(Tp::count == 1); + + try_throw(lhs, rhs); + + assert(large::count == 1); + assert(Tp::count == 1); + assertContains(lhs, 2); + assertContains(rhs); + } +#endif +} + +int main() { + test_copy_assign(); + test_copy_assign(); + test_copy_assign(); + test_copy_assign(); + test_copy_assign_empty(); + test_copy_assign_empty(); + test_copy_assign_self(); + test_copy_assign_throws(); + test_copy_assign_throws(); +} diff --git a/test/std/experimental/any/any.class/any.assign/move.pass.cpp b/test/std/experimental/any/any.class/any.assign/move.pass.cpp new file mode 100644 index 000000000000..0a2d71967cd4 --- /dev/null +++ b/test/std/experimental/any/any.class/any.assign/move.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any& operator=(any &&); + +// Test move assignment. + +#include +#include + +#include "any_helpers.h" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; + +template +void test_move_assign() { + assert(LHS::count == 0); + assert(RHS::count == 0); + { + LHS const s1(1); + any a(s1); + RHS const s2(2); + any a2(s2); + + assert(LHS::count == 2); + assert(RHS::count == 2); + + a = std::move(a2); + + assert(LHS::count == 1); + assert(RHS::count == 2); + + assertContains(a, 2); + assertEmpty(a2); + } + assert(LHS::count == 0); + assert(RHS::count == 0); +} + +template +void test_move_assign_empty() { + assert(LHS::count == 0); + { + any a; + any a2((LHS(1))); + + assert(LHS::count == 1); + + a = std::move(a2); + + assert(LHS::count == 1); + + assertContains(a, 1); + assertEmpty(a2); + } + assert(LHS::count == 0); + { + any a((LHS(1))); + any a2; + + assert(LHS::count == 1); + + a = std::move(a2); + + assert(LHS::count == 0); + + assertEmpty(a); + assertEmpty(a2); + } + assert(LHS::count == 0); +} + +void test_move_assign_noexcept() { + any a1; + any a2; + static_assert( + noexcept(a1 = std::move(a2)) + , "any & operator=(any &&) must be noexcept" + ); +} + +int main() { + test_move_assign_noexcept(); + test_move_assign(); + test_move_assign(); + test_move_assign(); + test_move_assign(); + test_move_assign_empty(); + test_move_assign_empty(); +} diff --git a/test/std/experimental/any/any.class/any.assign/value.pass.cpp b/test/std/experimental/any/any.class/any.assign/value.pass.cpp new file mode 100644 index 000000000000..8262990523c3 --- /dev/null +++ b/test/std/experimental/any/any.class/any.assign/value.pass.cpp @@ -0,0 +1,177 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any& operator=(any const &); + +// Test value copy and move assignment. + +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; + +template +void test_assign_value() { + assert(LHS::count == 0); + assert(RHS::count == 0); + LHS::reset(); + RHS::reset(); + { + any lhs(LHS(1)); + any const rhs(RHS(2)); + + assert(LHS::count == 1); + assert(RHS::count == 1); + assert(RHS::copied == 0); + + lhs = rhs; + + assert(RHS::copied == 1); + assert(LHS::count == 0); + assert(RHS::count == 2); + + assertContains(lhs, 2); + assertContains(rhs, 2); + } + assert(LHS::count == 0); + assert(RHS::count == 0); + LHS::reset(); + RHS::reset(); + { + any lhs(LHS(1)); + any rhs(RHS(2)); + + assert(LHS::count == 1); + assert(RHS::count == 1); + assert(RHS::moved == 1); + + lhs = std::move(rhs); + + assert(RHS::moved >= 1); + assert(RHS::copied == 0); + assert(LHS::count == 0); + assert(RHS::count == 1); + + assertContains(lhs, 2); + assertEmpty(rhs); + } + assert(LHS::count == 0); + assert(RHS::count == 0); +} + +template +void test_assign_value_empty() { + assert(RHS::count == 0); + RHS::reset(); + { + any lhs; + RHS rhs(42); + assert(RHS::count == 1); + assert(RHS::copied == 0); + + lhs = rhs; + + assert(RHS::count == 2); + assert(RHS::copied == 1); + assert(RHS::moved >= 0); + assertContains(lhs, 42); + } + assert(RHS::count == 0); + RHS::reset(); + { + any lhs; + RHS rhs(42); + assert(RHS::count == 1); + assert(RHS::moved == 0); + + lhs = std::move(rhs); + + assert(RHS::count == 2); + assert(RHS::copied == 0); + assert(RHS::moved >= 1); + assertContains(lhs, 42); + } + assert(RHS::count == 0); + RHS::reset(); +} + + +template +void test_assign_throws() { +#if !defined(TEST_HAS_NO_EXCEPTIONS) + auto try_throw= + [](any& lhs, auto&& rhs) { + try { + Move ? lhs = std::move(rhs) + : lhs = rhs; + assert(false); + } catch (my_any_exception const &) { + // do nothing + } catch (...) { + assert(false); + } + }; + // const lvalue to empty + { + any lhs; + Tp rhs(1); + assert(Tp::count == 1); + + try_throw(lhs, rhs); + + assert(Tp::count == 1); + assertEmpty(lhs); + } + { + any lhs((small(2))); + Tp rhs(1); + assert(small::count == 1); + assert(Tp::count == 1); + + try_throw(lhs, rhs); + + assert(small::count == 1); + assert(Tp::count == 1); + assertContains(lhs, 2); + } + { + any lhs((large(2))); + Tp rhs(1); + assert(large::count == 1); + assert(Tp::count == 1); + + try_throw(lhs, rhs); + + assert(large::count == 1); + assert(Tp::count == 1); + assertContains(lhs, 2); + } +#endif +} + +int main() { + test_assign_value(); + test_assign_value(); + test_assign_value(); + test_assign_value(); + test_assign_value_empty(); + test_assign_value_empty(); + test_assign_throws(); + test_assign_throws(); + test_assign_throws(); +} \ No newline at end of file diff --git a/test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp b/test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp new file mode 100644 index 000000000000..ce0d44f32d98 --- /dev/null +++ b/test/std/experimental/any/any.class/any.assign/value_non_copyable_assign.fail.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// any& operator=(Value &&); + +// Instantiate the value assignment operator with a non-copyable type. + +#include + +class non_copyable +{ + non_copyable(non_copyable const &); + +public: + non_copyable() {} + non_copyable(non_copyable &&) {} +}; + +int main() +{ + using namespace std::experimental; + non_copyable nc; + any a; + a = static_cast(nc); // expected-error@experimental/any:* 2 {{static_assert failed "_ValueType must be CopyConstructible."}} + // expected-error@experimental/any:* {{calling a private constructor of class 'non_copyable'}} + +} diff --git a/test/std/experimental/any/any.class/any.cons/copy.pass.cpp b/test/std/experimental/any/any.class/any.cons/copy.pass.cpp new file mode 100644 index 000000000000..3d0b34b27406 --- /dev/null +++ b/test/std/experimental/any/any.class/any.cons/copy.pass.cpp @@ -0,0 +1,100 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any(any const &); + +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; + +template +void test_copy_throws() { +#if !defined(TEST_HAS_NO_EXCEPTIONS) + assert(Type::count == 0); + { + any const a((Type(42))); + assert(Type::count == 1); + try { + any const a2(a); + assert(false); + } catch (my_any_exception const &) { + // do nothing + } catch (...) { + assert(false); + } + assert(Type::count == 1); + assertContains(a, 42); + } + assert(Type::count == 0); +#endif +} + +void test_copy_empty() { + DisableAllocationGuard g; ((void)g); // No allocations should occur. + any a1; + any a2(a1); + + assertEmpty(a1); + assertEmpty(a2); +} + +template +void test_copy() +{ + // Copying small types should not perform any allocations. + DisableAllocationGuard g(isSmallType()); ((void)g); + assert(Type::count == 0); + Type::reset(); + { + any a((Type(42))); + assert(Type::count == 1); + assert(Type::copied == 0); + + any a2(a); + + assert(Type::copied == 1); + assert(Type::count == 2); + assertContains(a, 42); + assertContains(a, 42); + + // Modify a and check that a2 is unchanged + modifyValue(a, -1); + assertContains(a, -1); + assertContains(a2, 42); + + // modify a2 and check that a is unchanged + modifyValue(a2, 999); + assertContains(a, -1); + assertContains(a2, 999); + + // clear a and check that a2 is unchanged + a.clear(); + assertEmpty(a); + assertContains(a2, 999); + } + assert(Type::count == 0); +} + +int main() { + test_copy(); + test_copy(); + test_copy_empty(); + test_copy_throws(); + test_copy_throws(); +} diff --git a/test/std/experimental/any/any.class/any.cons/default.pass.cpp b/test/std/experimental/any/any.class/any.cons/default.pass.cpp new file mode 100644 index 000000000000..b52c83fc3881 --- /dev/null +++ b/test/std/experimental/any/any.class/any.cons/default.pass.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any() noexcept; + +#include +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" + + +int main() +{ + using std::experimental::any; + { + static_assert( + std::is_nothrow_default_constructible::value + , "Must be default constructible" + ); + } + { + DisableAllocationGuard g; ((void)g); + any const a; + assertEmpty(a); + } +} diff --git a/test/std/experimental/any/any.class/any.cons/move.pass.cpp b/test/std/experimental/any/any.class/any.cons/move.pass.cpp new file mode 100644 index 000000000000..40534cb55066 --- /dev/null +++ b/test/std/experimental/any/any.class/any.cons/move.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any(any &&) noexcept; + +#include +#include +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; + +// Moves are always noexcept. The throws_on_move object +// must be stored dynamically so the pointer is moved and +// not the stored object. +void test_move_does_not_throw() +{ +#if !defined(TEST_HAS_NO_EXCEPTIONS) + assert(throws_on_move::count == 0); + { + throws_on_move v(42); + any a(v); + assert(throws_on_move::count == 2); + // No allocations should be performed after this point. + DisableAllocationGuard g; ((void)g); + try { + any const a2(std::move(a)); + assertEmpty(a); + assertContains(a2, 42); + } catch (...) { + assert(false); + } + assert(throws_on_move::count == 1); + assertEmpty(a); + } + assert(throws_on_move::count == 0); +#endif +} + +void test_move_empty() { + DisableAllocationGuard g; ((void)g); // no allocations should be performed. + + any a1; + any a2(std::move(a1)); + + assertEmpty(a1); + assertEmpty(a2); +} + +template +void test_move() { + assert(Type::count == 0); + Type::reset(); + { + any a((Type(42))); + assert(Type::count == 1); + assert(Type::copied == 0); + assert(Type::moved == 1); + + // Moving should not perform allocations since it must be noexcept. + DisableAllocationGuard g; ((void)g); + + any a2(std::move(a)); + + assert(Type::moved >= 1); // zero or more move operations can be performed. + assert(Type::copied == 0); // no copies can be performed. + assert(Type::count == 1); + assertEmpty(a); // Moves are always destructive. + assertContains(a2, 42); + } + assert(Type::count == 0); +} + +int main() +{ + // noexcept test + { + static_assert( + std::is_nothrow_move_constructible::value + , "any must be nothrow move constructible" + ); + } + test_move(); + test_move(); + test_move_empty(); + test_move_does_not_throw(); +} diff --git a/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp b/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp new file mode 100644 index 000000000000..643b9621ca2f --- /dev/null +++ b/test/std/experimental/any/any.class/any.cons/non_copyable_value.fail.cpp @@ -0,0 +1,36 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any::any(Value &&) + +// Attempt to construct any with a non-copyable type. + +#include + +class non_copyable +{ + non_copyable(non_copyable const &); + +public: + non_copyable() {} + non_copyable(non_copyable &&) {} +}; + +int main() +{ + using namespace std::experimental; + non_copyable nc; + any a(static_cast(nc)); + // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType must be CopyConstructible."}} + // expected-error@experimental/any:* 1 {{calling a private constructor of class 'non_copyable'}} +} diff --git a/test/std/experimental/any/any.class/any.cons/value.pass.cpp b/test/std/experimental/any/any.class/any.cons/value.pass.cpp new file mode 100644 index 000000000000..7bb134efd28a --- /dev/null +++ b/test/std/experimental/any/any.class/any.cons/value.pass.cpp @@ -0,0 +1,116 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template any(Value &&) + +// Test construction from a value. +// Concerns: +// --------- +// 1. The value is properly move/copied depending on the value category. +// 2. Both small and large values are properly handled. + + +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; + +template +void test_copy_value_throws() +{ +#if !defined(TEST_HAS_NO_EXCEPTIONS) + assert(Type::count == 0); + { + Type const t(42); + assert(Type::count == 1); + try { + any const a2(t); + assert(false); + } catch (my_any_exception const &) { + // do nothing + } catch (...) { + assert(false); + } + assert(Type::count == 1); + assert(t.value == 42); + } + assert(Type::count == 0); +#endif +} + +void test_move_value_throws() +{ +#if !defined(TEST_HAS_NO_EXCEPTIONS) + assert(throws_on_move::count == 0); + { + throws_on_move v; + assert(throws_on_move::count == 1); + try { + any const a(std::move(v)); + assert(false); + } catch (my_any_exception const &) { + // do nothing + } catch (...) { + assert(false); + } + assert(throws_on_move::count == 1); + } + assert(throws_on_move::count == 0); +#endif +} + +template +void test_copy_move_value() { + // constructing from a small type should perform no allocations. + DisableAllocationGuard g(isSmallType()); ((void)g); + assert(Type::count == 0); + Type::reset(); + { + Type t(42); + assert(Type::count == 1); + + any a(t); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::moved == 0); + assertContains(a, 42); + } + assert(Type::count == 0); + Type::reset(); + { + Type t(42); + assert(Type::count == 1); + + any a(std::move(t)); + + assert(Type::count == 2); + assert(Type::copied == 0); + assert(Type::moved == 1); + assertContains(a, 42); + } +} + + +int main() { + test_copy_move_value(); + test_copy_move_value(); + test_copy_value_throws(); + test_copy_value_throws(); + test_move_value_throws(); +} \ No newline at end of file diff --git a/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp b/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp new file mode 100644 index 000000000000..603490cef43d --- /dev/null +++ b/test/std/experimental/any/any.class/any.modifiers/clear.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any::clear() noexcept + +#include +#include + +#include "any_helpers.h" + +int main() +{ + using std::experimental::any; + using std::experimental::any_cast; + // empty + { + any a; + + // noexcept check + static_assert( + noexcept(a.clear()) + , "any.clear() must be noexcept" + ); + + assertEmpty(a); + + a.clear(); + + assertEmpty(a); + } + // small object + { + any a((small(1))); + assert(small::count == 1); + assertContains(a, 1); + + a.clear(); + + assertEmpty(a); + assert(small::count == 0); + } + // large object + { + any a(large(1)); + assert(large::count == 1); + assertContains(a); + + a.clear(); + + assertEmpty(a); + assert(large::count == 0); + } +} diff --git a/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp b/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp new file mode 100644 index 000000000000..064935167eb5 --- /dev/null +++ b/test/std/experimental/any/any.class/any.modifiers/swap.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any::swap(any &) noexcept + +// Test swap(large, small) and swap(small, large) + +#include +#include + +#include "any_helpers.h" + +using std::experimental::any; +using std::experimental::any_cast; + +template +void test_swap() { + assert(LHS::count == 0); + assert(RHS::count == 0); + { + any a1((LHS(1))); + any a2(RHS{2}); + assert(LHS::count == 1); + assert(RHS::count == 1); + + a1.swap(a2); + + assert(LHS::count == 1); + assert(RHS::count == 1); + + assertContains(a1, 2); + assertContains(a2, 1); + } + assert(LHS::count == 0); + assert(RHS::count == 0); + assert(LHS::copied == 0); + assert(RHS::copied == 0); +} + +template +void test_swap_empty() { + assert(Tp::count == 0); + { + any a1((Tp(1))); + any a2; + assert(Tp::count == 1); + + a1.swap(a2); + + assert(Tp::count == 1); + + assertContains(a2, 1); + assertEmpty(a1); + } + assert(Tp::count == 0); + { + any a1((Tp(1))); + any a2; + assert(Tp::count == 1); + + a2.swap(a1); + + assert(Tp::count == 1); + + assertContains(a2, 1); + assertEmpty(a1); + } + assert(Tp::count == 0); + assert(Tp::copied == 0); +} + +void test_noexcept() +{ + any a1; + any a2; + static_assert( + noexcept(a1.swap(a2)) + , "any::swap(any&) must be noexcept" + ); +} + +int main() +{ + test_noexcept(); + test_swap_empty(); + test_swap_empty(); + test_swap(); + test_swap(); + test_swap(); + test_swap(); +} diff --git a/test/std/experimental/any/any.class/any.observers/empty.pass.cpp b/test/std/experimental/any/any.class/any.observers/empty.pass.cpp new file mode 100644 index 000000000000..8c681f37017f --- /dev/null +++ b/test/std/experimental/any/any.class/any.observers/empty.pass.cpp @@ -0,0 +1,64 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// any::empty() noexcept + +#include +#include + +#include "any_helpers.h" + +int main() +{ + using std::experimental::any; + // noexcept test + { + any a; + static_assert(noexcept(a.empty()), "any::empty() must be noexcept"); + } + // empty + { + any a; + assert(a.empty()); + + a.clear(); + assert(a.empty()); + + a = 42; + assert(!a.empty()); + } + // small object + { + small const s(1); + any a(s); + assert(!a.empty()); + + a.clear(); + assert(a.empty()); + + a = s; + assert(!a.empty()); + } + // large object + { + large const l(1); + any a(l); + assert(!a.empty()); + + a.clear(); + assert(a.empty()); + + a = l; + assert(!a.empty()); + } +} diff --git a/test/std/experimental/any/any.class/any.observers/type.pass.cpp b/test/std/experimental/any/any.class/any.observers/type.pass.cpp new file mode 100644 index 000000000000..682b73bc98c4 --- /dev/null +++ b/test/std/experimental/any/any.class/any.observers/type.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// XFAIL: libcpp-no-rtti + +// + +// any::type() noexcept + +#include +#include +#include "any_helpers.h" + +int main() +{ + using std::experimental::any; + { + any const a; + assert(a.type() == typeid(void)); + static_assert(noexcept(a.type()), "any::type() must be noexcept"); + } + { + small const s(1); + any const a(s); + assert(a.type() == typeid(small)); + + } + { + large const l(1); + any const a(l); + assert(a.type() == typeid(large)); + } +} diff --git a/test/std/experimental/any/any.class/nothing_to_do.pass.cpp b/test/std/experimental/any/any.class/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..c21f8a701685 --- /dev/null +++ b/test/std/experimental/any/any.class/nothing_to_do.pass.cpp @@ -0,0 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include + +int main () {} diff --git a/test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp b/test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp new file mode 100644 index 000000000000..9d9a5cdb4726 --- /dev/null +++ b/test/std/experimental/any/any.nonmembers/any.cast/any_cast_pointer.pass.cpp @@ -0,0 +1,146 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// ValueType const* any_cast(any const *) noexcept; +// +// template +// ValueType * any_cast(any *) noexcept; + +#include +#include +#include + +#include "any_helpers.h" + +using std::experimental::any; +using std::experimental::any_cast; + +// Test that the operators are properly noexcept. +void test_cast_is_noexcept() { + any a; + static_assert(noexcept(any_cast(&a)), ""); + + any const& ca = a; + static_assert(noexcept(any_cast(&ca)), ""); +} + +// Test that the return type of any_cast is correct. +void test_cast_return_type() { + any a; + static_assert(std::is_same(&a)), int*>::value, ""); + static_assert(std::is_same(&a)), int const*>::value, ""); + + any const& ca = a; + static_assert(std::is_same(&ca)), int const*>::value, ""); + static_assert(std::is_same(&ca)), int const*>::value, ""); +} + +// Test that any_cast handles null pointers. +void test_cast_nullptr() { + any* a = nullptr; + assert(nullptr == any_cast(a)); + assert(nullptr == any_cast(a)); + + any const* ca = nullptr; + assert(nullptr == any_cast(ca)); + assert(nullptr == any_cast(ca)); +} + +// Test casting an empty object. +void test_cast_empty() { + { + any a; + assert(nullptr == any_cast(&a)); + assert(nullptr == any_cast(&a)); + + any const& ca = a; + assert(nullptr == any_cast(&ca)); + assert(nullptr == any_cast(&ca)); + } + // Create as non-empty, then make empty and run test. + { + any a(42); + a.clear(); + assert(nullptr == any_cast(&a)); + assert(nullptr == any_cast(&a)); + + any const& ca = a; + assert(nullptr == any_cast(&ca)); + assert(nullptr == any_cast(&ca)); + } +} + +template +void test_cast() { + assert(Type::count == 0); + Type::reset(); + { + any a((Type(42))); + any const& ca = a; + assert(Type::count == 1); + assert(Type::copied == 0); + assert(Type::moved == 1); + + // Try a cast to a bad type. + // NOTE: Type cannot be an int. + assert(any_cast(&a) == nullptr); + assert(any_cast(&a) == nullptr); + assert(any_cast(&a) == nullptr); + + // Try a cast to the right type, but as a pointer. + assert(any_cast(&a) == nullptr); + assert(any_cast(&a) == nullptr); + + // Check getting a unqualified type from a non-const any. + Type* v = any_cast(&a); + assert(v != nullptr); + assert(v->value == 42); + + // change the stored value and later check for the new value. + v->value = 999; + + // Check getting a const qualified type from a non-const any. + Type const* cv = any_cast(&a); + assert(cv != nullptr); + assert(cv == v); + assert(cv->value == 999); + + // Check getting a unqualified type from a const any. + cv = any_cast(&ca); + assert(cv != nullptr); + assert(cv == v); + assert(cv->value == 999); + + // Check getting a const-qualified type from a const any. + cv = any_cast(&ca); + assert(cv != nullptr); + assert(cv == v); + assert(cv->value == 999); + + // Check that no more objects were created, copied or moved. + assert(Type::count == 1); + assert(Type::copied == 0); + assert(Type::moved == 1); + } + assert(Type::count == 0); +} + +int main() { + test_cast_is_noexcept(); + test_cast_return_type(); + test_cast_nullptr(); + test_cast_empty(); + test_cast(); + test_cast(); +} diff --git a/test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp b/test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp new file mode 100644 index 000000000000..e97560937fb0 --- /dev/null +++ b/test/std/experimental/any/any.nonmembers/any.cast/any_cast_reference.pass.cpp @@ -0,0 +1,309 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// ValueType const any_cast(any const&); +// +// template +// ValueType any_cast(any &); +// +// template +// ValueType any_cast(any &&); + +#include +#include +#include + +#include "any_helpers.h" +#include "count_new.hpp" +#include "test_macros.h" + +using std::experimental::any; +using std::experimental::any_cast; +using std::experimental::bad_any_cast; + + +// Test that the operators are NOT marked noexcept. +void test_cast_is_not_noexcept() { + any a; + static_assert(!noexcept(any_cast(static_cast(a))), ""); + static_assert(!noexcept(any_cast(static_cast(a))), ""); + static_assert(!noexcept(any_cast(static_cast(a))), ""); +} + +// Test that the return type of any_cast is correct. +void test_cast_return_type() { + any a; + static_assert(std::is_same(a)), int>::value, ""); + static_assert(std::is_same(a)), int>::value, ""); + static_assert(std::is_same(a)), int&>::value, ""); + static_assert(std::is_same(a)), int const&>::value, ""); + + //static_assert(std::is_same(a)), int&&>::value, ""); + //static_assert(std::is_same(a)), int const&&>::value, ""); + + static_assert(std::is_same(std::move(a))), int>::value, ""); + static_assert(std::is_same(std::move(a))), int>::value, ""); + static_assert(std::is_same(std::move(a))), int&>::value, ""); + static_assert(std::is_same(std::move(a))), int const&>::value, ""); + + //static_assert(std::is_same(std::move(a))), int&&>::value, ""); + //static_assert(std::is_same(std::move(a))), int const&&>::value, ""); + + any const& ca = a; + static_assert(std::is_same(ca)), int>::value, ""); + static_assert(std::is_same(ca)), int>::value, ""); + static_assert(std::is_same(ca)), int const&>::value, ""); + + //static_assert(std::is_same(ca)), int const&&>::value, ""); +} + +template +void checkThrows(any& a) +{ +#if !defined(TEST_HAS_NO_EXCEPTIONS) + try { + any_cast(a); + assert(false); + } catch (bad_any_cast const &) { + // do nothing + } catch (...) { + assert(false); + } + + try { + any_cast(static_cast(a)); + assert(false); + } catch (bad_any_cast const &) { + // do nothing + } catch (...) { + assert(false); + } + + try { + any_cast(static_cast(a)); + assert(false); + } catch (bad_any_cast const &) { + // do nothing + } catch (...) { + assert(false); + } +#endif +} + +void test_cast_empty() { + // None of these operations should allocate. + DisableAllocationGuard g; ((void)g); + any a; + checkThrows(a); +} + +template +void test_cast_to_reference() { + assert(Type::count == 0); + Type::reset(); + { + any a((Type(42))); + any const& ca = a; + assert(Type::count == 1); + assert(Type::copied == 0); + assert(Type::moved == 1); + + // Try a cast to a bad type. + // NOTE: Type cannot be an int. + checkThrows(a); + checkThrows(a); + checkThrows(a); + checkThrows(a); + + // Check getting a type by reference from a non-const lvalue any. + { + Type& v = any_cast(a); + assert(v.value == 42); + + Type const &cv = any_cast(a); + assert(&cv == &v); + } + // Check getting a type by reference from a const lvalue any. + { + Type const& v = any_cast(ca); + assert(v.value == 42); + + Type const &cv = any_cast(ca); + assert(&cv == &v); + } + // Check getting a type by reference from a non-const rvalue + { + Type& v = any_cast(std::move(a)); + assert(v.value == 42); + + Type const &cv = any_cast(std::move(a)); + assert(&cv == &v); + } + // Check getting a type by reference from a const rvalue any. + { + Type const& v = any_cast(std::move(ca)); + assert(v.value == 42); + + Type const &cv = any_cast(std::move(ca)); + assert(&cv == &v); + } + + // Check that the original object hasn't been changed. + assertContains(a, 42); + + // Check that no objects have been created/copied/moved. + assert(Type::count == 1); + assert(Type::copied == 0); + assert(Type::moved == 1); + } + assert(Type::count == 0); +} + +template +void test_cast_to_value() { + assert(Type::count == 0); + Type::reset(); + { + any a((Type(42))); + any const& ca = a; + assert(Type::count == 1); + assert(Type::copied == 0); + assert(Type::moved == 1); + + // Try a cast to a bad type. + // NOTE: Type cannot be an int. + checkThrows(a); + checkThrows(a); + checkThrows(a); + checkThrows(a); + + Type::reset(); // NOTE: reset does not modify Type::count + // Check getting Type by value from a non-const lvalue any. + // This should cause the non-const copy constructor to be called. + { + Type t = any_cast(a); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::const_copied == 0); + assert(Type::non_const_copied == 1); + assert(Type::moved == 0); + assert(t.value == 42); + } + assert(Type::count == 1); + Type::reset(); + // Check getting const Type by value from a non-const lvalue any. + // This should cause the const copy constructor to be called. + { + Type t = any_cast(a); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::const_copied == 1); + assert(Type::non_const_copied == 0); + assert(Type::moved == 0); + assert(t.value == 42); + } + assert(Type::count == 1); + Type::reset(); + // Check getting Type by value from a non-const lvalue any. + // This should cause the const copy constructor to be called. + { + Type t = any_cast(static_cast(a)); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::const_copied == 1); + assert(Type::non_const_copied == 0); + assert(Type::moved == 0); + assert(t.value == 42); + } + assert(Type::count == 1); + Type::reset(); + // Check getting Type by value from a non-const rvalue any. + // This should cause the non-const copy constructor to be called. + { + Type t = any_cast(static_cast(a)); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::const_copied == 0); + assert(Type::non_const_copied == 1); + assert(Type::moved == 0); + assert(t.value == 42); + } + assert(Type::count == 1); + Type::reset(); + // Check getting const Type by value from a non-const rvalue any. + // This should cause the const copy constructor to be called. + { + Type t = any_cast(static_cast(a)); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::const_copied == 1); + assert(Type::non_const_copied == 0); + assert(Type::moved == 0); + assert(t.value == 42); + } + assert(Type::count == 1); + Type::reset(); + // Check getting Type by value from a const rvalue any. + // This should cause the const copy constructor to be called. + { + Type t = any_cast(static_cast(a)); + + assert(Type::count == 2); + assert(Type::copied == 1); + assert(Type::const_copied == 1); + assert(Type::non_const_copied == 0); + assert(Type::moved == 0); + assert(t.value == 42); + } + // Ensure we still only have 1 Type object alive. + assert(Type::count == 1); + + // Check that the original object hasn't been changed. + assertContains(a, 42); + } + assert(Type::count == 0); +} + +// Even though you can't get a non-copyable class into std::any +// the standard requires that these overloads compile and function. +void test_non_copyable_ref() { + struct no_copy + { + no_copy() {} + no_copy(no_copy &&) {} + private: + no_copy(no_copy const &); + }; + + any a; + checkThrows(a); + checkThrows(a); + assertEmpty(a); +} + +int main() { + test_cast_is_not_noexcept(); + test_cast_return_type(); + test_cast_empty(); + test_cast_to_reference(); + test_cast_to_reference(); + test_cast_to_value(); + test_cast_to_value(); + test_non_copyable_ref(); +} diff --git a/test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp b/test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp new file mode 100644 index 000000000000..db5149265ccc --- /dev/null +++ b/test/std/experimental/any/any.nonmembers/any.cast/const_correctness.fail.cpp @@ -0,0 +1,38 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// ValueType any_cast(any const &); + +// Try and cast away const. + +#include + +struct TestType {}; +struct TestType2 {}; + +int main() +{ + using std::experimental::any; + using std::experimental::any_cast; + + any a; + + // expected-error@experimental/any:* 2 {{binding value of type '_Tp' (aka 'const TestType') to reference to type 'TestType' drops 'const' qualifier}} + any_cast(static_cast(a)); // expected-note {{requested here}} + any_cast(static_cast(a)); // expected-note {{requested here}} + + // expected-error@experimental/any:* 2 {{binding value of type '_Tp' (aka 'const TestType2') to reference to type 'TestType2' drops 'const' qualifier}} + any_cast(static_cast(a)); // expected-note {{requested here}} + any_cast(static_cast(a)); // expected-note {{requested here}} +} diff --git a/test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp b/test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp new file mode 100644 index 000000000000..c6cc68d72706 --- /dev/null +++ b/test/std/experimental/any/any.nonmembers/any.cast/not_copy_constructible.fail.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// ValueType const any_cast(any const&); +// +// template +// ValueType any_cast(any &); +// +// template +// ValueType any_cast(any &&); + +// Test instantiating the any_cast with a non-copyable type. + +#include + +using std::experimental::any; +using std::experimental::any_cast; + +struct no_copy +{ + no_copy() {} + no_copy(no_copy &&) {} +private: + no_copy(no_copy const &); +}; + +int main() { + any a; + any_cast(static_cast(a)); + any_cast(static_cast(a)); + any_cast(static_cast(a)); + // expected-error@experimental/any:* 3 {{static_assert failed "_ValueType is required to be a reference or a CopyConstructible type."}} + // expected-error@experimental/any:* 3 {{calling a private constructor of class 'no_copy'}} +} \ No newline at end of file diff --git a/test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp b/test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp new file mode 100644 index 000000000000..6c6ccc68787a --- /dev/null +++ b/test/std/experimental/any/any.nonmembers/any.cast/reference_types.fail.cpp @@ -0,0 +1,37 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template +// ValueType const* any_cast(any const *) noexcept; +// +// template +// ValueType * any_cast(any *) noexcept; + +#include + +using std::experimental::any; +using std::experimental::any_cast; + +int main() +{ + any a(1); + any_cast(&a); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast(&a); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast(&a); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast(&a); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any const& a2 = a; + any_cast(&a2); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast(&a2); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast(&a2); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} + any_cast(&a2); // expected-error@experimental/any:* 1 {{static_assert failed "_ValueType may not be a reference."}} +} diff --git a/test/std/experimental/any/any.nonmembers/swap.pass.cpp b/test/std/experimental/any/any.nonmembers/swap.pass.cpp new file mode 100644 index 000000000000..a3fbd43d9247 --- /dev/null +++ b/test/std/experimental/any/any.nonmembers/swap.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// void swap(any &, any &) noexcept + +// swap(...) just wraps any::swap(...). That function is tested elsewhere. + +#include +#include + +using std::experimental::any; +using std::experimental::any_cast; + +int main() +{ + + { // test noexcept + any a; + static_assert(noexcept(swap(a, a)), "swap(any&, any&) must be noexcept"); + } + { + any a1(1); + any a2(2); + + swap(a1, a2); + + assert(any_cast(a1) == 2); + assert(any_cast(a2) == 1); + } +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/default.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/default.pass.cpp new file mode 100644 index 000000000000..7647b536aa95 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/default.pass.cpp @@ -0,0 +1,128 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_searcher { +// public: +// boyer_moore_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result) { + std::experimental::boyer_moore_searcher s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); + int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sj = sizeof(ij)/sizeof(ij[0]); + int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sk = sizeof(ik)/sizeof(ik[0]); + do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); + char ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sj = sizeof(ij)/sizeof(ij[0]); + char ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sk = sizeof(ik)/sizeof(ik[0]); + do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pass.cpp new file mode 100644 index 000000000000..1323044c8704 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pass.cpp @@ -0,0 +1,124 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_searcher { +// public: +// boyer_moore_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +template struct MyHash { + size_t operator () (T t) const { return static_cast(t); } +}; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::boyer_moore_searcher::value_type>::type>> + s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp new file mode 100644 index 000000000000..8fd5b8c9f784 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/hash.pred.pass.cpp @@ -0,0 +1,135 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_searcher { +// public: +// boyer_moore_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +template struct MyHash { + size_t operator () (T t) const { return static_cast(t); } +}; + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) const + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::boyer_moore_searcher::value_type>::type>, + count_equal> + s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp new file mode 100644 index 000000000000..d0655c82febb --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore/pred.pass.cpp @@ -0,0 +1,131 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_searcher { +// public: +// boyer_moore_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) const + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::boyer_moore_searcher::value_type>::type>, count_equal> s{b2, e2}; + count_equal::count = 0; + assert(result == std::experimental::search(b1, e1, s)); +// assert(count_equal::count <= max_count); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/default.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/default.pass.cpp new file mode 100644 index 000000000000..af3bbbafb24e --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/default.pass.cpp @@ -0,0 +1,128 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore_horspool searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_horspool_searcher { +// public: +// boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result) { + std::experimental::boyer_moore_horspool_searcher s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); + int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sj = sizeof(ij)/sizeof(ij[0]); + int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sk = sizeof(ik)/sizeof(ik[0]); + do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); + char ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sj = sizeof(ij)/sizeof(ij[0]); + char ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sk = sizeof(ik)/sizeof(ik[0]); + do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pass.cpp new file mode 100644 index 000000000000..ff289f0edeb0 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pass.cpp @@ -0,0 +1,123 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore_horspool searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_horspool_searcher { +// public: +// boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + +#include +#include +#include + +#include "test_iterators.h" + +template struct MyHash { + size_t operator () (T t) const { return static_cast(t); } +}; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::boyer_moore_horspool_searcher::value_type>::type>> + s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp new file mode 100644 index 000000000000..1150210a978a --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/hash.pred.pass.cpp @@ -0,0 +1,134 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore_horspool searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_horspool_searcher { +// public: +// boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + +#include +#include +#include + +#include "test_iterators.h" + +template struct MyHash { + size_t operator () (T t) const { return static_cast(t); } +}; + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) const + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::boyer_moore_horspool_searcher::value_type>::type>, + count_equal> + s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp new file mode 100644 index 000000000000..55426874abe5 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.boyer_moore_horspool/pred.pass.cpp @@ -0,0 +1,130 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// boyer_moore_horspool searcher +// template::value_type>, +// class BinaryPredicate = equal_to<>> +// class boyer_moore_horspool_searcher { +// public: +// boyer_moore_horspool_searcher(RandomAccessIterator1 pat_first, RandomAccessIterator1 pat_last, +// Hash hf = Hash(), BinaryPredicate pred = BinaryPredicate()); +// +// template +// RandomAccessIterator2 +// operator()(RandomAccessIterator2 first, RandomAccessIterator2 last) const; +// +// private: +// RandomAccessIterator1 pat_first_; // exposition only +// RandomAccessIterator1 pat_last_; // exposition only +// Hash hash_; // exposition only +// BinaryPredicate pred_; // exposition only +// }; + +#include +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) const + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::boyer_moore_horspool_searcher::value_type>::type>, count_equal> s{b2, e2}; + count_equal::count = 0; + assert(result == std::experimental::search(b1, e1, s)); +// assert(count_equal::count <= max_count); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +template +void +test2() +{ + char ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + char ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + char ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + char id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + char ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + char ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + char ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + char ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, random_access_iterator >(); + test2, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp new file mode 100644 index 000000000000..446dcbde42be --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.default/default.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// default searcher +// template> +// class default_searcher { +// public: +// default_searcher(_ForwardIterator __f, _ForwardIterator __l, +// _BinaryPredicate __p = _BinaryPredicate()) +// : __first_(__f), __last_(__l), __pred_(__p) {} +// +// template +// _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const { +// return std::search(__f, __l, __first_, __last_, __pred_); +// } +// +// private: +// _ForwardIterator __first_; +// _ForwardIterator __last_; +// _BinaryPredicate __pred_; +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result) { + std::experimental::default_searcher s{b2, e2}; + assert(result == std::experimental::search(b1, e1, s)); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); + int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sj = sizeof(ij)/sizeof(ij[0]); + int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sk = sizeof(ik)/sizeof(ik[0]); + do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); +} + +int main() { + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp new file mode 100644 index 000000000000..b65c500c3192 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.default/default.pred.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// UNSUPPORTED: c++98, c++03, c++11 + +// default searcher +// template> +// class default_searcher { +// public: +// default_searcher(_ForwardIterator __f, _ForwardIterator __l, +// _BinaryPredicate __p = _BinaryPredicate()) +// : __first_(__f), __last_(__l), __pred_(__p) {} +// +// template +// _ForwardIterator2 operator () (_ForwardIterator2 __f, _ForwardIterator2 __l) const { +// return std::search(__f, __l, __first_, __last_, __pred_); +// } +// +// private: +// _ForwardIterator __first_; +// _ForwardIterator __last_; +// _BinaryPredicate __pred_; +// }; + + +#include +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) const + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + std::experimental::default_searcher s{b2, e2}; + count_equal::count = 0; + assert(result == std::experimental::search(b1, e1, s)); + assert(count_equal::count <= max_count); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pass.cpp new file mode 100644 index 000000000000..9528002d5f2d --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pass.cpp @@ -0,0 +1,81 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template> +// default_searcher +// make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last, +// BinaryPredicate pred = BinaryPredicate()); + + +#include +#include +#include + +#include "test_iterators.h" + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result) { + assert(result == std::experimental::search(b1, e1, + std::experimental::make_default_searcher(b2, e2))); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2)); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3)); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia)); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1)); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1)); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1)); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1)); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4)); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8)); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3)); + int ij[] = {0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sj = sizeof(ij)/sizeof(ij[0]); + int ik[] = {0, 0, 0, 0, 1, 1, 1, 1, 0, 0}; + const unsigned sk = sizeof(ik)/sizeof(ik[0]); + do_search(Iter1(ij), Iter1(ij+sj), Iter2(ik), Iter2(ik+sk), Iter1(ij+6)); +} + +int main() { + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pred.pass.cpp b/test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pred.pass.cpp new file mode 100644 index 000000000000..277020213149 --- /dev/null +++ b/test/std/experimental/func/func.searchers/func.searchers.default/func.searchers.default.creation/make_default_searcher.pred.pass.cpp @@ -0,0 +1,88 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// + +// template> +// default_searcher +// make_default_searcher(ForwardIterator pat_first, ForwardIterator pat_last, +// BinaryPredicate pred = BinaryPredicate()); + + +#include +#include +#include + +#include "test_iterators.h" + +struct count_equal +{ + static unsigned count; + template + bool operator()(const T& x, const T& y) + {++count; return x == y;} +}; + +unsigned count_equal::count = 0; + +template +void do_search(Iter1 b1, Iter1 e1, Iter2 b2, Iter2 e2, Iter1 result, unsigned max_count) { + count_equal::count = 0; + assert(result == std::experimental::search(b1, e1, + std::experimental::make_default_searcher(b2, e2))); + assert(count_equal::count <= max_count); +} + +template +void +test() +{ + int ia[] = {0, 1, 2, 3, 4, 5}; + const unsigned sa = sizeof(ia)/sizeof(ia[0]); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+1), Iter1(ia), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+1), Iter2(ia+2), Iter1(ia+1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+2), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+2), Iter2(ia+3), Iter1(ia+2), sa); + do_search(Iter1(ia), Iter1(ia), Iter2(ia+2), Iter2(ia+3), Iter1(ia), 0); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-1), Iter2(ia+sa), Iter1(ia+sa-1), sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia+sa-3), Iter2(ia+sa), Iter1(ia+sa-3), 3*sa); + do_search(Iter1(ia), Iter1(ia+sa), Iter2(ia), Iter2(ia+sa), Iter1(ia), sa*sa); + do_search(Iter1(ia), Iter1(ia+sa-1), Iter2(ia), Iter2(ia+sa), Iter1(ia+sa-1), (sa-1)*sa); + do_search(Iter1(ia), Iter1(ia+1), Iter2(ia), Iter2(ia+sa), Iter1(ia+1), sa); + int ib[] = {0, 1, 2, 0, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sb = sizeof(ib)/sizeof(ib[0]); + int ic[] = {1}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ic), Iter2(ic+1), Iter1(ib+1), sb); + int id[] = {1, 2}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(id), Iter2(id+2), Iter1(ib+1), sb*2); + int ie[] = {1, 2, 3}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ie), Iter2(ie+3), Iter1(ib+4), sb*3); + int ig[] = {1, 2, 3, 4}; + do_search(Iter1(ib), Iter1(ib+sb), Iter2(ig), Iter2(ig+4), Iter1(ib+8), sb*4); + int ih[] = {0, 1, 1, 1, 1, 2, 3, 0, 1, 2, 3, 4}; + const unsigned sh = sizeof(ih)/sizeof(ih[0]); + int ii[] = {1, 1, 2}; + do_search(Iter1(ih), Iter1(ih+sh), Iter2(ii), Iter2(ii+3), Iter1(ih+3), sh*3); +} + +int main() { + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); + test, forward_iterator >(); + test, bidirectional_iterator >(); + test, random_access_iterator >(); +} diff --git a/test/std/experimental/func/func.searchers/nothing_to_do.pass.cpp b/test/std/experimental/func/func.searchers/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..9a59227abdd9 --- /dev/null +++ b/test/std/experimental/func/func.searchers/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/experimental/func/header.functional.synop/includes.pass.cpp b/test/std/experimental/func/header.functional.synop/includes.pass.cpp new file mode 100644 index 000000000000..1b72d4a7ad02 --- /dev/null +++ b/test/std/experimental/func/header.functional.synop/includes.pass.cpp @@ -0,0 +1,21 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// +// +// has to include + +#include + +int main() +{ + std::function x; +} diff --git a/test/std/experimental/func/nothing_to_do.pass.cpp b/test/std/experimental/func/nothing_to_do.pass.cpp new file mode 100644 index 000000000000..9a59227abdd9 --- /dev/null +++ b/test/std/experimental/func/nothing_to_do.pass.cpp @@ -0,0 +1,13 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +int main() +{ +} diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp index 81c3b4e6dfa2..999d03d3a885 100644 --- a/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.assign/copy.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // optional& operator=(const optional& rhs); diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp index c4361ea5178d..ec98ef449153 100644 --- a/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.assign/emplace.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template void optional::emplace(Args&&... args); diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp index 8d20be3de19a..aada0f4ec535 100644 --- a/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.assign/emplace_initializer_list.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template diff --git a/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp index d27313dad42b..3e084e5b7dc2 100644 --- a/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.assign/move.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // optional& operator=(optional&& rhs) diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp index 071f5943b972..9b6511a0006d 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/const_T.pass.cpp @@ -6,6 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// XFAIL: libcpp-no-exceptions // @@ -15,8 +18,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - using std::experimental::optional; class X @@ -39,18 +40,14 @@ class Y class Z { - int i_; public: - Z(int i) : i_(i) {} + Z(int) {} Z(const Z&) {throw 6;} }; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 { typedef int T; constexpr T t(5); @@ -113,5 +110,4 @@ int main() assert(i == 6); } } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp index 8726f95a00c0..7d401de1d978 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/copy.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // optional(const optional& rhs); diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp index 412c993ffbd7..014ee859e8a9 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/in_place_t.pass.cpp @@ -6,6 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// XFAIL: libcpp-no-exceptions // @@ -16,7 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 using std::experimental::optional; using std::experimental::in_place_t; @@ -52,17 +54,13 @@ class Y class Z { - int i_; public: - Z(int i) : i_(i) {throw 6;} + Z(int i) {throw 6;} }; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 { constexpr optional opt(in_place, 5); static_assert(static_cast(opt) == true, ""); @@ -141,5 +139,4 @@ int main() assert(i == 6); } } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp index 98cb929dc51e..7a98e0bf31f3 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/initializer_list.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp index b320c95c5827..40d55f918993 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/move.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // optional(optional&& rhs) noexcept(is_nothrow_move_constructible::value); diff --git a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp index ac52a42d5953..ef21fcdf9e6d 100644 --- a/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.ctor/rvalue_T.pass.cpp @@ -6,6 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11 +// XFAIL: libcpp-no-exceptions // @@ -15,8 +18,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - using std::experimental::optional; class X @@ -41,17 +42,14 @@ class Y class Z { - int i_; public: - Z(int i) : i_(i) {} + Z(int) {} Z(Z&&) {throw 6;} }; -#endif // _LIBCPP_STD_VER > 11 int main() { -#if _LIBCPP_STD_VER > 11 { typedef int T; constexpr optional opt(T(5)); @@ -106,5 +104,4 @@ int main() assert(i == 6); } } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp index e91805e9c8e5..85f9be6998a0 100644 --- a/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.observe/value.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // T& optional::value(); diff --git a/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp index 39bf687ff3c5..c99baab8b6e4 100644 --- a/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.observe/value_const.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // constexpr const T& optional::value() const; diff --git a/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp b/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp index e0ecfdebb8cf..d24a2d06b9d5 100644 --- a/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp +++ b/test/std/experimental/optional/optional.object/optional.object.swap/swap.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void swap(optional&) diff --git a/test/std/experimental/optional/optional.specalg/swap.pass.cpp b/test/std/experimental/optional/optional.specalg/swap.pass.cpp index e31d2173425b..6c5f7b0e860c 100644 --- a/test/std/experimental/optional/optional.specalg/swap.pass.cpp +++ b/test/std/experimental/optional/optional.specalg/swap.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template void swap(optional& x, optional& y) diff --git a/test/std/experimental/string.view/string.view.access/at.pass.cpp b/test/std/experimental/string.view/string.view.access/at.pass.cpp index 3003ea835470..a3208c1645a2 100644 --- a/test/std/experimental/string.view/string.view.access/at.pass.cpp +++ b/test/std/experimental/string.view/string.view.access/at.pass.cpp @@ -10,6 +10,7 @@ // NOTE: Older versions of clang have a bug where they fail to evalute // string_view::at as a constant expression. // XFAIL: clang-3.4, clang-3.3 +// XFAIL: libcpp-no-exceptions // diff --git a/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp index 6b20639f7752..7ccbd528c7fc 100644 --- a/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp +++ b/test/std/experimental/string.view/string.view.ops/compare.pointer_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // constexpr int compare(size_type pos1, size_type n1, const charT* s) const; diff --git a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp index 2047862b0002..244de9eb5104 100644 --- a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp +++ b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // constexpr int compare(size_type pos1, size_type n1, basic_string_view str) const; diff --git a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp index acb48f5fb6cc..1c3bc089a656 100644 --- a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp +++ b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // constexpr int compare(size_type pos1, size_type n1, diff --git a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp index 33407ef0747e..c7a6f1e1eb66 100644 --- a/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp +++ b/test/std/experimental/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // constexpr int compare(size_type pos1, size_type n1, basic_string_view str, diff --git a/test/std/experimental/string.view/string.view.ops/copy.pass.cpp b/test/std/experimental/string.view/string.view.ops/copy.pass.cpp index 96246d2732c7..0e4eb9e50bb0 100644 --- a/test/std/experimental/string.view/string.view.ops/copy.pass.cpp +++ b/test/std/experimental/string.view/string.view.ops/copy.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // size_type copy(charT* s, size_type n, size_type pos = 0) const; diff --git a/test/std/experimental/string.view/string.view.ops/substr.pass.cpp b/test/std/experimental/string.view/string.view.ops/substr.pass.cpp index 123646240f2e..c80e90a04788 100644 --- a/test/std/experimental/string.view/string.view.ops/substr.pass.cpp +++ b/test/std/experimental/string.view/string.view.ops/substr.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // constexpr basic_string_view substr(size_type pos = 0, size_type n = npos) const; diff --git a/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp index 56dc3c6aaa25..cb44707fa7e7 100644 --- a/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp +++ b/test/std/experimental/utilities/tuple/tuple.apply/arg_type.pass.cpp @@ -20,6 +20,11 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + + namespace ex = std::experimental; int call_with_value(int x, int y) { return (x + y); } diff --git a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp index 322554925d3f..0c5170f29cea 100644 --- a/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp +++ b/test/std/experimental/utilities/tuple/tuple.apply/extended_types.pass.cpp @@ -22,6 +22,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + int count = 0; struct A_int_0 diff --git a/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp b/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp index 5d3d564c26fb..52eec276394a 100644 --- a/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp +++ b/test/std/experimental/utilities/tuple/tuple.apply/types.pass.cpp @@ -20,6 +20,10 @@ #include #include +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#include "disable_missing_braces_warning.h" + namespace ex = std::experimental; int count = 0; diff --git a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp index ec4ad8a3bbca..a06f0443d701 100644 --- a/test/std/input.output/file.streams/c.files/cstdio.pass.cpp +++ b/test/std/input.output/file.streams/c.files/cstdio.pass.cpp @@ -80,6 +80,7 @@ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-zero-length" +#pragma clang diagnostic ignored "-Wdeprecated-declarations" int main() { diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp index e6f4e1e4c19e..dc4e0ba0de20 100644 --- a/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp +++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg.pass.cpp @@ -63,4 +63,13 @@ int main() is.seekg(-1); assert(is.fail()); } + { + testbuf sb(" 123456789"); + std::istream is(&sb); + is.setstate(std::ios_base::eofbit); + assert(is.eof()); + is.seekg(5); + assert(is.good()); + assert(!is.eof()); + } } diff --git a/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp index 73f3da1c6bd1..3cedf9192808 100644 --- a/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp +++ b/test/std/input.output/iostream.format/input.streams/istream.unformatted/seekg_off.pass.cpp @@ -71,4 +71,13 @@ int main() assert(is.fail()); assert(seekoff_called == 4); } + { + testbuf sb(" 123456789"); + std::istream is(&sb); + is.setstate(std::ios_base::eofbit); + assert(is.eof()); + is.seekg(5, std::ios_base::beg); + assert(is.good()); + assert(!is.eof()); + } } diff --git a/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp b/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp index 112928ca0ce6..a8ef34e49278 100644 --- a/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp +++ b/test/std/input.output/iostream.format/output.streams/ostream_sentry/destruct.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template > diff --git a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp index 5c9abbe53793..a9c5f30f37ae 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.types/ios_failure/ctor_string_error_code.pass.cpp @@ -19,6 +19,9 @@ int main() { + // LWG2462 std::ios_base::failure is overspecified + static_assert((std::is_base_of::value), ""); + { std::string what_arg("io test message"); std::ios_base::failure se(what_arg, make_error_code(std::errc::is_a_directory)); diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp index c46e2c054e8f..acefb8d16176 100644 --- a/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp +++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/copyfmt.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.fr_FR.UTF-8 diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp index 2d4beee37ec2..1c40a81aa069 100644 --- a/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp +++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/set_rdbuf.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template class basic_ios diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp index 0c2e8f0860ce..c4aad797801d 100644 --- a/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp +++ b/test/std/input.output/iostreams.base/ios/iostate.flags/clear.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template class basic_ios diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp index a0013eabdac6..9347644b12b1 100644 --- a/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp +++ b/test/std/input.output/iostreams.base/ios/iostate.flags/exceptions_iostate.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template class basic_ios diff --git a/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp b/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp index b3c66c487e9f..41cb61db194d 100644 --- a/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp +++ b/test/std/input.output/iostreams.base/ios/iostate.flags/setstate.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template class basic_ios diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp index 3abf9423a12e..67363b559d99 100644 --- a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp +++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/overflow.pass.cpp @@ -29,7 +29,7 @@ struct testbuf : base(str, which) {} typename base::int_type - overflow(typename base::int_type c = base::type_traits::eof()) + overflow(typename base::int_type c = base::traits_type::eof()) {++overflow_called; return base::overflow(c);} void pbump(int n) {base::pbump(n);} @@ -37,6 +37,10 @@ struct testbuf int main() { + { // sanity check + testbuf tb("");; + tb.overflow(); + } { testbuf sb("abc"); assert(sb.sputc('1') == '1'); diff --git a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp index 4af0e63029a7..a0509008d50b 100644 --- a/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp +++ b/test/std/input.output/string.streams/stringbuf/stringbuf.virtuals/pbackfail.pass.cpp @@ -27,7 +27,7 @@ struct testbuf : base(str, which) {} typename base::int_type - pbackfail(typename base::int_type c = base::type_traits::eof()) + pbackfail(typename base::int_type c = base::traits_type::eof()) {return base::pbackfail(c);} void pbump(int n) {base::pbump(n);} @@ -35,6 +35,10 @@ struct testbuf int main() { + { // sanity check + testbuf tb("");; + tb.pbackfail(); + } { testbuf sb("123", std::ios_base::in); assert(sb.sgetc() == '1'); diff --git a/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp b/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp index f584110499b8..0952588b0cb1 100644 --- a/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp +++ b/test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp @@ -12,6 +12,8 @@ // template // Iter next(Iter x, Iter::difference_type n = 1); +// LWG #2353 relaxed the requirement on next from ForwardIterator to InputIterator + #include #include @@ -34,11 +36,13 @@ test(It i, It x) int main() { const char* s = "1234567890"; + test(input_iterator(s), 10, input_iterator(s+10)); test(forward_iterator(s), 10, forward_iterator(s+10)); test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10)); test(random_access_iterator(s), 10, random_access_iterator(s+10)); test(s, 10, s+10); + test(input_iterator(s), input_iterator(s+1)); test(forward_iterator(s), forward_iterator(s+1)); test(bidirectional_iterator(s), bidirectional_iterator(s+1)); test(random_access_iterator(s), random_access_iterator(s+1)); diff --git a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp index 02ef571a06f9..932ef25b784c 100644 --- a/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp +++ b/test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp @@ -17,6 +17,10 @@ #include #include +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wliteral-conversion" +#endif + int main() { { diff --git a/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp index 6b799a3e83d8..0d4524cacb38 100644 --- a/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp +++ b/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp @@ -10,10 +10,14 @@ // test new_handler #include +#include +#include void f() {} int main() { + static_assert((std::is_same::value), ""); std::new_handler p = f; + assert(p == &f); } diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp index 5a87c0738784..55a3200a13b7 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test operator new[] // NOTE: asan and msan will not call the new handler. // UNSUPPORTED: sanitizer-new-delete @@ -38,7 +39,8 @@ int main() std::set_new_handler(new_handler); try { - void*volatile vp = operator new[] (std::numeric_limits::max()); + void* volatile vp = operator new[] (std::numeric_limits::max()); + ((void)vp); assert(false); } catch (std::bad_alloc&) diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp index b0db4a8e57e2..9531b1c37480 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test operator new [] (nothrow) // NOTE: asan and msan will not call the new handler. // UNSUPPORTED: sanitizer-new-delete diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp index 6447e29726c1..0e2cc6d8da4e 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp @@ -11,11 +11,10 @@ // UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11 -// TODO: Clang does not enable sized-deallocation in c++14 and behond by +// NOTE: Clang does not enable sized-deallocation in c++14 and beyond by // default. It is only enabled when -fsized-deallocation is given. -// (except clang-3.6 which temporarly enabled sized-deallocation) -// XFAIL: clang-3.4, clang-3.5, clang-3.7 -// XFAIL: apple-clang +// (except clang-3.6 which temporarily enabled sized-deallocation) +// UNSUPPORTED: clang, apple-clang // NOTE: GCC 4.9.1 does not support sized-deallocation in c++14. However // GCC 5.1 does. diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp index 58aa3f2d529c..57ce28752208 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test operator new // asan and msan will not call the new handler. @@ -39,6 +40,7 @@ int main() try { void* vp = operator new (std::numeric_limits::max()); + ((void)vp); assert(false); } catch (std::bad_alloc&) diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp index 8c095ad32db4..c2f5830495d2 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test operator new (nothrow) // asan and msan will not call the new handler. diff --git a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp index 3c7f54fef726..5d9ddd4f0526 100644 --- a/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp +++ b/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp @@ -11,11 +11,10 @@ // UNSUPPORTED: sanitizer-new-delete, c++98, c++03, c++11 -// TODO: Clang does not enable sized-deallocation in c++14 and behond by +// NOTE: Clang does not enable sized-deallocation in c++14 and beyond by // default. It is only enabled when -fsized-deallocation is given. -// (except clang-3.6 which temporarly enabled sized-deallocation) -// XFAIL: clang-3.4, clang-3.5, clang-3.7 -// XFAIL: apple-clang +// (except clang-3.6 which temporarily enabled sized-deallocation) +// UNSUPPORTED: clang, apple-clang // NOTE: GCC 4.9.1 does not support sized-deallocation in c++14. However // GCC 5.1 does. diff --git a/test/std/language.support/support.exception/except.nested/assign.pass.cpp b/test/std/language.support/support.exception/except.nested/assign.pass.cpp index cbe303c570d6..a5508d1436fa 100644 --- a/test/std/language.support/support.exception/except.nested/assign.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/assign.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class nested_exception; diff --git a/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp index bfa13707a971..f9f293300e62 100644 --- a/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/ctor_copy.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class nested_exception; diff --git a/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp index 1422f770eca8..67766aa2c461 100644 --- a/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/ctor_default.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class nested_exception; diff --git a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp index 567ed579eb7b..a8b6e15feab8 100644 --- a/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/rethrow_if_nested.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class nested_exception; @@ -36,6 +37,13 @@ class B B(const B& b) : A(b) {} }; +class C +{ +public: + virtual ~C() {} + C * operator&() const { assert(false); } // should not be called +}; + int main() { { @@ -78,7 +86,7 @@ int main() { try { - std::rethrow_if_nested(1); + std::rethrow_if_nested(C()); assert(true); } catch (...) @@ -86,4 +94,5 @@ int main() assert(false); } } + } diff --git a/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp index b07269061b4b..13c1dfe59311 100644 --- a/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/rethrow_nested.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class nested_exception; diff --git a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp index dad0df248076..98006bb1e3a0 100644 --- a/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp +++ b/test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class nested_exception; diff --git a/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp index 232ce0a5a888..e477f5298e89 100644 --- a/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp +++ b/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp @@ -10,10 +10,14 @@ // test terminate_handler #include +#include +#include void f() {} int main() { + static_assert((std::is_same::value), ""); std::terminate_handler p = f; + assert(p == &f); } diff --git a/test/std/language.support/support.exception/propagation/current_exception.pass.cpp b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp index 9ff0d6e2ce4d..09adf580bddf 100644 --- a/test/std/language.support/support.exception/propagation/current_exception.pass.cpp +++ b/test/std/language.support/support.exception/propagation/current_exception.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // exception_ptr current_exception(); diff --git a/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp index 89c9f85d3810..6e4c0a98b09f 100644 --- a/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp +++ b/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template exception_ptr make_exception_ptr(E e); diff --git a/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp index e47a5989d41c..c28c901bdd73 100644 --- a/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp +++ b/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void rethrow_exception [[noreturn]] (exception_ptr p); diff --git a/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp index 22d8d8e982ae..573d85bd242c 100644 --- a/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp +++ b/test/std/language.support/support.exception/uncaught/uncaught_exception.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test uncaught_exception #include diff --git a/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp index 1adc904fd5d2..b35ad7313bcc 100644 --- a/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp +++ b/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test uncaught_exceptions #include diff --git a/test/std/language.support/support.runtime/csignal.pass.cpp b/test/std/language.support/support.runtime/csignal.pass.cpp index 717347df7f00..a42363f8b27f 100644 --- a/test/std/language.support/support.runtime/csignal.pass.cpp +++ b/test/std/language.support/support.runtime/csignal.pass.cpp @@ -50,7 +50,8 @@ int main() { - std::sig_atomic_t sig; + std::sig_atomic_t sig = 0; + ((void)sig); typedef void (*func)(int); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/test/std/language.support/support.runtime/cstdarg.pass.cpp b/test/std/language.support/support.runtime/cstdarg.pass.cpp index 059ad2f4ff91..9d6f610a943e 100644 --- a/test/std/language.support/support.runtime/cstdarg.pass.cpp +++ b/test/std/language.support/support.runtime/cstdarg.pass.cpp @@ -32,4 +32,5 @@ int main() { std::va_list va; + ((void)va); } diff --git a/test/std/language.support/support.runtime/cstdlib.pass.cpp b/test/std/language.support/support.runtime/cstdlib.pass.cpp index 073949122b01..d8f88cf58d9d 100644 --- a/test/std/language.support/support.runtime/cstdlib.pass.cpp +++ b/test/std/language.support/support.runtime/cstdlib.pass.cpp @@ -11,6 +11,13 @@ #include #include +#include + +// As of 1/10/2015 clang emits a -Wnonnull warnings even if the warning occurs +// in an unevaluated context. For this reason we manually suppress the warning. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wnonnull" +#endif #ifndef EXIT_FAILURE #error EXIT_FAILURE not defined @@ -32,12 +39,23 @@ #error RAND_MAX not defined #endif +template +void test_div_struct() { + TestType obj; + static_assert(sizeof(obj) >= sizeof(IntType) * 2, ""); // >= to account for alignment. + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + ((void) obj); +}; + int main() { std::size_t s = 0; - std::div_t d; - std::ldiv_t ld; - std::lldiv_t lld; + ((void)s); + static_assert((std::is_same::value), ""); + test_div_struct(); + test_div_struct(); + test_div_struct(); char** endptr = 0; static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/test/std/language.support/support.runtime/ctime.pass.cpp b/test/std/language.support/support.runtime/ctime.pass.cpp index 8c5d2811d8a9..03a0aa4d6966 100644 --- a/test/std/language.support/support.runtime/ctime.pass.cpp +++ b/test/std/language.support/support.runtime/ctime.pass.cpp @@ -23,6 +23,7 @@ int main() { std::clock_t c = 0; + ((void)c); std::size_t s = 0; std::time_t t = 0; std::tm tm = {0}; diff --git a/test/std/language.support/support.types/nullptr_t.pass.cpp b/test/std/language.support/support.types/nullptr_t.pass.cpp index 4d7c8b0bc0a6..1cc2aa62032e 100644 --- a/test/std/language.support/support.types/nullptr_t.pass.cpp +++ b/test/std/language.support/support.types/nullptr_t.pass.cpp @@ -52,6 +52,24 @@ void test_comparisons() assert(!(nullptr > p)); } +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnull-conversion" +#endif +void test_nullptr_conversions() { + { + bool b = nullptr; + assert(!b); + } + { + bool b(nullptr); + assert(!b); + } +} +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + int main() { @@ -72,8 +90,5 @@ int main() test_comparisons(); test_comparisons(); } - { - bool b = nullptr; - assert(!b); - } + test_nullptr_conversions(); } diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp index 897141235cf2..04cc060ad985 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp @@ -26,7 +26,7 @@ int main() { // Ensure that the default locale is not C. If it is, the second tests will fail. - putenv(const_cast("LANG=" LOCALE_en_US_UTF_8)); + putenv(const_cast("LC_COLLATE=" LOCALE_en_US_UTF_8)); { std::locale l(LOCALE_en_US_UTF_8); { diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp index 331f4ba222dd..41c26508e22e 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_in.pass.cpp @@ -28,7 +28,7 @@ int main() const char from[] = "some text"; F::intern_type to[9]; const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char* from_next = 0; F::intern_type* to_next = 0; assert(f.in(mbs, from, from + 9, from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp index 34ab2178327e..bd3482974a53 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_length.pass.cpp @@ -22,7 +22,7 @@ int main() { std::locale l = std::locale::classic(); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char from[] = "some text"; assert(f.length(mbs, from, from+10, 0) == 0); assert(f.length(mbs, from, from+10, 8) == 8); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp index 0f65f13242c2..18997714fda6 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_out.pass.cpp @@ -31,7 +31,7 @@ int main() { F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'}; char to[9] = {0}; - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const F::intern_type* from_next = 0; char* to_next = 0; F::result r = f.out(mbs, from, from + 9, from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp index c21303070717..9b91a03d493a 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char16_t_unshift.pass.cpp @@ -26,7 +26,7 @@ int main() std::locale l = std::locale::classic(); std::vector to(3); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; char* to_next = 0; assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv); assert(to_next == to.data()); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp index 8fb28f0a26ac..8f9d1e6cd1f0 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_in.pass.cpp @@ -28,7 +28,7 @@ int main() const char from[] = "some text"; F::intern_type to[9]; const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char* from_next = 0; F::intern_type* to_next = 0; assert(f.in(mbs, from, from + 9, from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp index d8555d188566..4455b9f55fbb 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_length.pass.cpp @@ -22,7 +22,7 @@ int main() { std::locale l = std::locale::classic(); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char from[] = "some text"; assert(f.length(mbs, from, from+10, 0) == 0); assert(f.length(mbs, from, from+10, 8) == 8); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp index a1d11f748d9f..4e0f600097a0 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_out.pass.cpp @@ -31,7 +31,7 @@ int main() { F::intern_type from[9] = {'s', 'o', 'm', 'e', ' ', 't', 'e', 'x', 't'}; char to[9] = {0}; - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const F::intern_type* from_next = 0; char* to_next = 0; F::result r = f.out(mbs, from, from + 9, from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp index 1bd45e0370d9..0a4aa20039c5 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char32_t_unshift.pass.cpp @@ -26,7 +26,7 @@ int main() std::locale l = std::locale::classic(); std::vector to(3); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; char* to_next = 0; assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv); assert(to_next == to.data()); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp index 4d2f6f260dfc..10c9fcdc03fe 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_in.pass.cpp @@ -28,7 +28,7 @@ int main() const std::basic_string from("some text"); std::vector to(from.size()); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char* from_next = 0; char* to_next = 0; assert(f.in(mbs, from.data(), from.data() + from.size(), from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp index df33b182a07a..c5897c86bb8f 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_length.pass.cpp @@ -22,7 +22,7 @@ int main() { std::locale l = std::locale::classic(); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char from[10]= {0}; assert(f.length(mbs, from, from+10, 0) == 0); assert(f.length(mbs, from, from+10, 9) == 9); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp index de7f024fd467..17bde6cecc2f 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_out.pass.cpp @@ -28,7 +28,7 @@ int main() const std::basic_string from("some text"); std::vector to(from.size()); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char* from_next = 0; char* to_next = 0; assert(f.out(mbs, from.data(), from.data() + from.size(), from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp index 830bc43e9ead..834fa0f2724e 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/char_unshift.pass.cpp @@ -26,7 +26,7 @@ int main() std::locale l = std::locale::classic(); std::vector to(3); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; char* to_next = 0; assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::noconv); assert(to_next == to.data()); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp index 2505582c2613..c256078786d7 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/utf_sanity_check.pass.cpp @@ -30,7 +30,7 @@ int main() const F32_8& f32_8 = std::use_facet(std::locale::classic()); const F32_16& f32_16 = std::use_facet(l); const F16_8& f16_8 = std::use_facet(std::locale::classic()); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; F32_8::intern_type* c32p; F16_8::intern_type* c16p; F32_8::extern_type* c8p; diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp index e98097ba889c..a4ff61bcff65 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_in.pass.cpp @@ -29,7 +29,7 @@ int main() const std::basic_string expected(from.begin(), from.end()); std::basic_string to(from.size(), F::intern_type()); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const F::extern_type* from_next = 0; F::intern_type* to_next = 0; F::result r = f.in(mbs, from.data(), from.data() + from.size(), from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp index f97f2b4a324d..69037aad733d 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_length.pass.cpp @@ -22,7 +22,7 @@ int main() { std::locale l = std::locale::classic(); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const char* from = "123467890"; assert(f.length(mbs, from, from+10, 0) == 0); assert(f.length(mbs, from, from+10, 9) == 9); diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp index dce2d38c8279..6f025e3ff094 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_out.pass.cpp @@ -29,7 +29,7 @@ int main() { const std::basic_string from(L"some text"); std::vector to(from.size()+1); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const F::intern_type* from_next = 0; char* to_next = 0; F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next, @@ -43,7 +43,7 @@ int main() std::basic_string from(L"some text"); from[4] = '\0'; std::vector to(from.size()+1); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const F::intern_type* from_next = 0; char* to_next = 0; F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next, @@ -56,7 +56,7 @@ int main() { std::basic_string from(L"some text"); std::vector to(from.size()-1); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; const F::intern_type* from_next = 0; char* to_next = 0; F::result r = f.out(mbs, from.data(), from.data() + from.size(), from_next, diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp index 4d8895cf1a7e..10ab7a2b89f4 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt/locale.codecvt.members/wchar_t_unshift.pass.cpp @@ -28,7 +28,7 @@ int main() std::locale l = std::locale::classic(); std::vector to(3); const F& f = std::use_facet(l); - std::mbstate_t mbs = {0}; + std::mbstate_t mbs = {}; F::extern_type* to_next = 0; assert(f.unshift(mbs, to.data(), to.data() + to.size(), to_next) == F::ok); assert(to_next == to.data()); diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp index a442ae577b47..7ad431652a89 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp @@ -12,7 +12,7 @@ // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abreviated +// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abbreviated // months. This locale data was changed in glibc 2.14. // Debian uses glibc 2.13 as of 20/11/2014 // OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014 diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp index 631a500362da..631a6de03d82 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp @@ -12,7 +12,7 @@ // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abreviated +// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated // months. This locale data was fixed in glibc 2.14. // Debian uses glibc 2.13 as of 20/11/2014 // OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014 diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp index 27a3da76270f..5a58b06cc2d7 100644 --- a/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp +++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // wstring_convert diff --git a/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp b/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp index a40a2d2d8833..303fd790566c 100644 --- a/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp +++ b/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template const Facet& use_facet(const locale& loc); diff --git a/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp index 3567bf56c55a..b808a7650c47 100644 --- a/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 // UNSUPPORTED: sanitizer-new-delete diff --git a/test/std/localization/locales/locale/locale.members/combine.pass.cpp b/test/std/localization/locales/locale/locale.members/combine.pass.cpp index e956102c08fc..4573a4b01f47 100644 --- a/test/std/localization/locales/locale/locale.members/combine.pass.cpp +++ b/test/std/localization/locales/locale/locale.members/combine.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template locale combine(const locale& other) const; diff --git a/test/std/numerics/rand/rand.device/ctor.pass.cpp b/test/std/numerics/rand/rand.device/ctor.pass.cpp index 97f46b26aa27..a7b5a7c9c348 100644 --- a/test/std/numerics/rand/rand.device/ctor.pass.cpp +++ b/test/std/numerics/rand/rand.device/ctor.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class random_device; diff --git a/test/std/numerics/rand/rand.device/eval.pass.cpp b/test/std/numerics/rand/rand.device/eval.pass.cpp index 72aff076a5df..ed5361fbde75 100644 --- a/test/std/numerics/rand/rand.device/eval.pass.cpp +++ b/test/std/numerics/rand/rand.device/eval.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // class random_device; diff --git a/test/std/re/re.alg/re.alg.search/grep.pass.cpp b/test/std/re/re.alg/re.alg.search/grep.pass.cpp index 113243ecd349..9d74c2417d2d 100644 --- a/test/std/re/re.alg/re.alg.search/grep.pass.cpp +++ b/test/std/re/re.alg/re.alg.search/grep.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template @@ -19,8 +20,34 @@ #include #include +#include "test_macros.h" #include "test_iterators.h" +extern "C" void LLVMFuzzerTestOneInput(const char *data) +{ + size_t size = strlen(data); + if (size > 0) + { + try + { + std::regex::flag_type flag = std::regex_constants::grep; + std::string s((const char *)data, size); + std::regex re(s, flag); + std::regex_match(s, re); + } + catch (std::regex_error &ex) {} + } +} + + +void fuzz_tests() // patterns that the fuzzer has found +{ +// Raw string literals are a C++11 feature. +#if TEST_STD_VER >= 11 + LLVMFuzzerTestOneInput(R"XX(Õ)_%()()((\8'_%()_%()_%()_%(()_%()_%()_%(.t;)()¥f()_%()(.)_%;)()!¥f(((()()XX"); +#endif +} + int main() { { @@ -55,4 +82,5 @@ int main() assert(m.position(0) == 0); assert(m.str(0) == ""); } + fuzz_tests(); } diff --git a/test/std/re/re.regex/re.regex.assign/assign.pass.cpp b/test/std/re/re.regex/re.regex.assign/assign.pass.cpp index 8bf98268c493..9c5f834b9452 100644 --- a/test/std/re/re.regex/re.regex.assign/assign.pass.cpp +++ b/test/std/re/re.regex/re.regex.assign/assign.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template > class basic_regex; diff --git a/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp index 9455527412bb..4da4d957a88a 100644 --- a/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp +++ b/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template > class basic_regex; @@ -22,7 +23,7 @@ static bool error_escape_thrown(const char *pat) bool result = false; try { std::regex re(pat); - } catch (std::regex_error &ex) { + } catch (const std::regex_error &ex) { result = (ex.code() == std::regex_constants::error_escape); } return result; diff --git a/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp b/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp new file mode 100644 index 000000000000..c21672f02c98 --- /dev/null +++ b/test/std/re/re.regex/re.regex.construct/bad_repeat.pass.cpp @@ -0,0 +1,43 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// XFAIL: libcpp-no-exceptions +// + +// template > class basic_regex; + +// template +// basic_regex(const basic_string& s); + +#include +#include + +static bool error_badrepeat_thrown(const char *pat) +{ + bool result = false; + try { + std::regex re(pat); + } catch (const std::regex_error &ex) { + result = (ex.code() == std::regex_constants::error_badrepeat); + } + return result; +} + +int main() +{ + assert(error_badrepeat_thrown("?a")); + assert(error_badrepeat_thrown("*a")); + assert(error_badrepeat_thrown("+a")); + assert(error_badrepeat_thrown("{a")); + + assert(error_badrepeat_thrown("?(a+)")); + assert(error_badrepeat_thrown("*(a+)")); + assert(error_badrepeat_thrown("+(a+)")); + assert(error_badrepeat_thrown("{(a+)")); +} diff --git a/test/std/strings/basic.string/allocator_mismatch.fail.cpp b/test/std/strings/basic.string/allocator_mismatch.fail.cpp new file mode 100644 index 000000000000..644137ec2576 --- /dev/null +++ b/test/std/strings/basic.string/allocator_mismatch.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// +// The container's value type must be the same as the allocator's value type + +#include + +int main() +{ + std::basic_string, std::allocator > s; +} diff --git a/test/std/strings/basic.string/string.access/at.pass.cpp b/test/std/strings/basic.string/string.access/at.pass.cpp index 8fada8fb1eea..87998e18c581 100644 --- a/test/std/strings/basic.string/string.access/at.pass.cpp +++ b/test/std/strings/basic.string/string.access/at.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // const_reference at(size_type pos) const; diff --git a/test/std/strings/basic.string/string.capacity/capacity.pass.cpp b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp index bae762155527..c05346a633e9 100644 --- a/test/std/strings/basic.string/string.capacity/capacity.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/capacity.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // size_type capacity() const; diff --git a/test/std/strings/basic.string/string.capacity/max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp index e4ff556d9e3f..d857be28a6c9 100644 --- a/test/std/strings/basic.string/string.capacity/max_size.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/max_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // size_type max_size() const; diff --git a/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp index bbadb9ccc5a8..9c8f67950fb4 100644 --- a/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/over_max_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // size_type max_size() const; diff --git a/test/std/strings/basic.string/string.capacity/reserve.pass.cpp b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp index a155825be752..569ca760c7ce 100644 --- a/test/std/strings/basic.string/string.capacity/reserve.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/reserve.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void reserve(size_type res_arg=0); diff --git a/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp index 14fe209fd59a..16eca38e8012 100644 --- a/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/resize_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void resize(size_type n); diff --git a/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp index f293df971f21..cb01be01f34b 100644 --- a/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.capacity/resize_size_char.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // void resize(size_type n, charT c); diff --git a/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp b/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp index 32c9514a9154..d7bd5e06bbe9 100644 --- a/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp +++ b/test/std/strings/basic.string/string.cons/move_assign_noexcept.pass.cpp @@ -11,14 +11,18 @@ // basic_string& operator=(basic_string&& c) // noexcept( -// allocator_type::propagate_on_container_move_assignment::value && -// is_nothrow_move_assignable::value); - -// This tests a conforming extension +// allocator_traits::propagate_on_container_move_assignment::value || +// allocator_traits::is_always_equal::value); // C++17 +// +// before C++17, we use the conforming extension +// noexcept( +// allocator_type::propagate_on_container_move_assignment::value && +// is_nothrow_move_assignable::value); #include #include +#include "test_macros.h" #include "test_allocator.h" template @@ -28,6 +32,32 @@ struct some_alloc some_alloc(const some_alloc&); }; +template +struct some_alloc2 +{ + typedef T value_type; + + some_alloc2() {} + some_alloc2(const some_alloc2&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_move_assignment; + typedef std::true_type is_always_equal; +}; + +template +struct some_alloc3 +{ + typedef T value_type; + + some_alloc3() {} + some_alloc3(const some_alloc3&); + void deallocate(void*, unsigned) {} + + typedef std::false_type propagate_on_container_move_assignment; + typedef std::false_type is_always_equal; +}; + int main() { #if __has_feature(cxx_noexcept) @@ -41,7 +71,25 @@ int main() } { typedef std::basic_string, some_alloc> C; +#if TEST_STD_VER > 14 + // if the allocators are always equal, then the move assignment can be noexcept + static_assert( std::is_nothrow_move_assignable::value, ""); +#else + static_assert(!std::is_nothrow_move_assignable::value, ""); +#endif + } +#if TEST_STD_VER > 14 + { + // POCMA is false, always equal + typedef std::basic_string, some_alloc2> C; + static_assert( std::is_nothrow_move_assignable::value, ""); + } + { + // POCMA is false, not always equal + typedef std::basic_string, some_alloc3> C; static_assert(!std::is_nothrow_move_assignable::value, ""); } #endif + +#endif } diff --git a/test/std/strings/basic.string/string.cons/substr.pass.cpp b/test/std/strings/basic.string/string.cons/substr.pass.cpp index 2a9bf2ac88bb..2e42be13a842 100644 --- a/test/std/strings/basic.string/string.cons/substr.pass.cpp +++ b/test/std/strings/basic.string/string.cons/substr.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string(const basic_string& str, diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp index e8f54f475240..1d409b0932da 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp index d7ddb77b8e0f..99b53155d37e 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp @@ -76,4 +76,10 @@ int main() S("12345678901234567890")); } #endif +#if __cplusplus > 201402L + { + typedef std::string S; + static_assert(noexcept(S().assign(S())), ""); // LWG#2063 + } +#endif } diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp index 5f5983e76c94..db9e9a3271c6 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp index 33801352816f..69f001cf4f00 100644 --- a/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_copy/copy.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // size_type copy(charT* s, size_type n, size_type pos = 0) const; diff --git a/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp index bc9ec1cf8255..11015cb973ed 100644 --- a/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_erase/size_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp index 734dd8dffb78..8277f88d99cd 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp index 29b00ec55b9f..4df5a14cbc0e 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp index fd85696704cd..20e030273962 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp index 8c18941cf46a..016dcaf396fe 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp index 51c9e72fc56f..3c4c818e0396 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp index 914081bbc456..18f32bfe222a 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp index d98704287327..fc7ee98f9e34 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp index 33f57fd3b86c..cda4112257b0 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp index c130780dc9d1..59e4d5c28096 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp index ef0de8975eda..f5ac2e8b6023 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string& diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp index 9ed58a3e9bbc..2fef19a24df9 100644 --- a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // int compare(size_type pos, size_type n1, const charT *s) const; diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp index ee804d9cc6e5..cc61a2e453c4 100644 --- a/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_pointer_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // int compare(size_type pos, size_type n1, const charT *s, size_type n2) const; diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp index 3deb617e8d84..66417482fb58 100644 --- a/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // int compare(size_type pos1, size_type n1, const basic_string& str) const; diff --git a/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp index 122e6e9c487a..f5c067699233 100644 --- a/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.ops/string_compare/size_size_string_size_size.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // int compare(size_type pos1, size_type n1, const basic_string& str, diff --git a/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp index a73f70cd4b89..dc01f4f47747 100644 --- a/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp +++ b/test/std/strings/basic.string/string.ops/string_substr/substr.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // basic_string substr(size_type pos = 0, size_type n = npos) const; diff --git a/test/std/strings/c.strings/cctype.pass.cpp b/test/std/strings/c.strings/cctype.pass.cpp index 867338fb09c2..027fbcd469d5 100644 --- a/test/std/strings/c.strings/cctype.pass.cpp +++ b/test/std/strings/c.strings/cctype.pass.cpp @@ -86,18 +86,18 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); - assert(isalnum('a')); - assert(isalpha('a')); - assert(isblank(' ')); - assert(!iscntrl(' ')); - assert(!isdigit('a')); - assert(isgraph('a')); - assert(islower('a')); - assert(isprint('a')); - assert(!ispunct('a')); - assert(!isspace('a')); - assert(!isupper('a')); - assert(isxdigit('a')); - assert(tolower('A') == 'a'); - assert(toupper('a') == 'A'); + assert(std::isalnum('a')); + assert(std::isalpha('a')); + assert(std::isblank(' ')); + assert(!std::iscntrl(' ')); + assert(!std::isdigit('a')); + assert(std::isgraph('a')); + assert(std::islower('a')); + assert(std::isprint('a')); + assert(!std::ispunct('a')); + assert(!std::isspace('a')); + assert(!std::isupper('a')); + assert(std::isxdigit('a')); + assert(std::tolower('A') == 'a'); + assert(std::toupper('a') == 'A'); } diff --git a/test/std/strings/c.strings/cwchar.pass.cpp b/test/std/strings/c.strings/cwchar.pass.cpp index c3d868fbc3b7..93d2bb1efa50 100644 --- a/test/std/strings/c.strings/cwchar.pass.cpp +++ b/test/std/strings/c.strings/cwchar.pass.cpp @@ -30,7 +30,7 @@ int main() { - std::mbstate_t mb = {0}; + std::mbstate_t mb = {}; std::size_t s = 0; std::tm *tm = 0; std::wint_t w = 0; diff --git a/test/std/strings/string.conversions/stod.pass.cpp b/test/std/strings/string.conversions/stod.pass.cpp index 026d2301e071..27d5e5cbd19b 100644 --- a/test/std/strings/string.conversions/stod.pass.cpp +++ b/test/std/strings/string.conversions/stod.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // double stod(const string& str, size_t *idx = 0); diff --git a/test/std/strings/string.conversions/stof.pass.cpp b/test/std/strings/string.conversions/stof.pass.cpp index 3e9b681ddeb1..38519a2feba0 100644 --- a/test/std/strings/string.conversions/stof.pass.cpp +++ b/test/std/strings/string.conversions/stof.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 diff --git a/test/std/strings/string.conversions/stoi.pass.cpp b/test/std/strings/string.conversions/stoi.pass.cpp index c2fc2103579d..238072740703 100644 --- a/test/std/strings/string.conversions/stoi.pass.cpp +++ b/test/std/strings/string.conversions/stoi.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // int stoi(const string& str, size_t *idx = 0, int base = 10); diff --git a/test/std/strings/string.conversions/stol.pass.cpp b/test/std/strings/string.conversions/stol.pass.cpp index dbbccc92799c..2ca2c01cfb8c 100644 --- a/test/std/strings/string.conversions/stol.pass.cpp +++ b/test/std/strings/string.conversions/stol.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 diff --git a/test/std/strings/string.conversions/stold.pass.cpp b/test/std/strings/string.conversions/stold.pass.cpp index 93c59fe09a11..f489df2f124d 100644 --- a/test/std/strings/string.conversions/stold.pass.cpp +++ b/test/std/strings/string.conversions/stold.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // long double stold(const string& str, size_t *idx = 0); diff --git a/test/std/strings/string.conversions/stoll.pass.cpp b/test/std/strings/string.conversions/stoll.pass.cpp index f68490ed13ae..d41db4284acd 100644 --- a/test/std/strings/string.conversions/stoll.pass.cpp +++ b/test/std/strings/string.conversions/stoll.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 diff --git a/test/std/strings/string.conversions/stoul.pass.cpp b/test/std/strings/string.conversions/stoul.pass.cpp index 37d33c4a9091..9dbd952434a9 100644 --- a/test/std/strings/string.conversions/stoul.pass.cpp +++ b/test/std/strings/string.conversions/stoul.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 diff --git a/test/std/strings/string.conversions/stoull.pass.cpp b/test/std/strings/string.conversions/stoull.pass.cpp index c0667edb385e..837ca3120100 100644 --- a/test/std/strings/string.conversions/stoull.pass.cpp +++ b/test/std/strings/string.conversions/stoull.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 diff --git a/test/std/thread/futures/futures.async/async.pass.cpp b/test/std/thread/futures/futures.async/async.pass.cpp index c8a742566d8f..2c1313b7a2f0 100644 --- a/test/std/thread/futures/futures.async/async.pass.cpp +++ b/test/std/thread/futures/futures.async/async.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.async/async_race.pass.cpp b/test/std/thread/futures/futures.async/async_race.pass.cpp index 325a027132de..9acdd1abc485 100644 --- a/test/std/thread/futures/futures.async/async_race.pass.cpp +++ b/test/std/thread/futures/futures.async/async_race.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp b/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp index 70a4e00b0d6a..c0fe2ef881e8 100644 --- a/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp +++ b/test/std/thread/futures/futures.promise/alloc_ctor.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -19,36 +20,36 @@ #include #include -#include "../test_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" int main() { - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { - std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + std::promise p(std::allocator_arg, test_allocator(42)); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { - std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + std::promise p(std::allocator_arg, test_allocator(42)); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { - std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + std::promise p(std::allocator_arg, test_allocator(42)); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); // Test with a minimal allocator { std::promise p(std::allocator_arg, bare_allocator()); diff --git a/test/std/thread/futures/futures.promise/copy_assign.fail.cpp b/test/std/thread/futures/futures.promise/copy_assign.fail.cpp index c08278122225..e150ba0df65a 100644 --- a/test/std/thread/futures/futures.promise/copy_assign.fail.cpp +++ b/test/std/thread/futures/futures.promise/copy_assign.fail.cpp @@ -14,74 +14,36 @@ // promise& operator=(const promise& rhs) = delete; #include -#include -#include "../test_allocator.h" +#include "test_macros.h" int main() { - assert(test_alloc_base::count == 0); +#if TEST_STD_VER >= 11 { - std::promise p0(std::allocator_arg, test_allocator()); - std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); - p = p0; - assert(test_alloc_base::count == 1); - std::future f = p.get_future(); - assert(test_alloc_base::count == 1); - assert(f.valid()); - try - { - f = p0.get_future(); - assert(false); - } - catch (const std::future_error& e) - { - assert(e.code() == make_error_code(std::future_errc::no_state)); - } - assert(test_alloc_base::count == 1); + std::promise p0, p; + p = p0; // expected-error {{overload resolution selected deleted operator '='}} } - assert(test_alloc_base::count == 0); { - std::promise p0(std::allocator_arg, test_allocator()); - std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); - p = p0; - assert(test_alloc_base::count == 1); - std::future f = p.get_future(); - assert(test_alloc_base::count == 1); - assert(f.valid()); - try - { - f = p0.get_future(); - assert(false); - } - catch (const std::future_error& e) - { - assert(e.code() == make_error_code(std::future_errc::no_state)); - } - assert(test_alloc_base::count == 1); + std::promise p0, p; + p = p0; // expected-error {{overload resolution selected deleted operator '='}} } - assert(test_alloc_base::count == 0); { - std::promise p0(std::allocator_arg, test_allocator()); - std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); - p = p0; - assert(test_alloc_base::count == 1); - std::future f = p.get_future(); - assert(test_alloc_base::count == 1); - assert(f.valid()); - try - { - f = p0.get_future(); - assert(false); - } - catch (const std::future_error& e) - { - assert(e.code() == make_error_code(std::future_errc::no_state)); - } - assert(test_alloc_base::count == 1); + std::promise p0, p; + p = p0; // expected-error {{overload resolution selected deleted operator '='}} } - assert(test_alloc_base::count == 0); +#else + { + std::promise p0, p; + p = p0; // expected-error {{'operator=' is a private member of 'std::__1::promise'}} + } + { + std::promise p0, p; + p = p0; // expected-error {{'operator=' is a private member of 'std::__1::promise'}} + } + { + std::promise p0, p; + p = p0; // expected-error {{'operator=' is a private member of 'std::__1::promise'}} + } +#endif } diff --git a/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp b/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp index 36a3555aed46..34becbc1259b 100644 --- a/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp +++ b/test/std/thread/futures/futures.promise/copy_ctor.fail.cpp @@ -14,68 +14,36 @@ // promise(const promise&) = delete; #include -#include -#include "../test_allocator.h" +#include "test_macros.h" int main() { - assert(test_alloc_base::count == 0); +#if TEST_STD_VER >= 11 { - std::promise p0(std::allocator_arg, test_allocator()); - std::promise p(p0); - assert(test_alloc_base::count == 1); - std::future f = p.get_future(); - assert(test_alloc_base::count == 1); - assert(f.valid()); - try - { - f = p0.get_future(); - assert(false); - } - catch (const std::future_error& e) - { - assert(e.code() == make_error_code(std::future_errc::no_state)); - } - assert(test_alloc_base::count == 1); + std::promise p0; + std::promise p(p0); // expected-error {{call to deleted constructor of 'std::promise'}} } - assert(test_alloc_base::count == 0); { - std::promise p0(std::allocator_arg, test_allocator()); - std::promise p(p0); - assert(test_alloc_base::count == 1); - std::future f = p.get_future(); - assert(test_alloc_base::count == 1); - assert(f.valid()); - try - { - f = p0.get_future(); - assert(false); - } - catch (const std::future_error& e) - { - assert(e.code() == make_error_code(std::future_errc::no_state)); - } - assert(test_alloc_base::count == 1); + std::promise p0; + std::promise p(p0); // expected-error {{call to deleted constructor of 'std::promise'}} } - assert(test_alloc_base::count == 0); { - std::promise p0(std::allocator_arg, test_allocator()); - std::promise p(p0); - assert(test_alloc_base::count == 1); - std::future f = p.get_future(); - assert(test_alloc_base::count == 1); - assert(f.valid()); - try - { - f = p0.get_future(); - assert(false); - } - catch (const std::future_error& e) - { - assert(e.code() == make_error_code(std::future_errc::no_state)); - } - assert(test_alloc_base::count == 1); + std::promise p0; + std::promise p(p0); // expected-error {{call to deleted constructor of 'std::promise'}} } - assert(test_alloc_base::count == 0); +#else + { + std::promise p0; + std::promise p(p0); // expected-error {{calling a private constructor of class 'std::__1::promise'}} + } + { + std::promise p0; + std::promise p(p0); // expected-error {{calling a private constructor of class 'std::__1::promise'}} + } + { + std::promise p0; + std::promise p(p0); // expected-error {{calling a private constructor of class 'std::__1::promise'}} + } +#endif } diff --git a/test/std/thread/futures/futures.promise/default.pass.cpp b/test/std/thread/futures/futures.promise/default.pass.cpp index 95c9657c633e..d108b42756e2 100644 --- a/test/std/thread/futures/futures.promise/default.pass.cpp +++ b/test/std/thread/futures/futures.promise/default.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/dtor.pass.cpp b/test/std/thread/futures/futures.promise/dtor.pass.cpp index 78912f12adb9..e3151ab38322 100644 --- a/test/std/thread/futures/futures.promise/dtor.pass.cpp +++ b/test/std/thread/futures/futures.promise/dtor.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/get_future.pass.cpp b/test/std/thread/futures/futures.promise/get_future.pass.cpp index a7d084ee7873..bc45e28a9f96 100644 --- a/test/std/thread/futures/futures.promise/get_future.pass.cpp +++ b/test/std/thread/futures/futures.promise/get_future.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/move_assign.pass.cpp b/test/std/thread/futures/futures.promise/move_assign.pass.cpp index c3097df74990..9dd8a9daef80 100644 --- a/test/std/thread/futures/futures.promise/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.promise/move_assign.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -18,20 +20,19 @@ #include #include -#include "../test_allocator.h" +#include "test_allocator.h" int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); p = std::move(p0); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -42,17 +43,17 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); p = std::move(p0); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -63,17 +64,17 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); p = std::move(p0); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -84,8 +85,7 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(test_alloc_base::alloc_count == 0); } diff --git a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp index eeec4fb15b95..9a68b5c1b4e1 100644 --- a/test/std/thread/futures/futures.promise/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.promise/move_ctor.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -18,18 +20,17 @@ #include #include -#include "../test_allocator.h" +#include "test_allocator.h" int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::move(p0)); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -40,15 +41,15 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::move(p0)); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -59,15 +60,15 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::move(p0)); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); try { @@ -78,8 +79,7 @@ int main() { assert(e.code() == make_error_code(std::future_errc::no_state)); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + assert(test_alloc_base::alloc_count == 0); } diff --git a/test/std/thread/futures/futures.promise/set_exception.pass.cpp b/test/std/thread/futures/futures.promise/set_exception.pass.cpp index 51c05eb803cb..6ef41af94545 100644 --- a/test/std/thread/futures/futures.promise/set_exception.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_exception.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp index 5e57692563d8..f54d7cd16bdb 100644 --- a/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_exception_at_thread_exit.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp index cdc37775012c..98394871e703 100644 --- a/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_lvalue.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp index 18f87c596a00..e127d2c37faf 100644 --- a/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_lvalue_at_thread_exit.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp index dab4bf7e9c83..9cce3f59550a 100644 --- a/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_rvalue.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp index ec50cc310298..79137488e606 100644 --- a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_const.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp index 8c092084668d..6a0ce36326eb 100644 --- a/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_at_thread_exit_void.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_value_const.pass.cpp b/test/std/thread/futures/futures.promise/set_value_const.pass.cpp index 6673f6307579..db7465ceab85 100644 --- a/test/std/thread/futures/futures.promise/set_value_const.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_const.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/set_value_void.pass.cpp b/test/std/thread/futures/futures.promise/set_value_void.pass.cpp index 5012e0bfe5fd..87be8cd60a5e 100644 --- a/test/std/thread/futures/futures.promise/set_value_void.pass.cpp +++ b/test/std/thread/futures/futures.promise/set_value_void.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.promise/swap.pass.cpp b/test/std/thread/futures/futures.promise/swap.pass.cpp index 1ed3e646813c..21c946981a28 100644 --- a/test/std/thread/futures/futures.promise/swap.pass.cpp +++ b/test/std/thread/futures/futures.promise/swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -20,65 +21,65 @@ #include #include -#include "../test_allocator.h" +#include "test_allocator.h" int main() { - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); p.swap(p0); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); std::future f = p.get_future(); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); swap(p, p0); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); std::future f = p.get_future(); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::count == 2); + assert(test_alloc_base::alloc_count == 2); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p; - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); p.swap(p0); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { std::promise p0(std::allocator_arg, test_allocator()); std::promise p; - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); swap(p, p0); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); std::future f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); f = p0.get_future(); assert(f.valid()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); } diff --git a/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp b/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp index 458826e956e1..9a1d41cc0cb6 100644 --- a/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp +++ b/test/std/thread/futures/futures.promise/uses_allocator.pass.cpp @@ -18,7 +18,7 @@ // : true_type { }; #include -#include "../test_allocator.h" +#include "test_allocator.h" int main() { diff --git a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp index b23ba196ec30..3f9e945dddaf 100644 --- a/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/copy_assign.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -20,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise p; @@ -72,5 +72,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp index 425d1f9be96f..1da08808db2e 100644 --- a/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/copy_ctor.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp b/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp index 3a78b80f0634..1590efd7b634 100644 --- a/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/ctor_future.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp index baa89cb12b1c..af061268410d 100644 --- a/test/std/thread/futures/futures.shared_future/dtor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/dtor.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -18,51 +20,51 @@ #include #include -#include "../test_allocator.h" +#include "test_allocator.h" int main() { - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { typedef int T; std::shared_future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { typedef int& T; std::shared_future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { typedef void T; std::shared_future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); } diff --git a/test/std/thread/futures/futures.shared_future/get.pass.cpp b/test/std/thread/futures/futures.shared_future/get.pass.cpp index c5ee234b127f..6eea1d889b6d 100644 --- a/test/std/thread/futures/futures.shared_future/get.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/get.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp b/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp index 6b58f41c9085..3a1ef7a6849c 100644 --- a/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/move_assign.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -20,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef int T; std::promise p; @@ -72,5 +72,4 @@ int main() assert(!f0.valid()); assert(!f.valid()); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp b/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp index 32b8fd77c672..15323d678e3c 100644 --- a/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/move_ctor.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.shared_future/wait.pass.cpp b/test/std/thread/futures/futures.shared_future/wait.pass.cpp index 4293fcab3564..6ff74f6c6b90 100644 --- a/test/std/thread/futures/futures.shared_future/wait.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/wait.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp b/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp index e5a4754e38ad..1ec086266b0d 100644 --- a/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/wait_for.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp b/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp index 6a6aeba7759e..9cdc2e431f45 100644 --- a/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp +++ b/test/std/thread/futures/futures.shared_future/wait_until.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads + // UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp index 70ea0ad31fed..6c6418594d00 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/assign_copy.fail.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class packaged_task @@ -14,35 +16,11 @@ // packaged_task& operator=(packaged_task&) = delete; #include -#include - -class A -{ - long data_; - -public: - explicit A(long i) : data_(i) {} - - long operator()(long i, long j) const {return data_ + i + j;} -}; int main() { { - std::packaged_task p0(A(5)); - std::packaged_task p; - p = p0; - assert(!p0.valid()); - assert(p.valid()); - std::future f = p.get_future(); - p(3, 'a'); - assert(f.get() == 105.0); - } - { - std::packaged_task p0; - std::packaged_task p; - p = p0; - assert(!p0.valid()); - assert(!p.valid()); + std::packaged_task p0, p; + p = p0; // expected-error {{overload resolution selected deleted operator '='}} } } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp index 18786f4eb7a2..3f11d670bede 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/assign_move.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp index 45048b747f7a..7097d428962a 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class packaged_task @@ -25,5 +27,6 @@ typedef volatile std::packaged_task VPT; int main() { - PT p { VPT{} }; + PT p { VPT{} }; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task')}} + // expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}} } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp index e4df4ec225e7..feb7657bed37 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class packaged_task @@ -18,7 +20,7 @@ #include #include -#include "../../test_allocator.h" +#include "test_allocator.h" struct A {}; typedef std::packaged_task PT; @@ -26,5 +28,6 @@ typedef volatile std::packaged_task VPT; int main() { - PT p { std::allocator_arg_t{}, test_allocator{}, VPT {}}; + PT p { std::allocator_arg_t{}, test_allocator{}, VPT {}}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task')}} + // expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}} } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp index 9884c49a6dc7..97624f90f3df 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_copy.fail.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class packaged_task @@ -14,33 +16,12 @@ // packaged_task(packaged_task&) = delete; #include -#include -class A -{ - long data_; - -public: - explicit A(long i) : data_(i) {} - - long operator()(long i, long j) const {return data_ + i + j;} -}; int main() { - { - std::packaged_task p0(A(5)); - std::packaged_task p(p0); - assert(!p0.valid()); - assert(p.valid()); - std::future f = p.get_future(); - p(3, 'a'); - assert(f.get() == 105.0); - } { std::packaged_task p0; - std::packaged_task p(p0); - assert(!p0.valid()); - assert(!p.valid()); + std::packaged_task p(p0); // expected-error {{call to deleted constructor of 'std::packaged_task'}} } } diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp index 76904962a778..ed147d74895b 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_default.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp index 2eee2cbc2d50..14ac7614bb8e 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp index 3aac2b26bfc1..39784876b8c3 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_func_alloc.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -19,7 +20,7 @@ #include #include -#include "../../test_allocator.h" +#include "test_allocator.h" #include "min_allocator.h" class A @@ -47,7 +48,7 @@ int main() { std::packaged_task p(std::allocator_arg, test_allocator(), A(5)); - assert(test_alloc_base::count > 0); + assert(test_alloc_base::alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(3, 'a'); @@ -55,14 +56,14 @@ int main() assert(A::n_copies == 0); assert(A::n_moves > 0); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, test_allocator(), a); - assert(test_alloc_base::count > 0); + assert(test_alloc_base::alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(3, 'a'); @@ -70,31 +71,31 @@ int main() assert(A::n_copies > 0); assert(A::n_moves > 0); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, test_allocator(), &func); - assert(test_alloc_base::count > 0); + assert(test_alloc_base::alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(4); assert(f.get() == 4); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { A a(5); std::packaged_task p(std::allocator_arg, test_allocator(), func); - assert(test_alloc_base::count > 0); + assert(test_alloc_base::alloc_count > 0); assert(p.valid()); std::future f = p.get_future(); p(4); assert(f.get() == 4); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); A::n_copies = 0; A::n_moves = 0; { diff --git a/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp index 88f072281750..d9951dca585a 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/ctor_move.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp index e24232d1b227..7fafd1005649 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/dtor.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp index 13b5db110668..c8e5d6efd6b4 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/get_future.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp index 61a6a4f87965..54ac64458248 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/make_ready_at_thread_exit.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp index 2a09353b1e63..9ad1509517f6 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/operator.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp index 9d38d9b409c0..02a567500ee2 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/reset.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp index 33763bef0d0f..eb0091c8e817 100644 --- a/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.members/swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp index 668732b9b24a..d90d593a75bd 100644 --- a/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.nonmembers/swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp b/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp index 986f71e29a46..bbe75de7f8a9 100644 --- a/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp +++ b/test/std/thread/futures/futures.tas/futures.task.nonmembers/uses_allocator.pass.cpp @@ -9,6 +9,12 @@ // // UNSUPPORTED: libcpp-has-no-threads +// This test is marked XFAIL and not UNSUPPORTED because the non-variadic +// declaration of packaged_task is available in C++03. Therefore the test +// should fail because the static_assert fires and not because std::packaged_task +// in undefined. +// XFAIL: c++98, c++03 + // // class packaged_task @@ -18,7 +24,7 @@ // : true_type { }; #include -#include "../../test_allocator.h" +#include "test_allocator.h" int main() { diff --git a/test/std/thread/futures/futures.tas/types.pass.cpp b/test/std/thread/futures/futures.tas/types.pass.cpp index dd1724ddbda5..f7c9b223add1 100644 --- a/test/std/thread/futures/futures.tas/types.pass.cpp +++ b/test/std/thread/futures/futures.tas/types.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp b/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp index ebdcbf98d996..781c9c9d6199 100644 --- a/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp +++ b/test/std/thread/futures/futures.unique_future/copy_assign.fail.cpp @@ -14,61 +14,36 @@ // future& operator=(const future&) = delete; #include -#include + +#include "test_macros.h" int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { - typedef int T; - std::promise p; - std::future f0 = p.get_future(); - std::future f; - f = f0; - assert(!f0.valid()); - assert(f.valid()); + std::future f0, f; + f = f0; // expected-error {{overload resolution selected deleted operator '='}} } { - typedef int T; - std::future f0; - std::future f; - f = f0; - assert(!f0.valid()); - assert(!f.valid()); + std::future f0, f; + f = f0; // expected-error {{overload resolution selected deleted operator '='}} } { - typedef int& T; - std::promise p; - std::future f0 = p.get_future(); - std::future f; - f = f0; - assert(!f0.valid()); - assert(f.valid()); + std::future f0, f; + f = f0; // expected-error {{overload resolution selected deleted operator '='}} + } +#else + { + std::future f0, f; + f = f0; // expected-error {{'operator=' is a private member of 'std::__1::future'}} } { - typedef int& T; - std::future f0; - std::future f; - f = f0; - assert(!f0.valid()); - assert(!f.valid()); + std::future f0, f; + f = f0; // expected-error {{'operator=' is a private member of 'std::__1::future'}} } { - typedef void T; - std::promise p; - std::future f0 = p.get_future(); - std::future f; - f = f0; - assert(!f0.valid()); - assert(f.valid()); + std::future f0, f; + f = f0; // expected-error {{'operator=' is a private member of 'std::__1::future'}} } - { - typedef void T; - std::future f0; - std::future f; - f = f0; - assert(!f0.valid()); - assert(!f.valid()); - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp b/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp index 8d43294edc26..0d7b5f5074d3 100644 --- a/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp +++ b/test/std/thread/futures/futures.unique_future/copy_ctor.fail.cpp @@ -14,53 +14,36 @@ // future(const future&) = delete; #include -#include + +#include "test_macros.h" int main() { +#if TEST_STD_VER >= 11 { - typedef int T; - std::promise p; - std::future f0 = p.get_future(); - std::future f = f0; - assert(!f0.valid()); - assert(f.valid()); + std::future f0; + std::future f = f0; // expected-error {{call to deleted constructor of 'std::future'}} } { - typedef int T; - std::future f0; - std::future f = f0; - assert(!f0.valid()); - assert(!f.valid()); + std::future f0; + std::future f = f0; // expected-error {{call to deleted constructor of 'std::future'}} } { - typedef int& T; - std::promise p; - std::future f0 = p.get_future(); - std::future f = f0; - assert(!f0.valid()); - assert(f.valid()); + std::future f0; + std::future f = f0; // expected-error {{call to deleted constructor of 'std::future'}} + } +#else + { + std::future f0; + std::future f = f0; // expected-error {{calling a private constructor of class 'std::__1::future'}} } { - typedef int& T; - std::future f0; - std::future f = std::move(f0); - assert(!f0.valid()); - assert(!f.valid()); + std::future f0; + std::future f = f0; // expected-error {{calling a private constructor of class 'std::__1::future'}} } { - typedef void T; - std::promise p; - std::future f0 = p.get_future(); - std::future f = f0; - assert(!f0.valid()); - assert(f.valid()); - } - { - typedef void T; - std::future f0; - std::future f = f0; - assert(!f0.valid()); - assert(!f.valid()); + std::future f0; + std::future f = f0; // expected-error {{calling a private constructor of class 'std::__1::future'}} } +#endif } diff --git a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp index 5e9697bb939b..03d7c915cb61 100644 --- a/test/std/thread/futures/futures.unique_future/dtor.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/dtor.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // @@ -18,51 +20,51 @@ #include #include -#include "../test_allocator.h" +#include "test_allocator.h" int main() { - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { typedef int T; std::future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { typedef int& T; std::future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); { typedef void T; std::future f; { std::promise p(std::allocator_arg, test_allocator()); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); f = p.get_future(); - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 1); + assert(test_alloc_base::alloc_count == 1); assert(f.valid()); } - assert(test_alloc_base::count == 0); + assert(test_alloc_base::alloc_count == 0); } diff --git a/test/std/thread/futures/futures.unique_future/get.pass.cpp b/test/std/thread/futures/futures.unique_future/get.pass.cpp index 758e38a7dae9..67b1052c175d 100644 --- a/test/std/thread/futures/futures.unique_future/get.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/get.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.unique_future/share.pass.cpp b/test/std/thread/futures/futures.unique_future/share.pass.cpp index 794b5ce38feb..ef011d8df752 100644 --- a/test/std/thread/futures/futures.unique_future/share.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/share.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.unique_future/wait.pass.cpp b/test/std/thread/futures/futures.unique_future/wait.pass.cpp index e10d37cf8064..f6de983f3057 100644 --- a/test/std/thread/futures/futures.unique_future/wait.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/wait.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp b/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp index 0a381d9ca2f0..c4f358268432 100644 --- a/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/wait_for.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 // diff --git a/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp b/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp index d5865b9b9dcf..541c00860752 100644 --- a/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp +++ b/test/std/thread/futures/futures.unique_future/wait_until.pass.cpp @@ -1,129 +1,130 @@ - //===----------------------------------------------------------------------===// - // - // The LLVM Compiler Infrastructure - // - // This file is dual licensed under the MIT and the University of Illinois Open - // Source Licenses. See LICENSE.TXT for details. - // - //===----------------------------------------------------------------------===// - // - // UNSUPPORTED: libcpp-has-no-threads +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03 - // +// - // class future +// class future - // template - // future_status - // wait_until(const chrono::time_point& abs_time) const; +// template +// future_status +// wait_until(const chrono::time_point& abs_time) const; - #include - #include - #include +#include +#include +#include - enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting }; - typedef std::chrono::milliseconds ms; +enum class WorkerThreadState { Uninitialized, AllowedToRun, Exiting }; +typedef std::chrono::milliseconds ms; - std::atomic thread_state(WorkerThreadState::Uninitialized); +std::atomic thread_state(WorkerThreadState::Uninitialized); - void set_worker_thread_state(WorkerThreadState state) - { - thread_state.store(state, std::memory_order_relaxed); - } +void set_worker_thread_state(WorkerThreadState state) +{ + thread_state.store(state, std::memory_order_relaxed); +} - void wait_for_worker_thread_state(WorkerThreadState state) - { - while (thread_state.load(std::memory_order_relaxed) != state); - } +void wait_for_worker_thread_state(WorkerThreadState state) +{ + while (thread_state.load(std::memory_order_relaxed) != state); +} - void func1(std::promise p) - { - wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); - p.set_value(3); - set_worker_thread_state(WorkerThreadState::Exiting); - } +void func1(std::promise p) +{ + wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); + p.set_value(3); + set_worker_thread_state(WorkerThreadState::Exiting); +} - int j = 0; +int j = 0; - void func3(std::promise p) - { - wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); - j = 5; - p.set_value(j); - set_worker_thread_state(WorkerThreadState::Exiting); - } +void func3(std::promise p) +{ + wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); + j = 5; + p.set_value(j); + set_worker_thread_state(WorkerThreadState::Exiting); +} - void func5(std::promise p) - { - wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); - p.set_value(); - set_worker_thread_state(WorkerThreadState::Exiting); - } +void func5(std::promise p) +{ + wait_for_worker_thread_state(WorkerThreadState::AllowedToRun); + p.set_value(); + set_worker_thread_state(WorkerThreadState::Exiting); +} - int main() - { - typedef std::chrono::high_resolution_clock Clock; - { - typedef int T; - std::promise p; - std::future f = p.get_future(); - std::thread(func1, std::move(p)).detach(); - assert(f.valid()); - assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); - assert(f.valid()); +int main() +{ + typedef std::chrono::high_resolution_clock Clock; + { + typedef int T; + std::promise p; + std::future f = p.get_future(); + std::thread(func1, std::move(p)).detach(); + assert(f.valid()); + assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); + assert(f.valid()); - // allow the worker thread to produce the result and wait until the worker is done - set_worker_thread_state(WorkerThreadState::AllowedToRun); - wait_for_worker_thread_state(WorkerThreadState::Exiting); + // allow the worker thread to produce the result and wait until the worker is done + set_worker_thread_state(WorkerThreadState::AllowedToRun); + wait_for_worker_thread_state(WorkerThreadState::Exiting); - assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); - assert(f.valid()); - Clock::time_point t0 = Clock::now(); - f.wait(); - Clock::time_point t1 = Clock::now(); - assert(f.valid()); - assert(t1-t0 < ms(5)); - } - { - typedef int& T; - std::promise p; - std::future f = p.get_future(); - std::thread(func3, std::move(p)).detach(); - assert(f.valid()); - assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); - assert(f.valid()); + assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); + assert(f.valid()); + Clock::time_point t0 = Clock::now(); + f.wait(); + Clock::time_point t1 = Clock::now(); + assert(f.valid()); + assert(t1-t0 < ms(5)); + } + { + typedef int& T; + std::promise p; + std::future f = p.get_future(); + std::thread(func3, std::move(p)).detach(); + assert(f.valid()); + assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); + assert(f.valid()); - // allow the worker thread to produce the result and wait until the worker is done - set_worker_thread_state(WorkerThreadState::AllowedToRun); - wait_for_worker_thread_state(WorkerThreadState::Exiting); + // allow the worker thread to produce the result and wait until the worker is done + set_worker_thread_state(WorkerThreadState::AllowedToRun); + wait_for_worker_thread_state(WorkerThreadState::Exiting); - assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); - assert(f.valid()); - Clock::time_point t0 = Clock::now(); - f.wait(); - Clock::time_point t1 = Clock::now(); - assert(f.valid()); - assert(t1-t0 < ms(5)); - } - { - typedef void T; - std::promise p; - std::future f = p.get_future(); - std::thread(func5, std::move(p)).detach(); - assert(f.valid()); - assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); - assert(f.valid()); + assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); + assert(f.valid()); + Clock::time_point t0 = Clock::now(); + f.wait(); + Clock::time_point t1 = Clock::now(); + assert(f.valid()); + assert(t1-t0 < ms(5)); + } + { + typedef void T; + std::promise p; + std::future f = p.get_future(); + std::thread(func5, std::move(p)).detach(); + assert(f.valid()); + assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::timeout); + assert(f.valid()); - // allow the worker thread to produce the result and wait until the worker is done - set_worker_thread_state(WorkerThreadState::AllowedToRun); - wait_for_worker_thread_state(WorkerThreadState::Exiting); + // allow the worker thread to produce the result and wait until the worker is done + set_worker_thread_state(WorkerThreadState::AllowedToRun); + wait_for_worker_thread_state(WorkerThreadState::Exiting); - assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); - assert(f.valid()); - Clock::time_point t0 = Clock::now(); - f.wait(); - Clock::time_point t1 = Clock::now(); - assert(f.valid()); - assert(t1-t0 < ms(5)); - } - } + assert(f.wait_until(Clock::now() + ms(10)) == std::future_status::ready); + assert(f.valid()); + Clock::time_point t0 = Clock::now(); + f.wait(); + Clock::time_point t1 = Clock::now(); + assert(f.valid()); + assert(t1-t0 < ms(5)); + } +} diff --git a/test/std/thread/futures/test_allocator.h b/test/std/thread/futures/test_allocator.h deleted file mode 100644 index 50072909fa4e..000000000000 --- a/test/std/thread/futures/test_allocator.h +++ /dev/null @@ -1,158 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef TEST_ALLOCATOR_H -#define TEST_ALLOCATOR_H - -#include -#include -#include -#include -#include -#include - -class test_alloc_base -{ -public: - static int count; -public: - static int throw_after; -}; - -int test_alloc_base::count = 0; -int test_alloc_base::throw_after = INT_MAX; - -template -class test_allocator - : public test_alloc_base -{ - int data_; - - template friend class test_allocator; -public: - - typedef unsigned size_type; - typedef int difference_type; - typedef T value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - typedef typename std::add_lvalue_reference::type reference; - typedef typename std::add_lvalue_reference::type const_reference; - - template struct rebind {typedef test_allocator other;}; - - test_allocator() throw() : data_(-1) {} - explicit test_allocator(int i) throw() : data_(i) {} - test_allocator(const test_allocator& a) throw() - : data_(a.data_) {} - template test_allocator(const test_allocator& a) throw() - : data_(a.data_) {} - ~test_allocator() throw() {data_ = 0;} - pointer address(reference x) const {return &x;} - const_pointer address(const_reference x) const {return &x;} - pointer allocate(size_type n, const void* = 0) - { - if (count >= throw_after) { -#ifndef _LIBCPP_NO_EXCEPTIONS - throw std::bad_alloc(); -#else - std::terminate(); -#endif - } - ++count; - return (pointer)std::malloc(n * sizeof(T)); - } - void deallocate(pointer p, size_type n) - {--count; std::free(p);} - size_type max_size() const throw() - {return UINT_MAX / sizeof(T);} - void construct(pointer p, const T& val) - {::new(p) T(val);} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - void construct(pointer p, T&& val) - {::new(p) T(std::move(val));} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - void destroy(pointer p) {p->~T();} - - friend bool operator==(const test_allocator& x, const test_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const test_allocator& x, const test_allocator& y) - {return !(x == y);} -}; - -template <> -class test_allocator - : public test_alloc_base -{ - int data_; - - template friend class test_allocator; -public: - - typedef unsigned size_type; - typedef int difference_type; - typedef void value_type; - typedef value_type* pointer; - typedef const value_type* const_pointer; - - template struct rebind {typedef test_allocator other;}; - - test_allocator() throw() : data_(-1) {} - explicit test_allocator(int i) throw() : data_(i) {} - test_allocator(const test_allocator& a) throw() - : data_(a.data_) {} - template test_allocator(const test_allocator& a) throw() - : data_(a.data_) {} - ~test_allocator() throw() {data_ = 0;} - - friend bool operator==(const test_allocator& x, const test_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const test_allocator& x, const test_allocator& y) - {return !(x == y);} -}; - -template -class other_allocator -{ - int data_; - - template friend class other_allocator; - -public: - typedef T value_type; - - other_allocator() : data_(-1) {} - explicit other_allocator(int i) : data_(i) {} - template other_allocator(const other_allocator& a) - : data_(a.data_) {} - T* allocate(std::size_t n) - {return (T*)std::malloc(n * sizeof(T));} - void deallocate(T* p, std::size_t n) - {std::free(p);} - - other_allocator select_on_container_copy_construction() const - {return other_allocator(-2);} - - friend bool operator==(const other_allocator& x, const other_allocator& y) - {return x.data_ == y.data_;} - friend bool operator!=(const other_allocator& x, const other_allocator& y) - {return !(x == y);} - - typedef std::true_type propagate_on_container_copy_assignment; - typedef std::true_type propagate_on_container_move_assignment; - typedef std::true_type propagate_on_container_swap; - -#ifdef _LIBCPP_HAS_NO_ADVANCED_SFINAE - std::size_t max_size() const - {return UINT_MAX / sizeof(T);} -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE - -}; - -#endif // TEST_ALLOCATOR_H diff --git a/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp b/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp index 2b8772f92ed2..02da345cb7d1 100644 --- a/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp +++ b/test/std/thread/thread.condition/notify_all_at_thread_exit.pass.cpp @@ -9,6 +9,10 @@ // // UNSUPPORTED: libcpp-has-no-threads +// notify_all_at_thread_exit(...) requires move semantics to transfer the +// unique_lock. +// UNSUPPORTED: c++98, c++03 + // // void @@ -36,9 +40,10 @@ void func() int main() { std::unique_lock lk(mut); - std::thread(func).detach(); + std::thread t(func); Clock::time_point t0 = Clock::now(); cv.wait(lk); Clock::time_point t1 = Clock::now(); assert(t1-t0 > ms(250)); + t.join(); } diff --git a/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp index 6236a13df80e..e99ebee9c8e0 100644 --- a/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp +++ b/test/std/thread/thread.condition/thread.condition.condvar/notify_one.pass.cpp @@ -16,16 +16,17 @@ // void notify_one(); #include +#include #include #include #include + std::condition_variable cv; std::mutex mut; -int test0 = 0; -int test1 = 0; -int test2 = 0; +std::atomic_int test1(0); +std::atomic_int test2(0); void f1() { @@ -64,11 +65,13 @@ int main() } if (test1 == 2) { + assert(test2 == 1); t1.join(); test1 = 0; } else if (test2 == 2) { + assert(test1 == 1); t2.join(); test2 = 0; } @@ -81,11 +84,13 @@ int main() } if (test1 == 2) { + assert(test2 == 0); t1.join(); test1 = 0; } else if (test2 == 2) { + assert(test1 == 0); t2.join(); test2 = 0; } diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp deleted file mode 100644 index 522c61b02d17..000000000000 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait.exception.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads - -#include -#include -#include -#include -#include -#include - -void f1() -{ - std::exit(0); -} - -struct Mutex -{ - unsigned state = 0; - Mutex() = default; - ~Mutex() = default; - Mutex(const Mutex&) = delete; - Mutex& operator=(const Mutex&) = delete; - - void lock() - { - if (++state == 2) - throw 1; // this throw should end up calling terminate() - } - - void unlock() {} -}; - -Mutex mut; -std::condition_variable_any cv; - -void -signal_me() -{ - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - cv.notify_one(); -} - -int -main() -{ - std::set_terminate(f1); - try - { - std::thread(signal_me).detach(); - mut.lock(); - cv.wait(mut); - } - catch (...) {} - assert(false); -} diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp deleted file mode 100644 index 1906b5892506..000000000000 --- a/test/std/thread/thread.condition/thread.condition.condvarany/wait_for.exception.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads - -#include -#include -#include -#include -#include -#include - -void f1() -{ - std::exit(0); -} - -struct Mutex -{ - unsigned state = 0; - Mutex() = default; - ~Mutex() = default; - Mutex(const Mutex&) = delete; - Mutex& operator=(const Mutex&) = delete; - - void lock() - { - if (++state == 2) - throw 1; // this throw should end up calling terminate() - } - - void unlock() {} -}; - -Mutex mut; -std::condition_variable_any cv; - -void -signal_me() -{ - std::this_thread::sleep_for(std::chrono::milliseconds(500)); - cv.notify_one(); -} - -int -main() -{ - std::set_terminate(f1); - try - { - std::thread(signal_me).detach(); - mut.lock(); - cv.wait_for(mut, std::chrono::milliseconds(250)); - } - catch (...) {} - assert(false); -} diff --git a/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp new file mode 100644 index 000000000000..f9a35cc905c7 --- /dev/null +++ b/test/std/thread/thread.condition/thread.condition.condvarany/wait_terminates.sh.cpp @@ -0,0 +1,134 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// XFAIL: libcpp-no-exceptions +// UNSUPPORTED: libcpp-has-no-threads + +// + +// class condition_variable_any; + +// RUN: %build +// RUN: %run 1 +// RUN: %run 2 +// RUN: %run 3 +// RUN: %run 4 +// RUN: %run 5 +// RUN: %run 6 + +// ----------------------------------------------------------------------------- +// Overview +// Check that std::terminate is called if wait(...) fails to meet it's post +// conditions. This can happens when reacquiring the mutex throws +// an exception. +// +// The following methods are tested within this file +// 1. void wait(Lock& lock); +// 2. void wait(Lock& lock, Pred); +// 3. void wait_for(Lock& lock, Duration); +// 4. void wait_for(Lock& lock, Duration, Pred); +// 5. void wait_until(Lock& lock, TimePoint); +// 6. void wait_until(Lock& lock, TimePoint, Pred); +// +// Plan +// 1 Create a mutex type, 'ThrowingMutex', that throws when the lock is aquired +// for the *second* time. +// +// 2 Replace the terminate handler with one that exits with a '0' exit code. +// +// 3 Create a 'condition_variable_any' object 'cv' and a 'ThrowingMutex' +// object 'm' and lock 'm'. +// +// 4 Start a thread 'T2' that will notify 'cv' once 'm' has been unlocked. +// +// 5 From the main thread call the specified wait method on 'cv' with 'm'. +// When 'T2' notifies 'cv' and the wait method attempts to re-lock +// 'm' an exception will be thrown from 'm.lock()'. +// +// 6 Check that control flow does not return from the wait method and that +// terminate is called (If the program exits with a 0 exit code we know +// that terminate has been called) + + +#include +#include +#include +#include +#include +#include +#include + +void my_terminate() { + std::_Exit(0); // Use _Exit to prevent cleanup from taking place. +} + +// The predicate used in the cv.wait calls. +bool pred = false; +bool pred_function() { + return pred == true; +} + +class ThrowingMutex +{ + std::atomic_bool locked; + unsigned state = 0; + ThrowingMutex(const ThrowingMutex&) = delete; + ThrowingMutex& operator=(const ThrowingMutex&) = delete; +public: + ThrowingMutex() { + locked = false; + } + ~ThrowingMutex() = default; + + void lock() { + locked = true; + if (++state == 2) { + assert(pred); // Check that we actually waited until we were signaled. + throw 1; // this throw should end up calling terminate() + } + } + + void unlock() { locked = false; } + bool isLocked() const { return locked == true; } +}; + +ThrowingMutex mut; +std::condition_variable_any cv; + +void signal_me() { + while (mut.isLocked()) {} // wait until T1 releases mut inside the cv.wait call. + pred = true; + cv.notify_one(); +} + +typedef std::chrono::system_clock Clock; +typedef std::chrono::milliseconds MS; + +int main(int argc, char** argv) { + assert(argc == 2); + int id = std::stoi(argv[1]); + assert(id >= 1 && id <= 6); + std::set_terminate(my_terminate); // set terminate after std::stoi because it can throw. + MS wait(250); + try { + mut.lock(); + assert(pred == false); + std::thread(signal_me).detach(); + switch (id) { + case 1: cv.wait(mut); break; + case 2: cv.wait(mut, pred_function); break; + case 3: cv.wait_for(mut, wait); break; + case 4: cv.wait_for(mut, wait, pred_function); break; + case 5: cv.wait_until(mut, Clock::now() + wait); break; + case 6: cv.wait_until(mut, Clock::now() + wait, pred_function); break; + default: assert(false); + } + } catch (...) {} + assert(false); +} diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp index f67ca2169825..eac7600b5d11 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock.algorithm/lock.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp index f0c54b71883f..8889408be2d7 100644 --- a/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock.algorithm/try_lock.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp index 2c1c665fdeda..f7cf49c81f3f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/default.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -20,9 +21,7 @@ int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock ul; assert(!ul.owns_lock()); assert(ul.mutex() == nullptr); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp index 8676f2ca0472..15c193c60b5d 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_assign.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,16 +19,11 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m0; std::shared_timed_mutex m1; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0(m0); std::shared_lock lk1(m1); lk1 = std::move(lk0); @@ -35,5 +31,4 @@ int main() assert(lk1.owns_lock() == true); assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp index f59d2e826980..4f4f6a5e9fbd 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/move_ctor.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,18 +19,13 @@ #include #include -#if _LIBCPP_STD_VER > 11 -std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 + std::shared_timed_mutex m; std::shared_lock lk0(m); std::shared_lock lk = std::move(lk0); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); assert(lk0.mutex() == nullptr); assert(lk0.owns_lock() == false); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp index c8a0287314bf..12bef34cf87b 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -21,9 +22,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 - -std::shared_timed_mutex m; +#include "test_macros.h" typedef std::chrono::system_clock Clock; typedef Clock::time_point time_point; @@ -31,6 +30,19 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + +std::shared_timed_mutex m; + void f() { time_point t0 = Clock::now(); @@ -39,8 +51,8 @@ void f() std::shared_lock ul(m); t1 = Clock::now(); } - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } void g() @@ -52,30 +64,30 @@ void g() t1 = Clock::now(); } ns d = t1 - t0; - assert(d < ms(50)); // within 50ms + assert(d < Tolerance); // within tolerance } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 - m.lock(); std::vector v; - for (int i = 0; i < 5; ++i) - v.push_back(std::thread(f)); - std::this_thread::sleep_for(ms(250)); - m.unlock(); - for (auto& t : v) - t.join(); - m.lock_shared(); - for (auto& t : v) - t = std::thread(g); - std::thread q(f); - std::this_thread::sleep_for(ms(250)); - m.unlock_shared(); - for (auto& t : v) - t.join(); - q.join(); -#endif // _LIBCPP_STD_VER > 11 + { + m.lock(); + for (int i = 0; i < 5; ++i) + v.push_back(std::thread(f)); + std::this_thread::sleep_for(WaitTime); + m.unlock(); + for (auto& t : v) + t.join(); + } + { + m.lock_shared(); + for (auto& t : v) + t = std::thread(g); + std::thread q(f); + std::this_thread::sleep_for(WaitTime); + m.unlock_shared(); + for (auto& t : v) + t.join(); + q.join(); + } } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp index 3b49b3029052..995210221065 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_adopt_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -20,11 +21,9 @@ int main() { -#if _LIBCPP_STD_VER > 11 std::shared_timed_mutex m; m.lock_shared(); std::shared_lock lk(m, std::adopt_lock); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp index bbc38fcadb10..d81796b95bf3 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_defer_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -20,10 +21,8 @@ int main() { -#if _LIBCPP_STD_VER > 11 std::shared_timed_mutex m; std::shared_lock lk(m, std::defer_lock); assert(lk.mutex() == &m); assert(lk.owns_lock() == false); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp index 9816e57f692a..84f868d6810b 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_duration.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -22,7 +23,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h" std::shared_timed_mutex m; @@ -32,37 +33,46 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + + void f1() { time_point t0 = Clock::now(); - std::shared_lock lk(m, ms(300)); + std::shared_lock lk(m, WaitTime + Tolerance); assert(lk.owns_lock() == true); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } void f2() { time_point t0 = Clock::now(); - std::shared_lock lk(m, ms(250)); + std::shared_lock lk(m, WaitTime); assert(lk.owns_lock() == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 { m.lock(); std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f1)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -72,10 +82,9 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f2)); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); for (auto& t : v) t.join(); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp index 5d188ab06737..9359731486dd 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_time_point.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -22,7 +23,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h" std::shared_timed_mutex m; @@ -32,37 +33,45 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f1() { time_point t0 = Clock::now(); - std::shared_lock lk(m, Clock::now() + ms(300)); + std::shared_lock lk(m, Clock::now() + WaitTime + Tolerance); assert(lk.owns_lock() == true); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ns(50000000)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } void f2() { time_point t0 = Clock::now(); - std::shared_lock lk(m, Clock::now() + ms(250)); + std::shared_lock lk(m, Clock::now() + WaitTime); assert(lk.owns_lock() == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 { m.lock(); std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f1)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -72,10 +81,9 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f2)); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); for (auto& t : v) t.join(); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp index f2d4e0deb73f..7f89f0af801f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.cons/mutex_try_to_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -21,8 +22,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; typedef std::chrono::system_clock Clock; @@ -57,11 +56,8 @@ void f() assert(d < ms(200)); // within 200ms } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 m.lock(); std::vector v; for (int i = 0; i < 5; ++i) @@ -70,5 +66,4 @@ int main() m.unlock(); for (auto& t : v) t.join(); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp index f1500652badd..5c3513c98e03 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/lock.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -21,7 +23,7 @@ #include #include -#if _LIBCPP_STD_VER > 11 +#include "test_macros.h" std::shared_timed_mutex m; @@ -31,6 +33,18 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(25); +#else +ms Tolerance = ms(25 * 5); +#endif + + void f() { std::shared_lock lk(m, std::defer_lock); @@ -38,8 +52,8 @@ void f() lk.lock(); time_point t1 = Clock::now(); assert(lk.owns_lock() == true); - ns d = t1 - t0 - ms(250); - assert(d < ms(25)); // within 25ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance try { lk.lock(); @@ -62,18 +76,14 @@ void f() } } -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 m.lock(); std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp index 82b1ff865053..01693c77ea39 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +20,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool try_lock_called = false; struct mutex @@ -34,11 +34,9 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 + std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock() == true); assert(try_lock_called == true); @@ -66,5 +64,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp index 5867465a6626..852a94eb65ec 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_for.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -19,8 +21,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool try_lock_for_called = false; typedef std::chrono::milliseconds ms; @@ -39,11 +39,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock_for(ms(5)) == true); assert(try_lock_for_called == true); @@ -71,5 +68,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp index 9d38983be724..31574afd7d8f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/try_lock_until.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -19,8 +21,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool try_lock_until_called = false; struct mutex @@ -38,11 +38,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 typedef std::chrono::steady_clock Clock; std::shared_lock lk(m, std::defer_lock); assert(lk.try_lock_until(Clock::now()) == true); @@ -71,5 +68,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp index eb08a45cde6e..6a7385ed42a6 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.locking/unlock.pass.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +20,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - bool unlock_called = false; struct mutex @@ -30,11 +30,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk(m); lk.unlock(); assert(unlock_called == true); @@ -58,5 +55,4 @@ int main() { assert(e.code().value() == EPERM); } -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp index 8505763e44bc..23a0c7030d76 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/member_swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - struct mutex { void lock_shared() {} @@ -28,11 +27,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk1(m); std::shared_lock lk2; lk1.swap(lk2); @@ -41,5 +37,4 @@ int main() assert(lk2.mutex() == &m); assert(lk2.owns_lock() == true); static_assert(noexcept(lk1.swap(lk2)), "member swap must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp index 057dbc4cd3b7..0f19174d51f0 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/nonmember_swap.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -19,8 +20,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - struct mutex { void lock_shared() {} @@ -29,11 +28,8 @@ struct mutex mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk1(m); std::shared_lock lk2; swap(lk1, lk2); @@ -42,5 +38,4 @@ int main() assert(lk2.mutex() == &m); assert(lk2.owns_lock() == true); static_assert(noexcept(swap(lk1, lk2)), "non-member swap must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp index 65ddca624725..2b5f8c1f1658 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.mod/release.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,8 +19,6 @@ #include #include -#if _LIBCPP_STD_VER > 11 - struct mutex { static int lock_count; @@ -33,11 +32,8 @@ int mutex::unlock_count = 0; mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk(m); assert(lk.mutex() == &m); assert(lk.owns_lock() == true); @@ -49,5 +45,4 @@ int main() assert(mutex::lock_count == 1); assert(mutex::unlock_count == 0); static_assert(noexcept(lk.release()), "release must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp index 4eb75d8f050e..711ab7c6fca0 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/mutex.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,15 +19,10 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0; assert(lk0.mutex() == nullptr); std::shared_lock lk1(m); @@ -34,5 +30,4 @@ int main() lk1.unlock(); assert(lk1.mutex() == &m); static_assert(noexcept(lk0.mutex()), "mutex() must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp index d079d2d8b03a..3f6ad2b555a3 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/op_bool.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,15 +19,10 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0; assert(static_cast(lk0) == false); std::shared_lock lk1(m); @@ -34,5 +30,4 @@ int main() lk1.unlock(); assert(static_cast(lk1) == false); static_assert(noexcept(static_cast(lk0)), "explicit operator bool() must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp index d64b0aa6a736..5ab3ac009fe1 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/thread.lock.shared.obs/owns_lock.pass.cpp @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 // @@ -18,15 +19,10 @@ #include #include -#if _LIBCPP_STD_VER > 11 - std::shared_timed_mutex m; -#endif // _LIBCPP_STD_VER > 11 - int main() { -#if _LIBCPP_STD_VER > 11 std::shared_lock lk0; assert(lk0.owns_lock() == false); std::shared_lock lk1(m); @@ -34,5 +30,4 @@ int main() lk1.unlock(); assert(lk1.owns_lock() == false); static_assert(noexcept(lk0.owns_lock()), "owns_lock must be noexcept"); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp index c153b455f404..f555d3de5ee0 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.shared/types.pass.cpp @@ -8,6 +8,8 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads +// UNSUPPORTED: c++98, c++03, c++11 + // @@ -24,8 +26,6 @@ int main() { -#if _LIBCPP_STD_VER > 11 static_assert((std::is_same::mutex_type, std::mutex>::value), ""); -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp index f5408df98199..6ce33761068f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/lock.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp index bd88577f0a22..27d0562de31f 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp index 558f079463a4..6f0a7219d2d8 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_for.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp index 24e4d109a097..b7e87249b596 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/try_lock_until.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp index bbabfc41df11..62497c9ec45a 100644 --- a/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.lock/thread.lock.unique/thread.lock.unique.locking/unlock.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp index 7bcb2d61379a..5c67a34ab52b 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/assign.fail.cpp @@ -6,6 +6,8 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 // @@ -15,15 +17,9 @@ #include -#include "test_macros.h" - int main() { -#if TEST_STD_VER > 14 std::shared_mutex m0; std::shared_mutex m1; - m1 = m0; -#else -# error -#endif + m1 = m0; // expected-error {{overload resolution selected deleted operator '='}} } diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp index af064aeee26c..c7cac6041c82 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/copy.fail.cpp @@ -6,6 +6,8 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// +// +// UNSUPPORTED: c++98, c++03, c++11, c++14 // @@ -15,14 +17,8 @@ #include -#include "test_macros.h" - int main() { -#if TEST_STD_VER > 14 std::shared_mutex m0; - std::shared_mutex m1(m0); -#else -# error -#endif + std::shared_mutex m1(m0); // expected-error {{call to deleted constructor of 'std::shared_mutex'}} } diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp index 9bf7a79e3400..75ddebff0ed9 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock.pass.cpp @@ -21,6 +21,7 @@ #include #include +#include "test_macros.h" std::shared_mutex m; @@ -30,21 +31,32 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f() { time_point t0 = Clock::now(); m.lock(); time_point t1 = Clock::now(); m.unlock(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } int main() { m.lock(); std::thread t(f); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); t.join(); } diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp index 3ffa9e2d0065..6b5089d38859 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.shared_mutex.requirements/thread.shared_mutex.class/lock_shared.pass.cpp @@ -22,6 +22,8 @@ #include #include +#include "test_macros.h" + std::shared_mutex m; typedef std::chrono::system_clock Clock; @@ -30,14 +32,25 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f() { time_point t0 = Clock::now(); m.lock_shared(); time_point t1 = Clock::now(); m.unlock_shared(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } void g() @@ -47,7 +60,7 @@ void g() time_point t1 = Clock::now(); m.unlock_shared(); ns d = t1 - t0; - assert(d < ms(50)); // within 50ms + assert(d < Tolerance); // within tolerance } @@ -57,7 +70,7 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -65,7 +78,7 @@ int main() for (auto& t : v) t = std::thread(g); std::thread q(f); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock_shared(); for (auto& t : v) t.join(); diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp index 62bb736837ea..2818bd617542 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock.pass.cpp @@ -21,6 +21,8 @@ #include #include +#include "test_macros.h" + std::shared_timed_mutex m; typedef std::chrono::system_clock Clock; @@ -29,6 +31,19 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; + +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !TEST_HAS_FEATURE(thread_sanitizer) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(100); +#endif + + void f() { time_point t0 = Clock::now(); diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp index 8fc6299f1b8f..77a9107de923 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/lock_shared.pass.cpp @@ -22,6 +22,8 @@ #include #include +#include "test_macros.h" + std::shared_timed_mutex m; typedef std::chrono::system_clock Clock; @@ -30,14 +32,27 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; + +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + + void f() { time_point t0 = Clock::now(); m.lock_shared(); time_point t1 = Clock::now(); m.unlock_shared(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } void g() @@ -47,7 +62,7 @@ void g() time_point t1 = Clock::now(); m.unlock_shared(); ns d = t1 - t0; - assert(d < ms(50)); // within 50ms + assert(d < Tolerance); // within tolerance } @@ -57,7 +72,7 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -65,7 +80,7 @@ int main() for (auto& t : v) t = std::thread(g); std::thread q(f); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock_shared(); for (auto& t : v) t.join(); diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp index ab20241895ba..320a268ae77d 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_for.pass.cpp @@ -22,6 +22,8 @@ #include #include +#include "test_macros.h" + std::shared_timed_mutex m; typedef std::chrono::steady_clock Clock; @@ -30,23 +32,35 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; + +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f1() { time_point t0 = Clock::now(); - assert(m.try_lock_for(ms(300)) == true); + assert(m.try_lock_for(WaitTime + Tolerance) == true); time_point t1 = Clock::now(); m.unlock(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } void f2() { time_point t0 = Clock::now(); - assert(m.try_lock_for(ms(250)) == false); + assert(m.try_lock_for(WaitTime) == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } int main() @@ -54,14 +68,14 @@ int main() { m.lock(); std::thread t(f1); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); t.join(); } { m.lock(); std::thread t(f2); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); t.join(); } diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp index 9c2d8c9c8e5c..3d5604d886cb 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared.pass.cpp @@ -22,6 +22,8 @@ #include #include +#include "test_macros.h" + std::shared_timed_mutex m; typedef std::chrono::system_clock Clock; @@ -30,6 +32,13 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; + +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(200); +#else +ms Tolerance = ms(200 * 5); +#endif + void f() { time_point t0 = Clock::now(); @@ -41,7 +50,7 @@ void f() time_point t1 = Clock::now(); m.unlock_shared(); ns d = t1 - t0 - ms(250); - assert(d < ms(200)); // within 200ms + assert(d < Tolerance); // within tolerance } int main() diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp index 35444112a5da..4cdb5873f9a1 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_for.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "test_macros.h" + std::shared_timed_mutex m; typedef std::chrono::steady_clock Clock; @@ -31,23 +33,34 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f1() { time_point t0 = Clock::now(); - assert(m.try_lock_shared_for(ms(300)) == true); + assert(m.try_lock_shared_for(WaitTime + Tolerance) == true); time_point t1 = Clock::now(); m.unlock_shared(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } void f2() { time_point t0 = Clock::now(); - assert(m.try_lock_shared_for(ms(250)) == false); + assert(m.try_lock_shared_for(WaitTime) == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } int main() @@ -57,7 +70,7 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f1)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -67,7 +80,7 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f2)); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); for (auto& t : v) t.join(); diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp index 4e0f19de07ce..f7ddbaeef498 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_shared_until.pass.cpp @@ -23,6 +23,8 @@ #include #include +#include "test_macros.h" + std::shared_timed_mutex m; typedef std::chrono::steady_clock Clock; @@ -31,23 +33,34 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f1() { time_point t0 = Clock::now(); - assert(m.try_lock_shared_until(Clock::now() + ms(300)) == true); + assert(m.try_lock_shared_until(Clock::now() + WaitTime + Tolerance) == true); time_point t1 = Clock::now(); m.unlock_shared(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within 50ms } void f2() { time_point t0 = Clock::now(); - assert(m.try_lock_shared_until(Clock::now() + ms(250)) == false); + assert(m.try_lock_shared_until(Clock::now() + WaitTime) == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } int main() @@ -57,7 +70,7 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f1)); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); for (auto& t : v) t.join(); @@ -67,7 +80,7 @@ int main() std::vector v; for (int i = 0; i < 5; ++i) v.push_back(std::thread(f2)); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); for (auto& t : v) t.join(); diff --git a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp index aa90cf71502f..1560af2c9ecc 100644 --- a/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp +++ b/test/std/thread/thread.mutex/thread.mutex.requirements/thread.sharedtimedmutex.requirements/thread.sharedtimedmutex.class/try_lock_until.pass.cpp @@ -32,23 +32,35 @@ typedef Clock::duration duration; typedef std::chrono::milliseconds ms; typedef std::chrono::nanoseconds ns; + +ms WaitTime = ms(250); + +// Thread sanitizer causes more overhead and will sometimes cause this test +// to fail. To prevent this we give Thread sanitizer more time to complete the +// test. +#if !defined(TEST_HAS_SANITIZERS) +ms Tolerance = ms(50); +#else +ms Tolerance = ms(50 * 5); +#endif + void f1() { time_point t0 = Clock::now(); - assert(m.try_lock_until(Clock::now() + ms(300)) == true); + assert(m.try_lock_until(Clock::now() + WaitTime + Tolerance) == true); time_point t1 = Clock::now(); m.unlock(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } void f2() { time_point t0 = Clock::now(); - assert(m.try_lock_until(Clock::now() + ms(250)) == false); + assert(m.try_lock_until(Clock::now() + WaitTime) == false); time_point t1 = Clock::now(); - ns d = t1 - t0 - ms(250); - assert(d < ms(50)); // within 50ms + ns d = t1 - t0 - WaitTime; + assert(d < Tolerance); // within tolerance } int main() @@ -56,14 +68,14 @@ int main() { m.lock(); std::thread t(f1); - std::this_thread::sleep_for(ms(250)); + std::this_thread::sleep_for(WaitTime); m.unlock(); t.join(); } { m.lock(); std::thread t(f2); - std::this_thread::sleep_for(ms(300)); + std::this_thread::sleep_for(WaitTime + Tolerance); m.unlock(); t.join(); } diff --git a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp index 89b99348459b..afc318cc3d7a 100644 --- a/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp +++ b/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp index 7198d226960a..6c31df593c0e 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.assign/move2.pass.cpp @@ -8,13 +8,7 @@ //===----------------------------------------------------------------------===// // // UNSUPPORTED: libcpp-has-no-threads - -// NOTE: std::terminate is called so the destructors are not invoked and the -// memory is not freed. This will cause ASAN to fail. -// XFAIL: asan - -// NOTE: TSAN will report this test as leaking a thread. -// XFAIL: tsan +// UNSUPPORTED: c++98, c++03 // @@ -38,12 +32,7 @@ class G G(const G& g) : alive_(g.alive_) {++n_alive;} ~G() {alive_ = 0; --n_alive;} - void operator()() - { - assert(alive_ == 1); - assert(n_alive >= 1); - op_run = true; - } + void operator()(int i, double j) { @@ -60,7 +49,7 @@ bool G::op_run = false; void f1() { - std::exit(0); + std::_Exit(0); } int main() diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp index a8b4be16e631..3de15af8929b 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.constr/F.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// // +// XFAIL: libcpp-no-exceptions // UNSUPPORTED: libcpp-has-no-threads // @@ -22,6 +23,8 @@ #include #include +#include "test_macros.h" + unsigned throw_one = 0xFFFF; void* operator new(std::size_t s) throw(std::bad_alloc) @@ -75,7 +78,7 @@ class G int G::n_alive = 0; bool G::op_run = false; -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 class MoveOnly { @@ -137,7 +140,7 @@ int main() assert(!G::op_run); } } -#ifndef _LIBCPP_HAS_NO_VARIADICS +#if TEST_STD_VER >= 11 { assert(G::n_alive == 0); assert(!G::op_run); @@ -150,5 +153,5 @@ int main() std::thread t = std::thread(MoveOnly(), MoveOnly()); t.join(); } -#endif // _LIBCPP_HAS_NO_VARIADICS +#endif } diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp index ddf96d095730..0efb7713e985 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.destr/dtor.pass.cpp @@ -9,8 +9,6 @@ // // UNSUPPORTED: libcpp-has-no-threads -// NOTE: TSAN will report this test as leaking a thread. -// XFAIL: tsan // @@ -47,7 +45,7 @@ bool G::op_run = false; void f1() { - std::exit(0); + std::_Exit(0); } int main() diff --git a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp index f4a4d1f777f1..726395d99044 100644 --- a/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp +++ b/test/std/thread/thread.threads/thread.thread.class/thread.thread.member/detach.pass.cpp @@ -19,7 +19,7 @@ #include #include -std::atomic_bool done = ATOMIC_VAR_INIT(false); +std::atomic_bool done(false); class G { diff --git a/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp new file mode 100644 index 000000000000..72f0e867b1d2 --- /dev/null +++ b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/copy_assign.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor& other); + + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::scoped_allocator_adaptor> A; + A a1(A1(3)); + A aN; + A1::copy_called = false; + A1::move_called = false; + aN = a1; + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(aN == a1); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a1(A1(4), A2(5)); + A aN; + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + aN = a1; + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(aN == a1); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a1(A1(4), A2(5), A3(6)); + A aN; + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A3::copy_called = false; + A3::move_called = false; + aN = a1; + assert(A1::copy_called == true); + assert(A1::move_called == false); + assert(A2::copy_called == true); + assert(A2::move_called == false); + assert(A3::copy_called == true); + assert(A3::move_called == false); + assert(aN == a1); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp new file mode 100644 index 000000000000..0dc479c246c9 --- /dev/null +++ b/test/std/utilities/allocator.adaptor/scoped.adaptor.operators/move_assign.pass.cpp @@ -0,0 +1,72 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// class scoped_allocator_adaptor + +// scoped_allocator_adaptor& operator=(const scoped_allocator_adaptor&& other); + + +#include +#include + +#include "allocators.h" + +int main() +{ +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::scoped_allocator_adaptor> A; + A a1(A1(3)); + A aN; + A1::copy_called = false; + A1::move_called = false; + aN = std::move(a1); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(aN == a1); + } + { + typedef std::scoped_allocator_adaptor, A2> A; + A a1(A1(4), A2(5)); + A aN; + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + aN = std::move(a1); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(A2::copy_called == false); + assert(A2::move_called == true); + assert(aN == a1); + } + { + typedef std::scoped_allocator_adaptor, A2, A3> A; + A a1(A1(4), A2(5), A3(6)); + A aN; + A1::copy_called = false; + A1::move_called = false; + A2::copy_called = false; + A2::move_called = false; + A3::copy_called = false; + A3::move_called = false; + aN = std::move(a1); + assert(A1::copy_called == false); + assert(A1::move_called == true); + assert(A2::copy_called == false); + assert(A2::move_called == true); + assert(A3::copy_called == false); + assert(A3::move_called == true); + assert(aN == a1); + } +#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +} diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp index 6315598125c9..ad03e8fb6bb2 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/copy.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp index 33bf01855908..4577d0bf4d54 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_function_object.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp index ab4dd59534d5..815096f6b157 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_int_0.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp index af5efe464d5d..f69afbf57667 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_lvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp index 4913a510c36e..a1137ee388c1 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp index b7874b77cf03..73f26e4b585a 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/invoke_void_0.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp index 12720f7b550a..f61d93aefd89 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp index 7f8dd4a98d2b..83fa452fecb3 100644 --- a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template struct is_bind_expression diff --git a/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp new file mode 100644 index 000000000000..12a78dbc7548 --- /dev/null +++ b/test/std/utilities/function.objects/bind/func.bind/func.bind.isbind/is_bind_expression_03.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +//----------------------------------------------------------------------------- +// TESTING template struct is_bind_expression +// +// bind is not implemented in C++03 so nothing is a bind expression. However +// for compatibility reasons the trait is_bind_expression should be available +// in C++03 and it should always return false. + +#include + +template +void test() { + static_assert(!std::is_bind_expression::value, ""); +} + +struct C {}; + +int main() { + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); + test(); +} diff --git a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp index 4b9cc76f7e4f..97b0b4d158a0 100644 --- a/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp +++ b/test/std/utilities/function.objects/func.invoke/invoke.pass.cpp @@ -40,6 +40,7 @@ #include #include +#include // for std::move #include struct NonCopyable { diff --git a/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp b/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp index 4096bd814421..f371223ee84c 100644 --- a/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp +++ b/test/std/utilities/function.objects/func.memfn/member_function.pass.cpp @@ -69,4 +69,7 @@ int main() test0(std::mem_fn(&A::test0)); test1(std::mem_fn(&A::test1)); test2(std::mem_fn(&A::test2)); +#if __has_feature(cxx_noexcept) + static_assert((noexcept(std::mem_fn(&A::test0))), ""); // LWG#2489 +#endif } diff --git a/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp b/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp new file mode 100644 index 000000000000..e579f207a33f --- /dev/null +++ b/test/std/utilities/function.objects/func.require/bullet_1_and_2.pass.cpp @@ -0,0 +1,318 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// INVOKE (f, t1, t2, ..., tN) + +//------------------------------------------------------------------------------ +// TESTING INVOKE(f, t1, t2, ..., tN) +// - Bullet 1 -- (t1.*f)(t2, ..., tN) +// - Bullet 2 -- ((*t1).*f)(t2, ..., tN) +// +// Overview: +// Bullets 1 and 2 handle the case where 'f' is a pointer to member function. +// Bullet 1 only handles the cases where t1 is an object of type T or a +// type derived from 'T'. Bullet 2 handles all other cases. +// +// Concerns: +// 1) cv-qualified member function signatures are accepted. +// 2) reference qualified member function signatures are accepted. +// 3) member functions with varargs at the end are accepted. +// 4) The arguments are perfect forwarded to the member function call. +// 5) Classes that are publicly derived from 'T' are accepted as the call object +// 6) All types that dereference to T or a type derived from T can be used +// as the call object. +// 7) Pointers to T or a type derived from T can be used as the call object. +// 8) Reference return types are properly deduced. +// +// +// Plan: +// 1) Create a class that contains a set, 'S', of non-static functions. +// 'S' should include functions that cover every single combination +// of qualifiers and varargs for arities of 0, 1 and 2 (C-1,2,3). +// The argument types used in the functions should be non-copyable (C-4). +// The functions should return 'MethodID::setUncheckedCall()'. +// +// 2) Create a set of supported call object, 'Objs', of different types +// and behaviors. (C-5,6,7) +// +// 3) Attempt to call each function, 'f', in 'S' with each call object, 'c', +// in 'Objs'. After every attempted call to 'f' check that 'f' was +// actually called using 'MethodID::checkCalled()' +// +// 3b) If 'f' is reference qualified call 'f' with the properly qualified +// call object. Otherwise call 'f' with lvalue call objects. +// +// 3a) If 'f' is const, volatile, or cv qualified then call it with call +// objects that are equally or less cv-qualified. + +#include +#include +#include + +#include "test_macros.h" +#include "invoke_helpers.h" + +//============================================================================== +// MemFun03 - C++03 compatible set of test member functions. +struct MemFun03 { + typedef void*& R; +#define F(...) \ + R f(__VA_ARGS__) { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) const { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) volatile { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) const volatile { return MethodID::setUncheckedCall(); } +# + F() + F(...) + F(ArgType&) + F(ArgType&, ...) + F(ArgType&, ArgType&) + F(ArgType&, ArgType&, ...) + F(ArgType&, ArgType&, ArgType&) + F(ArgType&, ArgType&, ArgType&, ...) +#undef F +public: + MemFun03() {} +private: + MemFun03(MemFun03 const&); + MemFun03& operator=(MemFun03 const&); +}; + + +#if TEST_STD_VER >= 11 + +//============================================================================== +// MemFun11 - C++11 reference qualified test member functions. +struct MemFun11 { + typedef void*& R; + typedef MemFun11 C; +#define F(...) \ + R f(__VA_ARGS__) & { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) const & { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) volatile & { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) const volatile & { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) && { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) const && { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) volatile && { return MethodID::setUncheckedCall(); } \ + R f(__VA_ARGS__) const volatile && { return MethodID::setUncheckedCall(); } +# + F() + F(...) + F(ArgType&&) + F(ArgType&&, ...) + F(ArgType&&, ArgType&&) + F(ArgType&&, ArgType&&, ...) + F(ArgType&&, ArgType&&, ArgType&&) + F(ArgType&&, ArgType&&, ArgType&&, ...) +#undef F +public: + MemFun11() {} +private: + MemFun11(MemFun11 const&); + MemFun11& operator=(MemFun11 const&); +}; + +#endif // TEST_STD_VER >= 11 + + +//============================================================================== +// TestCase - A test case for a single member function. +// ClassType - The type of the class being tested. +// CallSig - The function signature of the method being tested. +// Arity - the arity of 'CallSig' +// CV - the cv qualifiers of 'CallSig' represented as a type tag. +// RValue - The method is RValue qualified. +// ArgRValue - Call the method with RValue arguments. +template +struct TestCaseImp { +public: + + static void run() { TestCaseImp().doTest(); } + +private: + //========================================================================== + // TEST DISPATCH + void doTest() { + // (Plan-2) Create test call objects. + typedef ClassType T; + typedef DerivedFromType D; + T obj; + T* obj_ptr = &obj; + D der; + D* der_ptr = &der; + DerefToType dref; + DerefPropType dref2; + + // (Plan-3) Dispatch based on the CV tags. + CV tag; + Bool NotRValue; + runTestDispatch(tag, obj); + runTestDispatch(tag, der); + runTestDispatch(tag, dref2); + runTestDispatchIf(NotRValue, tag, dref); + runTestDispatchIf(NotRValue, tag, obj_ptr); + runTestDispatchIf(NotRValue, tag, der_ptr); + } + + template + void runTestDispatchIf(Bool, QT q, Tp& v) { + runTestDispatch(q, v); + } + + template + void runTestDispatchIf(Bool, QT, Tp&) { + } + + template + void runTestDispatch(Q_None, Tp& v) { + runTest(v); + } + + template + void runTestDispatch(Q_Const, Tp& v) { + Tp const& cv = v; + runTest(v); + runTest(cv); + } + + template + void runTestDispatch(Q_Volatile, Tp& v) { + Tp volatile& vv = v; + runTest(v); + runTest(vv); + } + + template + void runTestDispatch(Q_CV, Tp& v) { + Tp const& cv = v; + Tp volatile& vv = v; + Tp const volatile& cvv = v; + runTest(v); + runTest(cv); + runTest(vv); + runTest(cvv); + } + + template + void runTest(Obj& obj) { + typedef Caster SCast; + typedef Caster ACast; + typedef CallSig (ClassType::*MemPtr); + // Delegate test to logic in invoke_helpers.h + BasicTest, Arity, SCast, ACast> b; + b.runTest( (MemPtr)&ClassType::f, obj); + } +}; + +template +struct TestCase : public TestCaseImp {}; + +#if TEST_STD_VER >= 11 +template +struct TestCase11 : public TestCaseImp {}; +#endif + +int main() { + typedef void*& R; + typedef ArgType A; + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + +#if TEST_STD_VER >= 11 + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); + TestCase11::run(); +#endif +} \ No newline at end of file diff --git a/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp b/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp new file mode 100644 index 000000000000..b6fe190bd2a7 --- /dev/null +++ b/test/std/utilities/function.objects/func.require/bullet_3_and_4.pass.cpp @@ -0,0 +1,164 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// INVOKE (f, t1, t2, ..., tN) + +//------------------------------------------------------------------------------ +// TESTING INVOKE(f, t1, t2, ..., tN) +// - Bullet 3 -- t1.*f +// - Bullet 4 -- (*t1).*f +// +// Overview: +// Bullets 3 and 4 handle the case where 'f' is a pointer to member object. +// Bullet 3 only handles the cases where t1 is an object of type T or a +// type derived from 'T'. Bullet 4 handles all other cases. +// +// Concerns: +// 1) The return type is always an lvalue reference. +// 2) The return type is not less cv-qualified that the object that contains it. +// 3) The return type is not less cv-qualified than object type. +// 4) The call object is perfectly forwarded. +// 5) Classes that are publicly derived from 'T' are accepted as the call object +// 6) All types that dereference to T or a type derived from T can be used +// as the call object. +// 7) Pointers to T or a type derived from T can be used as the call object. + +#include +#include +#include + +#include "test_macros.h" +#include "invoke_helpers.h" + +template +struct TestMemberObject { + TestMemberObject() : object() {} + Tp object; +private: + TestMemberObject(TestMemberObject const&); + TestMemberObject& operator=(TestMemberObject const&); +}; + +template +struct TestCase { + public: + + static void run() { TestCase().doTest(); } + +private: + typedef TestMemberObject TestType; + + //========================================================================== + // TEST DISPATCH + void doTest() { + typedef DerivedFromType Derived; + TestType obj; + TestType* obj_ptr = &obj; + Derived der; + Derived* der_ptr = &der; + DerefToType dref; + DerefPropType dref2; + + { + typedef ObjectType (TestType::*MemPtr); + typedef ObjectType E; + MemPtr M = &TestType::object; + runTestDispatch(M, obj, &obj.object); + runTestDispatch(M, der, &der.object); + runTestDispatch(M, dref2, &dref2.object.object); + runTestPointerDispatch(M, obj_ptr, &obj_ptr->object); + runTestPointerDispatch(M, der_ptr, &der_ptr->object); + runTestPointerDispatch(M, dref, &dref.object.object); + } + { + typedef ObjectType const (TestType::*CMemPtr); + typedef ObjectType const E; + CMemPtr M = &TestType::object; + runTestDispatch(M, obj, &obj.object); + runTestDispatch(M, der, &der.object); + runTestDispatch(M, dref2, &dref2.object.object); + runTestPointerDispatch(M, obj_ptr, &obj_ptr->object); + runTestPointerDispatch(M, der_ptr, &der_ptr->object); + runTestPointerDispatch(M, dref, &dref.object.object); + } + { + typedef ObjectType volatile (TestType::*VMemPtr); + typedef ObjectType volatile E; + VMemPtr M = &TestType::object; + runTestDispatch(M, obj, &obj.object); + runTestDispatch(M, der, &der.object); + runTestDispatch(M, dref2, &dref2.object.object); + runTestPointerDispatch(M, obj_ptr, &obj_ptr->object); + runTestPointerDispatch(M, der_ptr, &der_ptr->object); + runTestPointerDispatch(M, dref, &dref.object.object); + } + { + typedef ObjectType const volatile (TestType::*CVMemPtr); + typedef ObjectType const volatile E; + CVMemPtr M = &TestType::object; + runTestDispatch(M, obj, &obj.object); + runTestDispatch(M, der, &der.object); + runTestDispatch(M, dref2, &dref2.object.object); + runTestPointerDispatch(M, obj_ptr, &obj_ptr->object); + runTestPointerDispatch(M, der_ptr, &der_ptr->object); + runTestPointerDispatch(M, dref, &dref.object.object); + } + } + + template + void runTestDispatch(Fn M, T& obj, ObjectType* expect) { + runTest (M, C_(obj), expect); + runTest (M, C_(obj), expect); + runTest (M, C_(obj), expect); + runTest(M, C_(obj), expect); +#if TEST_STD_VER >= 11 + runTest (M, C_(obj), expect); + runTest (M, C_(obj), expect); + runTest (M, C_(obj), expect); + runTest(M, C_(obj), expect); +#endif + } + + template + void runTestPointerDispatch(Fn M, T& obj, ObjectType* expect) { + runTest(M, C_(obj), expect); + runTest(M, C_(obj), expect); + runTest(M, C_(obj), expect); + runTest(M, C_(obj), expect); +#if TEST_STD_VER >= 11 + runTest(M, C_(obj), expect); + runTest(M, C_(obj), expect); + runTest(M, C_(obj), expect); + runTest(M, C_(obj), expect); +#endif + } + + template +#if TEST_STD_VER >= 11 + void runTest(Fn M, T&& obj, ObjectType* expect) { +#else + void runTest(Fn M, T& obj, ObjectType* expect ) { +#endif + static_assert((std::is_same< + decltype(std::__invoke(M, std::forward(obj))), Expect + >::value), ""); + Expect e = std::__invoke(M, std::forward(obj)); + assert(&e == expect); + } +}; + +int main() { + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); + TestCase::run(); +} \ No newline at end of file diff --git a/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp b/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp new file mode 100644 index 000000000000..3f3c96a9b9bd --- /dev/null +++ b/test/std/utilities/function.objects/func.require/bullet_5.pass.cpp @@ -0,0 +1,327 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// INVOKE (f, t1, t2, ..., tN) + +//------------------------------------------------------------------------------ +// TESTING INVOKE(f, t1, t2, ..., tN) +// - Bullet 5 -- f(t2, ..., tN) +// +// Overview: +// Bullet 5 handles the cases where the first argument is not a member +// function. +// +// Concerns: +// 1) Different types of callable objects are supported. Including +// 1a) Free Function pointers and references. +// 1b) Classes which provide a call operator +// 1c) lambdas +// 2) The callable objects are perfect forwarded. +// 3) The arguments are perfect forwarded. +// 4) Signatures which include varargs are supported. +// 5) In C++03 3 extra arguments should be allowed. +// +// Plan: +// 1) Define a set of free functions, 'SF', and class types with call +// operators, 'SC', that address concerns 4 and 5. The free functions should +// return 'FunctionID::setUncheckedCall()' and the call operators should +// return 'MethodID::setUncheckedCall()'. +// +// 2) For each function 'f' in 'SF' and 'SC' attempt to call 'f' +// using the correct number of arguments and cv-ref qualifiers. Check that +// 'f' has been called using 'FunctionID::checkCall()' if 'f' is a free +// function and 'MethodID::checkCall()' otherwise. + + + +#include +#include +#include + +#include "test_macros.h" +#include "invoke_helpers.h" + + +//============================================================================== +// freeFunction03 - A C++03 free function. +void*& freeFunction03() { + return FunctionPtrID::setUncheckedCall(); +} + +void*& freeFunction03(...) { + return FunctionPtrID::setUncheckedCall(); +} + +template +void*& freeFunction03(A0&) { + return FunctionPtrID::setUncheckedCall(); +} + + +template +void*& freeFunction03(A0&, ...) { + return FunctionPtrID::setUncheckedCall(); +} + +template +void*& freeFunction03(A0&, A1&) { + return FunctionPtrID::setUncheckedCall(); +} + + +template +void*& freeFunction03(A0&, A1&, ...) { + return FunctionPtrID::setUncheckedCall(); +} + +template +void*& freeFunction03(A0&, A1&, A2&) { + return FunctionPtrID::setUncheckedCall(); +} + +template +void*& freeFunction03(A0&, A1&, A2&, ...) { + return FunctionPtrID::setUncheckedCall(); +} + +//============================================================================== +// Functor03 - C++03 compatible functor object +struct Functor03 { + typedef void*& R; + typedef Functor03 C; +#define F(Args, ...) \ + __VA_ARGS__ R operator() Args { return MethodID::setUncheckedCall(); } \ + __VA_ARGS__ R operator() Args const { return MethodID::setUncheckedCall(); } \ + __VA_ARGS__ R operator() Args volatile { return MethodID::setUncheckedCall(); } \ + __VA_ARGS__ R operator() Args const volatile { return MethodID::setUncheckedCall(); } +# + F(()) + F((A0&), template ) + F((A0&, A1&), template ) + F((A0&, A1&, A2&), template ) +#undef F +public: + Functor03() {} +private: + Functor03(Functor03 const&); + Functor03& operator=(Functor03 const&); +}; + + +#if TEST_STD_VER >= 11 + +//============================================================================== +// freeFunction11 - A C++11 free function. +template +void*& freeFunction11(Args&&...) { + return FunctionPtrID::setUncheckedCall(); +} + +template +void*& freeFunction11(Args&&...,...) { + return FunctionPtrID::setUncheckedCall(); +} + +//============================================================================== +// Functor11 - C++11 reference qualified test member functions. +struct Functor11 { + typedef void*& R; + typedef Functor11 C; + +#define F(CV) \ + template \ + R operator()(Args&&...) CV { return MethodID::setUncheckedCall(); } +# + F(&) + F(const &) + F(volatile &) + F(const volatile &) + F(&&) + F(const &&) + F(volatile &&) + F(const volatile &&) +#undef F +public: + Functor11() {} +private: + Functor11(Functor11 const&); + Functor11& operator=(Functor11 const&); +}; + +#endif // TEST_STD_VER >= 11 + + +//============================================================================== +// TestCaseFunctorImp - A test case for an operator() class method. +// ClassType - The type of the call object. +// CallSig - The function signature of the call operator being tested. +// Arity - the arity of 'CallSig' +// ObjCaster - Transformation function applied to call object. +// ArgCaster - Transformation function applied to the extra arguments. +template +struct TestCaseFunctorImp { +public: + static void run() { + typedef MethodID MID; + BasicTest t; + typedef ClassType T; + typedef DerivedFromType D; + T obj; + D der; + t.runTest(obj); + t.runTest(der); + } +}; + +//============================================================================== +// TestCaseFreeFunction - A test case for a free function. +// CallSig - The function signature of the free function being tested. +// FnPtr - The function being tested. +// Arity - the arity of 'CallSig' +// ArgCaster - Transformation function to be applied to the extra arguments. +template +struct TestCaseFreeFunction { +public: + static void run() { + typedef FunctionPtrID FID; + BasicTest t; + + DerefToType deref_to(FnPtr); + DerefToType deref_to_ref(*FnPtr); + + t.runTest(FnPtr); + t.runTest(*FnPtr); + t.runTest(deref_to); + t.runTest(deref_to_ref); + } +}; + +//============================================================================== +// runTest Helpers +//============================================================================== +#if TEST_STD_VER >= 11 +template +void runFunctionTestCase11() { + TestCaseFreeFunction(); +} +#endif + +template +void runFunctionTestCase() { + TestCaseFreeFunction(); +#if TEST_STD_VER >= 11 + runFunctionTestCase11(); +#endif +} + +template +void runFunctorTestCase() { + TestCaseFunctorImp::run(); +} + +template +void runFunctorTestCase() { + TestCaseFunctorImp::run(); +} + +#if TEST_STD_VER >= 11 +// runTestCase - Run a test case for C++11 class functor types +template +void runFunctorTestCase11() { + TestCaseFunctorImp::run(); +} +#endif + +// runTestCase - Run a test case for both function and functor types. +template +void runTestCase() { + runFunctionTestCase(); + runFunctorTestCase (); +}; + +int main() { + typedef void*& R; + typedef ArgType A; + typedef A const CA; + + runTestCase< R(), 0, LValueCaster >(); + runTestCase< R(A&), 1, LValueCaster >(); + runTestCase< R(A&, A&), 2, LValueCaster >(); + runTestCase< R(A&, A&, A&), 3, LValueCaster >(); + runTestCase< R(CA&), 1, ConstCaster >(); + runTestCase< R(CA&, CA&), 2, ConstCaster >(); + runTestCase< R(CA&, CA&, CA&), 3, ConstCaster >(); + + runFunctionTestCase(); + runFunctionTestCase(); + runFunctionTestCase(); + runFunctionTestCase(); + +#if TEST_STD_VER >= 11 + runFunctionTestCase11(); + runFunctionTestCase11(); +#endif + + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + { + typedef ConstCaster CC; + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + runFunctorTestCase(); + } + +#if TEST_STD_VER >= 11 + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + { + typedef MoveCaster MC; + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + runFunctorTestCase11(); + } +#endif +} diff --git a/test/std/utilities/function.objects/func.require/invoke_helpers.h b/test/std/utilities/function.objects/func.require/invoke_helpers.h new file mode 100644 index 000000000000..0583b624da31 --- /dev/null +++ b/test/std/utilities/function.objects/func.require/invoke_helpers.h @@ -0,0 +1,317 @@ +#ifndef INVOKE_HELPERS_H +#define INVOKE_HELPERS_H + +#include +#include +#include + +#include "test_macros.h" + +template +struct Int : public std::integral_constant {}; + +template +struct Bool : public std::integral_constant {}; + +struct Q_None { + template + struct apply { typedef T type; }; +}; + +struct Q_Const { + template + struct apply { typedef T const type; }; +}; + +struct Q_Volatile { + template + struct apply { typedef T volatile type; }; +}; + +struct Q_CV { + template + struct apply { typedef T const volatile type; }; +}; + +// Caster - A functor object that performs cv-qualifier and value category +// conversions. +// QualTag - A metafunction type that applies cv-qualifiers to its argument. +// RValue - True if the resulting object should be an RValue reference. +// False otherwise. +template +struct Caster { + template + struct apply { + typedef typename std::remove_reference::type RawType; + typedef typename QualTag::template apply::type CVType; +#if TEST_STD_VER >= 11 + typedef typename std::conditional::type type; +#else + typedef CVType& type; +#endif + }; + + template + typename apply::type + operator()(T& obj) const { + typedef typename apply::type OutType; + return static_cast(obj); + } +}; + +typedef Caster LValueCaster; +typedef Caster ConstCaster; +typedef Caster VolatileCaster; +typedef Caster CVCaster; +typedef Caster MoveCaster; +typedef Caster MoveConstCaster; +typedef Caster MoveVolatileCaster; +typedef Caster MoveCVCaster; + +// A shorter name for 'static_cast' +template +QualType C_(Tp& v) { return static_cast(v); }; + +//============================================================================== +// ArgType - A non-copyable type intended to be used as a dummy argument type +// to test functions. +struct ArgType { + int value; + explicit ArgType(int val = 0) : value(val) {} +private: + ArgType(ArgType const&); + ArgType& operator=(ArgType const&); +}; + +//============================================================================== +// DerivedFromBase - A type that derives from it's template argument 'Base' +template +struct DerivedFromType : public Base { + DerivedFromType() : Base() {} + template + explicit DerivedFromType(Tp const& t) : Base(t) {} +}; + +//============================================================================== +// DerefToType - A type that dereferences to it's template argument 'To'. +// The cv-ref qualifiers of the 'DerefToType' object do not propagate +// to the resulting 'To' object. +template +struct DerefToType { + To object; + + DerefToType() {} + + template + explicit DerefToType(Up const& val) : object(val) {} + + To& operator*() const volatile { return const_cast(object); } +}; + +//============================================================================== +// DerefPropToType - A type that dereferences to it's template argument 'To'. +// The cv-ref qualifiers of the 'DerefPropToType' object propagate +// to the resulting 'To' object. +template +struct DerefPropType { + To object; + + DerefPropType() {} + + template + explicit DerefPropType(Up const& val) : object(val) {} + +#if TEST_STD_VER < 11 + To& operator*() { return object; } + To const& operator*() const { return object; } + To volatile& operator*() volatile { return object; } + To const volatile& operator*() const volatile { return object; } +#else + To& operator*() & { return object; } + To const& operator*() const & { return object; } + To volatile& operator*() volatile & { return object; } + To const volatile& operator*() const volatile & { return object; } + To&& operator*() && { return static_cast(object); } + To const&& operator*() const && { return static_cast(object); } + To volatile&& operator*() volatile && { return static_cast(object); } + To const volatile&& operator*() const volatile && { return static_cast(object); } +#endif +}; + +//============================================================================== +// MethodID - A type that uniquely identifies a member function for a class. +// This type is used to communicate between the member functions being tested +// and the tests invoking them. +// - Test methods should call 'setUncheckedCall()' whenever they are invoked. +// - Tests consume the unchecked call using checkCall()` to assert +// that the method has been called and that the return value of `__invoke` +// matches what the method actually returned. +template +struct MethodID { + typedef void* IDType; + + static int dummy; // A dummy memory location. + static void* id; // The "ID" is the value of this pointer. + static bool unchecked_call; // Has a call happened that has not been checked. + + static void*& setUncheckedCall() { + assert(unchecked_call == false); + unchecked_call = true; + return id; + } + + static bool checkCalled(void*& return_value) { + bool old = unchecked_call; + unchecked_call = false; + return old && id == return_value && &id == &return_value; + } +}; + +template int MethodID::dummy = 0; +template void* MethodID::id = (void*)&MethodID::dummy; +template bool MethodID::unchecked_call = false; + + +//============================================================================== +// FunctionPtrID - Like MethodID but for free function pointers. +template +struct FunctionPtrID { + static int dummy; // A dummy memory location. + static void* id; // The "ID" is the value of this pointer. + static bool unchecked_call; // Has a call happened that has not been checked. + + static void*& setUncheckedCall() { + assert(unchecked_call == false); + unchecked_call = true; + return id; + } + + static bool checkCalled(void*& return_value) { + bool old = unchecked_call; + unchecked_call = false; + return old && id == return_value && &id == &return_value; + } +}; + +template int FunctionPtrID::dummy = 0; +template void* FunctionPtrID::id = (void*)&FunctionPtrID::dummy; +template bool FunctionPtrID::unchecked_call = false; + +//============================================================================== +// BasicTest - The basic test structure for everything except +// member object pointers. +// ID - The "Function Identifier" type used either MethodID or FunctionPtrID. +// Arity - The Arity of the call signature. +// ObjectCaster - The object transformation functor type. +// ArgCaster - The extra argument transformation functor type. +template +struct BasicTest { + template + void runTest(ObjectT& object) { + Int A; + runTestImp(A, object); + } + + template + void runTest(MethodPtr ptr, ObjectT& object) { + Int A; + runTestImp(A, ptr, object); + } + +private: + typedef void*& CallRet; + ObjectCaster object_cast; + ArgCaster arg_cast; + ArgType a0, a1, a2; + + //========================================================================== + // BULLET 1 AND 2 TEST METHODS + //========================================================================== + template + void runTestImp(Int<0>, MethodPtr ptr, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(ptr, object_cast(object))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(ptr, object_cast(object)); + assert(ID::checkCalled(ret)); + } + + template + void runTestImp(Int<1>, MethodPtr ptr, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0)); + assert(ID::checkCalled(ret)); + } + + template + void runTestImp(Int<2>, MethodPtr ptr, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1)); + assert(ID::checkCalled(ret)); + } + + template + void runTestImp(Int<3>, MethodPtr ptr, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(ptr, object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)); + assert(ID::checkCalled(ret)); + } + + //========================================================================== + // BULLET 5 TEST METHODS + //========================================================================== + template + void runTestImp(Int<0>, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(object_cast(object))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(object_cast(object)); + assert(ID::checkCalled(ret)); + } + + template + void runTestImp(Int<1>, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(object_cast(object), arg_cast(a0))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(object_cast(object), arg_cast(a0)); + assert(ID::checkCalled(ret)); + } + + template + void runTestImp(Int<2>, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1)); + assert(ID::checkCalled(ret)); + } + + template + void runTestImp(Int<3>, ObjectT& object) { + static_assert((std::is_same< + decltype(std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2))) + , CallRet>::value), ""); + assert(ID::unchecked_call == false); + CallRet ret = std::__invoke(object_cast(object), arg_cast(a0), arg_cast(a1), arg_cast(a2)); + assert(ID::checkCalled(ret)); + } +}; + +#endif // INVOKE_HELPERS_H diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp index cd86e4cbf8eb..82a6f6c5215e 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F.pass.cpp @@ -11,7 +11,7 @@ // class function -// function(nullptr_t); +// function(F); #include #include @@ -87,4 +87,8 @@ int main() assert(f.target() != 0); f(1); } + { + std::function f(static_cast(0)); + assert(!f); + } } diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp new file mode 100644 index 000000000000..f89bde8e6544 --- /dev/null +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.con/F_nullptr.pass.cpp @@ -0,0 +1,247 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// class function + +// function(Fp); + +// Ensure that __not_null works for all function types. +// See https://llvm.org/bugs/show_bug.cgi?id=23589 + +//------------------------------------------------------------------------------ +// TESTING std::function<...>::__not_null(Callable) +// +// Concerns: +// 1) The call __not_null(Callable) is well formed and correct for each +// possible 'Callable' type category. These categories include: +// 1a) function pointers +// 1b) member function pointer +// 1c) member data pointer +// 1d) callable class type +// 1e) lambdas +// Categories 1a, 1b, and 1c are 'Nullable' types. Only objects of these +// types can be null. The other categories are not tested here. +// 3) '__not_null(Callable)' is well formed when the call signature includes +// varargs. +// 4) '__not_null(Callable)' works for Callable types with all aritys less +// than or equal to 3 in C++03. +// 5) '__not_null(Callable)' works when 'Callable' is a member function +// pointer to a cv or ref qualified function type. +// +// Plan: +// 1 For categories 1a, 1b and 1c define a set of +// 'Callable' objects for this category. This set should include examples +// of arity 0, 1, 2 and possible 3 including versions with varargs as the +// last parameter. +// +// 2 For each 'Callable' object in categories 1a, 1b and 1c do the following. +// +// 1 Define a type 'std::function' as 'F' where 'Sig' is compatible with +// the signature of the 'Callable' object. +// +// 2 Create an object of type 'F' using a null pointer of type 'Callable'. +// Check that 'F.target()' is null. +// +// 3 Create an object of type 'F' that is not null. Check that +// 'F.target()' is not null and is equal to the original +// argument. + +#include +#include +#include + +#include "test_macros.h" + +/////////////////////////////////////////////////////////////////////////////// +int foo() { return 42; } +int foo(int) { return 42; } +int foo(int, int) { return 42; } +int foo(int, int, int) { return 42; } + +int foo(...) { return 42; } +int foo(int, ...) { return 42; } +int foo(int, int, ...) { return 42; } +int foo(int, int, int, ...) { return 42; } + +/////////////////////////////////////////////////////////////////////////////// +struct MemFun03 { + int foo() { return 42; } + int foo() const { return 42; } + int foo() volatile { return 42; } + int foo() const volatile { return 42; } + + int foo(int) { return 42; } + int foo(int) const { return 42; } + int foo(int) volatile { return 42; } + int foo(int) const volatile { return 42; } + + int foo(int, int) { return 42; } + int foo(int, int) const { return 42; } + int foo(int, int) volatile { return 42; } + int foo(int, int) const volatile { return 42; } + + int foo(int, int, int) { return 42; } + int foo(int, int, int) const { return 42; } + int foo(int, int, int) volatile { return 42; } + int foo(int, int, int) const volatile { return 42; } + + int foo(...) { return 42; } + int foo(...) const { return 42; } + int foo(...) volatile { return 42; } + int foo(...) const volatile { return 42; } + + int foo(int, ...) { return 42; } + int foo(int, ...) const { return 42; } + int foo(int, ...) volatile { return 42; } + int foo(int, ...) const volatile { return 42; } + + int foo(int, int, ...) { return 42; } + int foo(int, int, ...) const { return 42; } + int foo(int, int, ...) volatile { return 42; } + int foo(int, int, ...) const volatile { return 42; } + + int foo(int, int, int, ...) { return 42; } + int foo(int, int, int, ...) const { return 42; } + int foo(int, int, int, ...) volatile { return 42; } + int foo(int, int, int, ...) const volatile { return 42; } +}; + +#if TEST_STD_VER >= 11 +struct MemFun11 { + int foo() & { return 42; } + int foo() const & { return 42; } + int foo() volatile & { return 42; } + int foo() const volatile & { return 42; } + + int foo(...) & { return 42; } + int foo(...) const & { return 42; } + int foo(...) volatile & { return 42; } + int foo(...) const volatile & { return 42; } + + int foo() && { return 42; } + int foo() const && { return 42; } + int foo() volatile && { return 42; } + int foo() const volatile && { return 42; } + + int foo(...) && { return 42; } + int foo(...) const && { return 42; } + int foo(...) volatile && { return 42; } + int foo(...) const volatile && { return 42; } +}; +#endif // TEST_STD_VER >= 11 + +struct MemData { + int foo; +}; + +// Create a non-null free function by taking the address of +// &static_cast(foo); +template +struct Creator { + static Tp create() { + return &foo; + } +}; + +// Create a non-null member pointer. +template +struct Creator { + typedef Ret Class::*ReturnType; + static ReturnType create() { + return &Class::foo; + } +}; + +template +void test_imp() { + { // Check that the null value is detected + TestFn tf = nullptr; + std::function f = tf; + assert(f.template target() == nullptr); + } + { // Check that the non-null value is detected. + TestFn tf = Creator::create(); + assert(tf != nullptr); + std::function f = tf; + assert(f.template target() != nullptr); + assert(*f.template target() == tf); + } +} + +void test_func() { + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); +} + +void test_mf() { + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + +#if TEST_STD_VER >= 11 + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); + test_imp(); +#endif +} + +void test_md() { + test_imp(); +} + +int main() { + test_func(); + test_mf(); + test_md(); +} diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp index 6dcd2857452c..61eda7244d3b 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.fail.cpp @@ -30,13 +30,13 @@ test_int_1() { // member data pointer { - int A_int_1::*fp = &A_int_1::data_; - A_int_1 a; - std::function r2(fp); - const A_int_1* ap = &a; - assert(r2(ap) == 6); - r2(ap) = 7; - assert(r2(ap) == 7); + int A_int_1::*fp = &A_int_1::data_; + A_int_1 a; + std::function r2(fp); + const A_int_1* ap = &a; + assert(r2(ap) == 6); + r2(ap) = 7; + assert(r2(ap) == 7); } } diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp index 31b80c3323c1..cc4315c14422 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke.pass.cpp @@ -16,8 +16,85 @@ #include #include + int count = 0; + +// 0 args, return int + +int f_int_0() +{ + return 3; +} + +struct A_int_0 +{ + int operator()() {return 4;} +}; + +void test_int_0() +{ + // function + { + std::function r1(f_int_0); + assert(r1() == 3); + } + // function pointer + { + int (*fp)() = f_int_0; + std::function r1(fp); + assert(r1() == 3); + } + // functor + { + A_int_0 a0; + std::function r1(a0); + assert(r1() == 4); + } +} + + +// 0 args, return void + +void f_void_0() +{ + ++count; +} + +struct A_void_0 +{ + void operator()() {++count;} +}; + +void +test_void_0() +{ + int save_count = count; + // function + { + std::function r1(f_void_0); + r1(); + assert(count == save_count+1); + save_count = count; + } + // function pointer + { + void (*fp)() = f_void_0; + std::function r1(fp); + r1(); + assert(count == save_count+1); + save_count = count; + } + // functor + { + A_void_0 a0; + std::function r1(a0); + r1(); + assert(count == save_count+1); + save_count = count; + } +} + // 1 arg, return void void f_void_1(int i) @@ -42,57 +119,57 @@ test_void_1() int save_count = count; // function { - std::function r1(f_void_1); - int i = 2; - r1(i); - assert(count == save_count+2); - save_count = count; + std::function r1(f_void_1); + int i = 2; + r1(i); + assert(count == save_count+2); + save_count = count; } // function pointer { - void (*fp)(int) = f_void_1; - std::function r1(fp); - int i = 3; - r1(i); - assert(count == save_count+3); - save_count = count; + void (*fp)(int) = f_void_1; + std::function r1(fp); + int i = 3; + r1(i); + assert(count == save_count+3); + save_count = count; } // functor { - A_void_1 a0; - std::function r1(a0); - int i = 4; - r1(i); - assert(count == save_count+4); - save_count = count; + A_void_1 a0; + std::function r1(a0); + int i = 4; + r1(i); + assert(count == save_count+4); + save_count = count; } // member function pointer { - void (A_void_1::*fp)() = &A_void_1::mem1; - std::function r1(fp); - A_void_1 a; - r1(a); - assert(count == save_count+1); - save_count = count; - A_void_1* ap = &a; - std::function r2 = fp; - r2(ap); - assert(count == save_count+1); - save_count = count; + void (A_void_1::*fp)() = &A_void_1::mem1; + std::function r1(fp); + A_void_1 a; + r1(a); + assert(count == save_count+1); + save_count = count; + A_void_1* ap = &a; + std::function r2 = fp; + r2(ap); + assert(count == save_count+1); + save_count = count; } // const member function pointer { - void (A_void_1::*fp)() const = &A_void_1::mem2; - std::function r1(fp); - A_void_1 a; - r1(a); - assert(count == save_count+1); - save_count = count; - std::function r2(fp); - A_void_1* ap = &a; - r2(ap); - assert(count == save_count+1); - save_count = count; + void (A_void_1::*fp)() const = &A_void_1::mem2; + std::function r1(fp); + A_void_1 a; + r1(a); + assert(count == save_count+1); + save_count = count; + std::function r2(fp); + A_void_1* ap = &a; + r2(ap); + assert(count == save_count+1); + save_count = count; } } @@ -121,57 +198,57 @@ test_int_1() { // function { - std::function r1(f_int_1); - int i = 2; - assert(r1(i) == 3); + std::function r1(f_int_1); + int i = 2; + assert(r1(i) == 3); } // function pointer { - int (*fp)(int) = f_int_1; - std::function r1(fp); - int i = 3; - assert(r1(i) == 4); + int (*fp)(int) = f_int_1; + std::function r1(fp); + int i = 3; + assert(r1(i) == 4); } // functor { - A_int_1 a0; - std::function r1(a0); - int i = 4; - assert(r1(i) == 3); + A_int_1 a0; + std::function r1(a0); + int i = 4; + assert(r1(i) == 3); } // member function pointer { - int (A_int_1::*fp)() = &A_int_1::mem1; - std::function r1(fp); - A_int_1 a; - assert(r1(a) == 3); - std::function r2(fp); - A_int_1* ap = &a; - assert(r2(ap) == 3); + int (A_int_1::*fp)() = &A_int_1::mem1; + std::function r1(fp); + A_int_1 a; + assert(r1(a) == 3); + std::function r2(fp); + A_int_1* ap = &a; + assert(r2(ap) == 3); } // const member function pointer { - int (A_int_1::*fp)() const = &A_int_1::mem2; - std::function r1(fp); - A_int_1 a; - assert(r1(a) == 4); - std::function r2(fp); - A_int_1* ap = &a; - assert(r2(ap) == 4); + int (A_int_1::*fp)() const = &A_int_1::mem2; + std::function r1(fp); + A_int_1 a; + assert(r1(a) == 4); + std::function r2(fp); + A_int_1* ap = &a; + assert(r2(ap) == 4); } // member data pointer { - int A_int_1::*fp = &A_int_1::data_; - std::function r1(fp); - A_int_1 a; - assert(r1(a) == 5); - r1(a) = 6; - assert(r1(a) == 6); - std::function r2(fp); - A_int_1* ap = &a; - assert(r2(ap) == 6); - r2(ap) = 7; - assert(r2(ap) == 7); + int A_int_1::*fp = &A_int_1::data_; + std::function r1(fp); + A_int_1 a; + assert(r1(a) == 5); + r1(a) = 6; + assert(r1(a) == 6); + std::function r2(fp); + A_int_1* ap = &a; + assert(r2(ap) == 6); + r2(ap) = 7; + assert(r2(ap) == 7); } } @@ -199,62 +276,62 @@ test_void_2() int save_count = count; // function { - std::function r1(f_void_2); - int i = 2; - int j = 3; - r1(i, j); - assert(count == save_count+5); - save_count = count; + std::function r1(f_void_2); + int i = 2; + int j = 3; + r1(i, j); + assert(count == save_count+5); + save_count = count; } // function pointer { - void (*fp)(int, int) = f_void_2; - std::function r1(fp); - int i = 3; - int j = 4; - r1(i, j); - assert(count == save_count+7); - save_count = count; + void (*fp)(int, int) = f_void_2; + std::function r1(fp); + int i = 3; + int j = 4; + r1(i, j); + assert(count == save_count+7); + save_count = count; } // functor { - A_void_2 a0; - std::function r1(a0); - int i = 4; - int j = 5; - r1(i, j); - assert(count == save_count+9); - save_count = count; + A_void_2 a0; + std::function r1(a0); + int i = 4; + int j = 5; + r1(i, j); + assert(count == save_count+9); + save_count = count; } // member function pointer { - void (A_void_2::*fp)(int) = &A_void_2::mem1; - std::function r1(fp); - A_void_2 a; - int i = 3; - r1(a, i); - assert(count == save_count+3); - save_count = count; - std::function r2(fp); - A_void_2* ap = &a; - r2(ap, i); - assert(count == save_count+3); - save_count = count; + void (A_void_2::*fp)(int) = &A_void_2::mem1; + std::function r1(fp); + A_void_2 a; + int i = 3; + r1(a, i); + assert(count == save_count+3); + save_count = count; + std::function r2(fp); + A_void_2* ap = &a; + r2(ap, i); + assert(count == save_count+3); + save_count = count; } // const member function pointer { - void (A_void_2::*fp)(int) const = &A_void_2::mem2; - std::function r1(fp); - A_void_2 a; - int i = 4; - r1(a, i); - assert(count == save_count+4); - save_count = count; - std::function r2(fp); - A_void_2* ap = &a; - r2(ap, i); - assert(count == save_count+4); - save_count = count; + void (A_void_2::*fp)(int) const = &A_void_2::mem2; + std::function r1(fp); + A_void_2 a; + int i = 4; + r1(a, i); + assert(count == save_count+4); + save_count = count; + std::function r2(fp); + A_void_2* ap = &a; + r2(ap, i); + assert(count == save_count+4); + save_count = count; } } @@ -276,60 +353,61 @@ struct A_int_2 int mem2(int i) const {return i+2;} }; -void -testint_2() +void test_int_2() { // function { - std::function r1(f_int_2); - int i = 2; - int j = 3; - assert(r1(i, j) == i+j); + std::function r1(f_int_2); + int i = 2; + int j = 3; + assert(r1(i, j) == i+j); } // function pointer { - int (*fp)(int, int) = f_int_2; - std::function r1(fp); - int i = 3; - int j = 4; - assert(r1(i, j) == i+j); + int (*fp)(int, int) = f_int_2; + std::function r1(fp); + int i = 3; + int j = 4; + assert(r1(i, j) == i+j); } // functor { - A_int_2 a0; - std::function r1(a0); - int i = 4; - int j = 5; - assert(r1(i, j) == i+j); + A_int_2 a0; + std::function r1(a0); + int i = 4; + int j = 5; + assert(r1(i, j) == i+j); } // member function pointer { - int(A_int_2::*fp)(int) = &A_int_2::mem1; - std::function r1(fp); - A_int_2 a; - int i = 3; - assert(r1(a, i) == i+1); - std::function r2(fp); - A_int_2* ap = &a; - assert(r2(ap, i) == i+1); + int(A_int_2::*fp)(int) = &A_int_2::mem1; + std::function r1(fp); + A_int_2 a; + int i = 3; + assert(r1(a, i) == i+1); + std::function r2(fp); + A_int_2* ap = &a; + assert(r2(ap, i) == i+1); } // const member function pointer { - int (A_int_2::*fp)(int) const = &A_int_2::mem2; - std::function r1(fp); - A_int_2 a; - int i = 4; - assert(r1(a, i) == i+2); - std::function r2(fp); - A_int_2* ap = &a; - assert(r2(ap, i) == i+2); + int (A_int_2::*fp)(int) const = &A_int_2::mem2; + std::function r1(fp); + A_int_2 a; + int i = 4; + assert(r1(a, i) == i+2); + std::function r2(fp); + A_int_2* ap = &a; + assert(r2(ap, i) == i+2); } } int main() { + test_void_0(); + test_int_0(); test_void_1(); test_int_1(); test_void_2(); - testint_2(); + test_int_2(); } diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp deleted file mode 100644 index 67b4ec22da8c..000000000000 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_int_0.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// class function - -// R operator()(ArgTypes... args) const - -#include -#include - -// 0 args, return int - -int count = 0; - -int f_int_0() -{ - return 3; -} - -struct A_int_0 -{ - int operator()() {return 4;} -}; - -void -test_int_0() -{ - // function - { - std::function r1(f_int_0); - assert(r1() == 3); - } - // function pointer - { - int (*fp)() = f_int_0; - std::function r1(fp); - assert(r1() == 3); - } - // functor - { - A_int_0 a0; - std::function r1(a0); - assert(r1() == 4); - } -} - -int main() -{ - test_int_0(); -} diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp deleted file mode 100644 index c0a14fd96fcb..000000000000 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_no_variadics.pass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// class function - -// Test that we properly return both values and void for all non-variadic -// overloads of function::operator()(...) - -#define _LIBCPP_HAS_NO_VARIADICS -#include -#include - -int foo0() { return 42; } -int foo1(int) { return 42; } -int foo2(int, int) { return 42; } -int foo3(int, int, int) { return 42; } - -int main() -{ - { - std::function f(&foo0); - assert(f() == 42); - } - { - std::function f(&foo1); - assert(f(1) == 42); - } - { - std::function f(&foo2); - assert(f(1, 1) == 42); - } - { - std::function f(&foo3); - assert(f(1, 1, 1) == 42); - } - { - std::function f(&foo0); - f(); - } - { - std::function f(&foo1); - f(1); - } - { - std::function f(&foo2); - f(1, 1); - } - { - std::function f(&foo3); - f(1, 1, 1); - } -} diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp b/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp deleted file mode 100644 index a820cb1b8f38..000000000000 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/func.wrap.func.inv/invoke_void_0.pass.cpp +++ /dev/null @@ -1,67 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// class function - -// R operator()(ArgTypes... args) const - -#include -#include -#include -#include - -// 0 args, return void - -int count = 0; - -void f_void_0() -{ - ++count; -} - -struct A_void_0 -{ - void operator()() {++count;} -}; - -void -test_void_0() -{ - int save_count = count; - // function - { - std::function r1(f_void_0); - r1(); - assert(count == save_count+1); - save_count = count; - } - // function pointer - { - void (*fp)() = f_void_0; - std::function r1(fp); - r1(); - assert(count == save_count+1); - save_count = count; - } - // functor - { - A_void_0 a0; - std::function r1(a0); - r1(); - assert(count == save_count+1); - save_count = count; - } -} - -int main() -{ - test_void_0(); -} diff --git a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp index ba46946aae1b..a2316063cec6 100644 --- a/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp +++ b/test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.fail.cpp @@ -13,6 +13,8 @@ // reference_wrapper(T&&) = delete; +// XFAIL: c++98, c++03 + #include #include diff --git a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp index 86a5696f48ca..0aad4986a1f8 100644 --- a/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp +++ b/test/std/utilities/function.objects/refwrap/refwrap.helpers/ref_1.fail.cpp @@ -15,6 +15,8 @@ // Don't allow binding to a temp +// XFAIL: c++98, c++03 + #include struct A {}; diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp index 7cd9f15e93d1..d3db45fad7c0 100644 --- a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp @@ -57,4 +57,44 @@ int main() test(); test(); test(); + +// LWG #2119 + test(); + test(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + + test(); + test(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + + test(); + test(); + test(); + test(); + + test(); + test(); } diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp index 2dd6c17b3dee..af4a3c4dfe7f 100644 --- a/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp +++ b/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp @@ -12,19 +12,23 @@ // template // using make_integer_sequence = integer_sequence; +// UNSUPPORTED: c++98, c++03, c++11 + #include #include #include +#include "test_macros.h" + int main() { -#if _LIBCPP_STD_VER > 11 - - std::make_integer_sequence::value_type i; + typedef std::make_integer_sequence MakeSeqT; + // std::make_integer_sequence is implemented using a compiler builtin if available. + // this builtin has different diagnostic messages than the fallback implementation. +#if TEST_HAS_BUILTIN(__make_integer_seq) && !defined(_LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE) + MakeSeqT i; // expected-error@utility:* {{integer sequences must have non-negative sequence length}} #else - -X - -#endif // _LIBCPP_STD_VER > 11 + MakeSeqT i; // expected-error@utility:* {{static_assert failed "std::make_integer_sequence must have a non-negative sequence length"}} +#endif } diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp index 7e82b94a7da0..9bfc5f3d9d70 100644 --- a/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp +++ b/test/std/utilities/intseq/intseq.make/make_integer_seq.pass.cpp @@ -12,14 +12,14 @@ // template // using make_integer_sequence = integer_sequence; +// UNSUPPORTED: c++98, c++03, c++11 + #include #include #include int main() { -#if _LIBCPP_STD_VER > 11 - static_assert(std::is_same, std::integer_sequence>::value, ""); static_assert(std::is_same, std::integer_sequence>::value, ""); static_assert(std::is_same, std::integer_sequence>::value, ""); @@ -29,6 +29,4 @@ int main() static_assert(std::is_same, std::integer_sequence>::value, ""); static_assert(std::is_same, std::integer_sequence>::value, ""); static_assert(std::is_same, std::integer_sequence>::value, ""); - -#endif // _LIBCPP_STD_VER > 11 } diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp new file mode 100644 index 000000000000..b6431b56d5f0 --- /dev/null +++ b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.fail.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// using make_integer_sequence = integer_sequence; + +// UNSUPPORTED: c++98, c++03, c++11 + +#define _LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE +#include "make_integer_seq.fail.cpp" diff --git a/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp new file mode 100644 index 000000000000..c75d20b11af3 --- /dev/null +++ b/test/std/utilities/intseq/intseq.make/make_integer_seq_fallback.pass.cpp @@ -0,0 +1,18 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template +// using make_integer_sequence = integer_sequence; + +// UNSUPPORTED: c++98, c++03, c++11 + +#define _LIBCPP_TESTING_FALLBACK_MAKE_INTEGER_SEQUENCE +#include "make_integer_seq.pass.cpp" diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp index 1fa7291203ed..352c7c8d0caf 100644 --- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp +++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp @@ -45,12 +45,12 @@ int main() { A a; assert(std::allocator_traits >::max_size(a) == - std::numeric_limits::max()); + std::numeric_limits::max() / sizeof(int)); } { const A a = {}; assert(std::allocator_traits >::max_size(a) == - std::numeric_limits::max()); + std::numeric_limits::max() / sizeof(int)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE { diff --git a/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp index d0a870e60690..28dadd831514 100644 --- a/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp +++ b/test/std/utilities/memory/default.allocator/allocator.members/construct.pass.cpp @@ -15,6 +15,7 @@ #include #include +#include "test_macros.h" #include "count_new.hpp" int A_constructed = 0; @@ -34,30 +35,24 @@ struct A int move_only_constructed = 0; +#if TEST_STD_VER >= 11 class move_only { - int data; -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(const move_only&); - move_only& operator=(const move_only&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(move_only&); - move_only& operator=(move_only&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + move_only(const move_only&) = delete; + move_only& operator=(const move_only&)= delete; public: - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES move_only(move_only&&) {++move_only_constructed;} move_only& operator=(move_only&&) {return *this;} -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv () {return std::__rv(*this);} - move_only(std::__rv) {++move_only_constructed;} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES move_only() {++move_only_constructed;} ~move_only() {--move_only_constructed;} + +public: + int data; // unused other than to make sizeof(move_only) == sizeof(int). + // but public to suppress "-Wunused-private-field" }; +#endif // TEST_STD_VER >= 11 int main() { @@ -108,6 +103,7 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(A_constructed == 0); } +#if TEST_STD_VER >= 11 { std::allocator a; assert(globalMemCounter.checkOutstandingNewEq(0)); @@ -139,4 +135,5 @@ int main() assert(globalMemCounter.checkOutstandingNewEq(0)); assert(move_only_constructed == 0); } +#endif } diff --git a/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp index 6ec9339bc48f..10109383b0c7 100644 --- a/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp +++ b/test/std/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp @@ -22,6 +22,6 @@ int new_called = 0; int main() { const std::allocator a; - std::size_t M = a.max_size() * sizeof(int); - assert(M > 0xFFFF && M <= std::numeric_limits::max()); + std::size_t M = a.max_size(); + assert(M > 0xFFFF && M <= (std::numeric_limits::max() / sizeof(int))); } diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp index f431335db732..8bb818319a37 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template @@ -20,13 +21,15 @@ struct B { static int count_; + static int population_; int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} + explicit B() : data_(1) { ++population_; } + B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; } + ~B() {data_ = 0; --population_; } }; int B::count_ = 0; +int B::population_ = 0; struct Nasty { @@ -45,6 +48,7 @@ int main() char pool[sizeof(B)*N] = {0}; B* bp = (B*)pool; B b[N]; + assert(B::population_ == N); try { std::uninitialized_copy(b, b+N, bp); @@ -52,14 +56,15 @@ int main() } catch (...) { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); + assert(B::population_ == N); } B::count_ = 0; std::uninitialized_copy(b, b+2, bp); for (int i = 0; i < 2; ++i) assert(bp[i].data_ == 1); + assert(B::population_ == N + 2); } + { const int N = 5; char pool[sizeof(Nasty)*N] = {0}; diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp index 3b2007b969c3..ae438ef7d561 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template @@ -20,12 +21,14 @@ struct B { static int count_; + static int population_; int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} + explicit B() : data_(1) { ++population_; } + B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; } + ~B() {data_ = 0; --population_; } }; +int B::population_ = 0; int B::count_ = 0; struct Nasty @@ -45,6 +48,7 @@ int main() char pool[sizeof(B)*N] = {0}; B* bp = (B*)pool; B b[N]; + assert(B::population_ == N); try { std::uninitialized_copy_n(b, 5, bp); @@ -52,14 +56,15 @@ int main() } catch (...) { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); + assert(B::population_ == N); } B::count_ = 0; std::uninitialized_copy_n(b, 2, bp); for (int i = 0; i < 2; ++i) assert(bp[i].data_ == 1); + assert(B::population_ == N + 2); } + { const int N = 5; char pool[sizeof(Nasty)*N] = {0}; diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp index d2b1dfa28868..22aa8b98b8c9 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template @@ -19,13 +20,15 @@ struct B { static int count_; + static int population_; int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} + explicit B() : data_(1) { ++population_; } + B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; } + ~B() {data_ = 0; --population_; } }; int B::count_ = 0; +int B::population_ = 0; struct Nasty { @@ -43,6 +46,7 @@ int main() const int N = 5; char pool[sizeof(B)*N] = {0}; B* bp = (B*)pool; + assert(B::population_ == 0); try { std::uninitialized_fill_n(bp, 5, B()); @@ -50,14 +54,14 @@ int main() } catch (...) { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); + assert(B::population_ == 0); } B::count_ = 0; B* r = std::uninitialized_fill_n(bp, 2, B()); assert(r == bp + 2); for (int i = 0; i < 2; ++i) assert(bp[i].data_ == 1); + assert(B::population_ == 2); } { { diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp index 47cabdfa478a..95c45dd50541 100644 --- a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp +++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template @@ -20,13 +21,15 @@ struct B { static int count_; + static int population_; int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} + explicit B() : data_(1) { ++population_; } + B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; } + ~B() {data_ = 0; --population_; } }; int B::count_ = 0; +int B::population_ = 0; struct Nasty { @@ -44,6 +47,7 @@ int main() const int N = 5; char pool[sizeof(B)*N] = {0}; B* bp = (B*)pool; + assert(B::population_ == 0); try { std::uninitialized_fill(bp, bp+N, B()); @@ -51,13 +55,13 @@ int main() } catch (...) { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); + assert(B::population_ == 0); } B::count_ = 0; std::uninitialized_fill(bp, bp+2, B()); for (int i = 0; i < 2; ++i) assert(bp[i].data_ == 1); + assert(B::population_ == 2); } { const int N = 5; diff --git a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp index f77d6c75e17a..914802423ce7 100644 --- a/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp +++ b/test/std/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp @@ -13,6 +13,8 @@ #include #include +#include + int A_constructed = 0; struct A @@ -29,16 +31,33 @@ struct A int main() { - typedef std::aligned_storage<3*sizeof(A), std::alignment_of::value>::type + { + typedef A S; + typedef std::aligned_storage<3*sizeof(S), std::alignment_of::value>::type Storage; Storage buffer; - std::raw_storage_iterator it((A*)&buffer); + std::raw_storage_iterator it((S*)&buffer); assert(A_constructed == 0); for (int i = 0; i < 3; ++i) { - *it++ = A(i+1); - A* ap = (A*)&buffer + i; + *it++ = S(i+1); + S* ap = (S*)&buffer + i; assert(*ap == i+1); assert(A_constructed == i+1); } + } +#if _LIBCPP_STD_VER >= 14 + { + typedef MoveOnly S; + typedef std::aligned_storage<3*sizeof(S), std::alignment_of::value>::type + Storage; + Storage buffer; + std::raw_storage_iterator it((S*)&buffer); + S m{1}; + *it++ = std::move(m); + assert(m.get() == 0); // moved from + S *ap = (S*) &buffer; + assert(ap->get() == 1); // original value + } +#endif } diff --git a/test/std/utilities/memory/unique.ptr/deleter.h b/test/std/utilities/memory/unique.ptr/deleter.h index fb26044d98ff..1d8e19d5bc41 100644 --- a/test/std/utilities/memory/unique.ptr/deleter.h +++ b/test/std/utilities/memory/unique.ptr/deleter.h @@ -20,21 +20,19 @@ #include #include +#include "test_macros.h" + +#if TEST_STD_VER >= 11 + template class Deleter { int state_; -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES Deleter(const Deleter&); Deleter& operator=(const Deleter&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&); - Deleter& operator=(Deleter&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} Deleter& operator=(Deleter&& r) { @@ -42,22 +40,12 @@ class Deleter r.state_ = 0; return *this; } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv() {return std::__rv(*this);} - Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} - Deleter& operator=(std::__rv r) - { - state_ = r->state_; - r->state_ = 0; - return *this; - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + Deleter() : state_(0) {} explicit Deleter(int s) : state_(s) {} ~Deleter() {assert(state_ >= 0); state_ = -1;} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template Deleter(Deleter&& d, typename std::enable_if::value>::type* = 0) @@ -67,12 +55,6 @@ class Deleter template Deleter(const Deleter& d, typename std::enable_if::value>::type* = 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES public: int state() const {return state_;} void set_state(int i) {state_ = i;} @@ -85,16 +67,11 @@ class Deleter { int state_; -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES Deleter(const Deleter&); Deleter& operator=(const Deleter&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&); - Deleter& operator=(Deleter&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} Deleter& operator=(Deleter&& r) { @@ -102,16 +79,6 @@ class Deleter r.state_ = 0; return *this; } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv() {return std::__rv(*this);} - Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} - Deleter& operator=(std::__rv r) - { - state_ = r->state_; - r->state_ = 0; - return *this; - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES Deleter() : state_(0) {} explicit Deleter(int s) : state_(s) {} @@ -123,6 +90,68 @@ class Deleter void operator()(T* p) {delete [] p;} }; +#else // TEST_STD_VER < 11 + +template +class Deleter +{ + mutable int state_; + +public: + Deleter() : state_(0) {} + explicit Deleter(int s) : state_(s) {} + + Deleter(Deleter const & other) : state_(other.state_) { + other.state_ = 0; + } + Deleter& operator=(Deleter const& other) { + state_ = other.state_; + other.state_ = 0; + return *this; + } + + ~Deleter() {assert(state_ >= 0); state_ = -1;} + + template + Deleter(Deleter d, + typename std::enable_if::value>::type* = 0) + : state_(d.state()) {} + +public: + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete p;} +}; + +template +class Deleter +{ + mutable int state_; + +public: + + Deleter(Deleter const& other) : state_(other.state_) { + other.state_ = 0; + } + Deleter& operator=(Deleter const& other) { + state_ = other.state_; + other.state_ = 0; + return *this; + } + + Deleter() : state_(0) {} + explicit Deleter(int s) : state_(s) {} + ~Deleter() {assert(state_ >= 0); state_ = -1;} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete [] p;} +}; + +#endif + template void swap(Deleter& x, Deleter& y) @@ -132,6 +161,7 @@ swap(Deleter& x, Deleter& y) y = std::move(t); } + template class CDeleter { @@ -179,4 +209,130 @@ swap(CDeleter& x, CDeleter& y) y = std::move(t); } +// Non-copyable deleter +template +class NCDeleter +{ + int state_; + NCDeleter(NCDeleter const&); + NCDeleter& operator=(NCDeleter const&); +public: + + NCDeleter() : state_(0) {} + explicit NCDeleter(int s) : state_(s) {} + ~NCDeleter() {assert(state_ >= 0); state_ = -1;} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete p;} +}; + + +template +class NCDeleter +{ + int state_; + NCDeleter(NCDeleter const&); + NCDeleter& operator=(NCDeleter const&); +public: + + NCDeleter() : state_(0) {} + explicit NCDeleter(int s) : state_(s) {} + ~NCDeleter() {assert(state_ >= 0); state_ = -1;} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete [] p;} +}; + + +// Non-copyable deleter +template +class NCConstDeleter +{ + int state_; + NCConstDeleter(NCConstDeleter const&); + NCConstDeleter& operator=(NCConstDeleter const&); +public: + + NCConstDeleter() : state_(0) {} + explicit NCConstDeleter(int s) : state_(s) {} + ~NCConstDeleter() {assert(state_ >= 0); state_ = -1;} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) const {delete p;} +}; + + +template +class NCConstDeleter +{ + int state_; + NCConstDeleter(NCConstDeleter const&); + NCConstDeleter& operator=(NCConstDeleter const&); +public: + + NCConstDeleter() : state_(0) {} + explicit NCConstDeleter(int s) : state_(s) {} + ~NCConstDeleter() {assert(state_ >= 0); state_ = -1;} + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) const {delete [] p;} +}; + + +// Non-copyable deleter +template +class CopyDeleter +{ + int state_; +public: + + CopyDeleter() : state_(0) {} + explicit CopyDeleter(int s) : state_(s) {} + ~CopyDeleter() {assert(state_ >= 0); state_ = -1;} + + CopyDeleter(CopyDeleter const& other) : state_(other.state_) {} + CopyDeleter& operator=(CopyDeleter const& other) { + state_ = other.state_; + return *this; + } + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete p;} +}; + + +template +class CopyDeleter +{ + int state_; + +public: + + CopyDeleter() : state_(0) {} + explicit CopyDeleter(int s) : state_(s) {} + ~CopyDeleter() {assert(state_ >= 0); state_ = -1;} + + CopyDeleter(CopyDeleter const& other) : state_(other.state_) {} + CopyDeleter& operator=(CopyDeleter const& other) { + state_ = other.state_; + return *this; + } + + int state() const {return state_;} + void set_state(int i) {state_ = i;} + + void operator()(T* p) {delete [] p;} +}; + + #endif // DELETER_H diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp index 17375ede00f5..ed94c1a1e470 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp @@ -14,26 +14,15 @@ // Test unique_ptr move assignment #include -#include -#include -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; +#include "test_macros.h" int main() { - { - std::unique_ptr s(new A); - std::unique_ptr s2; - s2 = s; - } + std::unique_ptr s, s2; +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +#else + s2 = s; // expected-error {{'operator=' is a private member of 'std::__1::unique_ptr}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp index 03747b4f89cf..5088a4410e79 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp @@ -32,22 +32,6 @@ struct A int A::count = 0; -class NCDeleter -{ - int state_; - - NCDeleter(NCDeleter&); - NCDeleter& operator=(NCDeleter&); -public: - - NCDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - int main() { { @@ -71,10 +55,10 @@ int main() } assert(A::count == 0); { - NCDeleter d; - std::unique_ptr s(new A[3], d); + NCDeleter d; + std::unique_ptr&> s(new A[3], d); A* p = s.get(); - std::unique_ptr s2 = std::move(s); + std::unique_ptr&> s2 = std::move(s); assert(s2.get() == p); assert(s.get() == 0); assert(A::count == 3); diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp index ef821a915e44..5720d3bd288f 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp @@ -31,21 +31,6 @@ struct A int A::count = 0; -class NCDeleter -{ - int state_; - - NCDeleter(NCDeleter&); - NCDeleter& operator=(NCDeleter&); -public: - - NCDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; std::unique_ptr source1() @@ -67,14 +52,14 @@ void sink2(std::unique_ptr > p) { } -std::unique_ptr +std::unique_ptr&> source3() { - static NCDeleter d; - return std::unique_ptr(new A[3], d); + static NCDeleter d; + return std::unique_ptr&>(new A[3], d); } -void sink3(std::unique_ptr p) +void sink3(std::unique_ptr&> p) { } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp index b635d507b2ec..9d3f94098a08 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// XFAIL: c++98, c++03 + // // unique_ptr @@ -16,40 +18,16 @@ // unique_ptr(pointer, D()) should not compile #include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; class Deleter { - int state_; - public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete [] p;} + Deleter() {} + void operator()(int* p) const {delete [] p;} }; int main() { - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); + int* p = nullptr; + std::unique_ptr s(p, Deleter()); // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp index 57724ae10a70..87cfb72ad6e0 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp @@ -14,25 +14,16 @@ // Test unique_ptr move assignment #include -#include + +#include "test_macros.h" // Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - int main() { - { - std::unique_ptr s(new A); - std::unique_ptr s2; - s2 = s; - } + std::unique_ptr s, s2; +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +#else + s2 = s; // expected-error {{'operator=' is a private member}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp index 5046fd8aae6b..9cea12b1249f 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp @@ -14,25 +14,20 @@ // Test unique_ptr move assignment #include -#include + +#include "test_macros.h" // Can't copy from const lvalue -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - int main() { - { - const std::unique_ptr s(new A); - std::unique_ptr s2; - s2 = s; - } + const std::unique_ptr s(new int); + std::unique_ptr s2; +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +#else + // NOTE: The error says "constructor" because the assignment operator takes + // 's' by value and attempts to copy construct it. + s2 = s; // expected-error {{no matching constructor for initialization}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp index aa4fdb8a96b1..05a057f9bb32 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp @@ -14,43 +14,20 @@ // Test unique_ptr move assignment #include -#include + +#include "test_macros.h" + +struct Deleter { + void operator()(int* p) {delete p;} +}; // Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - int main() { - { - std::unique_ptr s(new A); - A* p = s.get(); - std::unique_ptr s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); + std::unique_ptr s, s2; +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +#else + s2 = s; // expected-error {{'operator=' is a private member}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp index e0d7c891c80f..24703ec98238 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp @@ -11,46 +11,26 @@ // unique_ptr -// Test unique_ptr move ctor +// Test unique_ptr move assignment #include -#include -// test move ctor. Can't copy from const lvalue +#include "test_macros.h" -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} +struct Deleter { + void operator()(int* p) {delete p;} }; +// Can't copy from a const lvalue int main() { - { - const std::unique_ptr s(new A); - A* p = s.get(); - std::unique_ptr s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); + const std::unique_ptr s(new int); + std::unique_ptr s2; +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{cannot be assigned because its copy assignment operator is implicitly deleted}} +#else + // NOTE: The error says "constructor" because the assignment operator takes + // 's' by value and attempts to copy construct it. + s2 = s; // expected-error {{no matching constructor for initialization}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp new file mode 100644 index 000000000000..4c4a32035641 --- /dev/null +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert.pass.cpp @@ -0,0 +1,89 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move assignment + +#include +#include +#include + +#include "../../deleter.h" + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + virtual ~A() {--count;} +}; + +int A::count = 0; + +struct B + : public A +{ + static int count; + B() {++count;} + B(const B&) {++count;} + virtual ~B() {--count;} +}; + +int B::count = 0; + + +template +void testAssign(APtr& aptr, BPtr& bptr) { + A* p = bptr.get(); + assert(A::count == 2); + aptr = std::move(bptr); + assert(aptr.get() == p); + assert(bptr.get() == 0); + assert(A::count == 1); + assert(B::count == 1); +} + +template +void checkDeleter(LHS& lhs, RHS& rhs, int LHSState, int RHSState) { + assert(lhs.get_deleter().state() == LHSState); + assert(rhs.get_deleter().state() == RHSState); +} + +int main() +{ + { + std::unique_ptr bptr(new B); + std::unique_ptr aptr(new A); + testAssign(aptr, bptr); + } + assert(A::count == 0); + assert(B::count == 0); + { + Deleter del(42); + std::unique_ptr > bptr(new B, std::move(del)); + std::unique_ptr > aptr(new A); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 0); + } + assert(A::count == 0); + assert(B::count == 0); + { + CDeleter adel(6); + CDeleter bdel(42); + std::unique_ptr&> bptr(new B, bdel); + std::unique_ptr&> aptr(new A, adel); + testAssign(aptr, bptr); + checkDeleter(aptr, bptr, 42, 42); + } + assert(A::count == 0); + assert(B::count == 0); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp index 3fd2cbc42bd6..816a598d9a23 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp @@ -14,44 +14,29 @@ // Test unique_ptr converting move assignment #include -#include -#include -// Can't assign from lvalue +#include "test_macros.h" struct A { - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} + A() {} + virtual ~A() {} }; -int A::count = 0; - -struct B - : public A +struct B : public A { - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} }; -int B::count = 0; - +// Can't assign from lvalue int main() { - { - std::unique_ptr s(new B); - A* p = s.get(); + std::unique_ptr s; std::unique_ptr s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{no viable overloaded '='}} +#else + // NOTE: The move-semantic emulation creates an ambiguous overload set + // so that assignment from an lvalue does not compile + s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp deleted file mode 100644 index 989f594e38b8..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp +++ /dev/null @@ -1,56 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr s(new B); - A* p = s.get(); - std::unique_ptr s2(new A); - assert(A::count == 2); - s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp index 0f900603e239..1ddf1d811651 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp @@ -14,48 +14,30 @@ // Test unique_ptr converting move assignment #include -#include -#include +#include "test_macros.h" #include "../../deleter.h" -// Can't assign from lvalue - struct A { - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} + A() {} + virtual ~A() {} }; -int A::count = 0; - -struct B - : public A +struct B : public A { - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} }; -int B::count = 0; - +// Can't assign from lvalue int main() { - { - std::unique_ptr > s(new B); - A* p = s.get(); + std::unique_ptr > s; std::unique_ptr > s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{no viable overloaded '='}} +#else + // NOTE: The move-semantic emulation creates an ambiguous overload set + // so that assignment from an lvalue does not compile + s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp deleted file mode 100644 index a448c77a66a7..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include -#include -#include - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr > s(new B, Deleter(5)); - A* p = s.get(); - std::unique_ptr > s2(new A); - assert(A::count == 2); - s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp index f35af9f453ff..570c1c42f4fe 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp @@ -16,47 +16,32 @@ // Can't assign from lvalue #include -#include -#include +#include "test_macros.h" #include "../../deleter.h" struct A { - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} + A() {} + virtual ~A() {} }; -int A::count = 0; - -struct B - : public A +struct B : public A { - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} }; -int B::count = 0; - +// Can't assign from lvalue int main() { - { - Deleter db(5); - std::unique_ptr&> s(new B, db); - A* p = s.get(); - Deleter da(6); - std::unique_ptr&> s2(new A, da); - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); + Deleter db; + std::unique_ptr& > s(new B, db); + Deleter da; + std::unique_ptr &> s2(new A, da); +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{no viable overloaded '='}} +#else + // NOTE: The move-semantic emulation creates an ambiguous overload set + // so that assignment from an lvalue does not compile + s2 = s; // expected-error {{use of overloaded operator '=' is ambiguous}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp deleted file mode 100644 index 9aea81a8b144..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move assignment - -// test converting move assignment with reference deleters - -#include -#include -#include - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - CDeleter db(5); - std::unique_ptr&> s(new B, db); - A* p = s.get(); - CDeleter da(6); - std::unique_ptr&> s2(new A, da); - s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s.get_deleter().state() == 5); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp index dba901b2ce17..2ebc33d21d81 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp @@ -14,44 +14,30 @@ // Test unique_ptr converting move assignment #include -#include -#include -// Can't assign from const lvalue +#include "test_macros.h" +#include "../../deleter.h" struct A { - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} + A() {} + virtual ~A() {} }; -int A::count = 0; - -struct B - : public A +struct B : public A { - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} }; -int B::count = 0; - +// Can't assign from lvalue int main() { - { const std::unique_ptr s(new B); - A* p = s.get(); std::unique_ptr s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); +#if TEST_STD_VER >= 11 + s2 = s; // expected-error {{no viable overloaded '='}} +#else + // NOTE: The error says "constructor" because the assignment operator takes + // 's' by value and attempts to copy construct it. + s2 = s; // expected-error {{no matching constructor for initialization}} +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp index 56ab43c7de24..412648420d46 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp @@ -32,5 +32,5 @@ int main() { std::unique_ptr s; std::unique_ptr s2; - s2 = std::move(s); + s2 = std::move(s); // expected-error {{no viable overloaded '='}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp index 1ce1838afbb7..7c3ac462c287 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp @@ -7,17 +7,21 @@ // //===----------------------------------------------------------------------===// +// libc++ cannot safely provide the auto_ptr constructor without rvalue +// references. +// XFAIL: c++98, c++03 + // // unique_ptr -// Test unique_ptr(pointer) ctor +// template unique_ptr(auto_ptr&&) noexcept #include #include #include -// template explicit unique_ptr(auto_ptr&); +#include "test_macros.h" struct A { @@ -65,4 +69,12 @@ int main() } assert(A::count == 0); assert(B::count == 0); +#if TEST_STD_VER >= 11 + { + static_assert(std::is_nothrow_constructible< + std::unique_ptr, + std::auto_ptr&& + >::value, ""); + } +#endif } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp new file mode 100644 index 000000000000..2694538145b9 --- /dev/null +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default.pass.cpp @@ -0,0 +1,86 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr() +// +// Concerns: +// 1 The default constructor works for any default constructible deleter types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Default construct unique_ptr's with various deleter types (C-1) +// 2 Default construct a unique_ptr with a incomplete element_type and +// various deleter types (C-1,2) + +#include +#include + +#include "../../deleter.h" + +struct IncompleteT; + +void checkNumIncompleteTypeAlive(int i); + +template > +struct StoresIncomplete { + std::unique_ptr m_ptr; + StoresIncomplete() {} + ~StoresIncomplete(); + + IncompleteT* get() const { return m_ptr.get(); } + Del& get_deleter() { return m_ptr.get_deleter(); } +}; + +int main() +{ + { + std::unique_ptr p; + assert(p.get() == 0); + } + { + std::unique_ptr > p; + assert(p.get() == 0); + assert(p.get_deleter().state() == 0); + p.get_deleter().set_state(5); + assert(p.get_deleter().state() == 5); + } + { + StoresIncomplete<> s; + assert(s.get() == 0); + checkNumIncompleteTypeAlive(0); + } + checkNumIncompleteTypeAlive(0); + { + StoresIncomplete< Deleter > s; + assert(s.get() == 0); + assert(s.get_deleter().state() == 0); + checkNumIncompleteTypeAlive(0); + } + checkNumIncompleteTypeAlive(0); +} + +struct IncompleteT { + static int count; + IncompleteT() { ++count; } + ~IncompleteT() {--count; } +}; + +int IncompleteT::count = 0; + +void checkNumIncompleteTypeAlive(int i) { + assert(IncompleteT::count == i); +} + +template +StoresIncomplete::~StoresIncomplete() { } \ No newline at end of file diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp deleted file mode 100644 index e63db5cb7185..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp +++ /dev/null @@ -1,46 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr default ctor - -#include -#include - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr p; - assert(p.get() == 0); - } - { - std::unique_ptr p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp deleted file mode 100644 index e9af7e285255..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp +++ /dev/null @@ -1,84 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test default unique_ptr ctor - -#include -#include - -// default unique_ptr ctor shouldn't require complete type - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template > -struct B -{ - std::unique_ptr a_; - B() {} - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -int main() -{ - { - B<> s; - assert(s.get() == 0); - } - check(0); - { - B s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template -B::~B() {} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp new file mode 100644 index 000000000000..4c5cc843a138 --- /dev/null +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move.pass.cpp @@ -0,0 +1,140 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr move ctor + +#include +#include +#include + +#include "../../deleter.h" + +//============================================================================= +// TESTING unique_ptr(unique_ptr&&) +// +// Concerns +// 1 The moved from pointer is empty and the new pointer stores the old value. +// 2 The only requirement on the deleter is that it is MoveConstructible +// or a reference. +// 3 The constructor works for explicitly moved values (ie std::move(x)) +// 4 The constructor works for true temporaries (ie a return value) +// +// Plan +// 1 Explicitly construct unique_ptr for various deleter types 'D'. +// check that the value and deleter have been properly moved. (C-1,2,3) +// +// 2 Use the expression 'sink(source())' to move construct a unique_ptr +// from a temporary. 'source' should return the unique_ptr by value and +// 'sink' should accept the unique_ptr by value. (C-1,2,4) + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + virtual ~A() {--count;} +}; + +int A::count = 0; + +template +void sinkFunction(Expect) +{ +} + +typedef std::unique_ptr APtrSource1; +typedef std::unique_ptr > APtrSource2; +typedef std::unique_ptr& > APtrSource3; + +APtrSource1 source1() { + return APtrSource1 (new A); +} + +void sink1(APtrSource1 p) { + assert(p.get() != nullptr); +} + +APtrSource2 source2() { + return APtrSource2(new A, Deleter(5)); +} + +void sink2(APtrSource2 p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); +} + +APtrSource3 source3() { + static NCDeleter d(5); + return APtrSource3(new A, d); +} + +void sink3(APtrSource3 p) { + assert(p.get() != nullptr); + assert(p.get_deleter().state() == 5); + assert(&p.get_deleter() == &source3().get_deleter()); +} + +int main() +{ + { + typedef std::unique_ptr APtr; + APtr s(new A); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == 1); + } + assert(A::count == 0); + { + typedef Deleter MoveDel; + typedef std::unique_ptr APtr; + MoveDel d(5); + APtr s(new A, std::move(d)); + assert(d.state() == 0); + assert(s.get_deleter().state() == 5); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == 1); + assert(s2.get_deleter().state() == 5); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + { + typedef NCDeleter NonCopyDel; + typedef std::unique_ptr APtr; + + NonCopyDel d; + APtr s(new A, d); + A* p = s.get(); + APtr s2 = std::move(s); + assert(s2.get() == p); + assert(s.get() == 0); + assert(A::count == 1); + d.set_state(6); + assert(s2.get_deleter().state() == d.state()); + assert(s.get_deleter().state() == d.state()); + } + assert(A::count == 0); + { + sink1(source1()); + assert(A::count == 0); + sink2(source2()); + assert(A::count == 0); + sink3(source3()); + assert(A::count == 0); + } + assert(A::count == 0); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp deleted file mode 100644 index dc16c3115376..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp +++ /dev/null @@ -1,142 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include -#include - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -template -class Deleter -{ - int state_; - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&); - Deleter& operator=(Deleter&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv() {return std::__rv(*this);} - Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} - Deleter& operator=(std::__rv r) - { - state_ = r->state_; - r->state_ = 0; - return *this; - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - - Deleter() : state_(5) {} - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter&& d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template - Deleter(const Deleter& d, - typename std::enable_if::value>::type* = 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr s(new A); - A* p = s.get(); - std::unique_ptr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); - { - std::unique_ptr > s(new A); - A* p = s.get(); - std::unique_ptr > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter d; - std::unique_ptr s(new A, d); - A* p = s.get(); - std::unique_ptr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp deleted file mode 100644 index 4b997df95a0b..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp +++ /dev/null @@ -1,143 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr move ctor - -#include -#include - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -template -class Deleter -{ - int state_; - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&); - Deleter& operator=(Deleter&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv() {return std::__rv(*this);} - Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} - Deleter& operator=(std::__rv r) - { - state_ = r->state_; - r->state_ = 0; - return *this; - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - - Deleter() : state_(5) {} - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter&& d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template - Deleter(const Deleter& d, - typename std::enable_if::value>::type* = 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -std::unique_ptr -source1() -{ - return std::unique_ptr(new A); -} - -void sink1(std::unique_ptr p) -{ -} - -std::unique_ptr > -source2() -{ - return std::unique_ptr >(new A); -} - -void sink2(std::unique_ptr > p) -{ -} - -std::unique_ptr -source3() -{ - static CDeleter d; - return std::unique_ptr(new A, d); -} - -void sink3(std::unique_ptr p) -{ -} - -int main() -{ - sink1(source1()); - sink2(source2()); - sink3(source3()); - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp new file mode 100644 index 000000000000..f00fcfe15b80 --- /dev/null +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert.pass.cpp @@ -0,0 +1,171 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// + +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +// Test unique_ptr converting move ctor + +// NOTE: unique_ptr does not provide converting constructors in c++03 +// XFAIL: c++98, c++03 + + + +#include +#include +#include +#include + +#include "../../deleter.h" + +// test converting move ctor. Should only require a MoveConstructible deleter, or if +// deleter is a reference, not even that. +// Explicit version + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + virtual ~A() {--count;} +}; + +int A::count = 0; + +struct B + : public A +{ + static int count; + B() {++count;} + B(const B&) {++count;} + virtual ~B() {--count;} +}; + +int B::count = 0; + + +template +void checkReferenceDeleter(LHS& lhs, RHS& rhs) { + typedef typename LHS::deleter_type NewDel; + static_assert(std::is_reference::value, ""); + rhs.get_deleter().set_state(42); + assert(rhs.get_deleter().state() == 42); + assert(lhs.get_deleter().state() == 42); + lhs.get_deleter().set_state(99); + assert(lhs.get_deleter().state() == 99); + assert(rhs.get_deleter().state() == 99); +} + +template +void checkDeleter(LHS& lhs, RHS& rhs, int LHSVal, int RHSVal) { + assert(lhs.get_deleter().state() == LHSVal); + assert(rhs.get_deleter().state() == RHSVal); +} + +template +void checkCtor(LHS& lhs, RHS& rhs, A* RHSVal) { + assert(lhs.get() == RHSVal); + assert(rhs.get() == nullptr); + assert(A::count == 1); + assert(B::count == 1); +} + +void checkNoneAlive() { + assert(A::count == 0); + assert(B::count == 0); +} + +int main() +{ + { + typedef std::unique_ptr APtr; + typedef std::unique_ptr BPtr; + { // explicit + BPtr b(new B); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + } + checkNoneAlive(); + { // implicit + BPtr b(new B); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + } + checkNoneAlive(); + } + { // test with moveable deleters + typedef std::unique_ptr > APtr; + typedef std::unique_ptr > BPtr; + { + Deleter del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + { + Deleter del(5); + BPtr b(new B, std::move(del)); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 0); + } + checkNoneAlive(); + + } + { // test with reference deleters + typedef std::unique_ptr& > APtr; + typedef std::unique_ptr& > BPtr; + NCDeleter del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkReferenceDeleter(a, b); + } + checkNoneAlive(); + } + { + typedef std::unique_ptr > APtr; + typedef std::unique_ptr& > BPtr; + CDeleter del(5); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a(std::move(b)); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + { + BPtr b(new B, del); + A* p = b.get(); + APtr a = std::move(b); + checkCtor(a, b, p); + checkDeleter(a, b, 5, 5); + } + checkNoneAlive(); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp deleted file mode 100644 index b65cf564a925..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr s(new B); - A* p = s.get(); - std::unique_ptr s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp deleted file mode 100644 index 829e7553acd9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr > s(new B, Deleter(5)); - A* p = s.get(); - std::unique_ptr > s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp deleted file mode 100644 index 792076a95245..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp deleted file mode 100644 index 12ab17fadcd3..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr s(new B); - A* p = s.get(); - std::unique_ptr s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp deleted file mode 100644 index 8077b0dacb23..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp +++ /dev/null @@ -1,62 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr > s(new B, Deleter(5)); - A* p = s.get(); - std::unique_ptr > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp deleted file mode 100644 index 4115107b85f9..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp +++ /dev/null @@ -1,79 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter d; - std::unique_ptr&> s(new B, d); - A* p = s.get(); - std::unique_ptr&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp deleted file mode 100644 index 978cb0e9024b..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include -#include -#include - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - CDeleter b(5); - std::unique_ptr&> s(new B, b); - A* p = s.get(); - std::unique_ptr > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp new file mode 100644 index 000000000000..faa554d8b320 --- /dev/null +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer.pass.cpp @@ -0,0 +1,163 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +//============================================================================= +// TESTING std::unique_ptr::unique_ptr() +// +// Concerns: +// 1 The pointer constructor works for any default constructible deleter types. +// 2 The pointer constructor accepts pointers to derived types. +// 2 The stored type 'T' is allowed to be incomplete. +// +// Plan +// 1 Construct unique_ptr's with a pointer to 'T' and various deleter +// types (C-1) +// 2 Construct unique_ptr's with a pointer to 'D' and various deleter +// types where 'D' is derived from 'T'. (C-1,2) +// 3 Construct a unique_ptr with a pointer to 'T' and various deleter +// types where 'T' is an incomplete type (C-1,3) + +// Test unique_ptr(pointer) ctor + +#include +#include + +#include "../../deleter.h" + +// unique_ptr(pointer) ctor should only require default Deleter ctor + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + virtual ~A() {--count;} +}; + +int A::count = 0; + + +struct B + : public A +{ + static int count; + B() {++count;} + B(const B&) {++count;} + virtual ~B() {--count;} +}; + +int B::count = 0; + + +struct IncompleteT; + +IncompleteT* getIncomplete(); +void checkNumIncompleteTypeAlive(int i); + +template > +struct StoresIncomplete { + std::unique_ptr m_ptr; + StoresIncomplete() {} + explicit StoresIncomplete(IncompleteT* ptr) : m_ptr(ptr) {} + ~StoresIncomplete(); + + IncompleteT* get() const { return m_ptr.get(); } + Del& get_deleter() { return m_ptr.get_deleter(); } +}; + +void test_pointer() +{ + { + A* p = new A; + assert(A::count == 1); + std::unique_ptr s(p); + assert(s.get() == p); + } + assert(A::count == 0); + { + A* p = new A; + assert(A::count == 1); + std::unique_ptr > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); +} + +void test_derived() +{ + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr s(p); + assert(s.get() == p); + } + assert(A::count == 0); + assert(B::count == 0); + { + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + assert(A::count == 0); + assert(B::count == 0); +} + +void test_incomplete() +{ + { + IncompleteT* p = getIncomplete(); + checkNumIncompleteTypeAlive(1); + StoresIncomplete<> s(p); + assert(s.get() == p); + } + checkNumIncompleteTypeAlive(0); + { + IncompleteT* p = getIncomplete(); + checkNumIncompleteTypeAlive(1); + StoresIncomplete< NCDeleter > s(p); + assert(s.get() == p); + assert(s.get_deleter().state() == 0); + } + checkNumIncompleteTypeAlive(0); +} + +struct IncompleteT { + static int count; + IncompleteT() { ++count; } + ~IncompleteT() {--count; } +}; + +int IncompleteT::count = 0; + +IncompleteT* getIncomplete() { + return new IncompleteT; +} + +void checkNumIncompleteTypeAlive(int i) { + assert(IncompleteT::count == i); +} + +template +StoresIncomplete::~StoresIncomplete() { } + +int main() +{ + test_pointer(); + test_derived(); + test_incomplete(); +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp deleted file mode 100644 index e5fff774b790..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp +++ /dev/null @@ -1,63 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer) ctor should only require default Deleter ctor - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp deleted file mode 100644 index a226e87d64a4..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp +++ /dev/null @@ -1,95 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer) ctor shouldn't require complete type - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template > -struct B -{ - std::unique_ptr a_; - explicit B(A*); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -A* get(); - -int main() -{ - { - A* p = get(); - check(1); - B<> s(p); - assert(s.get() == p); - } - check(0); - { - A* p = get(); - check(1); - B s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -A* get() {return new A;} - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template -B::B(A* a) : a_(a) {} - -template -B::~B() {} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp deleted file mode 100644 index 42fc09453914..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp +++ /dev/null @@ -1,78 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer) ctor should work with derived pointers - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr s(p); - assert(s.get() == p); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp new file mode 100644 index 000000000000..7ddd16265107 --- /dev/null +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter.pass.cpp @@ -0,0 +1,123 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// unique_ptr + +//============================================================================= +// TESTING unique_ptr(pointer, deleter) +// +// Concerns: +// 1 unique_ptr(pointer, deleter&&) only requires a MoveConstructible deleter. +// 2 unique_ptr(pointer, deleter&) requires a CopyConstructible deleter. +// 3 unique_ptr(pointer, deleter) does not require a CopyConstructible deleter. +// 4 unique_ptr(pointer, deleter) does not require a CopyConstructible deleter. +// 5 unique_ptr(pointer, deleter) should work for derived pointers. +// 6 unique_ptr(pointer, deleter) should work with function pointers. +// 7 unique_ptr should work. + + +#include +#include + +#include "../../deleter.h" + +struct A +{ + static int count; + A() {++count;} + A(const A&) {++count;} + virtual ~A() {--count;} +}; + +int A::count = 0; + + +struct B + : public A +{ + static int count; + B() {++count;} + B(const B&) {++count;} + virtual ~B() {--count;} +}; + +int B::count = 0; + +bool my_free_called = false; + +void my_free(void*) { + my_free_called = true; +} + +int main() +{ + { // MoveConstructible deleter (C-1) + A* p = new A; + assert(A::count == 1); + std::unique_ptr > s(p, Deleter(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // CopyConstructible deleter (C-2) + A* p = new A; + assert(A::count == 1); + CopyDeleter d(5); + std::unique_ptr > s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + { // Reference deleter (C-3) + A* p = new A; + assert(A::count == 1); + NCDeleter d(5); + std::unique_ptr&> s(p, d); + assert(s.get() == p); + assert(&s.get_deleter() == &d); + assert(s.get_deleter().state() == 5); + d.set_state(6); + assert(s.get_deleter().state() == 6); + } + assert(A::count == 0); + { // Const Reference deleter (C-4) + A* p = new A; + assert(A::count == 1); + NCConstDeleter d(5); + std::unique_ptr const&> s(p, d); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + assert(&s.get_deleter() == &d); + } + assert(A::count == 0); + { // Derived pointers (C-5) + B* p = new B; + assert(A::count == 1); + assert(B::count == 1); + std::unique_ptr > s(p, Deleter(5)); + assert(s.get() == p); + assert(s.get_deleter().state() == 5); + } + assert(A::count == 0); + assert(B::count == 0); + { // Void and function pointers (C-6,7) + { + int i = 0; + std::unique_ptr s(&i, my_free); + assert(s.get() == &i); + assert(s.get_deleter() == my_free); + assert(!my_free_called); + } + assert(my_free_called); + } +} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp deleted file mode 100644 index 130f91d6216f..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp +++ /dev/null @@ -1,99 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -template -class Deleter -{ - int state_; - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&); - Deleter& operator=(Deleter&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -public: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;} - Deleter& operator=(Deleter&& r) - { - state_ = r.state_; - r.state_ = 0; - return *this; - } -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv() {return std::__rv(*this);} - Deleter(std::__rv r) : state_(r->state_) {r->state_ = 0;} - Deleter& operator=(std::__rv r) - { - state_ = r->state_; - r->state_ = 0; - return *this; - } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - - Deleter() : state_(5) {} - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter&& d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {d.set_state(0);} - -private: - template - Deleter(const Deleter& d, - typename std::enable_if::value>::type* = 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - Deleter(Deleter d, - typename std::enable_if::value>::type* = 0) - : state_(d.state()) {} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -public: - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr > s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp deleted file mode 100644 index 421bec55f99c..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer, d) requires CopyConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - Deleter d; - std::unique_ptr s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp deleted file mode 100644 index bce79dbb1a97..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp +++ /dev/null @@ -1,60 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer, d) does not requires CopyConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - Deleter d; - std::unique_ptr s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp index 7cacd1fda9f3..ad64b5e4ea39 100644 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp +++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp @@ -7,49 +7,24 @@ // //===----------------------------------------------------------------------===// +// Without rvalue references it is impossible to detect when a rvalue deleter +// is given. +// XFAIL: c++98, c++03 + // // unique_ptr -// Test unique_ptr(pointer) ctor - -#include -#include - // unique_ptr(pointer, D()) should not compile -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; +#include -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete p;} +struct Deleter { + void operator()(int* p) const {delete p;} }; int main() { - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); + // expected-error@memory:* {{static_assert failed "rvalue deleter bound to reference"}} + std::unique_ptr s((int*)nullptr, Deleter()); // expected-note {{requested here}} } diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp deleted file mode 100644 index a7750fcb9f0f..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp +++ /dev/null @@ -1,58 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include -#include - -// unique_ptr(pointer, d) does not requires CopyConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - Deleter d; - std::unique_ptr s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp deleted file mode 100644 index 1a83258e1e41..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -#include -#include - -// unique_ptr(pointer, deleter) should work with derived pointers - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp deleted file mode 100644 index ed68052cd3bb..000000000000 --- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp +++ /dev/null @@ -1,39 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -#include -#include - -// unique_ptr(pointer, deleter) should work with function pointers -// unique_ptr should work - -bool my_free_called = false; - -void my_free(void*) -{ - my_free_called = true; -} - -int main() -{ - { - int i = 0; - std::unique_ptr s(&i, my_free); - assert(s.get() == &i); - assert(s.get_deleter() == my_free); - assert(!my_free_called); - } - assert(my_free_called); -} diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp index b2e61faff5ed..f17485108b92 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template explicit shared_ptr(auto_ptr&& r); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp index ab2c73e0c5f1..41aeb04a5feb 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template shared_ptr(nullptr_t, D d, A a); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp index 97d3f69fb5c4..6a79a8ef60db 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // shared_ptr diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp index 4220993a5fd1..c72847791778 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template shared_ptr(Y* p, D d, A a); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp index ead081645671..982313b07499 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // shared_ptr diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp index 041fe9a7853d..2e761d70bba0 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template explicit shared_ptr(Y* p); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp index 5e09d9a7934c..c62fcd689320 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // template explicit shared_ptr(unique_ptr&&r); diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp index a9d8aff145a7..35a7d077b424 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // // shared_ptr diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp index d091ae99fc27..bf1719c66ffa 100644 --- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp +++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp @@ -30,9 +30,28 @@ // bool operator()(shared_ptr const&, weak_ptr const&) const; // bool operator()(weak_ptr const&, shared_ptr const&) const; // }; +// +// Added in C++17 +// template<> struct owner_less +// { +// template +// bool operator()(shared_ptr const&, shared_ptr const&) const; +// template +// bool operator()(shared_ptr const&, weak_ptr const&) const; +// template +// bool operator()(weak_ptr const&, shared_ptr const&) const; +// template +// bool operator()(weak_ptr const&, weak_ptr const&) const; +// +// typedef unspecified is_transparent; +// }; #include #include +#include +#include "test_macros.h" + +struct X {}; int main() { @@ -79,4 +98,25 @@ int main() assert(cs(w1, p3) || cs(w3, p1)); assert(cs(w3, p1) == cs(w3, p2)); } +#if TEST_STD_VER > 14 + { + std::shared_ptr sp1; + std::shared_ptr sp2; + std::shared_ptr sp3; + std::weak_ptr wp1; + + std::owner_less<> cmp; + cmp(sp1, sp2); + cmp(sp1, wp1); + cmp(sp1, sp3); + cmp(wp1, sp1); + cmp(wp1, wp1); + } + { + // test heterogeneous lookups + std::set, std::owner_less<>> s; + std::shared_ptr vp; + s.find(vp); + } +#endif } diff --git a/test/std/utilities/meta/meta.logical/conjunction.pass.cpp b/test/std/utilities/meta/meta.logical/conjunction.pass.cpp new file mode 100644 index 000000000000..dce58ec23725 --- /dev/null +++ b/test/std/utilities/meta/meta.logical/conjunction.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// type_traits + +// template struct conjunction; // C++17 +// template +// constexpr bool conjunction_v = conjunction::value; // C++17 + +#include +#include + +struct True { static constexpr bool value = true; }; +struct False { static constexpr bool value = false; }; + +int main() +{ + static_assert ( std::conjunction<>::value, "" ); + static_assert ( std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + + static_assert ( std::conjunction_v<>, "" ); + static_assert ( std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + + static_assert ( std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + + static_assert ( std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + + static_assert ( std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + + static_assert ( std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); + + static_assert ( std::conjunction::value, "" ); + static_assert (!std::conjunction::value, "" ); + + static_assert ( std::conjunction_v, "" ); + static_assert (!std::conjunction_v, "" ); +} diff --git a/test/std/utilities/meta/meta.logical/disjunction.pass.cpp b/test/std/utilities/meta/meta.logical/disjunction.pass.cpp new file mode 100644 index 000000000000..13cd9341b99f --- /dev/null +++ b/test/std/utilities/meta/meta.logical/disjunction.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// type_traits + +// template struct disjunction; // C++17 +// template +// constexpr bool disjunction_v = disjunction::value; // C++17 + +#include +#include + +struct True { static constexpr bool value = true; }; +struct False { static constexpr bool value = false; }; + +int main() +{ + static_assert (!std::disjunction<>::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert (!std::disjunction::value, "" ); + + static_assert (!std::disjunction_v<>, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert (!std::disjunction_v, "" ); + + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert (!std::disjunction::value, "" ); + + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert (!std::disjunction_v, "" ); + + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert ( std::disjunction::value, "" ); + static_assert (!std::disjunction::value, "" ); + + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert ( std::disjunction_v, "" ); + static_assert (!std::disjunction_v, "" ); + + static_assert ( std::disjunction::value, "" ); + static_assert (!std::disjunction::value, "" ); + + static_assert ( std::disjunction_v, "" ); + static_assert (!std::disjunction_v, "" ); +} diff --git a/test/std/utilities/meta/meta.logical/negation.pass.cpp b/test/std/utilities/meta/meta.logical/negation.pass.cpp new file mode 100644 index 000000000000..76ff6c5b24db --- /dev/null +++ b/test/std/utilities/meta/meta.logical/negation.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// type_traits + +// template struct negation; // C++17 +// template +// constexpr bool negation_v = negation::value; // C++17 + +#include +#include + +struct True { static constexpr bool value = true; }; +struct False { static constexpr bool value = false; }; + +int main() +{ + static_assert (!std::negation::value, "" ); + static_assert ( std::negation::value, "" ); + + static_assert (!std::negation_v, "" ); + static_assert ( std::negation_v, "" ); + + static_assert (!std::negation::value, "" ); + static_assert ( std::negation::value, "" ); + + static_assert (!std::negation_v, "" ); + static_assert ( std::negation_v, "" ); + + static_assert ( std::negation>::value, "" ); + static_assert (!std::negation>::value, "" ); +} diff --git a/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp b/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp index 0f90ae5c1cab..4b17a9f96505 100644 --- a/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp +++ b/test/std/utilities/meta/meta.rel/is_base_of.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_is_base_of() { @@ -20,6 +22,12 @@ void test_is_base_of() static_assert((std::is_base_of::value), ""); static_assert((std::is_base_of::value), ""); static_assert((std::is_base_of::value), ""); +#if TEST_STD_VER > 14 + static_assert((std::is_base_of_v), ""); + static_assert((std::is_base_of_v), ""); + static_assert((std::is_base_of_v), ""); + static_assert((std::is_base_of_v), ""); +#endif } template diff --git a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp index 429fb33037ff..1681c39972d2 100644 --- a/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp +++ b/test/std/utilities/meta/meta.rel/is_convertible.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_is_convertible() { @@ -20,6 +22,12 @@ void test_is_convertible() static_assert((std::is_convertible::value), ""); static_assert((std::is_convertible::value), ""); static_assert((std::is_convertible::value), ""); +#if TEST_STD_VER > 14 + static_assert((std::is_convertible_v), ""); + static_assert((std::is_convertible_v), ""); + static_assert((std::is_convertible_v), ""); + static_assert((std::is_convertible_v), ""); +#endif } template @@ -29,6 +37,12 @@ void test_is_not_convertible() static_assert((!std::is_convertible::value), ""); static_assert((!std::is_convertible::value), ""); static_assert((!std::is_convertible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_convertible_v), ""); + static_assert((!std::is_convertible_v), ""); + static_assert((!std::is_convertible_v), ""); + static_assert((!std::is_convertible_v), ""); +#endif } typedef void Function(); diff --git a/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp b/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp index bd35ef63d08b..5a607f3b12ad 100644 --- a/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp +++ b/test/std/utilities/meta/meta.rel/is_convertible_fallback.pass.cpp @@ -13,6 +13,14 @@ // Test the fallback implementation. +// libc++ provides a fallback implementation of the compiler trait +// `__is_convertible` with the same name when clang doesn't. +// Because this test forces the use of the fallback even when clang provides +// it causing a keyword incompatibility. +#if defined(__clang__) +#pragma clang diagnostic ignored "-Wkeyword-compat" +#endif + #define _LIBCPP_USE_IS_CONVERTIBLE_FALLBACK #include "is_convertible.pass.cpp" diff --git a/test/std/utilities/meta/meta.rel/is_same.pass.cpp b/test/std/utilities/meta/meta.rel/is_same.pass.cpp index 7250d6ca7730..9db367391f69 100644 --- a/test/std/utilities/meta/meta.rel/is_same.pass.cpp +++ b/test/std/utilities/meta/meta.rel/is_same.pass.cpp @@ -13,13 +13,21 @@ #include +#include "test_macros.h" + template void test_is_same() { - static_assert((std::is_same::value), ""); + static_assert(( std::is_same::value), ""); static_assert((!std::is_same::value), ""); static_assert((!std::is_same::value), ""); - static_assert((std::is_same::value), ""); + static_assert(( std::is_same::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_same_v), ""); + static_assert((!std::is_same_v), ""); + static_assert((!std::is_same_v), ""); + static_assert(( std::is_same_v), ""); +#endif } template @@ -29,6 +37,12 @@ void test_is_same_ref() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); +#if TEST_STD_VER > 14 + static_assert((std::is_same_v), ""); + static_assert((std::is_same_v), ""); + static_assert((std::is_same_v), ""); + static_assert((std::is_same_v), ""); +#endif } template diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp index c87e99c46e80..a53bed984c5e 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/aligned_storage.pass.cpp @@ -12,12 +12,14 @@ // aligned_storage #include +#include // for std::max_align_t +#include "test_macros.h" int main() { { typedef std::aligned_storage<10, 1 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 1, ""); @@ -25,7 +27,7 @@ int main() } { typedef std::aligned_storage<10, 2 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 2, ""); @@ -33,7 +35,7 @@ int main() } { typedef std::aligned_storage<10, 4 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 4, ""); @@ -41,7 +43,7 @@ int main() } { typedef std::aligned_storage<10, 8 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 8, ""); @@ -49,7 +51,7 @@ int main() } { typedef std::aligned_storage<10, 16 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 16, ""); @@ -57,7 +59,7 @@ int main() } { typedef std::aligned_storage<10, 32 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 32, ""); @@ -65,7 +67,7 @@ int main() } { typedef std::aligned_storage<20, 32 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 32, ""); @@ -73,7 +75,7 @@ int main() } { typedef std::aligned_storage<40, 32 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 32, ""); @@ -81,7 +83,7 @@ int main() } { typedef std::aligned_storage<12, 16 >::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 16, ""); @@ -89,7 +91,7 @@ int main() } { typedef std::aligned_storage<1>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 1, ""); @@ -97,7 +99,7 @@ int main() } { typedef std::aligned_storage<2>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 2, ""); @@ -105,7 +107,7 @@ int main() } { typedef std::aligned_storage<3>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 2, ""); @@ -113,7 +115,7 @@ int main() } { typedef std::aligned_storage<4>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 4, ""); @@ -121,7 +123,7 @@ int main() } { typedef std::aligned_storage<5>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 4, ""); @@ -129,7 +131,7 @@ int main() } { typedef std::aligned_storage<7>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 4, ""); @@ -137,7 +139,7 @@ int main() } { typedef std::aligned_storage<8>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 8, ""); @@ -145,7 +147,7 @@ int main() } { typedef std::aligned_storage<9>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 8, ""); @@ -153,7 +155,7 @@ int main() } { typedef std::aligned_storage<15>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 8, ""); @@ -167,7 +169,7 @@ int main() #endif { typedef std::aligned_storage<16>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == alignof(std::max_align_t), @@ -176,7 +178,7 @@ int main() } { typedef std::aligned_storage<17>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == alignof(std::max_align_t), @@ -185,7 +187,7 @@ int main() } { typedef std::aligned_storage<10>::type T1; -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert(std::is_same, T1>::value, "" ); #endif static_assert(std::alignment_of::value == 8, ""); diff --git a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp index 91bf7e7654e0..e8611253c5d4 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.other/common_type.pass.cpp @@ -13,11 +13,39 @@ #include +#include "test_macros.h" + +struct E {}; + +template +struct X { explicit X(T const&){} }; + +template +struct S { explicit S(T const&){} }; + +namespace std +{ + template + struct common_type > + { + typedef S type; + }; +} + +#if TEST_STD_VER >= 11 +template +struct no_common_type : std::true_type {}; + +template +struct no_common_type::type, void>::type> : std::false_type {}; +#endif // TEST_STD_VER >= 11 + int main() { static_assert((std::is_same::type, int>::value), ""); static_assert((std::is_same::type, char>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same, int>::value), ""); static_assert((std::is_same, char>::value), ""); #endif @@ -29,7 +57,7 @@ int main() static_assert((std::is_same::type, int>::value), ""); static_assert((std::is_same::type, int>::value), ""); - + static_assert((std::is_same::type, long>::value), ""); static_assert((std::is_same::type, long>::value), ""); static_assert((std::is_same::type, long>::value), ""); @@ -38,15 +66,37 @@ int main() static_assert((std::is_same::type, double>::value), ""); static_assert((std::is_same::type, int>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same, double>::value), ""); static_assert((std::is_same, int>::value), ""); #endif static_assert((std::is_same::type, double>::value), ""); static_assert((std::is_same::type, long long>::value), ""); -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 static_assert((std::is_same, double>::value), ""); static_assert((std::is_same, long long>::value), ""); #endif + + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + static_assert((std::is_same::type, void>::value), ""); + +#if TEST_STD_VER >= 11 + static_assert((no_common_type::value), ""); + static_assert((no_common_type::value), ""); + static_assert((no_common_type::value), ""); + static_assert((no_common_type >::value), ""); +#endif // TEST_STD_VER >= 11 + + static_assert((std::is_same >::type, S >::value), ""); + static_assert((std::is_same, S >::type, S >::value), ""); + static_assert((std::is_same >::type, S >::value), ""); } diff --git a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp index 8150ce04e37f..fb53312cbe67 100644 --- a/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp +++ b/test/std/utilities/meta/meta.trans/meta.trans.ref/add_lvalue_ref.pass.cpp @@ -22,6 +22,26 @@ void test_add_lvalue_reference() #endif } +template +void test_function0() +{ + static_assert((std::is_same::type, F&>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, F&>::value), ""); +#endif +} + +template +void test_function1() +{ + static_assert((std::is_same::type, F>::value), ""); +#if _LIBCPP_STD_VER > 11 + static_assert((std::is_same, F>::value), ""); +#endif +} + +struct Foo {}; + int main() { test_add_lvalue_reference(); @@ -31,4 +51,20 @@ int main() test_add_lvalue_reference(); test_add_lvalue_reference(); test_add_lvalue_reference(); + +// LWG 2101 specifically talks about add_lvalue_reference and functions. +// The term of art is "a referenceable type", which a cv- or ref-qualified function is not. + test_function0(); +// test_function1(); +// test_function1(); +// test_function1(); +// test_function1(); +// test_function1(); + + test_function0(); + test_function0(); + test_function0(); + test_function0(); + test_function0(); + test_function0(); } diff --git a/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp index 6ea1cac789ef..0f55db64719b 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/alignment_of.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "test_macros.h" + template void test_alignment_of() { @@ -21,6 +23,12 @@ void test_alignment_of() static_assert( std::alignment_of::value == A, ""); static_assert( std::alignment_of::value == A, ""); static_assert( std::alignment_of::value == A, ""); +#if TEST_STD_VER > 14 + static_assert( std::alignment_of_v == A, ""); + static_assert( std::alignment_of_v == A, ""); + static_assert( std::alignment_of_v == A, ""); + static_assert( std::alignment_of_v == A, ""); +#endif } class Class diff --git a/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp index a99dc6948529..39a7c2b593bb 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/extent.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_extent() { @@ -20,6 +22,12 @@ void test_extent() static_assert((std::extent::value == A), ""); static_assert((std::extent::value == A), ""); static_assert((std::extent::value == A), ""); +#if TEST_STD_VER > 14 + static_assert((std::extent_v == A), ""); + static_assert((std::extent_v == A), ""); + static_assert((std::extent_v == A), ""); + static_assert((std::extent_v == A), ""); +#endif } template @@ -29,6 +37,12 @@ void test_extent1() static_assert((std::extent::value == A), ""); static_assert((std::extent::value == A), ""); static_assert((std::extent::value == A), ""); +#if TEST_STD_VER > 14 + static_assert((std::extent_v == A), ""); + static_assert((std::extent_v == A), ""); + static_assert((std::extent_v == A), ""); + static_assert((std::extent_v == A), ""); +#endif } class Class diff --git a/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp index 06f66a92c7c3..755269d1d403 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/rank.pass.cpp @@ -13,6 +13,8 @@ #include +#include "test_macros.h" + template void test_rank() { @@ -20,6 +22,12 @@ void test_rank() static_assert( std::rank::value == A, ""); static_assert( std::rank::value == A, ""); static_assert( std::rank::value == A, ""); +#if TEST_STD_VER > 14 + static_assert( std::rank_v == A, ""); + static_assert( std::rank_v == A, ""); + static_assert( std::rank_v == A, ""); + static_assert( std::rank_v == A, ""); +#endif } class Class diff --git a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp index 5deeeff110d4..ccec65fec399 100644 --- a/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp +++ b/test/std/utilities/meta/meta.unary.prop.query/void_t.pass.cpp @@ -11,11 +11,11 @@ // void_t -#include +// UNSUPPORTED: c++98, c++03, c++11, c++14 -#if _LIBCPP_STD_VER <= 14 -int main () {} -#else +// XFAIL: gcc-5.1 gcc-5.2 + +#include template void test1() @@ -66,4 +66,3 @@ int main() static_assert( std::is_same>::value, ""); } -#endif diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp new file mode 100644 index 000000000000..72955defa399 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_array.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_array + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_array() +{ + static_assert( std::is_array::value, ""); + static_assert( std::is_array::value, ""); + static_assert( std::is_array::value, ""); + static_assert( std::is_array::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_array_v, ""); + static_assert( std::is_array_v, ""); + static_assert( std::is_array_v, ""); + static_assert( std::is_array_v, ""); +#endif +} + +template +void test_is_not_array() +{ + static_assert(!std::is_array::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_array::value, ""); + static_assert(!std::is_array::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_array_v, ""); + static_assert(!std::is_array_v, ""); + static_assert(!std::is_array_v, ""); + static_assert(!std::is_array_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_array(); + test_is_array(); + test_is_array(); + + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); + test_is_not_array(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp new file mode 100644 index 000000000000..97671e7b62e0 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_class.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_class + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_class() +{ + static_assert( std::is_class::value, ""); + static_assert( std::is_class::value, ""); + static_assert( std::is_class::value, ""); + static_assert( std::is_class::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_class_v, ""); + static_assert( std::is_class_v, ""); + static_assert( std::is_class_v, ""); + static_assert( std::is_class_v, ""); +#endif +} + +template +void test_is_not_class() +{ + static_assert(!std::is_class::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_class::value, ""); + static_assert(!std::is_class::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_class_v, ""); + static_assert(!std::is_class_v, ""); + static_assert(!std::is_class_v, ""); + static_assert(!std::is_class_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_class(); + test_is_class(); + test_is_class(); + test_is_class(); + +#if TEST_STD_VER >= 11 +// In C++03 we have an emulation of std::nullptr_t + test_is_not_class(); +#endif + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); +#if TEST_STD_VER >= 11 + test_is_not_class(); +#endif + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); + test_is_not_class(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp new file mode 100644 index 000000000000..481260ea6e52 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_enum.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_enum + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_enum() +{ + static_assert( std::is_enum::value, ""); + static_assert( std::is_enum::value, ""); + static_assert( std::is_enum::value, ""); + static_assert( std::is_enum::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_enum_v, ""); + static_assert( std::is_enum_v, ""); + static_assert( std::is_enum_v, ""); + static_assert( std::is_enum_v, ""); +#endif +} + +template +void test_is_not_enum() +{ + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_enum::value, ""); + static_assert(!std::is_enum::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_enum_v, ""); + static_assert(!std::is_enum_v, ""); + static_assert(!std::is_enum_v, ""); + static_assert(!std::is_enum_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_enum(); + + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); + test_is_not_enum(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp new file mode 100644 index 000000000000..de9c146bcb4e --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_floating_point.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_floating_point + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_floating_point() +{ + static_assert( std::is_floating_point::value, ""); + static_assert( std::is_floating_point::value, ""); + static_assert( std::is_floating_point::value, ""); + static_assert( std::is_floating_point::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_floating_point_v, ""); + static_assert( std::is_floating_point_v, ""); + static_assert( std::is_floating_point_v, ""); + static_assert( std::is_floating_point_v, ""); +#endif +} + +template +void test_is_not_floating_point() +{ + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_floating_point::value, ""); + static_assert(!std::is_floating_point::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_floating_point_v, ""); + static_assert(!std::is_floating_point_v, ""); + static_assert(!std::is_floating_point_v, ""); + static_assert(!std::is_floating_point_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_floating_point(); + test_is_floating_point(); + test_is_floating_point(); + + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); + test_is_not_floating_point(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp new file mode 100644 index 000000000000..9a1d821b0746 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_function.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_function + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_function() +{ + static_assert( std::is_function::value, ""); + static_assert( std::is_function::value, ""); + static_assert( std::is_function::value, ""); + static_assert( std::is_function::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_function_v, ""); + static_assert( std::is_function_v, ""); + static_assert( std::is_function_v, ""); + static_assert( std::is_function_v, ""); +#endif +} + +template +void test_is_not_function() +{ + static_assert(!std::is_function::value, ""); + static_assert(!std::is_function::value, ""); + static_assert(!std::is_function::value, ""); + static_assert(!std::is_function::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_function_v, ""); + static_assert(!std::is_function_v, ""); + static_assert(!std::is_function_v, ""); + static_assert(!std::is_function_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_function(); + test_is_function(); + test_is_function(); + test_is_function(); + test_is_function(); + + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); // function pointer is not a function + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); + test_is_not_function(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp new file mode 100644 index 000000000000..86b63c53da54 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_integral.pass.cpp @@ -0,0 +1,104 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_integral + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_integral() +{ + static_assert( std::is_integral::value, ""); + static_assert( std::is_integral::value, ""); + static_assert( std::is_integral::value, ""); + static_assert( std::is_integral::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_integral_v, ""); + static_assert( std::is_integral_v, ""); + static_assert( std::is_integral_v, ""); + static_assert( std::is_integral_v, ""); +#endif +} + +template +void test_is_not_integral() +{ + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_integral::value, ""); + static_assert(!std::is_integral::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_integral_v, ""); + static_assert(!std::is_integral_v, ""); + static_assert(!std::is_integral_v, ""); + static_assert(!std::is_integral_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + test_is_integral(); + + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); + test_is_not_integral(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp new file mode 100644 index 000000000000..0e59f7153f50 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_lvalue_reference.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_lvalue_reference + +// UNSUPPORTED: c++98, c++03 + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_lvalue_reference() +{ + static_assert( std::is_lvalue_reference::value, ""); + static_assert( std::is_lvalue_reference::value, ""); + static_assert( std::is_lvalue_reference::value, ""); + static_assert( std::is_lvalue_reference::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_lvalue_reference_v, ""); + static_assert( std::is_lvalue_reference_v, ""); + static_assert( std::is_lvalue_reference_v, ""); + static_assert( std::is_lvalue_reference_v, ""); +#endif +} + +template +void test_is_not_lvalue_reference() +{ + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); + static_assert(!std::is_lvalue_reference::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_lvalue_reference_v, ""); + static_assert(!std::is_lvalue_reference_v, ""); + static_assert(!std::is_lvalue_reference_v, ""); + static_assert(!std::is_lvalue_reference_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_lvalue_reference(); + + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); + test_is_not_lvalue_reference(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp new file mode 100644 index 000000000000..8da411d2eeed --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_object_pointer.pass.cpp @@ -0,0 +1,97 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_member_object_pointer + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_member_object_pointer() +{ + static_assert( std::is_member_object_pointer::value, ""); + static_assert( std::is_member_object_pointer::value, ""); + static_assert( std::is_member_object_pointer::value, ""); + static_assert( std::is_member_object_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_member_object_pointer_v, ""); + static_assert( std::is_member_object_pointer_v, ""); + static_assert( std::is_member_object_pointer_v, ""); + static_assert( std::is_member_object_pointer_v, ""); +#endif +} + +template +void test_is_not_member_object_pointer() +{ + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); + static_assert(!std::is_member_object_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_member_object_pointer_v, ""); + static_assert(!std::is_member_object_pointer_v, ""); + static_assert(!std::is_member_object_pointer_v, ""); + static_assert(!std::is_member_object_pointer_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_member_object_pointer(); + test_is_member_object_pointer(); + test_is_member_object_pointer(); + + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); + test_is_not_member_object_pointer(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp new file mode 100644 index 000000000000..19a74b01d0fd --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_member_pointer.pass.cpp @@ -0,0 +1,98 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_member_pointer + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_member_pointer() +{ + static_assert( std::is_member_pointer::value, ""); + static_assert( std::is_member_pointer::value, ""); + static_assert( std::is_member_pointer::value, ""); + static_assert( std::is_member_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_member_pointer_v, ""); + static_assert( std::is_member_pointer_v, ""); + static_assert( std::is_member_pointer_v, ""); + static_assert( std::is_member_pointer_v, ""); +#endif +} + +template +void test_is_not_member_pointer() +{ + static_assert(!std::is_member_pointer::value, ""); + static_assert(!std::is_member_pointer::value, ""); + static_assert(!std::is_member_pointer::value, ""); + static_assert(!std::is_member_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_member_pointer_v, ""); + static_assert(!std::is_member_pointer_v, ""); + static_assert(!std::is_member_pointer_v, ""); + static_assert(!std::is_member_pointer_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_member_pointer(); + test_is_member_pointer(); + test_is_member_pointer(); + test_is_member_pointer(); + + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp new file mode 100644 index 000000000000..80f563e8969e --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_null_pointer.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_null_pointer + +// UNSUPPORTED: c++98, c++03, c++11 + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_null_pointer() +{ + static_assert( std::is_null_pointer::value, ""); + static_assert( std::is_null_pointer::value, ""); + static_assert( std::is_null_pointer::value, ""); + static_assert( std::is_null_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_null_pointer_v, ""); + static_assert( std::is_null_pointer_v, ""); + static_assert( std::is_null_pointer_v, ""); + static_assert( std::is_null_pointer_v, ""); +#endif +} + +template +void test_is_not_null_pointer() +{ + static_assert(!std::is_null_pointer::value, ""); + static_assert(!std::is_null_pointer::value, ""); + static_assert(!std::is_null_pointer::value, ""); + static_assert(!std::is_null_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_null_pointer_v, ""); + static_assert(!std::is_null_pointer_v, ""); + static_assert(!std::is_null_pointer_v, ""); + static_assert(!std::is_null_pointer_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_null_pointer(); + + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); + test_is_not_null_pointer(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp new file mode 100644 index 000000000000..a901aed1143e --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_pointer.pass.cpp @@ -0,0 +1,94 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_pointer + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_pointer() +{ + static_assert( std::is_pointer::value, ""); + static_assert( std::is_pointer::value, ""); + static_assert( std::is_pointer::value, ""); + static_assert( std::is_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_pointer_v, ""); + static_assert( std::is_pointer_v, ""); + static_assert( std::is_pointer_v, ""); + static_assert( std::is_pointer_v, ""); +#endif +} + +template +void test_is_not_pointer() +{ + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_pointer::value, ""); + static_assert(!std::is_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_pointer_v, ""); + static_assert(!std::is_pointer_v, ""); + static_assert(!std::is_pointer_v, ""); + static_assert(!std::is_pointer_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_pointer(); + test_is_pointer(); + test_is_pointer(); + test_is_pointer(); + test_is_pointer(); + + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); + test_is_not_pointer(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp new file mode 100644 index 000000000000..b7b52687018a --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_rvalue_reference.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_rvalue_reference + +// UNSUPPORTED: c++98, c++03 + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_rvalue_reference() +{ + static_assert( std::is_rvalue_reference::value, ""); + static_assert( std::is_rvalue_reference::value, ""); + static_assert( std::is_rvalue_reference::value, ""); + static_assert( std::is_rvalue_reference::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_rvalue_reference_v, ""); + static_assert( std::is_rvalue_reference_v, ""); + static_assert( std::is_rvalue_reference_v, ""); + static_assert( std::is_rvalue_reference_v, ""); +#endif +} + +template +void test_is_not_rvalue_reference() +{ + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); + static_assert(!std::is_rvalue_reference::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_rvalue_reference_v, ""); + static_assert(!std::is_rvalue_reference_v, ""); + static_assert(!std::is_rvalue_reference_v, ""); + static_assert(!std::is_rvalue_reference_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_rvalue_reference(); + + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); + test_is_not_rvalue_reference(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp new file mode 100644 index 000000000000..307fedb32b26 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_union.pass.cpp @@ -0,0 +1,93 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_union + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_union() +{ + static_assert( std::is_union::value, ""); + static_assert( std::is_union::value, ""); + static_assert( std::is_union::value, ""); + static_assert( std::is_union::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_union_v, ""); + static_assert( std::is_union_v, ""); + static_assert( std::is_union_v, ""); + static_assert( std::is_union_v, ""); +#endif +} + +template +void test_is_not_union() +{ + static_assert(!std::is_union::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_union::value, ""); + static_assert(!std::is_union::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_union_v, ""); + static_assert(!std::is_union_v, ""); + static_assert(!std::is_union_v, ""); + static_assert(!std::is_union_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_union(); + + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); + test_is_not_union(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp new file mode 100644 index 000000000000..1647666adf2e --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/is_void.pass.cpp @@ -0,0 +1,92 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_void + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_void() +{ + static_assert( std::is_void::value, ""); + static_assert( std::is_void::value, ""); + static_assert( std::is_void::value, ""); + static_assert( std::is_void::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_void_v, ""); + static_assert( std::is_void_v, ""); + static_assert( std::is_void_v, ""); + static_assert( std::is_void_v, ""); +#endif +} + +template +void test_is_not_void() +{ + static_assert(!std::is_void::value, ""); + static_assert(!std::is_void::value, ""); + static_assert(!std::is_void::value, ""); + static_assert(!std::is_void::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_void_v, ""); + static_assert(!std::is_void_v, ""); + static_assert(!std::is_void_v, ""); + static_assert(!std::is_void_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + +int main() +{ + test_is_void(); + + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); + test_is_not_void(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp index 691e3536167d..1c7a32fc9dc9 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.cat/nullptr.pass.cpp @@ -13,6 +13,7 @@ // is_null_pointer #include +#include // for std::nullptr_t #if _LIBCPP_STD_VER > 11 template diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp new file mode 100644 index 000000000000..a3f18d52a706 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_arithmetic.pass.cpp @@ -0,0 +1,104 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_arithmetic + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_arithmetic() +{ + static_assert( std::is_arithmetic::value, ""); + static_assert( std::is_arithmetic::value, ""); + static_assert( std::is_arithmetic::value, ""); + static_assert( std::is_arithmetic::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_arithmetic_v, ""); + static_assert( std::is_arithmetic_v, ""); + static_assert( std::is_arithmetic_v, ""); + static_assert( std::is_arithmetic_v, ""); +#endif +} + +template +void test_is_not_arithmetic() +{ + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_arithmetic::value, ""); + static_assert(!std::is_arithmetic::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_arithmetic_v, ""); + static_assert(!std::is_arithmetic_v, ""); + static_assert(!std::is_arithmetic_v, ""); + static_assert(!std::is_arithmetic_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + test_is_arithmetic(); + + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); + test_is_not_arithmetic(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp new file mode 100644 index 000000000000..6a1798ab5adc --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_compound.pass.cpp @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_compound + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_compound() +{ + static_assert( std::is_compound::value, ""); + static_assert( std::is_compound::value, ""); + static_assert( std::is_compound::value, ""); + static_assert( std::is_compound::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_compound_v, ""); + static_assert( std::is_compound_v, ""); + static_assert( std::is_compound_v, ""); + static_assert( std::is_compound_v, ""); +#endif +} + +template +void test_is_not_compound() +{ + static_assert(!std::is_compound::value, ""); + static_assert(!std::is_compound::value, ""); + static_assert(!std::is_compound::value, ""); + static_assert(!std::is_compound::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_compound_v, ""); + static_assert(!std::is_compound_v, ""); + static_assert(!std::is_compound_v, ""); + static_assert(!std::is_compound_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + test_is_compound(); + + test_is_not_compound(); + test_is_not_compound(); + test_is_not_compound(); + test_is_not_compound(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp new file mode 100644 index 000000000000..e16337e05f1c --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_fundamental.pass.cpp @@ -0,0 +1,112 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_fundamental + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_fundamental() +{ + static_assert( std::is_fundamental::value, ""); + static_assert( std::is_fundamental::value, ""); + static_assert( std::is_fundamental::value, ""); + static_assert( std::is_fundamental::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_fundamental_v, ""); + static_assert( std::is_fundamental_v, ""); + static_assert( std::is_fundamental_v, ""); + static_assert( std::is_fundamental_v, ""); +#endif +} + +template +void test_is_not_fundamental() +{ + static_assert(!std::is_fundamental::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert(!std::is_fundamental::value, ""); + static_assert(!std::is_fundamental::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_fundamental_v, ""); + static_assert(!std::is_fundamental_v, ""); + static_assert(!std::is_fundamental_v, ""); + static_assert(!std::is_fundamental_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + test_is_fundamental(); + + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); + test_is_not_fundamental(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp new file mode 100644 index 000000000000..890da659e218 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_member_pointer.pass.cpp @@ -0,0 +1,102 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_member_pointer + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_member_pointer() +{ + static_assert( std::is_member_pointer::value, ""); + static_assert( std::is_member_pointer::value, ""); + static_assert( std::is_member_pointer::value, ""); + static_assert( std::is_member_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_member_pointer_v, ""); + static_assert( std::is_member_pointer_v, ""); + static_assert( std::is_member_pointer_v, ""); + static_assert( std::is_member_pointer_v, ""); +#endif +} + +template +void test_is_not_member_pointer() +{ + static_assert(!std::is_member_pointer::value, ""); + static_assert(!std::is_member_pointer::value, ""); + static_assert(!std::is_member_pointer::value, ""); + static_assert(!std::is_member_pointer::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_member_pointer_v, ""); + static_assert(!std::is_member_pointer_v, ""); + static_assert(!std::is_member_pointer_v, ""); + static_assert(!std::is_member_pointer_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ +// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), +// std::nullptr_t, and cv-qualified versions of these types (3.9.3) +// are collectively called scalar types. + + test_is_member_pointer(); + test_is_member_pointer(); + + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); + test_is_not_member_pointer(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp new file mode 100644 index 000000000000..ff7dda30d111 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_object.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_object + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_object() +{ + static_assert( std::is_object::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_object::value, ""); + static_assert( std::is_object::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_object_v, ""); + static_assert( std::is_object_v, ""); + static_assert( std::is_object_v, ""); + static_assert( std::is_object_v, ""); +#endif +} + +template +void test_is_not_object() +{ + static_assert(!std::is_object::value, ""); + static_assert(!std::is_object::value, ""); + static_assert(!std::is_object::value, ""); + static_assert(!std::is_object::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_object_v, ""); + static_assert(!std::is_object_v, ""); + static_assert(!std::is_object_v, ""); + static_assert(!std::is_object_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ +// An object type is a (possibly cv-qualified) type that is not a function type, +// not a reference type, and not a void type. + + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + test_is_object(); + + test_is_not_object(); + test_is_not_object(); + test_is_not_object(); + test_is_not_object(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp new file mode 100644 index 000000000000..e56c8f761814 --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_reference.pass.cpp @@ -0,0 +1,101 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_reference + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_reference() +{ + static_assert( std::is_reference::value, ""); + static_assert( std::is_reference::value, ""); + static_assert( std::is_reference::value, ""); + static_assert( std::is_reference::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_reference_v, ""); + static_assert( std::is_reference_v, ""); + static_assert( std::is_reference_v, ""); + static_assert( std::is_reference_v, ""); +#endif +} + +template +void test_is_not_reference() +{ + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_reference::value, ""); + static_assert(!std::is_reference::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_reference_v, ""); + static_assert(!std::is_reference_v, ""); + static_assert(!std::is_reference_v, ""); + static_assert(!std::is_reference_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ + test_is_reference(); +#if TEST_STD_VER >= 11 + test_is_reference(); +#endif + + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + test_is_not_reference(); + +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp new file mode 100644 index 000000000000..2b412a68833b --- /dev/null +++ b/test/std/utilities/meta/meta.unary/meta.unary.comp/is_scalar.pass.cpp @@ -0,0 +1,111 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// type_traits + +// is_scalar + +#include +#include // for std::nullptr_t +#include "test_macros.h" + +template +void test_is_scalar() +{ + static_assert( std::is_scalar::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert( std::is_scalar::value, ""); + static_assert( std::is_scalar::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_scalar_v, ""); + static_assert( std::is_scalar_v, ""); + static_assert( std::is_scalar_v, ""); + static_assert( std::is_scalar_v, ""); +#endif +} + +template +void test_is_not_scalar() +{ + static_assert(!std::is_scalar::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert(!std::is_scalar::value, ""); + static_assert(!std::is_scalar::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_scalar_v, ""); + static_assert(!std::is_scalar_v, ""); + static_assert(!std::is_scalar_v, ""); + static_assert(!std::is_scalar_v, ""); +#endif +} + +class Empty +{ +}; + +class NotEmpty +{ + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + + +int main() +{ +// Arithmetic types (3.9.1), enumeration types, pointer types, pointer to member types (3.9.2), +// std::nullptr_t, and cv-qualified versions of these types (3.9.3) +// are collectively called scalar types. + + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + test_is_scalar(); + + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); + test_is_not_scalar(); +} diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp index 685d30de692f..36020139ec58 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/has_virtual_destructor.pass.cpp @@ -20,6 +20,12 @@ void test_has_virtual_destructor() static_assert( std::has_virtual_destructor::value, ""); static_assert( std::has_virtual_destructor::value, ""); static_assert( std::has_virtual_destructor::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::has_virtual_destructor_v, ""); + static_assert( std::has_virtual_destructor_v, ""); + static_assert( std::has_virtual_destructor_v, ""); + static_assert( std::has_virtual_destructor_v, ""); +#endif } template @@ -29,6 +35,12 @@ void test_has_not_virtual_destructor() static_assert(!std::has_virtual_destructor::value, ""); static_assert(!std::has_virtual_destructor::value, ""); static_assert(!std::has_virtual_destructor::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::has_virtual_destructor_v, ""); + static_assert(!std::has_virtual_destructor_v, ""); + static_assert(!std::has_virtual_destructor_v, ""); + static_assert(!std::has_virtual_destructor_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp index f2a8c23246b1..a54adf10258f 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_abstract.pass.cpp @@ -12,6 +12,7 @@ // is_abstract #include +#include "test_macros.h" template void test_is_abstract() @@ -20,6 +21,12 @@ void test_is_abstract() static_assert( std::is_abstract::value, ""); static_assert( std::is_abstract::value, ""); static_assert( std::is_abstract::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_abstract_v, ""); + static_assert( std::is_abstract_v, ""); + static_assert( std::is_abstract_v, ""); + static_assert( std::is_abstract_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_abstract() static_assert(!std::is_abstract::value, ""); static_assert(!std::is_abstract::value, ""); static_assert(!std::is_abstract::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_abstract_v, ""); + static_assert(!std::is_abstract_v, ""); + static_assert(!std::is_abstract_v, ""); + static_assert(!std::is_abstract_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp index d33019bcba9e..c0f6bb9bdfaf 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_assignable.pass.cpp @@ -12,6 +12,7 @@ // is_assignable #include +#include "test_macros.h" struct A { @@ -26,12 +27,18 @@ template void test_is_assignable() { static_assert(( std::is_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert( std::is_assignable_v, ""); +#endif } template void test_is_not_assignable() { static_assert((!std::is_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert( !std::is_assignable_v, ""); +#endif } struct D; diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp index 72f2ff458921..7f63ae40aca7 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_const.pass.cpp @@ -12,6 +12,7 @@ // is_const #include +#include "test_macros.h" template void test_is_const() @@ -20,6 +21,12 @@ void test_is_const() static_assert( std::is_const::value, ""); static_assert(!std::is_const::value, ""); static_assert( std::is_const::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_const_v, ""); + static_assert( std::is_const_v, ""); + static_assert(!std::is_const_v, ""); + static_assert( std::is_const_v, ""); +#endif } int main() diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp index 2b8f7efec602..5401d95532b1 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_constructible.pass.cpp @@ -13,6 +13,7 @@ // struct is_constructible; #include +#include "test_macros.h" struct A { @@ -38,30 +39,45 @@ template void test_is_constructible() { static_assert( (std::is_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert( std::is_constructible_v, ""); +#endif } template void test_is_constructible() { - static_assert( (std::is_constructible::value), ""); + static_assert(( std::is_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_constructible_v), ""); +#endif } template void test_is_constructible() { - static_assert( (std::is_constructible::value), ""); + static_assert(( std::is_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_constructible_v), ""); +#endif } template void test_is_not_constructible() { static_assert((!std::is_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_constructible_v), ""); +#endif } template void test_is_not_constructible() { static_assert((!std::is_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_constructible_v), ""); +#endif } int main() diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp index c43d59479fb2..421f865a623c 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_copy_assignable #include +#include "test_macros.h" template void test_is_copy_assignable() { static_assert(( std::is_copy_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_copy_assignable_v), ""); +#endif } template void test_is_not_copy_assignable() { static_assert((!std::is_copy_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_copy_assignable_v), ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp index f878a50c3af5..fe2e01429b22 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_copy_constructible.pass.cpp @@ -12,17 +12,24 @@ // is_copy_constructible #include +#include "test_macros.h" template void test_is_copy_constructible() { static_assert( std::is_copy_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_copy_constructible_v, ""); +#endif } template void test_is_not_copy_constructible() { static_assert(!std::is_copy_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_copy_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp index c8d5c42fbf89..7b46eeaab66b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_default_constructible.pass.cpp @@ -12,6 +12,7 @@ // is_default_constructible #include +#include "test_macros.h" template void test_is_default_constructible() @@ -20,6 +21,12 @@ void test_is_default_constructible() static_assert( std::is_default_constructible::value, ""); static_assert( std::is_default_constructible::value, ""); static_assert( std::is_default_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_default_constructible_v, ""); + static_assert( std::is_default_constructible_v, ""); + static_assert( std::is_default_constructible_v, ""); + static_assert( std::is_default_constructible_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_default_constructible() static_assert(!std::is_default_constructible::value, ""); static_assert(!std::is_default_constructible::value, ""); static_assert(!std::is_default_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_default_constructible_v, ""); + static_assert(!std::is_default_constructible_v, ""); + static_assert(!std::is_default_constructible_v, ""); + static_assert(!std::is_default_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp index 807745ef66c1..60d607aba61c 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_destructible.pass.cpp @@ -12,6 +12,7 @@ // is_destructible #include +#include "test_macros.h" template void test_is_destructible() @@ -20,6 +21,12 @@ void test_is_destructible() static_assert( std::is_destructible::value, ""); static_assert( std::is_destructible::value, ""); static_assert( std::is_destructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_destructible_v, ""); + static_assert( std::is_destructible_v, ""); + static_assert( std::is_destructible_v, ""); + static_assert( std::is_destructible_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_destructible() static_assert(!std::is_destructible::value, ""); static_assert(!std::is_destructible::value, ""); static_assert(!std::is_destructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_destructible_v, ""); + static_assert(!std::is_destructible_v, ""); + static_assert(!std::is_destructible_v, ""); + static_assert(!std::is_destructible_v, ""); +#endif } class Empty {}; @@ -68,6 +81,7 @@ struct PurePublicDestructor { public: virtual ~PurePublicDestruc struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; }; struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; }; +#if TEST_STD_VER >= 11 struct DeletedPublicDestructor { public: ~DeletedPublicDestructor() = delete; }; struct DeletedProtectedDestructor { protected: ~DeletedProtectedDestructor() = delete; }; struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor() = delete; }; @@ -75,6 +89,7 @@ struct DeletedPrivateDestructor { private: ~DeletedPrivateDestructor( struct DeletedVirtualPublicDestructor { public: virtual ~DeletedVirtualPublicDestructor() = delete; }; struct DeletedVirtualProtectedDestructor { protected: virtual ~DeletedVirtualProtectedDestructor() = delete; }; struct DeletedVirtualPrivateDestructor { private: virtual ~DeletedVirtualPrivateDestructor() = delete; }; +#endif int main() @@ -99,23 +114,27 @@ int main() test_is_not_destructible(); test_is_not_destructible(); + test_is_not_destructible(); +#if TEST_STD_VER >= 11 + // Test access controlled destructors test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); + + // Test deleted constructors test_is_not_destructible(); test_is_not_destructible(); test_is_not_destructible(); - -// test_is_not_destructible(); // currently fails due to clang bug #20268 + //test_is_not_destructible(); // previously failed due to clang bug #20268 test_is_not_destructible(); test_is_not_destructible(); -#if __has_feature(cxx_access_control_sfinae) + // Test private destructors test_is_not_destructible(); #endif - test_is_not_destructible(); + } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp index 47af3c45cdea..410c1db7244d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_empty.pass.cpp @@ -12,6 +12,7 @@ // is_empty #include +#include "test_macros.h" template void test_is_empty() @@ -20,6 +21,12 @@ void test_is_empty() static_assert( std::is_empty::value, ""); static_assert( std::is_empty::value, ""); static_assert( std::is_empty::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_empty_v, ""); + static_assert( std::is_empty_v, ""); + static_assert( std::is_empty_v, ""); + static_assert( std::is_empty_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_empty() static_assert(!std::is_empty::value, ""); static_assert(!std::is_empty::value, ""); static_assert(!std::is_empty::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_empty_v, ""); + static_assert(!std::is_empty_v, ""); + static_assert(!std::is_empty_v, ""); + static_assert(!std::is_empty_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp index cf32196213e1..baf85e3e8139 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_final.pass.cpp @@ -12,6 +12,7 @@ // is_final #include +#include "test_macros.h" #if _LIBCPP_STD_VER > 11 @@ -26,6 +27,12 @@ void test_is_final() static_assert( std::is_final::value, ""); static_assert( std::is_final::value, ""); static_assert( std::is_final::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_final_v, ""); + static_assert( std::is_final_v, ""); + static_assert( std::is_final_v, ""); + static_assert( std::is_final_v, ""); +#endif } template @@ -35,6 +42,12 @@ void test_is_not_final() static_assert(!std::is_final::value, ""); static_assert(!std::is_final::value, ""); static_assert(!std::is_final::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_final_v, ""); + static_assert(!std::is_final_v, ""); + static_assert(!std::is_final_v, ""); + static_assert(!std::is_final_v, ""); +#endif } int main () diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp index ce781cd936b0..59aa5e26a292 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_literal_type.pass.cpp @@ -12,35 +12,94 @@ // is_literal_type #include +#include // for std::nullptr_t +#include "test_macros.h" template void test_is_literal_type() { static_assert( std::is_literal_type::value, ""); + static_assert( std::is_literal_type::value, ""); + static_assert( std::is_literal_type::value, ""); + static_assert( std::is_literal_type::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_literal_type_v, ""); + static_assert( std::is_literal_type_v, ""); + static_assert( std::is_literal_type_v, ""); + static_assert( std::is_literal_type_v, ""); +#endif } template void test_is_not_literal_type() { static_assert(!std::is_literal_type::value, ""); + static_assert(!std::is_literal_type::value, ""); + static_assert(!std::is_literal_type::value, ""); + static_assert(!std::is_literal_type::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_literal_type_v, ""); + static_assert(!std::is_literal_type_v, ""); + static_assert(!std::is_literal_type_v, ""); + static_assert(!std::is_literal_type_v, ""); +#endif } -struct A +class Empty { }; -struct B +class NotEmpty { - B(); + virtual ~NotEmpty(); }; +union Union {}; + +struct bit_zero +{ + int : 0; +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +enum Enum {zero, one}; + +typedef void (*FunctionPtr)(); + int main() { - test_is_literal_type (); - test_is_literal_type (); - test_is_literal_type (); - test_is_literal_type (); - test_is_literal_type (); +#if TEST_STD_VER >= 11 + test_is_literal_type(); +#endif - test_is_not_literal_type (); +// Before C++14, void was not a literal type +// In C++14, cv-void is is a literal type +#if TEST_STD_VER < 14 + test_is_not_literal_type(); +#else + test_is_literal_type(); +#endif + + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); +#if TEST_STD_VER >= 11 + test_is_literal_type(); +#endif + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + test_is_literal_type(); + + test_is_not_literal_type(); + test_is_not_literal_type(); } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp index a89ee7d4e490..613c1123e3fa 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_move_assignable #include +#include "test_macros.h" template void test_is_move_assignable() { - static_assert( std::is_move_assignable::value, ""); + static_assert(( std::is_move_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_move_assignable_v), ""); +#endif } template void test_is_not_move_assignable() { - static_assert(!std::is_move_assignable::value, ""); + static_assert((!std::is_move_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_move_assignable_v), ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp index 7409ebaa56c8..07c283bf8890 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_move_constructible.pass.cpp @@ -12,17 +12,24 @@ // is_move_constructible #include +#include "test_macros.h" template void test_is_move_constructible() { static_assert( std::is_move_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_move_constructible_v, ""); +#endif } template void test_is_not_move_constructible() { static_assert(!std::is_move_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_move_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp index 8fff5f8b3de3..9d629dc7ef46 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_nothrow_assignable #include +#include "test_macros.h" template void test_is_nothrow_assignable() { static_assert(( std::is_nothrow_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_nothrow_assignable_v), ""); +#endif } template void test_is_not_nothrow_assignable() { static_assert((!std::is_nothrow_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_nothrow_assignable_v), ""); +#endif } struct A diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp index fe0b5673bc44..c778a5d24b2e 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp @@ -13,35 +13,51 @@ // struct is_nothrow_constructible; #include +#include "test_macros.h" template void test_is_nothrow_constructible() { static_assert(( std::is_nothrow_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_nothrow_constructible_v), ""); +#endif } template void test_is_nothrow_constructible() { static_assert(( std::is_nothrow_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_nothrow_constructible_v), ""); +#endif } template void test_is_not_nothrow_constructible() { static_assert((!std::is_nothrow_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_nothrow_constructible_v), ""); +#endif } template void test_is_not_nothrow_constructible() { static_assert((!std::is_nothrow_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_nothrow_constructible_v), ""); +#endif } template void test_is_not_nothrow_constructible() { static_assert((!std::is_nothrow_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_nothrow_constructible_v), ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp index d843803cf21d..01c9bd0d0941 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_nothrow_copy_assignable #include +#include "test_macros.h" template void test_has_nothrow_assign() { static_assert( std::is_nothrow_copy_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_copy_assignable_v, ""); +#endif } template void test_has_not_nothrow_assign() { static_assert(!std::is_nothrow_copy_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_nothrow_copy_assignable_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp index 99fce65dcc7e..9dbdc4e2acfb 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp @@ -12,12 +12,17 @@ // is_nothrow_copy_constructible #include +#include "test_macros.h" template void test_is_nothrow_copy_constructible() { static_assert( std::is_nothrow_copy_constructible::value, ""); static_assert( std::is_nothrow_copy_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_copy_constructible_v, ""); + static_assert( std::is_nothrow_copy_constructible_v, ""); +#endif } template @@ -27,6 +32,12 @@ void test_has_not_nothrow_copy_constructor() static_assert(!std::is_nothrow_copy_constructible::value, ""); static_assert(!std::is_nothrow_copy_constructible::value, ""); static_assert(!std::is_nothrow_copy_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_nothrow_copy_constructible_v, ""); + static_assert(!std::is_nothrow_copy_constructible_v, ""); + static_assert(!std::is_nothrow_copy_constructible_v, ""); + static_assert(!std::is_nothrow_copy_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp index 1550dff08bb5..c89ac8944a93 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp @@ -12,6 +12,7 @@ // is_nothrow_default_constructible #include +#include "test_macros.h" template void test_is_nothrow_default_constructible() @@ -20,6 +21,12 @@ void test_is_nothrow_default_constructible() static_assert( std::is_nothrow_default_constructible::value, ""); static_assert( std::is_nothrow_default_constructible::value, ""); static_assert( std::is_nothrow_default_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_default_constructible_v, ""); + static_assert( std::is_nothrow_default_constructible_v, ""); + static_assert( std::is_nothrow_default_constructible_v, ""); + static_assert( std::is_nothrow_default_constructible_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_has_not_nothrow_default_constructor() static_assert(!std::is_nothrow_default_constructible::value, ""); static_assert(!std::is_nothrow_default_constructible::value, ""); static_assert(!std::is_nothrow_default_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_nothrow_default_constructible_v, ""); + static_assert(!std::is_nothrow_default_constructible_v, ""); + static_assert(!std::is_nothrow_default_constructible_v, ""); + static_assert(!std::is_nothrow_default_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp index 8fd5bab5a019..42c9807efa83 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_destructible.pass.cpp @@ -12,6 +12,7 @@ // is_nothrow_destructible #include +#include "test_macros.h" template void test_is_nothrow_destructible() @@ -20,6 +21,12 @@ void test_is_nothrow_destructible() static_assert( std::is_nothrow_destructible::value, ""); static_assert( std::is_nothrow_destructible::value, ""); static_assert( std::is_nothrow_destructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_destructible_v, ""); + static_assert( std::is_nothrow_destructible_v, ""); + static_assert( std::is_nothrow_destructible_v, ""); + static_assert( std::is_nothrow_destructible_v, ""); +#endif } template @@ -29,16 +36,31 @@ void test_is_not_nothrow_destructible() static_assert(!std::is_nothrow_destructible::value, ""); static_assert(!std::is_nothrow_destructible::value, ""); static_assert(!std::is_nothrow_destructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_nothrow_destructible_v, ""); + static_assert(!std::is_nothrow_destructible_v, ""); + static_assert(!std::is_nothrow_destructible_v, ""); + static_assert(!std::is_nothrow_destructible_v, ""); +#endif } + +struct PublicDestructor { public: ~PublicDestructor() {}}; +struct ProtectedDestructor { protected: ~ProtectedDestructor() {}}; +struct PrivateDestructor { private: ~PrivateDestructor() {}}; + +struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}}; +struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}}; +struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}}; + +struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; }; +struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; }; +struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; }; + class Empty { }; -class NotEmpty -{ - virtual ~NotEmpty(); -}; union Union {}; @@ -52,40 +74,36 @@ class Abstract virtual void foo() = 0; }; -class AbstractDestructor -{ - virtual ~AbstractDestructor() = 0; -}; - -struct A -{ - ~A(); -}; int main() { test_is_not_nothrow_destructible(); - test_is_not_nothrow_destructible(); - test_is_not_nothrow_destructible(); test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); -#if __has_feature(cxx_noexcept) - test_is_nothrow_destructible(); -#endif test_is_nothrow_destructible(); -#if __has_feature(cxx_unrestricted_unions) - test_is_nothrow_destructible(); -#endif -#if __has_feature(cxx_access_control_sfinae) - test_is_nothrow_destructible(); -#endif test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); test_is_nothrow_destructible(); - test_is_nothrow_destructible(); -#if __has_feature(cxx_noexcept) + +#if TEST_STD_VER >= 11 + // requires noexcept. These are all destructible. + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + test_is_nothrow_destructible(); + + // requires access control + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); + test_is_not_nothrow_destructible(); #endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp index fe51e438864f..11852f6aec98 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp @@ -12,17 +12,24 @@ // has_nothrow_move_assign #include +#include "test_macros.h" template void test_has_nothrow_assign() { static_assert( std::is_nothrow_move_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_move_assignable_v, ""); +#endif } template void test_has_not_nothrow_assign() { static_assert(!std::is_nothrow_move_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_nothrow_move_assignable_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp index f5a42afe0d50..b93dbb634e4d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp @@ -12,12 +12,17 @@ // has_nothrow_move_constructor #include +#include "test_macros.h" template void test_is_nothrow_move_constructible() { static_assert( std::is_nothrow_move_constructible::value, ""); static_assert( std::is_nothrow_move_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_nothrow_move_constructible_v, ""); + static_assert( std::is_nothrow_move_constructible_v, ""); +#endif } template @@ -27,6 +32,12 @@ void test_has_not_nothrow_move_constructor() static_assert(!std::is_nothrow_move_constructible::value, ""); static_assert(!std::is_nothrow_move_constructible::value, ""); static_assert(!std::is_nothrow_move_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_nothrow_move_constructible_v, ""); + static_assert(!std::is_nothrow_move_constructible_v, ""); + static_assert(!std::is_nothrow_move_constructible_v, ""); + static_assert(!std::is_nothrow_move_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp index 4ec1ae9949ef..2ca2b8640141 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_pod.pass.cpp @@ -12,6 +12,7 @@ // is_pod #include +#include "test_macros.h" template void test_is_pod() @@ -20,6 +21,12 @@ void test_is_pod() static_assert( std::is_pod::value, ""); static_assert( std::is_pod::value, ""); static_assert( std::is_pod::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_pod_v, ""); + static_assert( std::is_pod_v, ""); + static_assert( std::is_pod_v, ""); + static_assert( std::is_pod_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_pod() static_assert(!std::is_pod::value, ""); static_assert(!std::is_pod::value, ""); static_assert(!std::is_pod::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_pod_v, ""); + static_assert(!std::is_pod_v, ""); + static_assert(!std::is_pod_v, ""); + static_assert(!std::is_pod_v, ""); +#endif } class Class diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp index 6e82cddc5166..b66e7a296f39 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_polymorphic.pass.cpp @@ -12,6 +12,7 @@ // is_polymorphic #include +#include "test_macros.h" template void test_is_polymorphic() @@ -20,6 +21,12 @@ void test_is_polymorphic() static_assert( std::is_polymorphic::value, ""); static_assert( std::is_polymorphic::value, ""); static_assert( std::is_polymorphic::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_polymorphic_v, ""); + static_assert( std::is_polymorphic_v, ""); + static_assert( std::is_polymorphic_v, ""); + static_assert( std::is_polymorphic_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_polymorphic() static_assert(!std::is_polymorphic::value, ""); static_assert(!std::is_polymorphic::value, ""); static_assert(!std::is_polymorphic::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_polymorphic_v, ""); + static_assert(!std::is_polymorphic_v, ""); + static_assert(!std::is_polymorphic_v, ""); + static_assert(!std::is_polymorphic_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp index 479c2529f02a..94bf7fb58041 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_signed.pass.cpp @@ -12,6 +12,7 @@ // is_signed #include +#include "test_macros.h" template void test_is_signed() @@ -20,6 +21,12 @@ void test_is_signed() static_assert( std::is_signed::value, ""); static_assert( std::is_signed::value, ""); static_assert( std::is_signed::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_signed_v, ""); + static_assert( std::is_signed_v, ""); + static_assert( std::is_signed_v, ""); + static_assert( std::is_signed_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_signed() static_assert(!std::is_signed::value, ""); static_assert(!std::is_signed::value, ""); static_assert(!std::is_signed::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_signed_v, ""); + static_assert(!std::is_signed_v, ""); + static_assert(!std::is_signed_v, ""); + static_assert(!std::is_signed_v, ""); +#endif } class Class diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp index 668c4cdc7dd6..6e601c1ac04b 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_standard_layout.pass.cpp @@ -12,6 +12,7 @@ // is_standard_layout #include +#include "test_macros.h" template void test_is_standard_layout() @@ -20,6 +21,12 @@ void test_is_standard_layout() static_assert( std::is_standard_layout::value, ""); static_assert( std::is_standard_layout::value, ""); static_assert( std::is_standard_layout::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_standard_layout_v, ""); + static_assert( std::is_standard_layout_v, ""); + static_assert( std::is_standard_layout_v, ""); + static_assert( std::is_standard_layout_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_standard_layout() static_assert(!std::is_standard_layout::value, ""); static_assert(!std::is_standard_layout::value, ""); static_assert(!std::is_standard_layout::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_standard_layout_v, ""); + static_assert(!std::is_standard_layout_v, ""); + static_assert(!std::is_standard_layout_v, ""); + static_assert(!std::is_standard_layout_v, ""); +#endif } template diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp index af38699d881b..2d2df14d3bbc 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivial.pass.cpp @@ -12,6 +12,7 @@ // is_trivial #include +#include "test_macros.h" template void test_is_trivial() @@ -20,6 +21,12 @@ void test_is_trivial() static_assert( std::is_trivial::value, ""); static_assert( std::is_trivial::value, ""); static_assert( std::is_trivial::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivial_v, ""); + static_assert( std::is_trivial_v, ""); + static_assert( std::is_trivial_v, ""); + static_assert( std::is_trivial_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_trivial() static_assert(!std::is_trivial::value, ""); static_assert(!std::is_trivial::value, ""); static_assert(!std::is_trivial::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivial_v, ""); + static_assert(!std::is_trivial_v, ""); + static_assert(!std::is_trivial_v, ""); + static_assert(!std::is_trivial_v, ""); +#endif } struct A {}; diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp index 735d05fa6ee4..3ebb9dba429d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_trivially_assignable #include +#include "test_macros.h" template void test_is_trivially_assignable() { static_assert(( std::is_trivially_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_trivially_assignable_v), ""); +#endif } template void test_is_not_trivially_assignable() { static_assert((!std::is_trivially_assignable::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_trivially_assignable_v), ""); +#endif } struct A diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp index 4171d4d32f5d..212245f00691 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_constructible.pass.cpp @@ -13,35 +13,51 @@ // struct is_trivially_constructible; #include +#include "test_macros.h" template void test_is_trivially_constructible() { static_assert(( std::is_trivially_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_trivially_constructible_v), ""); +#endif } template void test_is_trivially_constructible() { static_assert(( std::is_trivially_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert(( std::is_trivially_constructible_v), ""); +#endif } template void test_is_not_trivially_constructible() { static_assert((!std::is_trivially_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_trivially_constructible_v), ""); +#endif } template void test_is_not_trivially_constructible() { static_assert((!std::is_trivially_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_trivially_constructible_v), ""); +#endif } template void test_is_not_trivially_constructible() { static_assert((!std::is_trivially_constructible::value), ""); +#if TEST_STD_VER > 14 + static_assert((!std::is_trivially_constructible_v), ""); +#endif } struct A diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp index 7d72565e40ca..25429f5470e7 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_trivially_copy_assignable #include +#include "test_macros.h" template void test_has_trivially_copy_assignable() { static_assert( std::is_trivially_copy_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_copy_assignable_v, ""); +#endif } template void test_has_not_trivially_copy_assignable() { static_assert(!std::is_trivially_copy_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_copy_assignable_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp index 6bd78ec9e7a1..9556959e1262 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copy_constructible.pass.cpp @@ -12,12 +12,17 @@ // is_trivially_copy_constructible #include +#include "test_macros.h" template void test_is_trivially_copy_constructible() { static_assert( std::is_trivially_copy_constructible::value, ""); static_assert( std::is_trivially_copy_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_copy_constructible_v, ""); + static_assert( std::is_trivially_copy_constructible_v, ""); +#endif } template @@ -25,6 +30,10 @@ void test_has_not_trivial_copy_constructor() { static_assert(!std::is_trivially_copy_constructible::value, ""); static_assert(!std::is_trivially_copy_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_copy_constructible_v, ""); + static_assert(!std::is_trivially_copy_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp index d65882378fc4..c19a29ffb586 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_copyable.pass.cpp @@ -13,6 +13,7 @@ #include #include +#include "test_macros.h" template void test_is_trivially_copyable() @@ -21,6 +22,12 @@ void test_is_trivially_copyable() static_assert( std::is_trivially_copyable::value, ""); static_assert(!std::is_trivially_copyable::value, ""); static_assert(!std::is_trivially_copyable::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_copyable_v, ""); + static_assert( std::is_trivially_copyable_v, ""); + static_assert(!std::is_trivially_copyable_v, ""); + static_assert(!std::is_trivially_copyable_v, ""); +#endif } template @@ -30,6 +37,12 @@ void test_is_not_trivially_copyable() static_assert(!std::is_trivially_copyable::value, ""); static_assert(!std::is_trivially_copyable::value, ""); static_assert(!std::is_trivially_copyable::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_copyable_v, ""); + static_assert(!std::is_trivially_copyable_v, ""); + static_assert(!std::is_trivially_copyable_v, ""); + static_assert(!std::is_trivially_copyable_v, ""); +#endif } struct A diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp index 1f63401dacb7..2d367159ca30 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_default_constructible.pass.cpp @@ -12,6 +12,7 @@ // is_trivially_default_constructible #include +#include "test_macros.h" template void test_is_trivially_default_constructible() @@ -20,6 +21,12 @@ void test_is_trivially_default_constructible() static_assert( std::is_trivially_default_constructible::value, ""); static_assert( std::is_trivially_default_constructible::value, ""); static_assert( std::is_trivially_default_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_default_constructible_v, ""); + static_assert( std::is_trivially_default_constructible_v, ""); + static_assert( std::is_trivially_default_constructible_v, ""); + static_assert( std::is_trivially_default_constructible_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_has_not_trivial_default_constructor() static_assert(!std::is_trivially_default_constructible::value, ""); static_assert(!std::is_trivially_default_constructible::value, ""); static_assert(!std::is_trivially_default_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_default_constructible_v, ""); + static_assert(!std::is_trivially_default_constructible_v, ""); + static_assert(!std::is_trivially_default_constructible_v, ""); + static_assert(!std::is_trivially_default_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp index b18ace44bda1..9e2507067d2d 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_destructible.pass.cpp @@ -12,6 +12,7 @@ // is_trivially_destructible #include +#include "test_macros.h" template void test_is_trivially_destructible() @@ -20,6 +21,12 @@ void test_is_trivially_destructible() static_assert( std::is_trivially_destructible::value, ""); static_assert( std::is_trivially_destructible::value, ""); static_assert( std::is_trivially_destructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_destructible_v, ""); + static_assert( std::is_trivially_destructible_v, ""); + static_assert( std::is_trivially_destructible_v, ""); + static_assert( std::is_trivially_destructible_v, ""); +#endif } template @@ -29,17 +36,31 @@ void test_is_not_trivially_destructible() static_assert(!std::is_trivially_destructible::value, ""); static_assert(!std::is_trivially_destructible::value, ""); static_assert(!std::is_trivially_destructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_destructible_v, ""); + static_assert(!std::is_trivially_destructible_v, ""); + static_assert(!std::is_trivially_destructible_v, ""); + static_assert(!std::is_trivially_destructible_v, ""); +#endif } +struct PublicDestructor { public: ~PublicDestructor() {}}; +struct ProtectedDestructor { protected: ~ProtectedDestructor() {}}; +struct PrivateDestructor { private: ~PrivateDestructor() {}}; + +struct VirtualPublicDestructor { public: virtual ~VirtualPublicDestructor() {}}; +struct VirtualProtectedDestructor { protected: virtual ~VirtualProtectedDestructor() {}}; +struct VirtualPrivateDestructor { private: virtual ~VirtualPrivateDestructor() {}}; + +struct PurePublicDestructor { public: virtual ~PurePublicDestructor() = 0; }; +struct PureProtectedDestructor { protected: virtual ~PureProtectedDestructor() = 0; }; +struct PurePrivateDestructor { private: virtual ~PurePrivateDestructor() = 0; }; + + class Empty { }; -class NotEmpty -{ - virtual ~NotEmpty(); -}; - union Union {}; struct bit_zero @@ -66,18 +87,28 @@ int main() { test_is_not_trivially_destructible(); test_is_not_trivially_destructible(); - test_is_not_trivially_destructible(); - test_is_not_trivially_destructible(); test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); test_is_trivially_destructible(); - test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); + test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); test_is_trivially_destructible(); + +#if TEST_STD_VER >= 11 + // requires access control sfinae + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); + test_is_not_trivially_destructible(); +#endif } diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp index c3fc7ac0a3df..eca596ee1c19 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_assignable.pass.cpp @@ -12,17 +12,24 @@ // is_trivially_move_assignable #include +#include "test_macros.h" template void test_has_trivial_assign() { static_assert( std::is_trivially_move_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_move_assignable_v, ""); +#endif } template void test_has_not_trivial_assign() { static_assert(!std::is_trivially_move_assignable::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_move_assignable_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp index 54cb5e853a81..313da175f715 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_trivially_move_constructible.pass.cpp @@ -12,17 +12,24 @@ // is_trivially_move_constructible #include +#include "test_macros.h" template void test_is_trivially_move_constructible() { static_assert( std::is_trivially_move_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_trivially_move_constructible_v, ""); +#endif } template void test_has_not_trivial_move_constructor() { static_assert(!std::is_trivially_move_constructible::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_trivially_move_constructible_v, ""); +#endif } class Empty diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp index dfdb15542610..9ca42432df16 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_unsigned.pass.cpp @@ -12,6 +12,7 @@ // is_unsigned #include +#include "test_macros.h" template void test_is_unsigned() @@ -20,6 +21,12 @@ void test_is_unsigned() static_assert( std::is_unsigned::value, ""); static_assert( std::is_unsigned::value, ""); static_assert( std::is_unsigned::value, ""); +#if TEST_STD_VER > 14 + static_assert( std::is_unsigned_v, ""); + static_assert( std::is_unsigned_v, ""); + static_assert( std::is_unsigned_v, ""); + static_assert( std::is_unsigned_v, ""); +#endif } template @@ -29,6 +36,12 @@ void test_is_not_unsigned() static_assert(!std::is_unsigned::value, ""); static_assert(!std::is_unsigned::value, ""); static_assert(!std::is_unsigned::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_unsigned_v, ""); + static_assert(!std::is_unsigned_v, ""); + static_assert(!std::is_unsigned_v, ""); + static_assert(!std::is_unsigned_v, ""); +#endif } class Class diff --git a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp index f6805bc1c4ff..36697a3f3eba 100644 --- a/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp +++ b/test/std/utilities/meta/meta.unary/meta.unary.prop/is_volatile.pass.cpp @@ -12,6 +12,7 @@ // is_volatile #include +#include "test_macros.h" template void test_is_volatile() @@ -20,6 +21,12 @@ void test_is_volatile() static_assert(!std::is_volatile::value, ""); static_assert( std::is_volatile::value, ""); static_assert( std::is_volatile::value, ""); +#if TEST_STD_VER > 14 + static_assert(!std::is_volatile_v, ""); + static_assert(!std::is_volatile_v, ""); + static_assert( std::is_volatile_v, ""); + static_assert( std::is_volatile_v, ""); +#endif } int main() diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp index 78027f7e48b8..9331b7094f48 100644 --- a/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp +++ b/test/std/utilities/ratio/ratio.comparison/ratio_equal.pass.cpp @@ -11,46 +11,57 @@ #include +#include "test_macros.h" + +template +void test() +{ + static_assert((result == std::ratio_equal::value), ""); +#if TEST_STD_VER > 14 + static_assert((result == std::ratio_equal_v), ""); +#endif +} + int main() { { typedef std::ratio<1, 1> R1; typedef std::ratio<1, 1> R2; - static_assert((std::ratio_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((std::ratio_equal::value), ""); + test(); } { typedef std::ratio<1, 1> R1; typedef std::ratio<1, -1> R2; - static_assert((!std::ratio_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((!std::ratio_equal::value), ""); + test(); } } diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp index 9182a9ec503c..7f7a74068299 100644 --- a/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp +++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater.pass.cpp @@ -11,46 +11,57 @@ #include +#include "test_macros.h" + +template +void test() +{ + static_assert((result == std::ratio_greater::value), ""); +#if TEST_STD_VER > 14 + static_assert((result == std::ratio_greater_v), ""); +#endif +} + int main() { { typedef std::ratio<1, 1> R1; typedef std::ratio<1, 1> R2; - static_assert((!std::ratio_greater::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_greater::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_greater::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((!std::ratio_greater::value), ""); + test(); } { typedef std::ratio<1, 1> R1; typedef std::ratio<1, -1> R2; - static_assert((std::ratio_greater::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_greater::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_greater::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((std::ratio_greater::value), ""); + test(); } } diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp index a1f5a185e621..db78557ec4c1 100644 --- a/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp +++ b/test/std/utilities/ratio/ratio.comparison/ratio_greater_equal.pass.cpp @@ -11,46 +11,57 @@ #include +#include "test_macros.h" + +template +void test() +{ + static_assert((result == std::ratio_greater_equal::value), ""); +#if TEST_STD_VER > 14 + static_assert((result == std::ratio_greater_equal_v), ""); +#endif +} + int main() { { typedef std::ratio<1, 1> R1; typedef std::ratio<1, 1> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<1, 1> R1; typedef std::ratio<1, -1> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_greater_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((std::ratio_greater_equal::value), ""); + test(); } } diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp index db53ab0ad448..a428be28aa56 100644 --- a/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp +++ b/test/std/utilities/ratio/ratio.comparison/ratio_less.pass.cpp @@ -11,76 +11,87 @@ #include +#include "test_macros.h" + +template +void test() +{ + static_assert((result == std::ratio_less::value), ""); +#if TEST_STD_VER > 14 + static_assert((result == std::ratio_less_v), ""); +#endif +} + int main() { { typedef std::ratio<1, 1> R1; typedef std::ratio<1, 1> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<1, 1> R1; typedef std::ratio<1, -1> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_less::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R2; - static_assert((std::ratio_less::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFDLL, 0x7FFFFFFFFFFFFFFCLL> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R2; - static_assert((std::ratio_less::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 0x7FFFFFFFFFFFFFFELL> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFELL, 0x7FFFFFFFFFFFFFFDLL> R2; - static_assert((std::ratio_less::value), ""); + test(); } { typedef std::ratio<641981, 1339063> R1; typedef std::ratio<1291640, 2694141LL> R2; - static_assert((!std::ratio_less::value), ""); + test(); } { typedef std::ratio<1291640, 2694141LL> R1; typedef std::ratio<641981, 1339063> R2; - static_assert((std::ratio_less::value), ""); + test(); } } diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp index 5b148f0e1435..7b224ab7c892 100644 --- a/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp +++ b/test/std/utilities/ratio/ratio.comparison/ratio_less_equal.pass.cpp @@ -11,46 +11,57 @@ #include +#include "test_macros.h" + +template +void test() +{ + static_assert((result == std::ratio_less_equal::value), ""); +#if TEST_STD_VER > 14 + static_assert((result == std::ratio_less_equal_v), ""); +#endif +} + int main() { { typedef std::ratio<1, 1> R1; typedef std::ratio<1, 1> R2; - static_assert((std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<1, 1> R1; typedef std::ratio<1, -1> R2; - static_assert((!std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_less_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((!std::ratio_less_equal::value), ""); + test(); } } diff --git a/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp index ebf930746585..fcd31207fdbf 100644 --- a/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp +++ b/test/std/utilities/ratio/ratio.comparison/ratio_not_equal.pass.cpp @@ -11,46 +11,57 @@ #include +#include "test_macros.h" + +template +void test() +{ + static_assert((result == std::ratio_not_equal::value), ""); +#if TEST_STD_VER > 14 + static_assert((result == std::ratio_not_equal_v), ""); +#endif +} + int main() { { typedef std::ratio<1, 1> R1; typedef std::ratio<1, 1> R2; - static_assert((!std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((!std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((!std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<1, 1> R1; typedef std::ratio<1, -1> R2; - static_assert((std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<-0x7FFFFFFFFFFFFFFFLL, 1> R1; typedef std::ratio<0x7FFFFFFFFFFFFFFFLL, 1> R2; - static_assert((std::ratio_not_equal::value), ""); + test(); } { typedef std::ratio<1, 0x7FFFFFFFFFFFFFFFLL> R1; typedef std::ratio<1, -0x7FFFFFFFFFFFFFFFLL> R2; - static_assert((std::ratio_not_equal::value), ""); + test(); } } diff --git a/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp index 7fe78bad1cc6..9411435e29e8 100644 --- a/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.cons/char_ptr_ctor.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // template // explicit bitset(const charT* str, // typename basic_string::size_type n = basic_string::npos, @@ -14,6 +15,8 @@ #include #include +#include // for 'min' and 'max' +#include // for 'invalid_argument' #pragma clang diagnostic ignored "-Wtautological-compare" diff --git a/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp index bcee50c4c63a..b08720f57ee3 100644 --- a/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.cons/string_ctor.pass.cpp @@ -7,10 +7,13 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test bitset(string, pos, n, zero, one); #include #include +#include // for 'min' and 'max' +#include // for 'invalid_argument' #pragma clang diagnostic ignored "-Wtautological-compare" diff --git a/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp b/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp index 023fedc25839..f232447e08c3 100644 --- a/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp @@ -11,6 +11,7 @@ #include #include +#include // for 'min' and 'max' #pragma clang diagnostic ignored "-Wtautological-compare" diff --git a/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp index 3e09b202097d..cffca68fb1ea 100644 --- a/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/flip_one.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test bitset& flip(size_t pos); #include diff --git a/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp index ebaa9e7a8d72..6de256b00cc5 100644 --- a/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/reset_one.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test bitset& reset(size_t pos); #include diff --git a/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp b/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp index 116eaf3f46e0..debe5431d8d0 100644 --- a/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/set_one.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test bitset& set(size_t pos, bool val = true); #include diff --git a/test/std/utilities/template.bitset/bitset.members/test.pass.cpp b/test/std/utilities/template.bitset/bitset.members/test.pass.cpp index 5102b46171a2..ce594d0ae891 100644 --- a/test/std/utilities/template.bitset/bitset.members/test.pass.cpp +++ b/test/std/utilities/template.bitset/bitset.members/test.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// XFAIL: libcpp-no-exceptions // test constexpr bool test(size_t pos) const; #include diff --git a/test/std/utilities/date.time/tested_elsewhere.pass.cpp b/test/std/utilities/time/date.time/ctime.pass.cpp similarity index 96% rename from test/std/utilities/date.time/tested_elsewhere.pass.cpp rename to test/std/utilities/time/date.time/ctime.pass.cpp index 419f415dee19..d0a838e0c271 100644 --- a/test/std/utilities/date.time/tested_elsewhere.pass.cpp +++ b/test/std/utilities/time/date.time/ctime.pass.cpp @@ -30,9 +30,11 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); +#endif static_assert((std::is_same::value), ""); } diff --git a/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp b/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp new file mode 100644 index 000000000000..221004c568ce --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.alg/abs.fail.cpp @@ -0,0 +1,27 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// ceil + +// template +// constexpr duration abs(duration d) + +// This function shall not participate in overload resolution unless numeric_limits::is_signed is true. + +#include + +typedef std::chrono::duration unsigned_secs; + +int main() +{ + std::chrono::abs(unsigned_secs(0)); +} diff --git a/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp b/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp new file mode 100644 index 000000000000..ec32c37a9423 --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.alg/abs.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 + +// + +// abs + +// template +// constexpr duration abs(duration d) + +#include +#include +#include + +template +void +test(const Duration& f, const Duration& d) +{ + { + typedef decltype(std::chrono::abs(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::abs(f) == d); + } +} + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::milliseconds( 7290000)); + test(std::chrono::milliseconds(-7290000), std::chrono::milliseconds( 7290000)); + test(std::chrono::minutes( 122), std::chrono::minutes( 122)); + test(std::chrono::minutes(-122), std::chrono::minutes( 122)); + test(std::chrono::hours(0), std::chrono::hours(0)); + + { +// 9000000ms is 2 hours and 30 minutes + constexpr std::chrono::hours h1 = std::chrono::abs(std::chrono::hours(-3)); + static_assert(h1.count() == 3, ""); + constexpr std::chrono::hours h2 = std::chrono::abs(std::chrono::hours(3)); + static_assert(h2.count() == 3, ""); + } +} diff --git a/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp new file mode 100644 index 000000000000..909e8573247c --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.cast/ceil.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// ceil + +// template +// ToDuration +// ceil(const duration& d); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::ceil(std::chrono::milliseconds(3)); +} diff --git a/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp new file mode 100644 index 000000000000..6fb73b97db17 --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.cast/ceil.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 + +// + +// ceil + +// template +// constexpr +// ToDuration +// ceil(const duration& d); + +#include +#include +#include + +template +void +test(const FromDuration& f, const ToDuration& d) +{ + { + typedef decltype(std::chrono::ceil(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::ceil(f) == d); + } +} + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3)); + test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2)); + test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122)); + test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121)); + + { +// 9000000ms is 2 hours and 30 minutes + constexpr std::chrono::hours h1 = std::chrono::ceil(std::chrono::milliseconds(9000000)); + static_assert(h1.count() == 3, ""); + constexpr std::chrono::hours h2 = std::chrono::ceil(std::chrono::milliseconds(-9000000)); + static_assert(h2.count() == -2, ""); + } +} diff --git a/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp new file mode 100644 index 000000000000..14d9ca878df8 --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.cast/floor.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// floor + +// template +// ToDuration +// floor(const duration& d); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::floor(std::chrono::milliseconds(3)); +} diff --git a/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp new file mode 100644 index 000000000000..57929dd91228 --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.cast/floor.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// floor + +// template +// constexpr +// ToDuration +// floor(const duration& d); + +#include +#include +#include + +template +void +test(const FromDuration& f, const ToDuration& d) +{ + { + typedef decltype(std::chrono::floor(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::floor(f) == d); + } +} + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2)); + test(std::chrono::milliseconds(-7290000), std::chrono::hours(-3)); + test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 121)); + test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122)); + + { +// 9000000ms is 2 hours and 30 minutes + constexpr std::chrono::hours h1 = std::chrono::floor(std::chrono::milliseconds(9000000)); + static_assert(h1.count() == 2, ""); + constexpr std::chrono::hours h2 = std::chrono::floor(std::chrono::milliseconds(-9000000)); + static_assert(h2.count() == -3, ""); + } +} diff --git a/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp b/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp new file mode 100644 index 000000000000..6f9f5bd29b63 --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.cast/round.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// round + +// template +// ToDuration +// round(const duration& d); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::round(std::chrono::milliseconds(3)); +} diff --git a/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp b/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp new file mode 100644 index 000000000000..e50b85c991a2 --- /dev/null +++ b/test/std/utilities/time/time.duration/time.duration.cast/round.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// round + +// template +// constexpr +// ToDuration +// ceil(const duration& d); + +#include +#include +#include + +template +void +test(const FromDuration& f, const ToDuration& d) +{ + { + typedef decltype(std::chrono::round(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::round(f) == d); + } +} + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2)); + test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2)); + test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122)); + test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122)); + + { +// 9000000ms is 2 hours and 30 minutes + constexpr std::chrono::hours h1 = std::chrono::round(std::chrono::milliseconds(9000000)); + static_assert(h1.count() == 2, ""); + constexpr std::chrono::hours h2 = std::chrono::round(std::chrono::milliseconds(-9000000)); + static_assert(h2.count() == -2, ""); + } +} diff --git a/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp new file mode 100644 index 000000000000..1c92d75b97ca --- /dev/null +++ b/test/std/utilities/time/time.point/time.point.cast/ceil.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// ceil + +// template +// time_point +// ceil(const time_point& t); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::ceil(std::chrono::system_clock::now()); +} diff --git a/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp new file mode 100644 index 000000000000..379929c7f2d8 --- /dev/null +++ b/test/std/utilities/time/time.point/time.point.cast/ceil.pass.cpp @@ -0,0 +1,69 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// ceil + +// template +// time_point +// ceil(const time_point& t); + +#include +#include +#include + +template +void +test(const FromDuration& df, const ToDuration& d) +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + FromTimePoint f(df); + ToTimePoint t(d); + typedef decltype(std::chrono::ceil(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::ceil(f) == t); + } +} + +template +void test_constexpr () +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + constexpr FromTimePoint f{FromDuration{From}}; + constexpr ToTimePoint t{ToDuration{To}}; + static_assert(std::chrono::ceil(f) == t, ""); + } +} + + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::hours( 3)); + test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2)); + test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122)); + test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-121)); + +// 9000000ms is 2 hours and 30 minutes + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + + test_constexpr (); + test_constexpr (); +} diff --git a/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp new file mode 100644 index 000000000000..ea48e1219e34 --- /dev/null +++ b/test/std/utilities/time/time.point/time.point.cast/floor.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// floor + +// template +// time_point +// floor(const time_point& t); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::floor(std::chrono::system_clock::now()); +} diff --git a/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp new file mode 100644 index 000000000000..d0a908fa932a --- /dev/null +++ b/test/std/utilities/time/time.point/time.point.cast/floor.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// floor + +// template +// time_point +// floor(const time_point& t); + +#include +#include +#include + +template +void +test(const FromDuration& df, const ToDuration& d) +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + FromTimePoint f(df); + ToTimePoint t(d); + typedef decltype(std::chrono::floor(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::floor(f) == t); + } +} + +template +void test_constexpr () +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + constexpr FromTimePoint f{FromDuration{From}}; + constexpr ToTimePoint t{ToDuration{To}}; + static_assert(std::chrono::floor(f) == t, ""); + } +} + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2)); + test(std::chrono::milliseconds(-7290000), std::chrono::hours(-3)); + test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 121)); + test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122)); + +// 9000000ms is 2 hours and 30 minutes + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + + test_constexpr (); + test_constexpr (); +} diff --git a/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp b/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp new file mode 100644 index 000000000000..53c14f47de69 --- /dev/null +++ b/test/std/utilities/time/time.point/time.point.cast/round.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// round + +// template +// time_point +// round(const time_point& t); + +// ToDuration shall be an instantiation of duration. + +#include + +int main() +{ + std::chrono::round(std::chrono::system_clock::now()); +} diff --git a/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp b/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp new file mode 100644 index 000000000000..ab8bf3a75e79 --- /dev/null +++ b/test/std/utilities/time/time.point/time.point.cast/round.pass.cpp @@ -0,0 +1,68 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14 +// + +// round + +// template +// time_point +// round(const time_point& t); + +#include +#include +#include + +template +void +test(const FromDuration& df, const ToDuration& d) +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + FromTimePoint f(df); + ToTimePoint t(d); + typedef decltype(std::chrono::round(f)) R; + static_assert((std::is_same::value), ""); + assert(std::chrono::round(f) == t); + } +} + +template +void test_constexpr () +{ + typedef std::chrono::system_clock Clock; + typedef std::chrono::time_point FromTimePoint; + typedef std::chrono::time_point ToTimePoint; + { + constexpr FromTimePoint f{FromDuration{From}}; + constexpr ToTimePoint t{ToDuration{To}}; + static_assert(std::chrono::round(f) == t, ""); + } +} + +int main() +{ +// 7290000ms is 2 hours, 1 minute, and 30 seconds + test(std::chrono::milliseconds( 7290000), std::chrono::hours( 2)); + test(std::chrono::milliseconds(-7290000), std::chrono::hours(-2)); + test(std::chrono::milliseconds( 7290000), std::chrono::minutes( 122)); + test(std::chrono::milliseconds(-7290000), std::chrono::minutes(-122)); + +// 9000000ms is 2 hours and 30 minutes + test_constexpr (); + test_constexpr (); + test_constexpr (); + test_constexpr (); + + test_constexpr (); + test_constexpr (); +} diff --git a/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp b/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp index c32350faa83b..f9ddc87a7a14 100644 --- a/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp +++ b/test/std/utilities/time/time.traits/time.traits.is_fp/treat_as_floating_point.pass.cpp @@ -20,6 +20,10 @@ test() { static_assert((std::is_base_of, std::chrono::treat_as_floating_point >::value), ""); +#if TEST_STD_VER > 14 + static_assert((std::is_base_of, + std::chrono::treat_as_floating_point_v >), ""); +#endif } struct A {}; diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp new file mode 100644 index 000000000000..58df2df7679a --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.fail.cpp @@ -0,0 +1,34 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// const typename tuple_element >::type&& +// get(const tuple&& t); + +// UNSUPPORTED: c++98, c++03 + +#include + +template void cref(T const&) {}; +template void cref(T const&&) = delete; + +std::tuple const tup4() { return std::make_tuple(4); } + +int main() +{ + // LWG2485: tuple should not open a hole in the type system, get() should + // imitate [expr.ref]'s rules for accessing data members + { + cref(std::get<0>(tup4())); // expected-error {{call to deleted function 'cref'}} + } +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp new file mode 100644 index 000000000000..720a9064015d --- /dev/null +++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/get_const_rv.pass.cpp @@ -0,0 +1,80 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template class tuple; + +// template +// const typename tuple_element >::type&& +// get(const tuple&& t); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include +#include + +#include "test_macros.h" + +int main() +{ + { + typedef std::tuple T; + const T t(3); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(t))), ""); + const int&& i = std::get<0>(std::move(t)); + assert(i == 3); + } + + { + typedef std::tuple T; + const T t("high", 5); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(t))), ""); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get<1>(std::move(t))), ""); + const std::string&& s = std::get<0>(std::move(t)); + const int&& i = std::get<1>(std::move(t)); + assert(s == "high"); + assert(i == 5); + } + + { + int x = 42; + int const y = 43; + std::tuple const p(x, y); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(p))), ""); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<1>(std::move(p))), ""); + } + + { + int x = 42; + int const y = 43; + std::tuple const p(std::move(x), std::move(y)); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(p))), ""); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<1>(std::move(p))), ""); + } + +#if TEST_STD_VER > 11 + { + typedef std::tuple T; + constexpr const T t(2.718, 5); + static_assert(std::get<0>(std::move(t)) == 2.718, ""); + static_assert(std::get<1>(std::move(t)) == 5, ""); + } +#endif +} diff --git a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp index aa020dab47c7..b661a78de8db 100644 --- a/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp +++ b/test/std/utilities/tuple/tuple.tuple/tuple.elem/tuple.by.type.pass.cpp @@ -10,30 +10,31 @@ // UNSUPPORTED: c++98, c++03, c++11 #include +#include #include #include +#include #include int main() { -#if _LIBCPP_STD_VER > 11 typedef std::complex cf; { auto t1 = std::tuple { 42, "Hi", { 1,2 }}; - assert ( std::get(t1) == 42 ); // find at the beginning + assert ( std::get(t1) == 42 ); // find at the beginning assert ( std::get(t1) == "Hi" ); // find in the middle assert ( std::get(t1).real() == 1 ); // find at the end assert ( std::get(t1).imag() == 2 ); } - + { auto t2 = std::tuple { 42, "Hi", 23, { 1,2 }}; // get would fail! assert ( std::get(t2) == "Hi" ); assert (( std::get(t2) == cf{ 1,2 } )); } - + { constexpr std::tuple p5 { 1, 2, 3.4, 5.6 }; static_assert ( std::get(p5) == 1, "" ); @@ -53,8 +54,40 @@ int main() std::tuple t(upint(new int(4))); upint p = std::get(std::move(t)); // get rvalue assert(*p == 4); - assert(std::get<0>(t) == nullptr); // has been moved from + assert(std::get(t) == nullptr); // has been moved from } -#endif + { + typedef std::unique_ptr upint; + const std::tuple t(upint(new int(4))); + const upint&& p = std::get(std::move(t)); // get const rvalue + assert(*p == 4); + assert(std::get(t) != nullptr); + } + + { + int x = 42; + int y = 43; + std::tuple const t(x, y); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get(std::move(t))), ""); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get(std::move(t))), ""); + } + + { + int x = 42; + int y = 43; + std::tuple const t(std::move(x), std::move(y)); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get(std::move(t))), ""); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get(std::move(t))), ""); + } + + { + constexpr const std::tuple t { 1, 2, 3.4, 5.6 }; + static_assert(std::get(std::move(t)) == 1, ""); + static_assert(std::get(std::move(t)) == 2, ""); + } } diff --git a/test/std/utilities/utility/as_const/as_const.fail.cpp b/test/std/utilities/utility/as_const/as_const.fail.cpp new file mode 100644 index 000000000000..6334e1460259 --- /dev/null +++ b/test/std/utilities/utility/as_const/as_const.fail.cpp @@ -0,0 +1,22 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template constexpr add_const& as_const(T& t) noexcept; // C++17 +// template add_const& as_const(const T&&) = delete; // C++17 + +#include + +struct S {int i;}; + +int main() +{ + std::as_const(S{}); +} diff --git a/test/std/utilities/utility/as_const/as_const.pass.cpp b/test/std/utilities/utility/as_const/as_const.pass.cpp new file mode 100644 index 000000000000..ff3f84a5532f --- /dev/null +++ b/test/std/utilities/utility/as_const/as_const.pass.cpp @@ -0,0 +1,46 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 + +// template constexpr add_const& as_const(T& t) noexcept; // C++17 +// template add_const& as_const(const T&&) = delete; // C++17 + +#include +#include + +struct S {int i;}; +bool operator==(const S& x, const S& y) { return x.i == y.i; } +bool operator==(const volatile S& x, const volatile S& y) { return x.i == y.i; } + +template +void test(T& t) +{ + static_assert(std::is_const::type>::value, ""); + static_assert(std::is_const(t))>::type>::value, ""); + static_assert(std::is_const(t))>::type>::value, ""); + static_assert(std::is_const(t))>::type>::value, ""); + static_assert(std::is_const(t))>::type>::value, ""); + + assert(std::as_const(t) == t); + assert(std::as_const< T>(t) == t); + assert(std::as_const(t) == t); + assert(std::as_const(t) == t); + assert(std::as_const(t) == t); +} + +int main() +{ + int i = 3; + double d = 4.0; + S s{2}; + test(i); + test(d); + test(s); +} diff --git a/test/std/utilities/utility/declval/declval.pass.cpp b/test/std/utilities/utility/declval/declval.pass.cpp index 81f4df8e8b2b..aabd0e6f6c74 100644 --- a/test/std/utilities/utility/declval/declval.pass.cpp +++ b/test/std/utilities/utility/declval/declval.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "test_macros.h" + class A { A(const A&); @@ -22,9 +24,9 @@ class A int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 static_assert((std::is_same()), A&&>::value), ""); #else - static_assert((std::is_same()), A>::value), ""); + static_assert((std::is_same()), A&>::value), ""); #endif } diff --git a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp index c8375e9d7238..bc60d3d27614 100644 --- a/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp +++ b/test/std/utilities/utility/forward/move_if_noexcept.pass.cpp @@ -56,13 +56,14 @@ int main() static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); #else // C++ < 11 - // libc++ defines decltype to be __typeof__ in C++03. __typeof__ does not - // deduce the reference qualifiers. - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); - static_assert((std::is_same::value), ""); + // In C++03 libc++ #define's decltype to be __decltype on clang and + // __typeof__ for other compilers. __typeof__ does not deduce the reference + // qualifiers and will cause this test to fail. + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); + static_assert((std::is_same::value), ""); #endif #if TEST_STD_VER > 11 diff --git a/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp new file mode 100644 index 000000000000..edd2f3d0752f --- /dev/null +++ b/test/std/utilities/utility/pairs/pair.astuple/get_const_rv.pass.cpp @@ -0,0 +1,66 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// template +// const typename tuple_element >::type&& +// get(const pair&&); + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include +#include + +#include "test_macros.h" + +int main() +{ + { + typedef std::pair, short> P; + const P p(std::unique_ptr(new int(3)), 4); + static_assert(std::is_same&&, decltype(std::get<0>(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(p))), ""); + const std::unique_ptr&& ptr = std::get<0>(std::move(p)); + assert(*ptr == 3); + } + + { + int x = 42; + int const y = 43; + std::pair const p(x, y); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(p))), ""); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<1>(std::move(p))), ""); + } + + { + int x = 42; + int const y = 43; + std::pair const p(std::move(x), std::move(y)); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<0>(std::move(p))), ""); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get<1>(std::move(p))), ""); + } + +#if TEST_STD_VER > 11 + { + typedef std::pair P; + constexpr const P p1(3, 4); + static_assert(std::get<0>(std::move(p1)) == 3, ""); + static_assert(std::get<1>(std::move(p1)) == 4, ""); + } +#endif +} diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp index 176d58330d16..efcc2cedc6e1 100644 --- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp +++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp @@ -7,15 +7,17 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 + #include #include +#include #include #include int main() { -#if _LIBCPP_STD_VER > 11 typedef std::complex cf; { auto t1 = std::make_pair ( 42, { 1,2 } ); @@ -23,7 +25,7 @@ int main() assert ( std::get(t1).real() == 1 ); assert ( std::get(t1).imag() == 2 ); } - + { const std::pair p1 { 1, 2 }; const int &i1 = std::get(p1); @@ -35,10 +37,48 @@ int main() { typedef std::unique_ptr upint; std::pair t(upint(new int(4)), 42); - upint p = std::get<0>(std::move(t)); // get rvalue + upint p = std::get(std::move(t)); // get rvalue assert(*p == 4); - assert(std::get<0>(t) == nullptr); // has been moved from + assert(std::get(t) == nullptr); // has been moved from } -#endif + { + typedef std::unique_ptr upint; + const std::pair t(upint(new int(4)), 42); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get(std::move(t))), ""); + static_assert(std::is_same(std::move(t)))>::value, ""); + static_assert(noexcept(std::get(std::move(t))), ""); + auto&& p = std::get(std::move(t)); // get const rvalue + auto&& i = std::get(std::move(t)); // get const rvalue + assert(*p == 4); + assert(i == 42); + assert(std::get(t) != nullptr); + } + + { + int x = 42; + int const y = 43; + std::pair const p(x, y); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get(std::move(p))), ""); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get(std::move(p))), ""); + } + + { + int x = 42; + int const y = 43; + std::pair const p(std::move(x), std::move(y)); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get(std::move(p))), ""); + static_assert(std::is_same(std::move(p)))>::value, ""); + static_assert(noexcept(std::get(std::move(p))), ""); + } + + { + constexpr const std::pair p { 1, 2 }; + static_assert(std::get(std::move(p)) == 1, ""); + static_assert(std::get(std::move(p)) == 2, ""); + } } diff --git a/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp new file mode 100644 index 000000000000..8f9fc669251a --- /dev/null +++ b/test/std/utilities/utility/pairs/pairs.pair/default-sfinae.pass.cpp @@ -0,0 +1,164 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// template struct pair + +// Test the SFINAE required by LWG Issue #2367. +// is_default_constructible + +// UNSUPPORTED: c++98, c++03 + +#include +#include +#include + +#include "test_macros.h" + +#if TEST_STD_VER > 11 +#define CONSTEXPR_CXX14 constexpr +#define STATIC_ASSERT_CXX14(Pred) static_assert(Pred, "") +#else +#define CONSTEXPR_CXX14 +#define STATIC_ASSERT_CXX14(Pred) assert(Pred) +#endif + +struct DeletedDefault { + // A class with a deleted default constructor. Used to test the SFINAE + // on std::pairs default constructor. + constexpr explicit DeletedDefault(int x) : value(x) {} + constexpr DeletedDefault() = delete; + int value; +}; + +template +struct DependantType: public Tp {}; + +template +using DependantIsDefault = DependantType, Val>; + +template +struct DefaultSFINAES { + template ::value + >::type + > + constexpr DefaultSFINAES() : value() {} + constexpr explicit DefaultSFINAES(T const& x) : value(x) {} + T value; +}; + +struct NoDefault { + constexpr NoDefault(int v) : value(v) {} + int value; +}; + +template +void test_not_is_default_constructible() +{ + { + typedef std::pair P; + static_assert(!std::is_default_constructible

::value, ""); + static_assert(std::is_constructible::value, ""); + } + { + typedef std::pair P; + static_assert(!std::is_default_constructible

::value, ""); + static_assert(std::is_constructible::value, ""); + } + { + typedef std::pair P; + static_assert(!std::is_default_constructible

::value, ""); + static_assert(std::is_constructible::value, ""); + } +} + +template +void test_is_default_constructible() +{ + { + typedef std::pair P; + static_assert(std::is_default_constructible

::value, ""); + } + { + typedef std::pair P; + static_assert(std::is_default_constructible

::value, ""); + } + { + typedef std::pair P; + static_assert(std::is_default_constructible

::value, ""); + } +} + +template +struct IllFormedDefaultImp { + constexpr explicit IllFormedDefaultImp(int v) : value(v) {} + constexpr IllFormedDefaultImp() : value(T::DoesNotExistAndShouldNotCompile) {} + int value; +}; + +typedef IllFormedDefaultImp IllFormedDefault; + // A class which provides a constexpr default constructor with a valid + // signature but an ill-formed body. The A compile error will be emitted if + // the default constructor is instantiated. + + +// Check that the SFINAE on the default constructor is not evaluated when +// it isn't needed. If the default constructor of 'IllFormedDefault' is evaluated +// in C++11, even with is_default_constructible, then this test should fail to +// compile. In C++14 and greater evaluate each test is evaluated as a constant +// expression. +// See LWG issue #2367 +void test_illformed_default() +{ + { + typedef std::pair P; + static_assert((std::is_constructible::value), ""); + CONSTEXPR_CXX14 P p(IllFormedDefault(42), -5); + STATIC_ASSERT_CXX14(p.first.value == 42 && p.second == -5); + } + { + typedef std::pair P; + static_assert((std::is_constructible::value), ""); + CONSTEXPR_CXX14 IllFormedDefault dd(-5); + CONSTEXPR_CXX14 P p(42, dd); + STATIC_ASSERT_CXX14(p.first == 42 && p.second.value == -5); + } + { + typedef std::pair P; + static_assert((std::is_constructible::value), ""); + CONSTEXPR_CXX14 P p(IllFormedDefault(42), IllFormedDefault(-5)); + STATIC_ASSERT_CXX14(p.first.value == 42 && p.second.value == -5); + } +} + + +int main() +{ + { + // Check that pair can still be used even if + // is_default_constructible or is_default_constructible cause + // a compilation error. + test_illformed_default(); + } + { + // pair::pair() is only disable in C++11 and beyond. + test_not_is_default_constructible(); + test_not_is_default_constructible(); + test_not_is_default_constructible>(); + test_not_is_default_constructible>(); + test_not_is_default_constructible(); + test_not_is_default_constructible(); + } + { + test_is_default_constructible(); + test_is_default_constructible>(); + } +} diff --git a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp index bb6661f7966c..d83328b8f2d0 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/default.pass.cpp @@ -13,9 +13,15 @@ // constexpr pair(); +// NOTE: The SFINAE on the default constructor is tested in +// default-sfinae.pass.cpp + #include +#include #include +#include "test_macros.h" + int main() { { @@ -24,13 +30,12 @@ int main() assert(p.first == 0.0f); assert(p.second == nullptr); } - -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 11 { - typedef std::pair P; - constexpr P p; - static_assert(p.first == 0.0f, ""); - static_assert(p.second == nullptr, ""); + typedef std::pair P; + constexpr P p; + static_assert(p.first == 0.0f, ""); + static_assert(p.second == nullptr, ""); } #endif } diff --git a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp index a912df00d7bb..0ad5786bce29 100644 --- a/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp +++ b/test/std/utilities/utility/pairs/pairs.pair/swap.pass.cpp @@ -16,6 +16,15 @@ #include #include +struct S { + int i; + S() : i(0) {} + S(int j) : i(j) {} + S * operator& () { assert(false); return this; } + S const * operator& () const { assert(false); return this; } + bool operator==(int x) const { return i == x; } + }; + int main() { { @@ -28,4 +37,14 @@ int main() assert(p2.first == 3); assert(p2.second == 4); } + { + typedef std::pair P1; + P1 p1(3, S(4)); + P1 p2(5, S(6)); + p1.swap(p2); + assert(p1.first == 5); + assert(p1.second == 6); + assert(p2.first == 3); + assert(p2.second == 4); + } } diff --git a/test/support/allocators.h b/test/support/allocators.h index b7aba12e21fd..7c2103ff2721 100644 --- a/test/support/allocators.h +++ b/test/support/allocators.h @@ -35,6 +35,8 @@ class A1 A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} A1(A1&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;} + A1& operator=(const A1& a) TEST_NOEXCEPT { id_ = a.id(); copy_called = true; return *this;} + A1& operator=(A1&& a) TEST_NOEXCEPT { id_ = a.id(); move_called = true; return *this;} template A1(const A1& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} @@ -96,6 +98,8 @@ class A2 A2(const A2& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} A2(A2&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;} + A2& operator=(const A2& a) TEST_NOEXCEPT { id_ = a.id(); copy_called = true; return *this;} + A2& operator=(A2&& a) TEST_NOEXCEPT { id_ = a.id(); move_called = true; return *this;} T* allocate(std::size_t n, const void* hint) { @@ -142,7 +146,9 @@ class A3 static bool destroy_called; A3(const A3& a) TEST_NOEXCEPT : id_(a.id()) {copy_called = true;} - A3(A3&& a) TEST_NOEXCEPT: id_(a.id()) {move_called = true;} + A3(A3&& a) TEST_NOEXCEPT : id_(a.id()) {move_called = true;} + A3& operator=(const A3& a) TEST_NOEXCEPT { id_ = a.id(); copy_called = true; return *this;} + A3& operator=(A3&& a) TEST_NOEXCEPT { id_ = a.id(); move_called = true; return *this;} template void construct(U* p, Args&& ...args) diff --git a/test/support/any_helpers.h b/test/support/any_helpers.h new file mode 100644 index 000000000000..76b1922fb1f1 --- /dev/null +++ b/test/support/any_helpers.h @@ -0,0 +1,318 @@ +#ifndef ANY_HELPERS_H +#define ANY_HELPERS_H + +#include +#include +#include +#include + +#include "test_macros.h" + +#if !defined(TEST_HAS_NO_RTTI) +#define RTTI_ASSERT(X) assert(X) +#else +#define RTTI_ASSERT(X) +#endif + +template + struct IsSmallObject + : public std::integral_constant::value + % std::alignment_of<_Tp>::value == 0 + && std::is_nothrow_move_constructible<_Tp>::value + > + {}; + + +// Return 'true' if 'Type' will be considered a small type by 'any' +template +bool isSmallType() { +#if defined(_LIBCPP_VERSION) + return std::experimental::__any_imp::_IsSmallObject::value; +#else + return IsSmallObject::value; +#endif + +} + +// Assert that an object is empty. If the object used to contain an object +// of type 'LastType' check that it can no longer be accessed. +template +void assertEmpty(std::experimental::any const& a) { + assert(a.empty()); + RTTI_ASSERT(a.type() == typeid(void)); + assert(std::experimental::any_cast(&a) == nullptr); +} + +// Assert that an 'any' object stores the specified 'Type' and 'value'. +template +void assertContains(std::experimental::any const& a, int value = 1) { + assert(!a.empty()); + RTTI_ASSERT(a.type() == typeid(Type)); + assert(std::experimental::any_cast(a).value == value); +} + +// Modify the value of a "test type" stored within an any to the specified +// 'value'. +template +void modifyValue(std::experimental::any& a, int value) { + assert(!a.empty()); + RTTI_ASSERT(a.type() == typeid(Type)); + std::experimental::any_cast(a).value = value; +} + +// A test type that will trigger the small object optimization within 'any'. +template +struct small_type +{ + static int count; + static int copied; + static int moved; + static int const_copied; + static int non_const_copied; + + static void reset() { + small_type::copied = 0; + small_type::moved = 0; + small_type::const_copied = 0; + small_type::non_const_copied = 0; + } + + int value; + + explicit small_type(int val) : value(val) { + ++count; + } + + small_type(small_type const & other) throw() { + value = other.value; + ++count; + ++copied; + ++const_copied; + } + + small_type(small_type& other) throw() { + value = other.value; + ++count; + ++copied; + ++non_const_copied; + } + + small_type(small_type && other) throw() { + value = other.value; + other.value = 0; + ++count; + ++moved; + } + + ~small_type() { + value = -1; + --count; + } + +private: + small_type& operator=(small_type const&) = delete; + small_type& operator=(small_type&&) = delete; +}; + +template +int small_type::count = 0; + +template +int small_type::copied = 0; + +template +int small_type::moved = 0; + +template +int small_type::const_copied = 0; + +template +int small_type::non_const_copied = 0; + +typedef small_type<> small; +typedef small_type<1> small1; +typedef small_type<2> small2; + + +// A test type that will NOT trigger the small object optimization in any. +template +struct large_type +{ + static int count; + static int copied; + static int moved; + static int const_copied; + static int non_const_copied; + + static void reset() { + large_type::copied = 0; + large_type::moved = 0; + large_type::const_copied = 0; + large_type::non_const_copied = 0; + } + + int value; + + large_type(int val) : value(val) { + ++count; + data[0] = 0; + } + + large_type(large_type const & other) { + value = other.value; + ++count; + ++copied; + ++const_copied; + } + + large_type(large_type & other) { + value = other.value; + ++count; + ++copied; + ++non_const_copied; + } + + large_type(large_type && other) { + value = other.value; + other.value = 0; + ++count; + ++moved; + } + + ~large_type() { + value = 0; + --count; + } + +private: + large_type& operator=(large_type const&) = delete; + large_type& operator=(large_type &&) = delete; + int data[10]; +}; + +template +int large_type::count = 0; + +template +int large_type::copied = 0; + +template +int large_type::moved = 0; + +template +int large_type::const_copied = 0; + +template +int large_type::non_const_copied = 0; + +typedef large_type<> large; +typedef large_type<1> large1; +typedef large_type<2> large2; + +// The exception type thrown by 'small_throws_on_copy', 'large_throws_on_copy' +// and 'throws_on_move'. +struct my_any_exception {}; + +void throwMyAnyExpression() { +#if !defined(TEST_HAS_NO_EXCEPTIONS) + throw my_any_exception(); +#else + assert(false && "Exceptions are disabled"); +#endif +} + +// A test type that will trigger the small object optimization within 'any'. +// this type throws if it is copied. +struct small_throws_on_copy +{ + static int count; + int value; + + explicit small_throws_on_copy(int val = 0) : value(val) { + ++count; + } + + small_throws_on_copy(small_throws_on_copy const &) { + throwMyAnyExpression(); + } + + small_throws_on_copy(small_throws_on_copy && other) throw() { + value = other.value; + ++count; + } + + ~small_throws_on_copy() { + --count; + } +private: + small_throws_on_copy& operator=(small_throws_on_copy const&) = delete; + small_throws_on_copy& operator=(small_throws_on_copy &&) = delete; +}; + +int small_throws_on_copy::count = 0; + +// A test type that will NOT trigger the small object optimization within 'any'. +// this type throws if it is copied. +struct large_throws_on_copy +{ + static int count; + int value = 0; + + explicit large_throws_on_copy(int val = 0) : value(val) { + data[0] = 0; + ++count; + } + + large_throws_on_copy(large_throws_on_copy const &) { + throwMyAnyExpression(); + } + + large_throws_on_copy(large_throws_on_copy && other) throw() { + value = other.value; + ++count; + } + + ~large_throws_on_copy() { + --count; + } + +private: + large_throws_on_copy& operator=(large_throws_on_copy const&) = delete; + large_throws_on_copy& operator=(large_throws_on_copy &&) = delete; + int data[10]; +}; + +int large_throws_on_copy::count = 0; + +// A test type that throws when it is moved. This object will NOT trigger +// the small object optimization in 'any'. +struct throws_on_move +{ + static int count; + int value; + + explicit throws_on_move(int val = 0) : value(val) { ++count; } + + throws_on_move(throws_on_move const & other) { + value = other.value; + ++count; + } + + throws_on_move(throws_on_move &&) { + throwMyAnyExpression(); + } + + ~throws_on_move() { + --count; + } +private: + throws_on_move& operator=(throws_on_move const&) = delete; + throws_on_move& operator=(throws_on_move &&) = delete; +}; + +int throws_on_move::count = 0; + + +#endif diff --git a/test/support/count_new.hpp b/test/support/count_new.hpp index ddaf036f7d16..57aca7def335 100644 --- a/test/support/count_new.hpp +++ b/test/support/count_new.hpp @@ -30,6 +30,10 @@ class MemCounter // All checks return true when disable_checking is enabled. static const bool disable_checking; + // Disallow any allocations from occurring. Useful for testing that + // code doesn't perform any allocations. + bool disable_allocations; + int outstanding_new; int new_called; int delete_called; @@ -43,6 +47,7 @@ class MemCounter public: void newCalled(std::size_t s) { + assert(disable_allocations == false); assert(s); ++new_called; ++outstanding_new; @@ -58,6 +63,7 @@ class MemCounter void newArrayCalled(std::size_t s) { + assert(disable_allocations == false); assert(s); ++outstanding_array_new; ++new_array_called; @@ -71,8 +77,20 @@ class MemCounter ++delete_array_called; } + void disableAllocations() + { + disable_allocations = true; + } + + void enableAllocations() + { + disable_allocations = false; + } + void reset() { + disable_allocations = false; + outstanding_new = 0; new_called = 0; delete_called = 0; @@ -203,4 +221,29 @@ void operator delete[](void* p) throw() #endif // DISABLE_NEW_COUNT + +struct DisableAllocationGuard { + explicit DisableAllocationGuard(bool disable = true) : m_disabled(disable) + { + // Don't re-disable if already disabled. + if (globalMemCounter.disable_allocations == true) m_disabled = false; + if (m_disabled) globalMemCounter.disableAllocations(); + } + + void release() { + if (m_disabled) globalMemCounter.enableAllocations(); + m_disabled = false; + } + + ~DisableAllocationGuard() { + release(); + } + +private: + bool m_disabled; + + DisableAllocationGuard(DisableAllocationGuard const&); + DisableAllocationGuard& operator=(DisableAllocationGuard const&); +}; + #endif /* COUNT_NEW_HPP */ diff --git a/test/support/disable_missing_braces_warning.h b/test/support/disable_missing_braces_warning.h new file mode 100644 index 000000000000..967a87ab3a2e --- /dev/null +++ b/test/support/disable_missing_braces_warning.h @@ -0,0 +1,8 @@ +#ifndef SUPPORT_DISABLE_MISSING_BRACES_WARNING_H +#define SUPPORT_DISABLE_MISSING_BRACES_WARNING_H + +// std::array is explicitly allowed to be initialized with A a = { init-list };. +// Disable the missing braces warning for this reason. +#pragma GCC diagnostic ignored "-Wmissing-braces" + +#endif // SUPPORT_DISABLE_MISSING_BRACES_WARNING_H diff --git a/test/support/test_allocator.h b/test/support/test_allocator.h index 47ef1d556784..3ca672f89a9b 100644 --- a/test/support/test_allocator.h +++ b/test/support/test_allocator.h @@ -171,13 +171,13 @@ class test_allocator template struct rebind {typedef test_allocator other;}; - test_allocator() throw() : data_(-1) {} + test_allocator() throw() : data_(0) {} explicit test_allocator(int i) throw() : data_(i) {} test_allocator(const test_allocator& a) throw() : data_(a.data_) {} template test_allocator(const test_allocator& a) throw() : data_(a.data_) {} - ~test_allocator() throw() {data_ = 0;} + ~test_allocator() throw() {data_ = -1;} friend bool operator==(const test_allocator& x, const test_allocator& y) {return x.data_ == y.data_;} diff --git a/test/support/test_macros.h b/test/support/test_macros.h index a08ca87be935..c34e8cf7ef14 100644 --- a/test/support/test_macros.h +++ b/test/support/test_macros.h @@ -14,12 +14,24 @@ #define TEST_CONCAT1(X, Y) X##Y #define TEST_CONCAT(X, Y) TEST_CONCAT1(X, Y) +#ifdef __has_feature +#define TEST_HAS_FEATURE(X) __has_feature(X) +#else +#define TEST_HAS_FEATURE(X) 0 +#endif + #ifdef __has_extension #define TEST_HAS_EXTENSION(X) __has_extension(X) #else #define TEST_HAS_EXTENSION(X) 0 #endif +#ifdef __has_builtin +#define TEST_HAS_BUILTIN(X) __has_builtin(X) +#else +#define TEST_HAS_BUILTIN(X) 0 +#endif + /* Make a nice name for the standard version */ #if __cplusplus <= 199711L # define TEST_STD_VER 3 @@ -56,8 +68,10 @@ #endif #if TEST_STD_VER >= 11 +#define TEST_CONSTEXPR constexpr #define TEST_NOEXCEPT noexcept #else +#define TEST_CONSTEXPR #define TEST_NOEXCEPT #endif @@ -80,4 +94,17 @@ template struct static_assert_check {}; } // end namespace test_detail +#if !TEST_HAS_FEATURE(cxx_rtti) && !defined(__cxx_rtti) +#define TEST_HAS_NO_RTTI +#endif + +#if !TEST_HAS_FEATURE(cxx_exceptions) && !defined(__cxx_exceptions) +#define TEST_HAS_NO_EXCEPTIONS +#endif + +#if TEST_HAS_FEATURE(address_sanitizer) || TEST_HAS_FEATURE(memory_sanitizer) || \ + TEST_HAS_FEATURE(thread_sanitizer) +#define TEST_HAS_SANITIZERS +#endif + #endif // SUPPORT_TEST_MACROS_HPP diff --git a/test/testit b/test/testit index 821292efb5a3..cac668497fa5 100755 --- a/test/testit +++ b/test/testit @@ -42,7 +42,7 @@ then fi if [ -z "$OPTIONS" ] then - OPTIONS="-std=${CXX_LANG} -stdlib=libc++" + OPTIONS="-std=${CXX_LANG} -stdlib=libc++ -nostdinc++" fi OPTIONS="$OPTIONS -I$LIBCXX_ROOT/test/support" diff --git a/utils/gen_link_script/gen_link_script.py b/utils/gen_link_script/gen_link_script.py new file mode 100755 index 000000000000..5de18f9129c6 --- /dev/null +++ b/utils/gen_link_script/gen_link_script.py @@ -0,0 +1,79 @@ +#!/usr/bin/env python +import os +import sys + +def print_and_exit(msg): + sys.stderr.write(msg + '\n') + sys.exit(1) + +def usage_and_exit(): + print_and_exit("Usage: ./gen_link_script.py [--help] [--dryrun] ") + +def help_and_exit(): + help_msg = \ +"""Usage + + gen_link_script.py [--help] [--dryrun] + + Generate a linker script that links libc++ to the proper ABI library. + The script replaces the specified libc++ symlink. + An example script for c++abi would look like "INPUT(libc++.so.1 -lc++abi)". + +Arguments + - The top level symlink to the versioned libc++ shared + library. This file is replaced with a linker script. + - The name of the ABI library to use in the linker script. + The name must be one of [c++abi, stdc++, supc++, cxxrt]. + +Exit Status: + 0 if OK, + 1 if the action failed. +""" + print_and_exit(help_msg) + +def parse_args(): + args = list(sys.argv) + del args[0] + if len(args) == 0: + usage_and_exit() + if args[0] == '--help': + help_and_exit() + dryrun = '--dryrun' == args[0] + if dryrun: + del args[0] + if len(args) != 2: + usage_and_exit() + symlink_file = args[0] + abi_libname = args[1] + return dryrun, symlink_file, abi_libname + +def main(): + dryrun, symlink_file, abi_libname = parse_args() + + # Check that the given libc++.so file is a valid symlink. + if not os.path.islink(symlink_file): + print_and_exit("symlink file %s is not a symlink" % symlink_file) + + # Read the symlink so we know what libc++ to link to in the linker script. + linked_libcxx = os.readlink(symlink_file) + + # Check that the abi_libname is one of the supported values. + supported_abi_list = ['c++abi', 'stdc++', 'supc++', 'cxxrt'] + if abi_libname not in supported_abi_list: + print_and_exit("abi name '%s' is not supported: Use one of %r" % + (abi_libname, supported_abi_list)) + + # Generate the linker script contents and print the script and destination + # information. + contents = "INPUT(%s -l%s)" % (linked_libcxx, abi_libname) + print("GENERATING SCRIPT: '%s' as file %s" % (contents, symlink_file)) + + # Remove the existing libc++ symlink and replace it with the script. + if not dryrun: + os.unlink(symlink_file) + with open(symlink_file, 'w') as f: + f.write(contents + "\n") + + +if __name__ == '__main__': + main() diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html index 2b9c05ae1e2f..f28d67a7dd3e 100644 --- a/www/cxx1y_status.html +++ b/www/cxx1y_status.html @@ -109,165 +109,165 @@ - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Issue #Issue NameMeetingStatus
1214Insufficient/inconsistent key immutability requirements for associative containersKonaComplete
2009Reporting out-of-bound values on numeric string conversionsKonaComplete
2010is_* traits for binding operations can't be meaningfully specializedKonaComplete
2015Incorrect pre-conditions for some type traitsKonaComplete
2021Further incorrect usages of result_ofKonaComplete
2028messages_base::catalog overspecifiedKonaComplete
2033Preconditions of reserve, shrink_to_fit, and resize functionsKonaComplete
2039Issues with std::reverse and std::copy_ifKonaComplete
2044No definition of "Stable" for copy algorithmsKonaComplete
2045forward_list::merge and forward_list::splice_after with unequal allocatorsKonaComplete
2047Incorrect "mixed" move-assignment semantics of unique_ptrKonaComplete
2050Unordered associative containers do not use allocator_traits to define member typesKonaComplete
2053Errors in regex bitmask typesKonaComplete
2061make_move_iterator and arraysKonaComplete
2064More noexcept issues in basic_stringKonaComplete
2065Minimal allocator interfaceKonaComplete
2067packaged_task should have deleted copy c'tor with const parameterKonaComplete
2069Inconsistent exception spec for basic_string move constructorKonaComplete
2096Incorrect constraints of future::get in regard to MoveAssignableKonaComplete
2102Why is std::launch an implementation-defined type?KonaComplete
1214Insufficient/inconsistent key immutability requirements for associative containersKonaComplete
2009Reporting out-of-bound values on numeric string conversionsKonaComplete
2010is_* traits for binding operations can't be meaningfully specializedKonaComplete
2015Incorrect pre-conditions for some type traitsKonaComplete
2021Further incorrect usages of result_ofKonaComplete
2028messages_base::catalog overspecifiedKonaComplete
2033Preconditions of reserve, shrink_to_fit, and resize functionsKonaComplete
2039Issues with std::reverse and std::copy_ifKonaComplete
2044No definition of "Stable" for copy algorithmsKonaComplete
2045forward_list::merge and forward_list::splice_after with unequal allocatorsKonaComplete
2047Incorrect "mixed" move-assignment semantics of unique_ptrKonaComplete
2050Unordered associative containers do not use allocator_traits to define member typesKonaComplete
2053Errors in regex bitmask typesKonaComplete
2061make_move_iterator and arraysKonaComplete
2064More noexcept issues in basic_stringKonaComplete
2065Minimal allocator interfaceKonaComplete
2067packaged_task should have deleted copy c'tor with const parameterKonaComplete
2069Inconsistent exception spec for basic_string move constructorKonaComplete
2096Incorrect constraints of future::get in regard to MoveAssignableKonaComplete
2102Why is std::launch an implementation-defined type?KonaComplete
2071std::valarray move-assignmentPortlandComplete
2074Off by one error in std::reverse_copyPortlandComplete
2081Allocator requirements should include CopyConstructiblePortlandComplete
2083const-qualification on weak_ptr::owner_beforePortlandComplete
2086Overly generic type support for math functionsPortlandComplete
2099Unnecessary constraints of va_start() usagePortlandComplete
2103std::allocator_traits<std::allocator<T>>::propagate_on_container_move_assignmentPortlandComplete
2105Inconsistent requirements on const_iterator's value_typePortlandComplete
2110remove can't swap but note says it mightPortlandComplete
2123merge() allocator requirements for lists versus forward listsPortlandComplete
2005unordered_map::insert(T&&) protection should apply to map tooPortlandComplete
2011Unexpected output required of stringsPortlandComplete
2048Unnecessary mem_fn overloadsPortlandComplete
2049is_destructible is underspecifiedPortlandComplete
2056future_errc enums start with value 0 (invalid value for broken_promise)PortlandComplete
2058valarray and begin/endPortlandComplete
2071std::valarray move-assignmentPortlandComplete
2074Off by one error in std::reverse_copyPortlandComplete
2081Allocator requirements should include CopyConstructiblePortlandComplete
2083const-qualification on weak_ptr::owner_beforePortlandComplete
2086Overly generic type support for math functionsPortlandComplete
2099Unnecessary constraints of va_start() usagePortlandComplete
2103std::allocator_traits<std::allocator<T>>::propagate_on_container_move_assignmentPortlandComplete
2105Inconsistent requirements on const_iterator's value_typePortlandComplete
2110remove can't swap but note says it mightPortlandComplete
2123merge() allocator requirements for lists versus forward listsPortlandComplete
2005unordered_map::insert(T&&) protection should apply to map tooPortlandComplete
2011Unexpected output required of stringsPortlandComplete
2048Unnecessary mem_fn overloadsPortlandComplete
2049is_destructible is underspecifiedPortlandComplete
2056future_errc enums start with value 0 (invalid value for broken_promise)PortlandComplete
2058valarray and begin/endPortlandComplete
2091Misplaced effect in m.try_lock_for()BristolComplete
2092Vague Wording for condition_variable_anyBristolComplete
2093Throws clause of condition_variable::wait with predicateBristolComplete
2094duration conversion overflow shouldn't participate in overload resolutionBristolComplete
2122merge() stability for lists versus forward listsBristolComplete
2128Absence of global functions cbegin/cendBristolComplete
2145error_category default constructorBristolComplete
2147Unclear hint type in Allocator's allocate functionBristolComplete
2148Hashing enums should be supported directly by std::hashBristolComplete
2149Concerns about 20.8/5BristolComplete
2162allocator_traits::max_size missing noexceptBristolComplete
2163nth_element requires inconsistent post-conditionsBristolComplete
2169Missing reset() requirements in unique_ptr specializationBristolComplete
2172Does atomic_compare_exchange_* accept v == nullptr arguments?BristolComplete
2080Specify when once_flag becomes invalidBristolComplete
2098promise throws clausesBristolComplete
2109Incorrect requirements for hash specializationsBristolComplete
2130missing ordering constraints for fencesBristolComplete
2138atomic_flag::clear ordering constraintsBristolComplete
2140notify_all_at_thread_exit synchronizationBristolComplete
2144Missing noexcept specification in type_indexBristolComplete
2174wstring_convert::converted() should be noexceptBristolComplete
2175string_convert and wbuffer_convert validityBristolComplete
2176Special members for wstring_convert and wbuffer_convertBristolComplete
2177Requirements on Copy/MoveInsertableBristolComplete
2185Missing throws clause for future/shared_future::wait_for/wait_untilBristolComplete
2187vector<bool> is missing emplace and emplace_back member functionsBristolComplete
2190ordering of condition variable operations, reflects Posix discussionBristolComplete
2196Specification of is_*[copy/move]_[constructible/assignable] unclear for non-referencable typesBristolComplete
2197Specification of is_[un]signed unclear for non-arithmetic typesBristolComplete
2200Data race avoidance for all containers, not only for sequencesBristolComplete
2203scoped_allocator_adaptor uses wrong argument types for piecewise constructionBristolComplete
2207basic_string::at should not have a Requires clauseBristolComplete
2209assign() overspecified for sequence containersBristolComplete
2210Missing allocator-extended constructor for allocator-aware containersBristolComplete
2211Replace ambiguous use of "Allocator" in container requirementsBristolComplete
2222Inconsistency in description of forward_list::splice_after single-element overloadBristolComplete
2225Unrealistic header inclusion checks requiredBristolComplete
2229Standard code conversion facets underspecifiedBristolComplete
2231DR 704 removes complexity guarantee for clear()BristolComplete
2235Undefined behavior without proper requirements on basic_string constructorsBristolComplete
2091Misplaced effect in m.try_lock_for()BristolComplete
2092Vague Wording for condition_variable_anyBristolComplete
2093Throws clause of condition_variable::wait with predicateBristolComplete
2094duration conversion overflow shouldn't participate in overload resolutionBristolComplete
2122merge() stability for lists versus forward listsBristolComplete
2128Absence of global functions cbegin/cendBristolComplete
2145error_category default constructorBristolComplete
2147Unclear hint type in Allocator's allocate functionBristolComplete
2148Hashing enums should be supported directly by std::hashBristolComplete
2149Concerns about 20.8/5BristolComplete
2162allocator_traits::max_size missing noexceptBristolComplete
2163nth_element requires inconsistent post-conditionsBristolComplete
2169Missing reset() requirements in unique_ptr specializationBristolComplete
2172Does atomic_compare_exchange_* accept v == nullptr arguments?BristolComplete
2080Specify when once_flag becomes invalidBristolComplete
2098promise throws clausesBristolComplete
2109Incorrect requirements for hash specializationsBristolComplete
2130missing ordering constraints for fencesBristolComplete
2138atomic_flag::clear ordering constraintsBristolComplete
2140notify_all_at_thread_exit synchronizationBristolComplete
2144Missing noexcept specification in type_indexBristolComplete
2174wstring_convert::converted() should be noexceptBristolComplete
2175string_convert and wbuffer_convert validityBristolComplete
2176Special members for wstring_convert and wbuffer_convertBristolComplete
2177Requirements on Copy/MoveInsertableBristolComplete
2185Missing throws clause for future/shared_future::wait_for/wait_untilBristolComplete
2187vector<bool> is missing emplace and emplace_back member functionsBristolComplete
2190ordering of condition variable operations, reflects Posix discussionBristolComplete
2196Specification of is_*[copy/move]_[constructible/assignable] unclear for non-referencable typesBristolComplete
2197Specification of is_[un]signed unclear for non-arithmetic typesBristolComplete
2200Data race avoidance for all containers, not only for sequencesBristolComplete
2203scoped_allocator_adaptor uses wrong argument types for piecewise constructionBristolComplete
2207basic_string::at should not have a Requires clauseBristolComplete
2209assign() overspecified for sequence containersBristolComplete
2210Missing allocator-extended constructor for allocator-aware containersBristolComplete
2211Replace ambiguous use of "Allocator" in container requirementsBristolComplete
2222Inconsistency in description of forward_list::splice_after single-element overloadBristolComplete
2225Unrealistic header inclusion checks requiredBristolComplete
2229Standard code conversion facets underspecifiedBristolComplete
2231DR 704 removes complexity guarantee for clear()BristolComplete
2235Undefined behavior without proper requirements on basic_string constructorsBristolComplete
2141common_type trait produces reference typesChicagoComplete
2246unique_ptr assignment effects w.r.t. deleterChicagoComplete
2247Type traits and std::nullptr_tChicagoComplete
2085Wrong description of effect 1 of basic_istream::ignoreChicagoComplete
2087iostream_category() and noexceptChicagoComplete
2143ios_base::xalloc should be thread-safeChicagoComplete
2150Unclear specification of find_endChicagoComplete
2180Exceptions from std::seed_seq operationsChicagoComplete
2194Impossible container requirements for adaptor typesChicagoComplete
2013Do library implementers have the freedom to add constexpr?ChicagoComplete
2018regex_traits::isctype Returns clause is wrongChicagoComplete
2078Throw specification of async() incompleteChicagoComplete
2097packaged_task constructors should be constrainedChicagoComplete
2100Timed waiting functions cannot timeout if launch::async policy usedChicagoComplete
2120What should async do if neither 'async' nor 'deferred' is set in policy?ChicagoComplete
2159atomic_flag initializationChicagoComplete
2275Why is forward_as_tuple not constexpr?ChicagoComplete
2284Inconsistency in allocator_traits::max_sizeChicagoComplete
2298is_nothrow_constructible is always false because of create<>ChicagoComplete
2300Redundant sections for map and multimap members should be removedChicagoComplete
2141common_type trait produces reference typesChicagoComplete
2246unique_ptr assignment effects w.r.t. deleterChicagoComplete
2247Type traits and std::nullptr_tChicagoComplete
2085Wrong description of effect 1 of basic_istream::ignoreChicagoComplete
2087iostream_category() and noexceptChicagoComplete
2143ios_base::xalloc should be thread-safeChicagoComplete
2150Unclear specification of find_endChicagoComplete
2180Exceptions from std::seed_seq operationsChicagoComplete
2194Impossible container requirements for adaptor typesChicagoComplete
2013Do library implementers have the freedom to add constexpr?ChicagoComplete
2018regex_traits::isctype Returns clause is wrongChicagoComplete
2078Throw specification of async() incompleteChicagoComplete
2097packaged_task constructors should be constrainedChicagoComplete
2100Timed waiting functions cannot timeout if launch::async policy usedChicagoComplete
2120What should async do if neither 'async' nor 'deferred' is set in policy?ChicagoComplete
2159atomic_flag initializationChicagoComplete
2275Why is forward_as_tuple not constexpr?ChicagoComplete
2284Inconsistency in allocator_traits::max_sizeChicagoComplete
2298is_nothrow_constructible is always false because of create<>ChicagoComplete
2300Redundant sections for map and multimap members should be removedChicagoComplete
NB comment: GB9 Remove gets from C++14ChicagoComplete
2135Unclear requirement for exceptions thrown in condition_variable::wait()IssaquahComplete
2291std::hash is vulnerable to collision DoS attackIssaquahComplete
2142packaged_task::operator() synchronization too broad?IssaquahComplete
2240Probable misuse of term "function scope" in [thread.condition]IssaquahComplete
2252Strong guarantee on vector::push_back() still broken with C++11?IssaquahComplete
2257Simplify container requirements with the new algorithmsIssaquahComplete
2268Setting a default argument in the declaration of a member function assign of std::basic_stringIssaquahComplete
2271regex_traits::lookup_classname specification unclearIssaquahComplete
2272quoted should use char_traits::eq for character comparisonIssaquahComplete
2278User-defined literals for Standard Library typesIssaquahComplete
2280begin / end for arrays should be constexpr and noexceptIssaquahComplete
2285make_reverse_iteratorIssaquahComplete
2135Unclear requirement for exceptions thrown in condition_variable::wait()IssaquahComplete
2291std::hash is vulnerable to collision DoS attackIssaquahComplete
2142packaged_task::operator() synchronization too broad?IssaquahComplete
2240Probable misuse of term "function scope" in [thread.condition]IssaquahComplete
2252Strong guarantee on vector::push_back() still broken with C++11?IssaquahComplete
2257Simplify container requirements with the new algorithmsIssaquahComplete
2268Setting a default argument in the declaration of a member function assign of std::basic_stringIssaquahComplete
2271regex_traits::lookup_classname specification unclearIssaquahComplete
2272quoted should use char_traits::eq for character comparisonIssaquahComplete
2278User-defined literals for Standard Library typesIssaquahComplete
2280begin / end for arrays should be constexpr and noexceptIssaquahComplete
2285make_reverse_iteratorIssaquahComplete
2299Effects of inaccessible key_compare::is_transparent type are not clearIssaquahComplete
2299Effects of inaccessible key_compare::is_transparent type are not clearIssaquahComplete
1450Contradiction in regex_constantsIssaquahComplete
2003String exception inconsistency in erase.IssaquahComplete
2112User-defined classes that cannot be derived fromIssaquahComplete
2132std::function ambiguityIssaquahComplete
2182Container::[const_]reference types are misleadingly specifiedIssaquahComplete
2188Reverse iterator does not fully support targets that overload operator&IssaquahComplete
2193Default constructors for standard library containers are explicitIssaquahComplete
2205Problematic postconditions of regex_match and regex_searchIssaquahComplete
2213Return value of std::regex_replaceIssaquahComplete
1450Contradiction in regex_constantsIssaquahComplete
2003String exception inconsistency in erase.IssaquahComplete
2112User-defined classes that cannot be derived fromIssaquahComplete
2132std::function ambiguityIssaquahComplete
2182Container::[const_]reference types are misleadingly specifiedIssaquahComplete
2188Reverse iterator does not fully support targets that overload operator&IssaquahComplete
2193Default constructors for standard library containers are explicitIssaquahComplete
2205Problematic postconditions of regex_match and regex_searchIssaquahComplete
2213Return value of std::regex_replaceIssaquahComplete
2258a.erase(q1, q2) unable to directly return q2IssaquahComplete
2263Comparing iterators and allocator pointers with different const-characterIssaquahComplete
2293Wrong facet used by num_put::do_putIssaquahComplete
2301Why is std::tie not constexpr?IssaquahComplete
2304Complexity of count in unordered associative containersIssaquahComplete
2306match_results::reference should be value_type&, not const value_type&IssaquahComplete
2308Clarify container destructor requirements w.r.t. std::arrayIssaquahComplete
2313tuple_size should always derive from integral_constantIssaquahComplete
2314apply() should return decltype(auto) and use decay_t before tuple_sizeIssaquahComplete
2315weak_ptr should be movableIssaquahComplete
2316weak_ptr::lock() should be atomicIssaquahComplete
2317The type property queries should be UnaryTypeTraits returning size_tIssaquahComplete
2320select_on_container_copy_construction() takes allocators, not containersIssaquahComplete
2322Associative(initializer_list, stuff) constructors are underspecifiedIssaquahComplete
2323vector::resize(n, t)'s specification should be simplifiedIssaquahComplete
2324Insert iterator constructors should use addressof()IssaquahComplete
2329regex_match()/regex_search() with match_results should forbid temporary stringsIssaquahComplete
2330regex("meow", regex::icase) is technically forbidden but should be permittedIssaquahComplete
2332regex_iterator/regex_token_iterator should forbid temporary regexesIssaquahComplete
2339Wording issue in nth_elementIssaquahComplete
2341Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir)IssaquahComplete
2344quoted()'s interaction with padding is unclearIssaquahComplete
2346integral_constant's member functions should be marked noexceptIssaquahComplete
2350min, max, and minmax should be constexprIssaquahComplete
2356Stability of erasure in unordered associative containersIssaquahComplete
2357Remaining "Assignable" requirementIssaquahComplete
2359How does regex_constants::nosubs affect basic_regex::mark_count()?IssaquahComplete
2360reverse_iterator::operator*() is unimplementableIssaquahComplete
2104unique_lock move-assignment should not be noexceptIssaquahComplete
2186Incomplete action on async/launch::deferredIssaquahComplete
2075Progress guarantees, lock-free property, and scheduling assumptionsIssaquahComplete
2288Inconsistent requirements for shared mutexesIssaquahComplete
2258a.erase(q1, q2) unable to directly return q2IssaquahComplete
2263Comparing iterators and allocator pointers with different const-characterIssaquahComplete
2293Wrong facet used by num_put::do_putIssaquahComplete
2301Why is std::tie not constexpr?IssaquahComplete
2304Complexity of count in unordered associative containersIssaquahComplete
2306match_results::reference should be value_type&, not const value_type&IssaquahComplete
2308Clarify container destructor requirements w.r.t. std::arrayIssaquahComplete
2313tuple_size should always derive from integral_constantIssaquahComplete
2314apply() should return decltype(auto) and use decay_t before tuple_sizeIssaquahComplete
2315weak_ptr should be movableIssaquahComplete
2316weak_ptr::lock() should be atomicIssaquahComplete
2317The type property queries should be UnaryTypeTraits returning size_tIssaquahComplete
2320select_on_container_copy_construction() takes allocators, not containersIssaquahComplete
2322Associative(initializer_list, stuff) constructors are underspecifiedIssaquahComplete
2323vector::resize(n, t)'s specification should be simplifiedIssaquahComplete
2324Insert iterator constructors should use addressof()IssaquahComplete
2329regex_match()/regex_search() with match_results should forbid temporary stringsIssaquahComplete
2330regex("meow", regex::icase) is technically forbidden but should be permittedIssaquahComplete
2332regex_iterator/regex_token_iterator should forbid temporary regexesIssaquahComplete
2339Wording issue in nth_elementIssaquahComplete
2341Inconsistency between basic_ostream::seekp(pos) and basic_ostream::seekp(off, dir)IssaquahComplete
2344quoted()'s interaction with padding is unclearIssaquahComplete
2346integral_constant's member functions should be marked noexceptIssaquahComplete
2350min, max, and minmax should be constexprIssaquahComplete
2356Stability of erasure in unordered associative containersIssaquahComplete
2357Remaining "Assignable" requirementIssaquahComplete
2359How does regex_constants::nosubs affect basic_regex::mark_count()?IssaquahComplete
2360reverse_iterator::operator*() is unimplementableIssaquahComplete
2104unique_lock move-assignment should not be noexceptIssaquahComplete
2186Incomplete action on async/launch::deferredIssaquahComplete
2075Progress guarantees, lock-free property, and scheduling assumptionsIssaquahComplete
2288Inconsistent requirements for shared mutexesIssaquahComplete
diff --git a/www/cxx1z_status.html b/www/cxx1z_status.html index 436981087d82..42bc3d76032a 100644 --- a/www/cxx1z_status.html +++ b/www/cxx1z_status.html @@ -69,6 +69,14 @@
N4508LWGshared_mutex for C++17LenexaComplete3.7 N4366LWGLWG 2228 missing SFINAE ruleLenexaComplete3.1 N4510LWGMinimal incomplete type support for standard containers, revision 4LenexaComplete3.6 + + P0004R1LWGRemove Deprecated iostreams aliases.KonaComplete3.8 + P0006R0LWGAdopt Type Traits Variable Templates for C++17.KonaComplete3.8 + P0092R1LWGPolishing <chrono>KonaComplete3.8 + P0007R1LWGConstant View: A proposal for a std::as_const helper function template.KonaComplete3.8 + P0156R0LWGVariadic lock_guard(rev 3).Kona + P0074R0LWGMaking std::owner_less more flexibleKonaComplete3.8 + P0013R1LWGLogical type traits rev 2KonaComplete3.8 @@ -76,76 +84,115 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Issue #Issue NameMeetingStatus
2016Allocators must be no-throw swappableUrbana
2118unique_ptr for array does not support cv qualification conversion of actual argumentUrbanaWill be resolved by N4089
2170Aggregates cannot be DefaultConstructibleUrbanaComplete
2308Clarify container destructor requirements w.r.t. std::arrayUrbanaComplete
2340Replacement allocation functions declared as inlineUrbanaComplete
2354Unnecessary copying when inserting into maps with braced-init syntaxUrbana
2377std::align requirements overly strictUrbanaComplete
2396underlying_type doesn't say what to do for an incomplete enumeration typeUrbanaComplete
2399shared_ptr's constructor from unique_ptr should be constrainedUrbanaComplete
2400shared_ptr's get_deleter() should use addressof()UrbanaComplete
2401std::function needs more noexceptUrbanaComplete
2404mismatch()'s complexity needs to be updatedUrbanaComplete
2408SFINAE-friendly common_type / iterator_traits is missing in C++14Urbanacommon_type is waiting on LWG#2465
2016Allocators must be no-throw swappableUrbana
2118unique_ptr for array does not support cv qualification conversion of actual argumentUrbanaWill be resolved by N4089
2170Aggregates cannot be DefaultConstructibleUrbanaComplete
2308Clarify container destructor requirements w.r.t. std::arrayUrbanaComplete
2340Replacement allocation functions declared as inlineUrbanaComplete
2354Unnecessary copying when inserting into maps with braced-init syntaxUrbana
2377std::align requirements overly strictUrbanaComplete
2396underlying_type doesn't say what to do for an incomplete enumeration typeUrbanaComplete
2399shared_ptr's constructor from unique_ptr should be constrainedUrbanaComplete
2400shared_ptr's get_deleter() should use addressof()UrbanaComplete
2401std::function needs more noexceptUrbanaComplete
2404mismatch()'s complexity needs to be updatedUrbanaComplete
2408SFINAE-friendly common_type / iterator_traits is missing in C++14Urbanacommon_type is waiting on LWG#2465
2106move_iterator wrapping iterators returning prvaluesUrbana
2129User specializations of std::initializer_listUrbanaComplete
2212tuple_size for const pair request headerUrbanaComplete
2217operator==(sub_match, string) slices on embedded '\0'sUrbanaComplete
2230"see below" for initializer_list constructors of unordered containersUrbanaComplete
2233bad_function_call::what() unhelpfulUrbanaComplete
2266vector and deque have incorrect insert requirementsUrbanaComplete
2325minmax_element()'s behavior differing from max_element()'s should be notedUrbanaComplete
2361Apply 2299 resolution throughout libraryUrbana
2365Missing noexcept in shared_ptr::shared_ptr(nullptr_t)UrbanaComplete
2376bad_weak_ptr::what() overspecifiedUrbanaComplete
2387More nested types that must be accessible and unambiguousUrbanaComplete
2106move_iterator wrapping iterators returning prvaluesUrbana
2129User specializations of std::initializer_listUrbanaComplete
2212tuple_size for const pair request headerUrbanaComplete
2217operator==(sub_match, string) slices on embedded '\0'sUrbanaComplete
2230"see below" for initializer_list constructors of unordered containersUrbanaComplete
2233bad_function_call::what() unhelpfulUrbanaComplete
2266vector and deque have incorrect insert requirementsUrbanaComplete
2325minmax_element()'s behavior differing from max_element()'s should be notedUrbanaComplete
2361Apply 2299 resolution throughout libraryUrbana
2365Missing noexcept in shared_ptr::shared_ptr(nullptr_t)UrbanaComplete
2376bad_weak_ptr::what() overspecifiedUrbanaComplete
2387More nested types that must be accessible and unambiguousUrbanaComplete
2059C++0x ambiguity problem with map::eraseLenexaComplete
2063Contradictory requirements for string move assignmentLenexa
2076Bad CopyConstructible requirement in set constructorsLenexaComplete
2160Unintended destruction ordering-specification of resizeLenexaComplete
2168Inconsistent specification of uniform_real_distribution constructorLenexaComplete
2239min/max/minmax requirementsLenexaComplete
2364deque and vector pop_back don't specify iterator invalidation requirementsLenexaComplete
2369constexpr max(initializer_list) vs max_elementLenexaComplete
2378Behaviour of standard exception typesLenexaComplete
2403stof() should call strtof() and wcstof()LenexaComplete
2406negative_binomial_distribution should reject p == 1LenexaComplete
2407packaged_task(allocator_arg_t, const Allocator&, F&&) should neither be constrained nor explicitLenexaComplete
2411shared_ptr is only contextually convertible to boolLenexaComplete
2415Inconsistency between unique_ptr and shared_ptrLenexaComplete
2420function does not discard the return value of the target objectLenexaComplete
2425operator delete(void*, size_t) doesn't invalidate pointers sufficientlyLenexaComplete
2427Container adaptors as sequence containers, reduxLenexaComplete
2428"External declaration" used without being definedLenexaComplete
2433uninitialized_copy()/etc. should tolerate overloaded operator&LenexaComplete
2434shared_ptr::use_count() is efficientLenexaComplete
2437iterator_traits::reference can and can't be voidLenexaComplete
2438std::iterator inheritance shouldn't be mandatedLenexaComplete
2439unique_copy() sometimes can't fall back to reading its outputLenexaComplete
2440seed_seq::size() should be noexceptLenexaComplete
2442call_once() shouldn't DECAY_COPY()LenexaComplete
2448Non-normative Container destructor specificationLenexaComplete
2454Add raw_storage_iterator::base() memberLenexaComplete
2455Allocator default construction should be allowed to throwLenexaComplete
2458N3778 and new library deallocation signaturesLenexaComplete
2459std::polar should require a non-negative rhoLenexaComplete
2464try_emplace and insert_or_assign misspecifiedLenexaComplete
2467is_always_equal has slightly inconsistent defaultLenexaComplete
2470Allocator's destroy function should be allowed to fail to instantiateLenexaComplete
2482[c.strings] Table 73 mentions nonexistent functionsLenexaComplete
2488Placeholders should be allowed and encouraged to be constexprLenexa
2059C++0x ambiguity problem with map::eraseLenexaComplete
2063Contradictory requirements for string move assignmentLenexaComplete
2076Bad CopyConstructible requirement in set constructorsLenexaComplete
2160Unintended destruction ordering-specification of resizeLenexaComplete
2168Inconsistent specification of uniform_real_distribution constructorLenexaComplete
2239min/max/minmax requirementsLenexaComplete
2364deque and vector pop_back don't specify iterator invalidation requirementsLenexaComplete
2369constexpr max(initializer_list) vs max_elementLenexaComplete
2378Behaviour of standard exception typesLenexaComplete
2403stof() should call strtof() and wcstof()LenexaComplete
2406negative_binomial_distribution should reject p == 1LenexaComplete
2407packaged_task(allocator_arg_t, const Allocator&, F&&) should neither be constrained nor explicitLenexaComplete
2411shared_ptr is only contextually convertible to boolLenexaComplete
2415Inconsistency between unique_ptr and shared_ptrLenexaComplete
2420function does not discard the return value of the target objectLenexaComplete
2425operator delete(void*, size_t) doesn't invalidate pointers sufficientlyLenexaComplete
2427Container adaptors as sequence containers, reduxLenexaComplete
2428"External declaration" used without being definedLenexaComplete
2433uninitialized_copy()/etc. should tolerate overloaded operator&LenexaComplete
2434shared_ptr::use_count() is efficientLenexaComplete
2437iterator_traits::reference can and can't be voidLenexaComplete
2438std::iterator inheritance shouldn't be mandatedLenexaComplete
2439unique_copy() sometimes can't fall back to reading its outputLenexaComplete
2440seed_seq::size() should be noexceptLenexaComplete
2442call_once() shouldn't DECAY_COPY()LenexaComplete
2448Non-normative Container destructor specificationLenexaComplete
2454Add raw_storage_iterator::base() memberLenexaComplete
2455Allocator default construction should be allowed to throwLenexaComplete
2458N3778 and new library deallocation signaturesLenexaComplete
2459std::polar should require a non-negative rhoLenexaComplete
2464try_emplace and insert_or_assign misspecifiedLenexaComplete
2467is_always_equal has slightly inconsistent defaultLenexaComplete
2470Allocator's destroy function should be allowed to fail to instantiateLenexaComplete
2482[c.strings] Table 73 mentions nonexistent functionsLenexaComplete
2488Placeholders should be allowed and encouraged to be constexprLenexa
1169num_get not fully compatible with strto*Kona
2072Unclear wording about capacity of temporary buffersKonaComplete
2101Some transformation types can produce impossible typesKona
2111Which unexpected/terminate handler is called from the exception handling runtime?KonaComplete
2119Missing hash specializations for extended integer typesKona
2127Move-construction with raw_storage_iteratorKonaComplete
2133Attitude to overloaded comma for iteratorsKonaComplete
2156Unordered containers' reserve(n) reserves for n-1 elementsKonaComplete
2218Unclear how containers use allocator_traits::construct()Kona
2219INVOKE-ing a pointer to member with a reference_wrapper as the object expressionKona
2224Ambiguous status of access to non-live objectsKonaComplete
2234assert() should allow usage in constant expressionsKonaComplete
2244Issue on basic_istream::seekgKonaComplete
2250Follow-up On Library Issue 2207Kona
2259Issues in 17.6.5.5 rules for member functionsKonaComplete
2273regex_match ambiguityKona
2336is_trivially_constructible/is_trivially_assignable traits are always falseKona
2353std::next is over-constrainedKonaComplete
2367pair and tuple are not correctly implemented for is_constructible with no argsKonaComplete
2380May <cstdlib> provide long ::abs(long) and long long ::abs(long long)?KonaComplete
2384Allocator's deallocate function needs better specificationKonaComplete
2385function::assign allocator argument doesn't make senseKona
2435reference_wrapper::operator()'s Remark should be deletedKonaComplete
2447Allocators and volatile-qualified value typesKonaComplete
2462std::ios_base::failure is overspecifiedKonaComplete
2466allocator_traits::max_size() default behavior is incorrectKonaComplete
2469Wrong specification of Requires clause of operator[] for map and unordered_mapKona
2473basic_filebuf's relation to C FILE semanticsKonaComplete
2476scoped_allocator_adaptor is not assignableKonaComplete
2477Inconsistency of wordings in std::vector::erase() and std::deque::erase()KonaComplete
2483throw_with_nested() should use is_finalKonaComplete
2484rethrow_if_nested() is doubly unimplementableKonaComplete
2485get() should be overloaded for const tuple&&KonaCompleted
2486mem_fn() should be required to use perfect forwardingKonaComplete
2487bind() should be const-overloaded, not cv-overloadedKonaComplete
2489mem_fn() should be noexceptKonaComplete
2492Clarify requirements for compKonaComplete
2495There is no such thing as an Exception Safety elementKonaComplete
-

Last Updated: 27-May-2015

+

Last Updated: 5-Oct-2015

diff --git a/www/index.html b/www/index.html index 8f1489e84553..821f25d7e04f 100644 --- a/www/index.html +++ b/www/index.html @@ -42,6 +42,16 @@ href="http://llvm.org/docs/DeveloperPolicy.html#license">dual licensed under the MIT license and the UIUC License (a BSD-like license).

+ +

New Documentation Coming Soon!

+ + +

Looking for documentation on how to use, build and test libc++? If so + checkout the new libc++ documentation.

+ +

+ Click here for the new libc++ documentation.

+

Features and Goals

@@ -184,26 +194,30 @@

In-tree build:

    +
  • cd where-you-want-to-live
  • Check out libcxx and libcxxabi into llvm/projects
  • -
  • cd llvm
  • +
  • cd where-you-want-to-build
  • mkdir build && cd build
  • -
  • cmake .. # Linux may require -DCMAKE_C_COMPILER=clang +
  • cmake path/to/llvm # Linux may require -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
  • make cxx
-

Out-of-tree build:

+

Out-of-tree buildc:

    -
  • Check out libcxx
  • +
  • cd where-you-want-to-live
  • +
  • Check out libcxx and llvm
  • If not on a Mac, also check out libcxxabi
  • -
  • cd libcxx
  • +
  • cd where-you-want-to-build
  • mkdir build && cd build
  • -
  • cmake -DLIBCXX_CXX_ABI=libcxxabi +
  • cmake -DLLVM_PATH=path/to/llvm + -DLIBCXX_CXX_ABI=libcxxabi -DLIBCXX_CXX_ABI_INCLUDE_PATHS=path/to/libcxxabi/include - -DLIT_EXECUTABLE=path/to/llvm/utils/lit/lit.py .. # Linux may require - -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
  • + -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ + path/to/libcxx +
  • make
diff --git a/www/kona.html b/www/kona.html new file mode 100644 index 000000000000..8fdfba163e4a --- /dev/null +++ b/www/kona.html @@ -0,0 +1,154 @@ + + + + + + libc++ Kona Status + + + + + + + +
+ +

libc++ Kona Status

+ + +

This is a temporary page; please check the c++1z status here

+

This page shows the status of the papers and issues that are expected to be adopted in Kona.

+ +

The groups that have contributed papers: +

    +
  • LWG - Library working group
  • +
  • CWG - Core Language Working group
  • +
  • SG1 - Study group #1 (Concurrency working group)
  • +
+

+ +

Paper Status

+ + + + +
Paper #GroupPaper NameMeetingStatusFirst released version
+ +

Library Working group Issues Status

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Issue #Issue NameMeetingStatus
1169num_get not fully compatible with strto*Kona
2072Unclear wording about capacity of temporary buffersKonaComplete
2101Some transformation types can produce impossible typesKona
2111Which unexpected/terminate handler is called from the exception handling runtime?KonaComplete
2119Missing hash specializations for extended integer typesKona
2127Move-construction with raw_storage_iteratorKonaPatch Ready
2133Attitude to overloaded comma for iteratorsKonaComplete
2156Unordered containers' reserve(n) reserves for n-1 elementsKona
2218Unclear how containers use allocator_traits::construct()Kona
2219INVOKE-ing a pointer to member with a reference_wrapper as the object expressionKona
2224Ambiguous status of access to non-live objectsKona
2234assert() should allow usage in constant expressionsKona
2244Issue on basic_istream::seekgKonaPatch Ready
2250Follow-up On Library Issue 2207Kona
2259Issues in 17.6.5.5 rules for member functionsKonaComplete
2273regex_match ambiguityKona
2336is_trivially_constructible/is_trivially_assignable traits are always falseKona
2353std::next is over-constrainedKona
2367pair and tuple are not correctly implemented for is_constructible with no argsKonaPatch Ready
2380May <cstdlib> provide long ::abs(long) and long long ::abs(long long)?KonaComplete
2384Allocator's deallocate function needs better specificationKonaComplete
2385function::assign allocator argument doesn't make senseKona
2435reference_wrapper::operator()'s Remark should be deletedKonaComplete
2447Allocators and volatile-qualified value typesKonaComplete
2462std::ios_base::failure is overspecifiedKonaComplete
2466allocator_traits::max_size() default behavior is incorrectKonaPatch Ready
2469Wrong specification of Requires clause of operator[] for map and unordered_mapKona
2473basic_filebuf's relation to C FILE semanticsKonaComplete
2476scoped_allocator_adaptor is not assignableKonaPatch Ready
2477Inconsistency of wordings in std::vector::erase() and std::deque::erase()KonaComplete
2483throw_with_nested() should use is_finalKonaComplete
2484rethrow_if_nested() is doubly unimplementableKonaComplete
2485get() should be overloaded for const tuple&&Kona
2486mem_fn() should be required to use perfect forwardingKona
2487bind() should be const-overloaded, not cv-overloadedKonaComplete
2489mem_fn() should be noexceptKonaPatch Ready
2492Clarify requirements for compKonaComplete
2494[fund.ts.v2] ostream_joiner needs noexceptKona
2495There is no such thing as an Exception Safety elementKona
+ +

Comments about the issues

+
    +
  • 1169 - We currently have a single function __num_get_float that calls strtold_l, and then casts down to the appropriate floating point type. That will have to change.
  • +
  • 2072 - We already do this; this is just making the wording better.
  • +
  • 2101 - Need to write some careful test cases. In particular, need to check function types with/without const/ref qualifiers. Currently we get this wrong. Installing metashell to play with these.
  • +
  • 2111 - Resolved an ambiguity by calling it out. No code change required.
  • +
  • 2119 - Hashes for all integral and enumeration types. Research needed
  • +
  • 2127 - Add a new member to raw_storage_iterator. Looks simple. Patch Available
  • +
  • 2133 - We do this already; thanks Eric.
  • +
  • 2156 - check and make sure that we already do this. Write a test.
  • +
  • 2181 - I suspect that this will not require any code changes, but will need to be read carefully.
  • +
  • 2218 - Shouldn't require any code changes.
  • +
  • 2219 - Sizable changes required. INVOKE needs 2 additional overloads and plenty of tests. I'm not going to back port this to C++03. (Eric)
  • +
  • 2224 -
  • +
  • 2234 -
  • +
  • 2244 - We don't do this; easy fix. Patch Available
  • +
  • 2250 - Looks like wording cleanup. Need to check more closely, but I think there's no code changes here.
  • +
  • 2259 - No code changes needed here.
  • +
  • 2273 -
  • +
  • 2336 - Check later
  • +
  • 2353 - Simple change, needs a test. (test probably used to exist)
  • +
  • 2367 - Patch Available as D13750 (Eric)
  • +
  • 2380 - No code changes here; we already do this.
  • +
  • 2384 - Wording cleanup; no code change required
  • +
  • 2385 - Removing broken signatures. Only question is "how far back"?
  • +
  • 2435 - Wording cleanup; no code change required
  • +
  • 2447 - This is a relaxation of a requirement that we satisfy. No changes needed..
  • +
  • 2462 - Added a simple test. No code change needed Patch Available
  • +
  • 2466 - Simple change; need a test. Patch Available
  • +
  • 2469 - This is a follow on to 2464, which we're done. This restates a bunch of operations in terms of newer ops. Probably refactoring to do here, but tests shouldn't change.
  • +
  • 2473 - There are two changes here; one to filebuf::seekpos and the other to filebuf::sync. We do both of these already.
  • +
  • 2476 - Just needed tests. Patch Available
  • +
  • 2477 - Wording cleanup.
  • +
  • 2483 - We already do this.
  • +
  • 2484 - We already do this.
  • +
  • 2485 - Ask Eric to do it.
  • +
  • 2486 - Lots of code changes, all mechanical. Tests will be sizable.
  • +
  • 2487 - This is removing a requirement on bind(), which we don't currently satisfy. So, nothing to do.
  • +
  • 2489 - Looks easy. Just add some NOEXCEPT, and tests. Patch Available
  • +
  • 2492 - Wording cleanup; no code changes needed.
  • +
  • 2494 - My implementation of this (not checked in) already has these.
  • +
  • 2494 -
  • +
+ +

Last Updated: 5-Oct-2015

+
+ + diff --git a/www/ts1z_status.html b/www/ts1z_status.html index 698996f845f0..9d4a000b0b99 100644 --- a/www/ts1z_status.html +++ b/www/ts1z_status.html @@ -35,8 +35,8 @@

Post-C++14 TS Implementation Status

-

In April 2013, the C++ standard committee approved the draft for the next version of the C++ standard, known as "C++1Y" (probably to be C++14)

-

The draft standard includes papers and issues that were voted on at the previous three meetings (Kona, Portland, and Bristol)

+

In November 2014, the C++ standard committee approved the draft for the next version of the C++ standard, known as "C++1z" (probably to be C++17)

+

In addition, there are several "Technical Specifications", that consist of new features that are proposed, but not yet accepted for C++1z.

This page shows the status of libc++; the status of clang's support of the language features is here.

Technical Specifications

@@ -47,10 +47,10 @@ 3940Technical Specification - File SystemFile System - 4273Uniform Container Erasure.Library Fundamentals 2 + 4273Uniform Container Erasure.Library Fundamentals 2 4061Greatest Common Divisor and Least Common Multiple.Library Fundamentals 2 - 4257Delimited iterators.Library Fundamentals 2 - 4282The World's Dumbest Smart Pointer.Library Fundamentals 2 + 4257Delimited iterators.Library Fundamentals 2 + 4282The World's Dumbest Smart Pointer.Library Fundamentals 2 @@ -61,24 +61,23 @@ Uses-allocator constructionNot started Changes to std::shared_ptr and weak_ptrNot started Additions to std::functionNot started - Changes to std::common_typeNot started - Changes to std::iterator_traitsNot started Additions to std::promiseNot started Additions to std::packaged_taskNot started Class erased_typeComplete Calling a function with a tuple of argumentsComplete + Type traits (_v)Complete Other type transformationsNot started Compile-time Rational ArithmeticImplementation in progress Time UtilitiesComplete System Error SupportComplete - SearchersNot started + SearchersComplete Optional ObjectsInitial implementation complete - class anyImplementation in progress - string_viewImplementation in progress + class anyComplete + string_viewComplete memoryImplementation in progress - Algorithms libraryImplementation in progress + Algorithms libraryComplete @@ -96,7 +95,7 @@ -

Last Updated: 2-June-2014

+

Last Updated: 7-Dec-2015

From 722ebc7ad794cf56284863322f8220e769093709 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 6 Jan 2016 20:05:20 +0000 Subject: [PATCH 2/8] Vendor import of libc++ trunk r256945: https://llvm.org/svn/llvm-project/libcxx/trunk@256945 --- include/__config | 2 + include/__hash_table | 68 +--- include/__tree | 137 ++++---- include/ext/hash_map | 20 +- include/forward_list | 36 +- include/list | 318 +++++++++++------- include/map | 42 ++- include/unordered_map | 20 +- test/libcxx/test/config.py | 1 + test/libcxx/test/target_info.py | 2 +- .../map/map.modifiers/insert_iter_rv.pass.cpp | 33 +- .../map/map.modifiers/insert_rv.pass.cpp | 38 ++- .../insert_iter_rv.pass.cpp | 34 +- .../multimap.modifiers/insert_rv.pass.cpp | 33 +- test/support/MoveOnly.h | 1 + 15 files changed, 449 insertions(+), 336 deletions(-) diff --git a/include/__config b/include/__config index f141f4f1b7f9..c0b1ef201c05 100644 --- a/include/__config +++ b/include/__config @@ -39,6 +39,8 @@ #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT // Fix deque iterator type in order to support incomplete types. #define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE +// Fix undefined behavior in how std::list stores it's linked nodes. +#define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB #endif #define _LIBCPP_CONCAT1(_LIBCPP_X,_LIBCPP_Y) _LIBCPP_X##_LIBCPP_Y diff --git a/include/__hash_table b/include/__hash_table index cfa763ab217a..c7d1ef3d082f 100644 --- a/include/__hash_table +++ b/include/__hash_table @@ -46,12 +46,7 @@ template struct __hash_node : public __hash_node_base < - typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__hash_node<_Tp, _VoidPtr> > -#else - rebind<__hash_node<_Tp, _VoidPtr> >::other -#endif + typename __rebind_pointer<_VoidPtr, __hash_node<_Tp, _VoidPtr> >::type > { typedef _Tp value_type; @@ -98,13 +93,7 @@ public: typedef typename pointer_traits<__node_pointer>::element_type::value_type value_type; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __hash_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 @@ -229,20 +218,8 @@ public: typedef typename __node::value_type value_type; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; typedef const value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__node> -#else - rebind<__node>::other -#endif - __non_const_node_pointer; + typedef typename __rebind_pointer<__node_pointer, const value_type>::type pointer; + typedef typename __rebind_pointer<__node_pointer, __node>::type __non_const_node_pointer; typedef __hash_iterator<__non_const_node_pointer> __non_const_iterator; _LIBCPP_INLINE_VISIBILITY __hash_const_iterator() _NOEXCEPT @@ -376,13 +353,7 @@ public: typedef typename __pointer_traits::element_type::value_type value_type; typedef typename __pointer_traits::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __hash_local_iterator() _NOEXCEPT { @@ -514,13 +485,9 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator typedef pointer_traits<__node_pointer> __pointer_traits; typedef typename __pointer_traits::element_type __node; typedef typename remove_const<__node>::type __non_const_node; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__non_const_node> -#else - rebind<__non_const_node>::other -#endif - __non_const_node_pointer; + typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type + __non_const_node_pointer; + typedef __hash_local_iterator<__non_const_node_pointer> __non_const_iterator; public: @@ -530,13 +497,9 @@ public: >::type value_type; typedef typename __pointer_traits::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, const value_type>::type + pointer; + _LIBCPP_INLINE_VISIBILITY __hash_const_local_iterator() _NOEXCEPT { @@ -780,13 +743,8 @@ public: typedef typename __node_traits::pointer __node_pointer; typedef typename __node_traits::pointer __node_const_pointer; typedef __hash_node_base<__node_pointer> __first_node; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__first_node> -#else - rebind<__first_node>::other -#endif - __node_base_pointer; + typedef typename __rebind_pointer<__node_pointer, __first_node>::type + __node_base_pointer; private: diff --git a/include/__tree b/include/__tree index 6391609b3982..94565bc3f74c 100644 --- a/include/__tree +++ b/include/__tree @@ -548,31 +548,15 @@ template class __tree_node_base : public __tree_end_node < - typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__tree_node_base<_VoidPtr> > -#else - rebind<__tree_node_base<_VoidPtr> >::other -#endif + typename __rebind_pointer<_VoidPtr, __tree_node_base<_VoidPtr> >::type > { __tree_node_base(const __tree_node_base&); __tree_node_base& operator=(const __tree_node_base&); public: - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__tree_node_base> -#else - rebind<__tree_node_base>::other -#endif - pointer; - typedef typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - const_pointer; + typedef typename __rebind_pointer<_VoidPtr, __tree_node_base>::type pointer; + typedef typename __rebind_pointer<_VoidPtr, const __tree_node_base>::type const_pointer; + typedef __tree_end_node base; pointer __right_; @@ -623,13 +607,7 @@ public: typedef _Tp value_type; typedef _DiffType difference_type; typedef value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 @@ -694,13 +672,7 @@ public: typedef _Tp value_type; typedef _DiffType difference_type; typedef const value_type& reference; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, const value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT #if _LIBCPP_STD_VER > 11 @@ -710,13 +682,8 @@ public: private: typedef typename remove_const<__node>::type __non_const_node; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__non_const_node> -#else - rebind<__non_const_node>::other -#endif - __non_const_node_pointer; + typedef typename __rebind_pointer<__node_pointer, __non_const_node>::type + __non_const_node_pointer; typedef __tree_iterator __non_const_iterator; public: @@ -730,14 +697,8 @@ public: _LIBCPP_INLINE_VISIBILITY __tree_const_iterator& operator++() { - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - __node_base_pointer; - + typedef typename __rebind_pointer<__node_pointer, typename __node::base>::type + __node_base_pointer; __ptr_ = static_cast<__node_pointer>( __tree_next(static_cast<__node_base_pointer>(__ptr_))); return *this; @@ -749,14 +710,8 @@ public: _LIBCPP_INLINE_VISIBILITY __tree_const_iterator& operator--() { - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - __node_base_pointer; - + typedef typename __rebind_pointer<__node_pointer, typename __node::base>::type + __node_base_pointer; __ptr_ = static_cast<__node_pointer>( __tree_prev(static_cast<__node_base_pointer>(__ptr_))); return *this; @@ -810,20 +765,9 @@ public: typedef typename __node_base::pointer __node_base_const_pointer; private: typedef typename __node_base::base __end_node_t; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__end_node_t> -#else - rebind<__end_node_t>::other -#endif - __end_node_ptr; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__end_node_t> -#else - rebind<__end_node_t>::other -#endif - __end_node_const_ptr; + typedef typename __rebind_pointer<__node_pointer, __end_node_t>::type + __end_node_ptr; + typedef __end_node_ptr __end_node_const_ptr; __node_pointer __begin_node_; __compressed_pair<__end_node_t, __node_allocator> __pair1_; @@ -965,6 +909,13 @@ public: iterator __insert_multi(const value_type& __v); iterator __insert_multi(const_iterator __p, const value_type& __v); +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + pair __insert_unique( value_type&& __v); + iterator __insert_unique(const_iterator __p, value_type&& __v); + iterator __insert_multi( value_type&& __v); + iterator __insert_multi(const_iterator __p, value_type&& __v); +#endif + pair __node_insert_unique(__node_pointer __nd); iterator __node_insert_unique(const_iterator __p, __node_pointer __nd); @@ -1785,6 +1736,28 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, #endif // _LIBCPP_HAS_NO_VARIADICS +template +pair::iterator, bool> +__tree<_Tp, _Compare, _Allocator>::__insert_unique(value_type&& __v) +{ + __node_holder __h = __construct_node(_VSTD::forward(__v)); + pair __r = __node_insert_unique(__h.get()); + if (__r.second) + __h.release(); + return __r; +} + +template +typename __tree<_Tp, _Compare, _Allocator>::iterator +__tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, value_type&& __v) +{ + __node_holder __h = __construct_node(_VSTD::forward(__v)); + iterator __r = __node_insert_unique(__p, __h.get()); + if (__r.__ptr_ == __h.get()) + __h.release(); + return __r; +} + template template pair::iterator, bool> @@ -1809,6 +1782,28 @@ __tree<_Tp, _Compare, _Allocator>::__insert_unique(const_iterator __p, _Vp&& __v return __r; } +template +typename __tree<_Tp, _Compare, _Allocator>::iterator +__tree<_Tp, _Compare, _Allocator>::__insert_multi(value_type&& __v) +{ + __node_base_pointer __parent; + __node_base_pointer& __child = __find_leaf_high(__parent, __v); + __node_holder __h = __construct_node(_VSTD::forward(__v)); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); + return iterator(__h.release()); +} + +template +typename __tree<_Tp, _Compare, _Allocator>::iterator +__tree<_Tp, _Compare, _Allocator>::__insert_multi(const_iterator __p, value_type&& __v) +{ + __node_base_pointer __parent; + __node_base_pointer& __child = __find_leaf(__p, __parent, __v); + __node_holder __h = __construct_node(_VSTD::forward(__v)); + __insert_node_at(__parent, __child, static_cast<__node_base_pointer>(__h.get())); + return iterator(__h.release()); +} + template template typename __tree<_Tp, _Compare, _Allocator>::iterator diff --git a/include/ext/hash_map b/include/ext/hash_map index 0e4ab6910eb5..3ac27b2ca330 100644 --- a/include/ext/hash_map +++ b/include/ext/hash_map @@ -368,7 +368,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::first_type key_type; typedef typename _HashIterator::value_type::second_type mapped_type; public: @@ -376,13 +375,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() {} @@ -419,7 +413,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::first_type key_type; typedef typename _HashIterator::value_type::second_type mapped_type; public: @@ -427,13 +420,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() {} diff --git a/include/forward_list b/include/forward_list index adbc32cf861c..4f9ecf49bd58 100644 --- a/include/forward_list +++ b/include/forward_list @@ -197,15 +197,9 @@ struct __forward_begin_node template struct _LIBCPP_HIDDEN __begin_node_of { - typedef __forward_begin_node - < - typename pointer_traits<_VoidPtr>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__forward_list_node<_Tp, _VoidPtr> > -#else - rebind<__forward_list_node<_Tp, _VoidPtr> >::other -#endif - > type; + typedef __forward_begin_node< + typename __rebind_pointer<_VoidPtr, __forward_list_node<_Tp, _VoidPtr> >::type + > type; }; template @@ -240,13 +234,7 @@ public: typedef value_type& reference; typedef typename pointer_traits<__node_pointer>::difference_type difference_type; - typedef typename pointer_traits<__node_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_pointer, value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __forward_list_iterator() _NOEXCEPT : __ptr_(nullptr) {} @@ -295,13 +283,7 @@ class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator < typename pointer_traits<__node_const_pointer>::element_type >::type __node; - typedef typename pointer_traits<__node_const_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind<__node> -#else - rebind<__node>::other -#endif - __node_pointer; + typedef typename __rebind_pointer<__node_const_pointer, __node>::type __node_pointer; template friend class forward_list; @@ -311,13 +293,7 @@ public: typedef const value_type& reference; typedef typename pointer_traits<__node_const_pointer>::difference_type difference_type; - typedef typename pointer_traits<__node_const_pointer>::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer<__node_const_pointer, const value_type>::type pointer; _LIBCPP_INLINE_VISIBILITY __forward_list_const_iterator() _NOEXCEPT : __ptr_(nullptr) {} diff --git a/include/list b/include/list index 28d505582c0d..44b20e2fa28c 100644 --- a/include/list +++ b/include/list @@ -175,6 +175,7 @@ template #include #include #include +#include #include <__undef_min_max> @@ -187,25 +188,66 @@ template _LIBCPP_BEGIN_NAMESPACE_STD template struct __list_node; +template struct __list_node_base; + +template +struct __list_node_pointer_traits { + typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type + __node_pointer; + typedef typename __rebind_pointer<_VoidPtr, __list_node_base<_Tp, _VoidPtr> >::type + __base_pointer; + +#if defined(_LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB) + typedef __base_pointer __link_pointer; +#else + typedef typename conditional< + is_pointer<_VoidPtr>::value, + __base_pointer, + __node_pointer + >::type __link_pointer; +#endif + + typedef typename conditional< + is_same<__link_pointer, __node_pointer>::value, + __base_pointer, + __node_pointer + >::type __non_link_pointer; + + static _LIBCPP_INLINE_VISIBILITY + __link_pointer __unsafe_link_pointer_cast(__link_pointer __p) { + return __p; + } + + static _LIBCPP_INLINE_VISIBILITY + __link_pointer __unsafe_link_pointer_cast(__non_link_pointer __p) { + return static_cast<__link_pointer>(static_cast<_VoidPtr>(__p)); + } + +}; template struct __list_node_base { - typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type - pointer; - typedef typename __rebind_pointer<_VoidPtr, __list_node_base>::type - __base_pointer; + typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; + typedef typename _NodeTraits::__node_pointer __node_pointer; + typedef typename _NodeTraits::__base_pointer __base_pointer; + typedef typename _NodeTraits::__link_pointer __link_pointer; - pointer __prev_; - pointer __next_; + __link_pointer __prev_; + __link_pointer __next_; _LIBCPP_INLINE_VISIBILITY - __list_node_base() : __prev_(__self()), __next_(__self()) {} + __list_node_base() : __prev_(_NodeTraits::__unsafe_link_pointer_cast(__self())), + __next_(_NodeTraits::__unsafe_link_pointer_cast(__self())) {} _LIBCPP_INLINE_VISIBILITY - pointer __self() - { - return static_cast(pointer_traits<__base_pointer>::pointer_to(*this)); + __base_pointer __self() { + return pointer_traits<__base_pointer>::pointer_to(*this); + } + + _LIBCPP_INLINE_VISIBILITY + __node_pointer __as_node() { + return static_cast<__node_pointer>(__self()); } }; @@ -214,6 +256,14 @@ struct __list_node : public __list_node_base<_Tp, _VoidPtr> { _Tp __value_; + + typedef __list_node_base<_Tp, _VoidPtr> __base; + typedef typename __base::__link_pointer __link_pointer; + + _LIBCPP_INLINE_VISIBILITY + __link_pointer __as_link() { + return static_cast<__link_pointer>(__base::__self()); + } }; template > class _LIBCPP_TYPE_VIS_ONLY list; @@ -223,21 +273,21 @@ template class _LIBCPP_TYPE_VIS_ONLY __list_const_it template class _LIBCPP_TYPE_VIS_ONLY __list_iterator { - typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type - __node_pointer; + typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; + typedef typename _NodeTraits::__link_pointer __link_pointer; - __node_pointer __ptr_; + __link_pointer __ptr_; #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - explicit __list_iterator(__node_pointer __p, const void* __c) _NOEXCEPT + explicit __list_iterator(__link_pointer __p, const void* __c) _NOEXCEPT : __ptr_(__p) { __get_db()->__insert_ic(this, __c); } #else _LIBCPP_INLINE_VISIBILITY - explicit __list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} + explicit __list_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} #endif @@ -295,7 +345,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::iterator"); #endif - return __ptr_->__value_; + return __ptr_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const @@ -304,7 +354,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::iterator"); #endif - return pointer_traits::pointer_to(__ptr_->__value_); + return pointer_traits::pointer_to(__ptr_->__as_node()->__value_); } _LIBCPP_INLINE_VISIBILITY @@ -346,21 +396,21 @@ public: template class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator { - typedef typename __rebind_pointer<_VoidPtr, __list_node<_Tp, _VoidPtr> >::type - __node_pointer; + typedef __list_node_pointer_traits<_Tp, _VoidPtr> _NodeTraits; + typedef typename _NodeTraits::__link_pointer __link_pointer; - __node_pointer __ptr_; + __link_pointer __ptr_; #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY - explicit __list_const_iterator(__node_pointer __p, const void* __c) _NOEXCEPT + explicit __list_const_iterator(__link_pointer __p, const void* __c) _NOEXCEPT : __ptr_(__p) { __get_db()->__insert_ic(this, __c); } #else _LIBCPP_INLINE_VISIBILITY - explicit __list_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} + explicit __list_const_iterator(__link_pointer __p) _NOEXCEPT : __ptr_(__p) {} #endif template friend class list; @@ -422,7 +472,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::const_iterator"); #endif - return __ptr_->__value_; + return __ptr_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY pointer operator->() const @@ -431,7 +481,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__dereferenceable(this), "Attempted to dereference a non-dereferenceable list::iterator"); #endif - return pointer_traits::pointer_to(__ptr_->__value_); + return pointer_traits::pointer_to(__ptr_->__as_node()->__value_); } _LIBCPP_INLINE_VISIBILITY @@ -489,6 +539,9 @@ protected: typedef allocator_traits<__node_allocator> __node_alloc_traits; typedef typename __node_alloc_traits::pointer __node_pointer; typedef typename __node_alloc_traits::pointer __node_const_pointer; + typedef __list_node_pointer_traits __node_pointer_traits; + typedef typename __node_pointer_traits::__link_pointer __link_pointer; + typedef __link_pointer __link_const_pointer; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; typedef typename __alloc_traits::difference_type difference_type; @@ -499,6 +552,12 @@ protected: __node_base __end_; __compressed_pair __size_alloc_; + _LIBCPP_INLINE_VISIBILITY + __link_pointer __end_as_link() const _NOEXCEPT { + return __node_pointer_traits::__unsafe_link_pointer_cast( + const_cast<__node_base&>(__end_).__self()); + } + _LIBCPP_INLINE_VISIBILITY size_type& __sz() _NOEXCEPT {return __size_alloc_.first();} _LIBCPP_INLINE_VISIBILITY @@ -511,7 +570,7 @@ protected: const __node_allocator& __node_alloc() const _NOEXCEPT {return __size_alloc_.second();} - static void __unlink_nodes(__node_pointer __f, __node_pointer __l) _NOEXCEPT; + static void __unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT; __list_imp() _NOEXCEPT_(is_nothrow_default_constructible<__node_allocator>::value); @@ -543,22 +602,18 @@ protected: iterator end() _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_)), this); + return iterator(__end_as_link(), this); #else - return iterator(static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_))); + return iterator(__end_as_link()); #endif } _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT { #if _LIBCPP_DEBUG_LEVEL >= 2 - return const_iterator(static_cast<__node_const_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_))), this); + return const_iterator(__end_as_link(), this); #else - return const_iterator(static_cast<__node_const_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(__end_)))); + return const_iterator(__end_as_link()); #endif } @@ -613,7 +668,7 @@ private: template inline _LIBCPP_INLINE_VISIBILITY void -__list_imp<_Tp, _Alloc>::__unlink_nodes(__node_pointer __f, __node_pointer __l) +__list_imp<_Tp, _Alloc>::__unlink_nodes(__link_pointer __f, __link_pointer __l) _NOEXCEPT { __f->__prev_->__next_ = __l->__next_; @@ -651,17 +706,16 @@ __list_imp<_Tp, _Alloc>::clear() _NOEXCEPT if (!empty()) { __node_allocator& __na = __node_alloc(); - __node_pointer __f = __end_.__next_; - __node_pointer __l = static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_)); + __link_pointer __f = __end_.__next_; + __link_pointer __l = __end_as_link(); __unlink_nodes(__f, __l->__prev_); __sz() = 0; while (__f != __l) { - __node_pointer __n = __f; + __node_pointer __np = __f->__as_node(); __f = __f->__next_; - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } #if _LIBCPP_DEBUG_LEVEL >= 2 __c_node* __c = __get_db()->__find_c_and_lock(this); @@ -700,13 +754,13 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) swap(__sz(), __c.__sz()); swap(__end_, __c.__end_); if (__sz() == 0) - __end_.__next_ = __end_.__prev_ = __end_.__self(); + __end_.__next_ = __end_.__prev_ = __end_as_link(); else - __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_.__self(); + __end_.__prev_->__next_ = __end_.__next_->__prev_ = __end_as_link(); if (__c.__sz() == 0) - __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_.__self(); + __c.__end_.__next_ = __c.__end_.__prev_ = __c.__end_as_link(); else - __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_.__self(); + __c.__end_.__prev_->__next_ = __c.__end_.__next_->__prev_ = __c.__end_as_link(); #if _LIBCPP_DEBUG_LEVEL >= 2 __libcpp_db* __db = __get_db(); @@ -719,8 +773,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) { --__p; const_iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ == static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_))) + if (__i->__ptr_ == __c.__end_as_link()) { __cn2->__add(*__p); if (--__cn1->end_ != __p) @@ -733,8 +786,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) { --__p; const_iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ == static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__end_))) + if (__i->__ptr_ == __end_as_link()) { __cn1->__add(*__p); if (--__cn2->end_ != __p) @@ -758,6 +810,7 @@ class _LIBCPP_TYPE_VIS_ONLY list typedef typename base::__node_alloc_traits __node_alloc_traits; typedef typename base::__node_base __node_base; typedef typename base::__node_base_pointer __node_base_pointer; + typedef typename base::__link_pointer __link_pointer; public: typedef _Tp value_type; @@ -881,25 +934,25 @@ public: reference front() { _LIBCPP_ASSERT(!empty(), "list::front called on empty list"); - return base::__end_.__next_->__value_; + return base::__end_.__next_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY const_reference front() const { _LIBCPP_ASSERT(!empty(), "list::front called on empty list"); - return base::__end_.__next_->__value_; + return base::__end_.__next_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY reference back() { _LIBCPP_ASSERT(!empty(), "list::back called on empty list"); - return base::__end_.__prev_->__value_; + return base::__end_.__prev_->__as_node()->__value_; } _LIBCPP_INLINE_VISIBILITY const_reference back() const { _LIBCPP_ASSERT(!empty(), "list::back called on empty list"); - return base::__end_.__prev_->__value_; + return base::__end_.__prev_->__as_node()->__value_; } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1004,9 +1057,9 @@ public: #endif // _LIBCPP_DEBUG_LEVEL >= 2 private: - static void __link_nodes (__node_pointer __p, __node_pointer __f, __node_pointer __l); - void __link_nodes_at_front(__node_pointer __f, __node_pointer __l); - void __link_nodes_at_back (__node_pointer __f, __node_pointer __l); + static void __link_nodes (__link_pointer __p, __link_pointer __f, __link_pointer __l); + void __link_nodes_at_front(__link_pointer __f, __link_pointer __l); + void __link_nodes_at_back (__link_pointer __f, __link_pointer __l); iterator __iterator(size_type __n); template static iterator __sort(iterator __f1, iterator __e2, size_type __n, _Comp& __comp); @@ -1020,7 +1073,7 @@ private: template inline _LIBCPP_INLINE_VISIBILITY void -list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_pointer __l) +list<_Tp, _Alloc>::__link_nodes(__link_pointer __p, __link_pointer __f, __link_pointer __l) { __p->__prev_->__next_ = __f; __f->__prev_ = __p->__prev_; @@ -1032,9 +1085,9 @@ list<_Tp, _Alloc>::__link_nodes(__node_pointer __p, __node_pointer __f, __node_p template inline _LIBCPP_INLINE_VISIBILITY void -list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l) +list<_Tp, _Alloc>::__link_nodes_at_front(__link_pointer __f, __link_pointer __l) { - __f->__prev_ = base::__end_.__self(); + __f->__prev_ = base::__end_as_link(); __l->__next_ = base::__end_.__next_; __l->__next_->__prev_ = __l; base::__end_.__next_ = __f; @@ -1044,9 +1097,9 @@ list<_Tp, _Alloc>::__link_nodes_at_front(__node_pointer __f, __node_pointer __l) template inline _LIBCPP_INLINE_VISIBILITY void -list<_Tp, _Alloc>::__link_nodes_at_back(__node_pointer __f, __node_pointer __l) +list<_Tp, _Alloc>::__link_nodes_at_back(__link_pointer __f, __link_pointer __l) { - __l->__next_ = base::__end_.__self(); + __l->__next_ = base::__end_as_link(); __f->__prev_ = base::__end_.__prev_; __f->__prev_->__next_ = __f; base::__end_.__prev_ = __l; @@ -1323,12 +1376,12 @@ list<_Tp, _Alloc>::insert(const_iterator __p, const value_type& __x) unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes(__p.__ptr_, __hold.get(), __hold.get()); + __link_nodes(__p.__ptr_, __hold->__as_link(), __hold->__as_link()); ++base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__hold.release(), this); + return iterator(__hold.release()->__as_link(), this); #else - return iterator(__hold.release()); + return iterator(__hold.release()->__as_link()); #endif } @@ -1354,9 +1407,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); ++__ds; #if _LIBCPP_DEBUG_LEVEL >= 2 - __r = iterator(__hold.get(), this); + __r = iterator(__hold->__as_link(), this); #else - __r = iterator(__hold.get()); + __r = iterator(__hold->__as_link()); #endif __hold.release(); iterator __e = __r; @@ -1368,7 +1421,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1379,8 +1432,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, size_type __n, const value_type& _ while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1422,9 +1475,9 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); ++__ds; #if _LIBCPP_DEBUG_LEVEL >= 2 - __r = iterator(__hold.get(), this); + __r = iterator(__hold.get()->__as_link(), this); #else - __r = iterator(__hold.get()); + __r = iterator(__hold.get()->__as_link()); #endif __hold.release(); iterator __e = __r; @@ -1436,7 +1489,7 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), *__f); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold.get()->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1447,8 +1500,8 @@ list<_Tp, _Alloc>::insert(const_iterator __p, _InpIter __f, _InpIter __l, while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1474,7 +1527,8 @@ list<_Tp, _Alloc>::push_front(const value_type& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes_at_front(__hold.get(), __hold.get()); + __link_pointer __nl = __hold->__as_link(); + __link_nodes_at_front(__nl, __nl); ++base::__sz(); __hold.release(); } @@ -1487,7 +1541,7 @@ list<_Tp, _Alloc>::push_back(const value_type& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __link_nodes_at_back(__hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1502,7 +1556,7 @@ list<_Tp, _Alloc>::push_front(value_type&& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes_at_front(__hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1515,7 +1569,7 @@ list<_Tp, _Alloc>::push_back(value_type&& __x) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes_at_back(__hold.get(), __hold.get()); + __link_nodes_at_back(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1531,7 +1585,7 @@ list<_Tp, _Alloc>::emplace_front(_Args&&... __args) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes_at_front(__hold.get(), __hold.get()); + __link_nodes_at_front(__hold.get()->__as_link(), __hold.get()->__as_link()); ++base::__sz(); __hold.release(); } @@ -1545,7 +1599,8 @@ list<_Tp, _Alloc>::emplace_back(_Args&&... __args) typedef __allocator_destructor<__node_allocator> _Dp; unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes_at_back(__hold.get(), __hold.get()); + __link_pointer __nl = __hold->__as_link(); + __link_nodes_at_back(__nl, __nl); ++base::__sz(); __hold.release(); } @@ -1565,12 +1620,14 @@ list<_Tp, _Alloc>::emplace(const_iterator __p, _Args&&... __args) unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::forward<_Args>(__args)...); - __link_nodes(__p.__ptr_, __hold.get(), __hold.get()); + __link_pointer __nl = __hold.get()->__as_link(); + __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); + __hold.release(); #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__hold.release(), this); + return iterator(__nl, this); #else - return iterator(__hold.release()); + return iterator(__nl); #endif } @@ -1590,12 +1647,14 @@ list<_Tp, _Alloc>::insert(const_iterator __p, value_type&& __x) unique_ptr<__node, _Dp> __hold(__node_alloc_traits::allocate(__na, 1), _Dp(__na, 1)); __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), _VSTD::move(__x)); - __link_nodes(__p.__ptr_, __hold.get(), __hold.get()); + __link_pointer __nl = __hold->__as_link(); + __link_nodes(__p.__ptr_, __nl, __nl); ++base::__sz(); + __hold.release(); #if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(__hold.release(), this); + return iterator(__nl, this); #else - return iterator(__hold.release()); + return iterator(__nl); #endif } @@ -1607,7 +1666,7 @@ list<_Tp, _Alloc>::pop_front() { _LIBCPP_ASSERT(!empty(), "list::pop_front() called with empty list"); __node_allocator& __na = base::__node_alloc(); - __node_pointer __n = base::__end_.__next_; + __link_pointer __n = base::__end_.__next_; base::__unlink_nodes(__n, __n); --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1625,8 +1684,9 @@ list<_Tp, _Alloc>::pop_front() } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } template @@ -1635,7 +1695,7 @@ list<_Tp, _Alloc>::pop_back() { _LIBCPP_ASSERT(!empty(), "list::pop_back() called with empty list"); __node_allocator& __na = base::__node_alloc(); - __node_pointer __n = base::__end_.__prev_; + __link_pointer __n = base::__end_.__prev_; base::__unlink_nodes(__n, __n); --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1653,8 +1713,9 @@ list<_Tp, _Alloc>::pop_back() } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } template @@ -1669,8 +1730,8 @@ list<_Tp, _Alloc>::erase(const_iterator __p) _LIBCPP_ASSERT(__p != end(), "list::erase(iterator) called with a non-dereferenceable iterator"); __node_allocator& __na = base::__node_alloc(); - __node_pointer __n = __p.__ptr_; - __node_pointer __r = __n->__next_; + __link_pointer __n = __p.__ptr_; + __link_pointer __r = __n->__next_; base::__unlink_nodes(__n, __n); --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1688,8 +1749,9 @@ list<_Tp, _Alloc>::erase(const_iterator __p) } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); #if _LIBCPP_DEBUG_LEVEL >= 2 return iterator(__r, this); #else @@ -1712,7 +1774,7 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) base::__unlink_nodes(__f.__ptr_, __l.__ptr_->__prev_); while (__f != __l) { - __node_pointer __n = __f.__ptr_; + __link_pointer __n = __f.__ptr_; ++__f; --base::__sz(); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1730,8 +1792,9 @@ list<_Tp, _Alloc>::erase(const_iterator __f, const_iterator __l) } __get_db()->unlock(); #endif - __node_alloc_traits::destroy(__na, _VSTD::addressof(__n->__value_)); - __node_alloc_traits::deallocate(__na, __n, 1); + __node_pointer __np = __n->__as_node(); + __node_alloc_traits::destroy(__na, _VSTD::addressof(__np->__value_)); + __node_alloc_traits::deallocate(__na, __np, 1); } } #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1758,9 +1821,9 @@ list<_Tp, _Alloc>::resize(size_type __n) __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); ++__ds; #if _LIBCPP_DEBUG_LEVEL >= 2 - iterator __r = iterator(__hold.release(), this); + iterator __r = iterator(__hold.release()->__as_link(), this); #else - iterator __r = iterator(__hold.release()); + iterator __r = iterator(__hold.release()->__as_link()); #endif iterator __e = __r; #ifndef _LIBCPP_NO_EXCEPTIONS @@ -1771,7 +1834,7 @@ list<_Tp, _Alloc>::resize(size_type __n) { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_)); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold.get()->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1782,8 +1845,8 @@ list<_Tp, _Alloc>::resize(size_type __n) while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1816,10 +1879,11 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) __hold->__prev_ = 0; __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); ++__ds; + __link_pointer __nl = __hold.release()->__as_link(); #if _LIBCPP_DEBUG_LEVEL >= 2 - iterator __r = iterator(__hold.release(), this); + iterator __r = iterator(__nl, this); #else - iterator __r = iterator(__hold.release()); + iterator __r = iterator(__nl); #endif iterator __e = __r; #ifndef _LIBCPP_NO_EXCEPTIONS @@ -1830,7 +1894,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) { __hold.reset(__node_alloc_traits::allocate(__na, 1)); __node_alloc_traits::construct(__na, _VSTD::addressof(__hold->__value_), __x); - __e.__ptr_->__next_ = __hold.get(); + __e.__ptr_->__next_ = __hold.get()->__as_link(); __hold->__prev_ = __e.__ptr_; __hold.release(); } @@ -1841,8 +1905,8 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) while (true) { __node_alloc_traits::destroy(__na, _VSTD::addressof(*__e)); - __node_pointer __prev = __e.__ptr_->__prev_; - __node_alloc_traits::deallocate(__na, __e.__ptr_, 1); + __link_pointer __prev = __e.__ptr_->__prev_; + __node_alloc_traits::deallocate(__na, __e.__ptr_->__as_node(), 1); if (__prev == 0) break; #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1854,8 +1918,7 @@ list<_Tp, _Alloc>::resize(size_type __n, const value_type& __x) throw; } #endif // _LIBCPP_NO_EXCEPTIONS - __link_nodes(static_cast<__node_pointer>(pointer_traits<__node_base_pointer>:: - pointer_to(base::__end_)), __r.__ptr_, __e.__ptr_); + __link_nodes(base::__end_as_link(), __r.__ptr_, __e.__ptr_); base::__sz() += __ds; } } @@ -1873,8 +1936,8 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) #endif if (!__c.empty()) { - __node_pointer __f = __c.__end_.__next_; - __node_pointer __l = __c.__end_.__prev_; + __link_pointer __f = __c.__end_.__next_; + __link_pointer __l = __c.__end_.__prev_; base::__unlink_nodes(__f, __l); __link_nodes(__p.__ptr_, __f, __l); base::__sz() += __c.__sz(); @@ -1887,8 +1950,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c) { --__p; iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ != static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_))) + if (__i->__ptr_ != __c.__end_as_link()) { __cn1->__add(*__p); (*__p)->__c_ = __cn1; @@ -1918,7 +1980,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __i) #endif if (__p.__ptr_ != __i.__ptr_ && __p.__ptr_ != __i.__ptr_->__next_) { - __node_pointer __f = __i.__ptr_; + __link_pointer __f = __i.__ptr_; base::__unlink_nodes(__f, __f); __link_nodes(__p.__ptr_, __f, __f); --__c.__sz(); @@ -1972,9 +2034,9 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con __c.__sz() -= __s; base::__sz() += __s; } - __node_pointer __first = __f.__ptr_; + __link_pointer __first = __f.__ptr_; --__l; - __node_pointer __last = __l.__ptr_; + __link_pointer __last = __l.__ptr_; base::__unlink_nodes(__first, __last); __link_nodes(__p.__ptr_, __first, __last); #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1985,7 +2047,7 @@ list<_Tp, _Alloc>::splice(const_iterator __p, list& __c, const_iterator __f, con { --__p; iterator* __j = static_cast((*__p)->__i_); - for (__node_pointer __k = __f.__ptr_; + for (__link_pointer __k = __f.__ptr_; __k != __l.__ptr_; __k = __k->__next_) { if (__j->__ptr_ == __k) @@ -2097,8 +2159,8 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) ; base::__sz() += __ds; __c.__sz() -= __ds; - __node_pointer __f = __f2.__ptr_; - __node_pointer __l = __m2.__ptr_->__prev_; + __link_pointer __f = __f2.__ptr_; + __link_pointer __l = __m2.__ptr_->__prev_; __f2 = __m2; base::__unlink_nodes(__f, __l); __m2 = _VSTD::next(__f1); @@ -2117,8 +2179,7 @@ list<_Tp, _Alloc>::merge(list& __c, _Comp __comp) { --__p; iterator* __i = static_cast((*__p)->__i_); - if (__i->__ptr_ != static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(__c.__end_))) + if (__i->__ptr_ != __c.__end_as_link()) { __cn1->__add(*__p); (*__p)->__c_ = __cn1; @@ -2161,7 +2222,7 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ case 2: if (__comp(*--__e2, *__f1)) { - __node_pointer __f = __e2.__ptr_; + __link_pointer __f = __e2.__ptr_; base::__unlink_nodes(__f, __f); __link_nodes(__f1.__ptr_, __f, __f); return __e2; @@ -2177,8 +2238,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ iterator __m2 = _VSTD::next(__f2); for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) ; - __node_pointer __f = __f2.__ptr_; - __node_pointer __l = __m2.__ptr_->__prev_; + __link_pointer __f = __f2.__ptr_; + __link_pointer __l = __m2.__ptr_->__prev_; __r = __f2; __e1 = __f2 = __m2; base::__unlink_nodes(__f, __l); @@ -2195,8 +2256,8 @@ list<_Tp, _Alloc>::__sort(iterator __f1, iterator __e2, size_type __n, _Comp& __ iterator __m2 = _VSTD::next(__f2); for (; __m2 != __e2 && __comp(*__m2, *__f1); ++__m2) ; - __node_pointer __f = __f2.__ptr_; - __node_pointer __l = __m2.__ptr_->__prev_; + __link_pointer __f = __f2.__ptr_; + __link_pointer __l = __m2.__ptr_->__prev_; if (__e1 == __f2) __e1 = __m2; __f2 = __m2; @@ -2240,8 +2301,7 @@ template bool list<_Tp, _Alloc>::__dereferenceable(const const_iterator* __i) const { - return __i->__ptr_ != static_cast<__node_pointer>( - pointer_traits<__node_base_pointer>::pointer_to(const_cast<__node_base&>(this->__end_))); + return __i->__ptr_ != this->__end_as_link(); } template diff --git a/include/map b/include/map index adfb4cdb5e9e..87add437a545 100644 --- a/include/map +++ b/include/map @@ -126,9 +126,11 @@ public: template iterator emplace_hint(const_iterator position, Args&&... args); pair insert(const value_type& v); + pair insert( value_type&& v); // C++17 template pair insert(P&& p); iterator insert(const_iterator position, const value_type& v); + iterator insert(const_iterator position, value_type&& v); // C++17 template iterator insert(const_iterator position, P&& p); template @@ -336,9 +338,11 @@ public: template iterator emplace_hint(const_iterator position, Args&&... args); iterator insert(const value_type& v); + iterator insert( value_type&& v); // C++17 template iterator insert(P&& p); iterator insert(const_iterator position, const value_type& v); + iterator insert(const_iterator position, value_type&& v); // C++17 template iterator insert(const_iterator position, P&& p); template @@ -704,13 +708,8 @@ public: typedef pair<__key_type, __mapped_type> value_type; typedef typename _TreeIterator::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __map_iterator() _NOEXCEPT {} @@ -770,13 +769,8 @@ public: typedef pair<__key_type, __mapped_type> value_type; typedef typename _TreeIterator::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __map_const_iterator() _NOEXCEPT {} @@ -1099,6 +1093,17 @@ public: insert(const_iterator __p, const value_type& __v) {return __tree_.__insert_unique(__p.__i_, __v);} +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + _LIBCPP_INLINE_VISIBILITY + pair + insert( value_type&& __v) {return __tree_.__insert_unique(_VSTD::forward(__v));} + + _LIBCPP_INLINE_VISIBILITY + iterator + insert(const_iterator __p, value_type&& __v) + {return __tree_.__insert_unique(__p.__i_, _VSTD::forward(__v));} +#endif + template _LIBCPP_INLINE_VISIBILITY void insert(_InputIterator __f, _InputIterator __l) @@ -1950,6 +1955,15 @@ public: iterator insert(const_iterator __p, const value_type& __v) {return __tree_.__insert_multi(__p.__i_, __v);} +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) + _LIBCPP_INLINE_VISIBILITY + iterator insert( value_type&& __v) {return __tree_.__insert_multi(_VSTD::forward(__v));} + + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, value_type&& __v) + {return __tree_.__insert_multi(__p.__i_, _VSTD::forward(__v));} +#endif + template _LIBCPP_INLINE_VISIBILITY void insert(_InputIterator __f, _InputIterator __l) diff --git a/include/unordered_map b/include/unordered_map index 3c774d4094e0..85a54a7b6ddb 100644 --- a/include/unordered_map +++ b/include/unordered_map @@ -656,7 +656,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::value_type::first_type key_type; typedef typename _HashIterator::value_type::value_type::second_type mapped_type; public: @@ -664,13 +663,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_iterator() _NOEXCEPT {} @@ -712,7 +706,6 @@ class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; - typedef pointer_traits __pointer_traits; typedef const typename _HashIterator::value_type::value_type::first_type key_type; typedef typename _HashIterator::value_type::value_type::second_type mapped_type; public: @@ -720,13 +713,8 @@ public: typedef pair value_type; typedef typename _HashIterator::difference_type difference_type; typedef const value_type& reference; - typedef typename __pointer_traits::template -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - rebind -#else - rebind::other -#endif - pointer; + typedef typename __rebind_pointer::type + pointer; _LIBCPP_INLINE_VISIBILITY __hash_map_const_iterator() _NOEXCEPT {} diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py index fefbf01ad450..5ab7fcb37401 100644 --- a/test/libcxx/test/config.py +++ b/test/libcxx/test/config.py @@ -558,6 +558,7 @@ def configure_sanitizer(self): '-fno-sanitize=vptr,function', '-fno-sanitize-recover'] self.cxx.compile_flags += ['-O3'] + self.env['UBSAN_OPTIONS'] = 'print_stacktrace=1' self.config.available_features.add('ubsan') elif san == 'Thread': self.cxx.flags += ['-fsanitize=thread'] diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py index 667644d2fec6..df216fcb21fa 100644 --- a/test/libcxx/test/target_info.py +++ b/test/libcxx/test/target_info.py @@ -62,7 +62,7 @@ def __init__(self, full_config): super(DarwinLocalTI, self).__init__(full_config) def add_locale_features(self, features): - add_common_locales(feature, self.full_config.lit_config) + add_common_locales(features, self.full_config.lit_config) def add_cxx_compile_flags(self, flags): try: diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp index 42b41fd7b867..9db1e5c70732 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp @@ -19,6 +19,7 @@ #include "MoveOnly.h" #include "min_allocator.h" +#include "test_macros.h" int main() { @@ -52,7 +53,7 @@ int main() assert(r->first == 3); assert(r->second == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map, min_allocator>> M; typedef std::pair P; @@ -83,5 +84,35 @@ int main() assert(r->second == 3); } #endif +#if TEST_STD_VER > 14 + { + typedef std::map M; + typedef M::iterator R; + M m; + R r = m.insert(m.end(), {2, MoveOnly(2)}); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.end(), {1, MoveOnly(1)}); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.end(), {3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.end(), {3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } diff --git a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp index a9d3277e6d94..23eb84d687ff 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp @@ -11,6 +11,7 @@ // class map +// pair insert( value_type&& v); // C++17 and later // template // pair insert(P&& p); @@ -19,6 +20,7 @@ #include "MoveOnly.h" #include "min_allocator.h" +#include "test_macros.h" int main() { @@ -55,7 +57,7 @@ int main() assert(r.first->first == 3); assert(r.first->second == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map, min_allocator>> M; typedef std::pair R; @@ -89,5 +91,39 @@ int main() assert(r.first->second == 3); } #endif +#if TEST_STD_VER > 14 + { + typedef std::map M; + typedef std::pair R; + M m; + R r = m.insert({2, MoveOnly(2)}); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(r.first->first == 2); + assert(r.first->second == 2); + + r = m.insert({1, MoveOnly(1)}); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(r.first->first == 1); + assert(r.first->second == 1); + + r = m.insert({3, MoveOnly(3)}); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + + r = m.insert({3, MoveOnly(3)}); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp index b44f46429ec8..7035de83f990 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp @@ -19,6 +19,7 @@ #include "MoveOnly.h" #include "min_allocator.h" +#include "test_macros.h" int main() { @@ -52,7 +53,7 @@ int main() assert(r->first == 3); assert(r->second == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap, min_allocator>> M; typedef std::pair P; @@ -83,5 +84,36 @@ int main() assert(r->second == 2); } #endif +#if TEST_STD_VER > 14 + { + typedef std::multimap M; + typedef std::pair P; + typedef M::iterator R; + M m; + R r = m.insert(m.cend(), {2, MoveOnly(2)}); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.cend(), {1, MoveOnly(1)}); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.cend(), {3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.cend(), {3, MoveOnly(2)}); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 2); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp index b1c043586d65..825e304f65a8 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp @@ -19,6 +19,7 @@ #include "MoveOnly.h" #include "min_allocator.h" +#include "test_macros.h" int main() { @@ -51,7 +52,7 @@ int main() assert(r->first == 3); assert(r->second == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap, min_allocator>> M; typedef M::iterator R; @@ -81,5 +82,35 @@ int main() assert(r->second == 3); } #endif +#if TEST_STD_VER > 14 + { + typedef std::multimap M; + typedef M::iterator R; + M m; + R r = m.insert({2, MoveOnly(2)}); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert({1, MoveOnly(1)}); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert({3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert({3, MoveOnly(3)}); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 3); + } +#endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/support/MoveOnly.h b/test/support/MoveOnly.h index e4d9f6495602..ee6ae7c7e5f9 100644 --- a/test/support/MoveOnly.h +++ b/test/support/MoveOnly.h @@ -17,6 +17,7 @@ class MoveOnly { + friend class MoveOnly2; MoveOnly(const MoveOnly&); MoveOnly& operator=(const MoveOnly&); From 043da5ce84d67963aeeba7fa694033d953da16b6 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 13 Jan 2016 20:04:50 +0000 Subject: [PATCH 3/8] Vendor import of libc++ trunk r257626: https://llvm.org/svn/llvm-project/libcxx/trunk@257626 --- include/__config | 9 +++ include/istream | 46 +++++++-------- include/limits | 3 +- include/memory | 4 +- include/ostream | 32 +++++------ include/sstream | 56 +++++++++---------- include/streambuf | 38 ++++++------- .../sequences/vector.bool/find.pass.cpp | 1 + .../unord/unord.map/load_factor.pass.cpp | 5 +- .../unord.map/unord.map.cnstr/copy.pass.cpp | 7 ++- .../unord.map.cnstr/copy_alloc.pass.cpp | 5 +- .../unord.map.cnstr/init_size.pass.cpp | 5 +- .../unord.map.cnstr/init_size_hash.pass.cpp | 5 +- .../init_size_hash_equal.pass.cpp | 5 +- .../init_size_hash_equal_allocator.pass.cpp | 5 +- .../unord.map/unord.map.cnstr/move.pass.cpp | 5 +- .../unord.map.cnstr/move_alloc.pass.cpp | 7 ++- .../unord.map.cnstr/range_size.pass.cpp | 5 +- .../unord.map.cnstr/range_size_hash.pass.cpp | 5 +- .../range_size_hash_equal.pass.cpp | 5 +- .../range_size_hash_equal_allocator.pass.cpp | 5 +- .../unord/unord.multimap/load_factor.pass.cpp | 5 +- .../unord/unord.multimap/rehash.pass.cpp | 3 +- .../unord.multimap.cnstr/copy.pass.cpp | 7 ++- .../unord.multimap.cnstr/copy_alloc.pass.cpp | 5 +- .../unord.multimap.cnstr/init_size.pass.cpp | 5 +- .../init_size_hash.pass.cpp | 5 +- .../init_size_hash_equal.pass.cpp | 5 +- .../init_size_hash_equal_allocator.pass.cpp | 5 +- .../unord.multimap.cnstr/move.pass.cpp | 5 +- .../unord.multimap.cnstr/move_alloc.pass.cpp | 7 ++- .../unord.multimap.cnstr/range_size.pass.cpp | 5 +- .../range_size_hash.pass.cpp | 5 +- .../range_size_hash_equal.pass.cpp | 5 +- .../range_size_hash_equal_allocator.pass.cpp | 5 +- .../unord/unord.multiset/load_factor.pass.cpp | 5 +- .../unord.multiset.cnstr/copy.pass.cpp | 7 ++- .../unord.multiset.cnstr/copy_alloc.pass.cpp | 5 +- .../unord.multiset.cnstr/init_size.pass.cpp | 5 +- .../init_size_hash.pass.cpp | 5 +- .../init_size_hash_equal.pass.cpp | 5 +- .../init_size_hash_equal_allocator.pass.cpp | 5 +- .../unord.multiset.cnstr/move.pass.cpp | 5 +- .../unord.multiset.cnstr/move_alloc.pass.cpp | 9 +-- .../unord.multiset.cnstr/range_size.pass.cpp | 5 +- .../range_size_hash.pass.cpp | 5 +- .../range_size_hash_equal.pass.cpp | 5 +- .../range_size_hash_equal_allocator.pass.cpp | 5 +- .../unord/unord.set/load_factor.pass.cpp | 5 +- .../unord.set/unord.set.cnstr/copy.pass.cpp | 7 ++- .../unord.set.cnstr/copy_alloc.pass.cpp | 5 +- .../unord.set.cnstr/init_size.pass.cpp | 5 +- .../unord.set.cnstr/init_size_hash.pass.cpp | 5 +- .../init_size_hash_equal.pass.cpp | 5 +- .../init_size_hash_equal_allocator.pass.cpp | 5 +- .../unord.set/unord.set.cnstr/move.pass.cpp | 5 +- .../unord.set.cnstr/move_alloc.pass.cpp | 7 ++- .../unord.set.cnstr/range_size.pass.cpp | 5 +- .../unord.set.cnstr/range_size_hash.pass.cpp | 5 +- .../range_size_hash_equal.pass.cpp | 5 +- .../range_size_hash_equal_allocator.pass.cpp | 5 +- .../string.view.access/at.pass.cpp | 1 + .../numeric.limits.members/traps.pass.cpp | 3 +- .../locale.collate.byname/transform.pass.cpp | 2 +- .../locale/locale.members/combine.pass.cpp | 1 + .../numerics/rand/rand.device/ctor.pass.cpp | 1 + .../unord.hash/integral.pass.cpp | 3 +- .../intseq/intseq.intseq/integer_seq.pass.cpp | 5 +- .../pairs/pair.astuple/pairs.by.type.pass.cpp | 1 + 69 files changed, 279 insertions(+), 208 deletions(-) diff --git a/include/__config b/include/__config index c0b1ef201c05..db5a832b6cd1 100644 --- a/include/__config +++ b/include/__config @@ -433,6 +433,11 @@ namespace std { #define _LIBCPP_HAS_NO_ASAN #endif +// Allow for build-time disabling of unsigned integer sanitization +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK __attribute((no_sanitize("unsigned-integer-overflow"))) +#endif + #elif defined(__GNUC__) #define _ALIGNAS(x) __attribute__((__aligned__(x))) @@ -826,6 +831,10 @@ extern "C" void __sanitizer_annotate_contiguous_container( #define _LIBCPP_HAS_NO_ATOMIC_HEADER #endif +#ifndef _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#define _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK +#endif + #endif // __cplusplus #endif // _LIBCPP_CONFIG diff --git a/include/istream b/include/istream index c6a272e75ef1..0bcc7eeaf639 100644 --- a/include/istream +++ b/include/istream @@ -304,7 +304,7 @@ basic_istream<_CharT, _Traits>::sentry::sentry(basic_istream<_CharT, _Traits>& _ } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf* __sb) : __gc_(0) { @@ -314,7 +314,7 @@ basic_istream<_CharT, _Traits>::basic_istream(basic_streambuf -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) : __gc_(__rhs.__gc_) { @@ -323,7 +323,7 @@ basic_istream<_CharT, _Traits>::basic_istream(basic_istream&& __rhs) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator=(basic_istream&& __rhs) { @@ -339,7 +339,7 @@ basic_istream<_CharT, _Traits>::~basic_istream() } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_istream<_CharT, _Traits>::swap(basic_istream& __rhs) { @@ -725,7 +725,7 @@ basic_istream<_CharT, _Traits>::operator>>(int& __n) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream&)) { @@ -733,7 +733,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_istream& (*__pf)(basic_istream& } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(basic_ios& (*__pf)(basic_ios&)) @@ -743,7 +743,7 @@ basic_istream<_CharT, _Traits>::operator>>(basic_ios& } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::operator>>(ios_base& (*__pf)(ios_base&)) { @@ -800,7 +800,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _CharT* __s) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, unsigned char* __s) { @@ -808,7 +808,7 @@ operator>>(basic_istream& __is, unsigned char* __s) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, signed char* __s) { @@ -843,7 +843,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, _CharT& __c) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, unsigned char& __c) { @@ -851,7 +851,7 @@ operator>>(basic_istream& __is, unsigned char& __c) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream& operator>>(basic_istream& __is, signed char& __c) { @@ -947,7 +947,7 @@ basic_istream<_CharT, _Traits>::get() } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type& __c) { @@ -1006,7 +1006,7 @@ basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n, char_type __ } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(char_type* __s, streamsize __n) { @@ -1068,7 +1068,7 @@ basic_istream<_CharT, _Traits>::get(basic_streambuf& __s } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::get(basic_streambuf& __sb) { @@ -1129,7 +1129,7 @@ basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n, char_typ } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& basic_istream<_CharT, _Traits>::getline(char_type* __s, streamsize __n) { @@ -1462,7 +1462,7 @@ ws(basic_istream<_CharT, _Traits>& __is) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) { @@ -1504,7 +1504,7 @@ public: }; template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf* __sb) : basic_istream<_CharT, _Traits>(__sb) { @@ -1513,14 +1513,14 @@ basic_iostream<_CharT, _Traits>::basic_iostream(basic_streambuf -inline +inline _LIBCPP_INLINE_VISIBILITY basic_iostream<_CharT, _Traits>::basic_iostream(basic_iostream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)) { } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_iostream<_CharT, _Traits>& basic_iostream<_CharT, _Traits>::operator=(basic_iostream&& __rhs) { @@ -1536,7 +1536,7 @@ basic_iostream<_CharT, _Traits>::~basic_iostream() } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_iostream<_CharT, _Traits>::swap(basic_iostream& __rhs) { @@ -1645,7 +1645,7 @@ getline(basic_istream<_CharT, _Traits>& __is, } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>& __is, basic_string<_CharT, _Traits, _Allocator>& __str) @@ -1656,7 +1656,7 @@ getline(basic_istream<_CharT, _Traits>& __is, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str, _CharT __dlm) @@ -1665,7 +1665,7 @@ getline(basic_istream<_CharT, _Traits>&& __is, } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istream<_CharT, _Traits>& getline(basic_istream<_CharT, _Traits>&& __is, basic_string<_CharT, _Traits, _Allocator>& __str) diff --git a/include/limits b/include/limits index ce967ea1b239..80a1be40fe47 100644 --- a/include/limits +++ b/include/limits @@ -237,7 +237,8 @@ protected: static _LIBCPP_CONSTEXPR const bool is_bounded = true; static _LIBCPP_CONSTEXPR const bool is_modulo = !_VSTD::is_signed<_Tp>::value; -#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) +#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \ + defined(__wasm__) static _LIBCPP_CONSTEXPR const bool traps = true; #else static _LIBCPP_CONSTEXPR const bool traps = false; diff --git a/include/memory b/include/memory index 65369d2632c4..3ef687c1774b 100644 --- a/include/memory +++ b/include/memory @@ -3194,7 +3194,7 @@ struct __murmur2_or_cityhash<_Size, 32> // murmur2 template _Size -__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) +__murmur2_or_cityhash<_Size, 32>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { const _Size __m = 0x5bd1e995; const _Size __r = 24; @@ -3344,7 +3344,7 @@ struct __murmur2_or_cityhash<_Size, 64> // cityhash64 template _Size -__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) +__murmur2_or_cityhash<_Size, 64>::operator()(const void* __key, _Size __len) _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK { const char* __s = static_cast(__key); if (__len <= 32) { diff --git a/include/ostream b/include/ostream index 01157b2377db..f55fd40856ec 100644 --- a/include/ostream +++ b/include/ostream @@ -275,7 +275,7 @@ basic_ostream<_CharT, _Traits>::sentry::~sentry() } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf* __sb) { this->init(__sb); @@ -284,14 +284,14 @@ basic_ostream<_CharT, _Traits>::basic_ostream(basic_streambuf -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>::basic_ostream(basic_ostream&& __rhs) { this->move(__rhs); } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator=(basic_ostream&& __rhs) { @@ -307,7 +307,7 @@ basic_ostream<_CharT, _Traits>::~basic_ostream() } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs) { @@ -315,7 +315,7 @@ basic_ostream<_CharT, _Traits>::swap(basic_ostream& __rhs) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream&)) { @@ -323,7 +323,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_ostream& (*__pf)(basic_ostream& } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(basic_ios& (*__pf)(basic_ios&)) @@ -333,7 +333,7 @@ basic_ostream<_CharT, _Traits>::operator<<(basic_ios& } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(ios_base& (*__pf)(ios_base&)) { @@ -989,7 +989,7 @@ basic_ostream<_CharT, _Traits>::flush() } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_ostream<_CharT, _Traits>::pos_type basic_ostream<_CharT, _Traits>::tellp() { @@ -999,7 +999,7 @@ basic_ostream<_CharT, _Traits>::tellp() } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { @@ -1013,7 +1013,7 @@ basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { @@ -1027,7 +1027,7 @@ basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& endl(basic_ostream<_CharT, _Traits>& __os) { @@ -1037,7 +1037,7 @@ endl(basic_ostream<_CharT, _Traits>& __os) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& ends(basic_ostream<_CharT, _Traits>& __os) { @@ -1046,7 +1046,7 @@ ends(basic_ostream<_CharT, _Traits>& __os) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& flush(basic_ostream<_CharT, _Traits>& __os) { @@ -1057,7 +1057,7 @@ flush(basic_ostream<_CharT, _Traits>& __os) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY typename enable_if < !is_lvalue_reference<_Stream>::value && @@ -1081,7 +1081,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) { @@ -1089,7 +1089,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec) } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p) { diff --git a/include/sstream b/include/sstream index 308c3b62f2bc..27ae78f9d45f 100644 --- a/include/sstream +++ b/include/sstream @@ -236,7 +236,7 @@ protected: }; template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode __wch) : __hm_(0), __mode_(__wch) @@ -245,7 +245,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(ios_base::openmode } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const string_type& __s, ios_base::openmode __wch) : __hm_(0), @@ -425,7 +425,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::swap(basic_stringbuf& __rhs) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x, basic_stringbuf<_CharT, _Traits, _Allocator>& __y) @@ -607,7 +607,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekoff(off_type __off, } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_stringbuf<_CharT, _Traits, _Allocator>::pos_type basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, ios_base::openmode __wch) @@ -654,7 +654,7 @@ public: }; template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base::openmode __wch) : basic_istream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::in) @@ -662,7 +662,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(ios_base:: } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const string_type& __s, ios_base::openmode __wch) : basic_istream<_CharT, _Traits>(&__sb_), @@ -673,7 +673,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(const stri #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_istringstream<_CharT, _Traits, _Allocator>::basic_istringstream(basic_istringstream&& __rhs) : basic_istream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) @@ -693,7 +693,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::operator=(basic_istringstream& #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rhs) { @@ -702,7 +702,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::swap(basic_istringstream& __rh } template -inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, basic_istringstream<_CharT, _Traits, _Allocator>& __y) @@ -711,7 +711,7 @@ swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x, } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf<_CharT, _Traits, _Allocator>* basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const { @@ -719,7 +719,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::rdbuf() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> basic_istringstream<_CharT, _Traits, _Allocator>::str() const { @@ -727,7 +727,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { @@ -773,7 +773,7 @@ public: }; template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base::openmode __wch) : basic_ostream<_CharT, _Traits>(&__sb_), __sb_(__wch | ios_base::out) @@ -781,7 +781,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(ios_base:: } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const string_type& __s, ios_base::openmode __wch) : basic_ostream<_CharT, _Traits>(&__sb_), @@ -792,7 +792,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(const stri #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_ostringstream<_CharT, _Traits, _Allocator>::basic_ostringstream(basic_ostringstream&& __rhs) : basic_ostream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) @@ -812,7 +812,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::operator=(basic_ostringstream& #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rhs) { @@ -821,7 +821,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::swap(basic_ostringstream& __rh } template -inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, basic_ostringstream<_CharT, _Traits, _Allocator>& __y) @@ -830,7 +830,7 @@ swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x, } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf<_CharT, _Traits, _Allocator>* basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const { @@ -838,7 +838,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::rdbuf() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> basic_ostringstream<_CharT, _Traits, _Allocator>::str() const { @@ -846,7 +846,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { @@ -892,7 +892,7 @@ public: }; template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::openmode __wch) : basic_iostream<_CharT, _Traits>(&__sb_), __sb_(__wch) @@ -900,7 +900,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(ios_base::op } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string_type& __s, ios_base::openmode __wch) : basic_iostream<_CharT, _Traits>(&__sb_), @@ -911,7 +911,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(const string #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringstream<_CharT, _Traits, _Allocator>::basic_stringstream(basic_stringstream&& __rhs) : basic_iostream<_CharT, _Traits>(_VSTD::move(__rhs)), __sb_(_VSTD::move(__rhs.__sb_)) @@ -931,7 +931,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::operator=(basic_stringstream&& #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs) { @@ -940,7 +940,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::swap(basic_stringstream& __rhs) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, basic_stringstream<_CharT, _Traits, _Allocator>& __y) @@ -949,7 +949,7 @@ swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x, } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_stringbuf<_CharT, _Traits, _Allocator>* basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const { @@ -957,7 +957,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::rdbuf() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> basic_stringstream<_CharT, _Traits, _Allocator>::str() const { @@ -965,7 +965,7 @@ basic_stringstream<_CharT, _Traits, _Allocator>::str() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_stringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) { diff --git a/include/streambuf b/include/streambuf index e75e8be2271d..603c68038796 100644 --- a/include/streambuf +++ b/include/streambuf @@ -220,7 +220,7 @@ basic_streambuf<_CharT, _Traits>::~basic_streambuf() } template -inline +inline _LIBCPP_INLINE_VISIBILITY locale basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) { @@ -231,7 +231,7 @@ basic_streambuf<_CharT, _Traits>::pubimbue(const locale& __loc) } template -inline +inline _LIBCPP_INLINE_VISIBILITY locale basic_streambuf<_CharT, _Traits>::getloc() const { @@ -239,7 +239,7 @@ basic_streambuf<_CharT, _Traits>::getloc() const } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_streambuf<_CharT, _Traits>* basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n) { @@ -247,7 +247,7 @@ basic_streambuf<_CharT, _Traits>::pubsetbuf(char_type* __s, streamsize __n) } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::pos_type basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off, ios_base::seekdir __way, @@ -257,7 +257,7 @@ basic_streambuf<_CharT, _Traits>::pubseekoff(off_type __off, } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::pos_type basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp, ios_base::openmode __which) @@ -266,7 +266,7 @@ basic_streambuf<_CharT, _Traits>::pubseekpos(pos_type __sp, } template -inline +inline _LIBCPP_INLINE_VISIBILITY int basic_streambuf<_CharT, _Traits>::pubsync() { @@ -274,7 +274,7 @@ basic_streambuf<_CharT, _Traits>::pubsync() } template -inline +inline _LIBCPP_INLINE_VISIBILITY streamsize basic_streambuf<_CharT, _Traits>::in_avail() { @@ -284,7 +284,7 @@ basic_streambuf<_CharT, _Traits>::in_avail() } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::snextc() { @@ -294,7 +294,7 @@ basic_streambuf<_CharT, _Traits>::snextc() } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sbumpc() { @@ -304,7 +304,7 @@ basic_streambuf<_CharT, _Traits>::sbumpc() } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sgetc() { @@ -314,7 +314,7 @@ basic_streambuf<_CharT, _Traits>::sgetc() } template -inline +inline _LIBCPP_INLINE_VISIBILITY streamsize basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n) { @@ -322,7 +322,7 @@ basic_streambuf<_CharT, _Traits>::sgetn(char_type* __s, streamsize __n) } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c) { @@ -332,7 +332,7 @@ basic_streambuf<_CharT, _Traits>::sputbackc(char_type __c) } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sungetc() { @@ -342,7 +342,7 @@ basic_streambuf<_CharT, _Traits>::sungetc() } template -inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_streambuf<_CharT, _Traits>::int_type basic_streambuf<_CharT, _Traits>::sputc(char_type __c) { @@ -353,7 +353,7 @@ basic_streambuf<_CharT, _Traits>::sputc(char_type __c) } template -inline +inline _LIBCPP_INLINE_VISIBILITY streamsize basic_streambuf<_CharT, _Traits>::sputn(const char_type* __s, streamsize __n) { @@ -411,7 +411,7 @@ basic_streambuf<_CharT, _Traits>::swap(basic_streambuf& __sb) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_streambuf<_CharT, _Traits>::gbump(int __n) { @@ -419,7 +419,7 @@ basic_streambuf<_CharT, _Traits>::gbump(int __n) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext, char_type* __gend) @@ -430,7 +430,7 @@ basic_streambuf<_CharT, _Traits>::setg(char_type* __gbeg, char_type* __gnext, } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_streambuf<_CharT, _Traits>::pbump(int __n) { @@ -438,7 +438,7 @@ basic_streambuf<_CharT, _Traits>::pbump(int __n) } template -inline +inline _LIBCPP_INLINE_VISIBILITY void basic_streambuf<_CharT, _Traits>::setp(char_type* __pbeg, char_type* __pend) { diff --git a/test/std/containers/sequences/vector.bool/find.pass.cpp b/test/std/containers/sequences/vector.bool/find.pass.cpp index 75567a9b7bbc..a4b5537d2949 100644 --- a/test/std/containers/sequences/vector.bool/find.pass.cpp +++ b/test/std/containers/sequences/vector.bool/find.pass.cpp @@ -15,6 +15,7 @@ // http://llvm.org/bugs/show_bug.cgi?id=16816 #include +#include #include int main() diff --git a/test/std/containers/unord/unord.map/load_factor.pass.cpp b/test/std/containers/unord/unord.map/load_factor.pass.cpp index b25c019688a6..2d6162f280c4 100644 --- a/test/std/containers/unord/unord.map/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.map/load_factor.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "test_macros.h" @@ -40,7 +41,7 @@ int main() P(80, "eighty"), }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_map C; @@ -64,7 +65,7 @@ int main() P(80, "eighty"), }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_map, std::equal_to, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp index 227343e6d5b7..447bcab12e6a 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -63,7 +64,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -103,7 +104,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -144,7 +145,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp index d1757d8a3c1b..7e9125381cab 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -63,7 +64,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -103,7 +104,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp index ac09053b1ebc..b60fb2cad90c 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -58,7 +59,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -92,7 +93,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp index 7a4130bde8fa..f3c086f78876 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -59,7 +60,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -94,7 +95,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp index 036008c0b863..f71c48a70136 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -61,7 +62,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -97,7 +98,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp index 7c83192b664c..c02831676715 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -62,7 +63,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -99,7 +100,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp index 1420204c5f76..0f40e349db67 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -91,7 +92,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -158,7 +159,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp index 091a72f0d160..72a634f0a93d 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -64,7 +65,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -105,7 +106,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -147,7 +148,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp index f914b3060718..b63c47a57dfa 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -62,7 +63,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -98,7 +99,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp index 7a0dbceb17c1..675949e9d9be 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -64,7 +65,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -101,7 +102,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp index 61eef5bc40a4..d55359f7aa06 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -65,7 +66,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -103,7 +104,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp index 99493fad32c5..61f9f21ad25b 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -67,7 +68,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -106,7 +107,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp index f407097dc0c6..52b3f03d88a1 100644 --- a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "min_allocator.h" @@ -39,7 +40,7 @@ int main() P(80, "eighty"), }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_multimap C; @@ -64,7 +65,7 @@ int main() P(80, "eighty"), }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_multimap, std::equal_to, diff --git a/test/std/containers/unord/unord.multimap/rehash.pass.cpp b/test/std/containers/unord/unord.multimap/rehash.pass.cpp index d36dc42e262d..5ef21d3bc4ce 100644 --- a/test/std/containers/unord/unord.multimap/rehash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/rehash.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "min_allocator.h" @@ -62,7 +63,7 @@ void test(const C& c) assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } int main() diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp index d71838f1dfb4..06adfd7cfe05 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -77,7 +78,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -131,7 +132,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -186,7 +187,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp index 2a064c5b5f62..0fb508f1f124 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -77,7 +78,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -131,7 +132,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp index 48239db1fa22..8f6710a93317 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -77,7 +78,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >()); assert(c.key_eq() == test_compare >()); @@ -133,7 +134,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >()); assert(c.key_eq() == test_compare >()); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp index ff0054677055..0962e9b29f83 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -78,7 +79,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >()); @@ -135,7 +136,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >()); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp index 095e9c327f0e..324b0a7c1a5e 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -80,7 +81,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -138,7 +139,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp index d2f698ac2bcb..23ae7d19f9c2 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -81,7 +82,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -140,7 +141,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp index fd70ff10a70a..b61735eb0256 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -119,7 +120,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -219,7 +220,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp index d958e23ddd04..106c29cda8d0 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -86,7 +87,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -150,7 +151,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -215,7 +216,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp index a3fd4d14573d..ad33b13054c7 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -81,7 +82,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >()); assert(c.key_eq() == test_compare >()); @@ -139,7 +140,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >()); assert(c.key_eq() == test_compare >()); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp index 4e7b1ac17a20..98644c75e33b 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -83,7 +84,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >()); @@ -142,7 +143,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >()); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp index 879e6811f2d9..9a79c3056358 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -84,7 +85,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -144,7 +145,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp index 8e42ca7245ee..a5aafb96c7b0 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../NotConstructible.h" @@ -86,7 +87,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); @@ -147,7 +148,7 @@ int main() assert(i->second == "four"); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); diff --git a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp index 07980c2afc85..2a5724b3d270 100644 --- a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "min_allocator.h" @@ -38,7 +39,7 @@ int main() P(80) }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_multiset C; @@ -63,7 +64,7 @@ int main() P(80) }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_multiset, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp index 94241830a06c..a91ee1dae071 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -69,7 +70,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -116,7 +117,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -164,7 +165,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp index 22e372bb3ad1..32c876d32878 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -69,7 +70,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -116,7 +117,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp index a6543a0e6f46..ad42d76db9ee 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -56,7 +57,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -89,7 +90,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp index 7d0f37163a1f..7cc50fa30067 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -58,7 +59,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -92,7 +93,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp index cd013f9554ae..18d3c8288cd2 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -59,7 +60,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -94,7 +95,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp index 4621c7fbb3ff..92d9d86040bb 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -60,7 +61,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -96,7 +97,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp index a68cfe8cd3bb..687f2654f86c 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -97,7 +98,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -173,7 +174,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp index 9eee69a58e5d..c03c605f40ce 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -71,7 +72,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -112,7 +113,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -162,7 +163,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -203,7 +204,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp index 4f5e03e28f4e..f2d0db932bd7 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -59,7 +60,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -94,7 +95,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp index 6b83bde9bc5e..dc40b361d1f3 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -61,7 +62,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -97,7 +98,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp index 89e7c7fa2e3d..c316b7809d53 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -62,7 +63,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -99,7 +100,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp index b712a96f05bc..ab76248c326c 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -64,7 +65,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -102,7 +103,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/load_factor.pass.cpp b/test/std/containers/unord/unord.set/load_factor.pass.cpp index e0ed1694b05b..3e56442d384c 100644 --- a/test/std/containers/unord/unord.set/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/load_factor.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "min_allocator.h" @@ -38,7 +39,7 @@ int main() P(80) }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_set C; @@ -63,7 +64,7 @@ int main() P(80) }; const C c(std::begin(a), std::end(a)); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); } { typedef std::unordered_set, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp index ee05acd6be90..e1a9b27619b7 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -61,7 +62,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -100,7 +101,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE @@ -140,7 +141,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp index 8e1ecd8167f2..b31875befa38 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -61,7 +62,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -100,7 +101,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp index 36dab799c789..340fc410109a 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -56,7 +57,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -89,7 +90,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp index 81af2b41bae2..fa6f0bd2ad5f 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -58,7 +59,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -92,7 +93,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp index f35dd1afa876..dc3a6652ec25 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -59,7 +60,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -94,7 +95,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp index 34ff62ea77b5..1b006dbbc91c 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -60,7 +61,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -96,7 +97,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp index 6bda4afc99cf..f2a2a68d4036 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -97,7 +98,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -173,7 +174,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp index 229e79925f23..92eb36d513b6 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include "../../../test_compare.h" #include "../../../test_hash.h" @@ -63,7 +64,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -104,7 +105,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); @@ -146,7 +147,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); assert(c0.empty()); diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp index 179f73d7e184..ff50c712ab5d 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -59,7 +60,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -94,7 +95,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp index 60350de962c7..bcdcc5510c3c 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -61,7 +62,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -97,7 +98,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp index 70e82d034647..632265ac861d 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -62,7 +63,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -99,7 +100,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp index a6fb2e667ae1..ebe54fd4cbc6 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include "test_iterators.h" #include "../../../test_compare.h" @@ -64,7 +65,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #if __cplusplus >= 201103L @@ -102,7 +103,7 @@ int main() assert(!c.empty()); assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); - assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } #endif diff --git a/test/std/experimental/string.view/string.view.access/at.pass.cpp b/test/std/experimental/string.view/string.view.access/at.pass.cpp index a3208c1645a2..46804d4df3af 100644 --- a/test/std/experimental/string.view/string.view.access/at.pass.cpp +++ b/test/std/experimental/string.view/string.view.access/at.pass.cpp @@ -17,6 +17,7 @@ // constexpr const _CharT& at(size_type _pos) const; #include +#include #include template diff --git a/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp b/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp index af93e78c0e91..23811fada5e2 100644 --- a/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp +++ b/test/std/language.support/support.limits/limits/numeric.limits.members/traps.pass.cpp @@ -13,7 +13,8 @@ #include -#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) +#if defined(__i386__) || defined(__x86_64__) || defined(__pnacl__) || \ + defined(__wasm__) static const bool integral_types_trap = true; #else static const bool integral_types_trap = false; diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp index 04cc060ad985..d31705e5ad1b 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp @@ -26,7 +26,7 @@ int main() { // Ensure that the default locale is not C. If it is, the second tests will fail. - putenv(const_cast("LC_COLLATE=" LOCALE_en_US_UTF_8)); + putenv(const_cast("LC_ALL=" LOCALE_en_US_UTF_8)); { std::locale l(LOCALE_en_US_UTF_8); { diff --git a/test/std/localization/locales/locale/locale.members/combine.pass.cpp b/test/std/localization/locales/locale/locale.members/combine.pass.cpp index 4573a4b01f47..26a760f773a5 100644 --- a/test/std/localization/locales/locale/locale.members/combine.pass.cpp +++ b/test/std/localization/locales/locale/locale.members/combine.pass.cpp @@ -13,6 +13,7 @@ // template locale combine(const locale& other) const; #include +#include #include #include "count_new.hpp" diff --git a/test/std/numerics/rand/rand.device/ctor.pass.cpp b/test/std/numerics/rand/rand.device/ctor.pass.cpp index a7b5a7c9c348..dfeccc81e30e 100644 --- a/test/std/numerics/rand/rand.device/ctor.pass.cpp +++ b/test/std/numerics/rand/rand.device/ctor.pass.cpp @@ -20,6 +20,7 @@ // throw. #include +#include #include #include diff --git a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp index d3db45fad7c0..c20f31ff2c99 100644 --- a/test/std/utilities/function.objects/unord.hash/integral.pass.cpp +++ b/test/std/utilities/function.objects/unord.hash/integral.pass.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include template @@ -59,7 +60,7 @@ int main() test(); // LWG #2119 - test(); + test(); test(); test(); diff --git a/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp b/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp index a795e90c41e4..5c789f5db274 100644 --- a/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp +++ b/test/std/utilities/intseq/intseq.intseq/integer_seq.pass.cpp @@ -19,6 +19,7 @@ #include #include +#include #include int main() @@ -27,7 +28,7 @@ int main() // Make a few of sequences using int3 = std::integer_sequence; - using size1 = std::integer_sequence; + using size1 = std::integer_sequence; using ushort2 = std::integer_sequence; using bool0 = std::integer_sequence; @@ -35,7 +36,7 @@ int main() static_assert ( std::is_same::value, "int3 type wrong" ); static_assert ( int3::size() == 3, "int3 size wrong" ); - static_assert ( std::is_same::value, "size1 type wrong" ); + static_assert ( std::is_same::value, "size1 type wrong" ); static_assert ( size1::size() == 1, "size1 size wrong" ); static_assert ( std::is_same::value, "ushort2 type wrong" ); diff --git a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp index efcc2cedc6e1..f4a6232266bb 100644 --- a/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp +++ b/test/std/utilities/utility/pairs/pair.astuple/pairs.by.type.pass.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include From dfd66a522f6e3ab9b03c0921ba40f012de0958b0 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 16 Jan 2016 17:20:41 +0000 Subject: [PATCH 4/8] Vendor import of libc++ release_38 branch r257836: https://llvm.org/svn/llvm-project/libcxx/branches/release_38@257836 --- include/algorithm | 19 -- include/iterator | 23 ++ include/string | 114 +++++----- .../iterators/trivial_iterators.pass.cpp | 187 ++++++++++++++++ .../strings/iterators.exceptions.pass.cpp | 79 +++++++ .../strings/iterators.noexcept.pass.cpp | 79 +++++++ .../string_append/initializer_list.pass.cpp | 2 +- .../string_append/iterator.pass.cpp | 31 ++- .../string_append/pointer.pass.cpp | 2 +- .../string_append/pointer_size.pass.cpp | 2 +- .../string_append/push_back.pass.cpp | 2 +- .../string_append/size_char.pass.cpp | 2 +- .../string_append/string.pass.cpp | 2 +- .../string_append/string_size_size.pass.cpp | 2 +- .../string_assign/initializer_list.pass.cpp | 2 +- .../string_assign/iterator.pass.cpp | 29 ++- .../string_assign/pointer.pass.cpp | 2 +- .../string_assign/pointer_size.pass.cpp | 2 +- .../string_assign/rv_string.pass.cpp | 2 +- .../string_assign/size_char.pass.cpp | 2 +- .../string_assign/string.pass.cpp | 2 +- .../string_assign/string_size_size.pass.cpp | 2 +- .../string_insert/iter_char.pass.cpp | 2 +- .../iter_initializer_list.pass.cpp | 2 +- .../string_insert/iter_iter_iter.pass.cpp | 32 ++- .../string_insert/iter_size_char.pass.cpp | 2 +- .../string_insert/size_pointer.pass.cpp | 2 +- .../string_insert/size_pointer_size.pass.cpp | 2 +- .../string_insert/size_size_char.pass.cpp | 2 +- .../string_insert/size_string.pass.cpp | 2 +- .../size_string_size_size.pass.cpp | 2 +- .../iter_iter_initializer_list.pass.cpp | 2 +- .../iter_iter_iter_iter.pass.cpp | 32 ++- .../string_replace/iter_iter_pointer.pass.cpp | 2 +- .../iter_iter_pointer_size.pass.cpp | 2 +- .../iter_iter_size_char.pass.cpp | 2 +- .../string_replace/iter_iter_string.pass.cpp | 2 +- .../string_replace/size_size_pointer.pass.cpp | 2 +- .../size_size_pointer_size.pass.cpp | 2 +- .../size_size_size_char.pass.cpp | 2 +- .../string_replace/size_size_string.pass.cpp | 2 +- .../size_size_string_size_size.pass.cpp | 2 +- test/support/test_iterators.h | 199 ++++++++++++++++++ 43 files changed, 776 insertions(+), 112 deletions(-) create mode 100644 test/libcxx/iterators/trivial_iterators.pass.cpp create mode 100644 test/libcxx/strings/iterators.exceptions.pass.cpp create mode 100644 test/libcxx/strings/iterators.noexcept.pass.cpp diff --git a/include/algorithm b/include/algorithm index 9c051198930d..71e5df37dfeb 100644 --- a/include/algorithm +++ b/include/algorithm @@ -1687,25 +1687,6 @@ search_n(_ForwardIterator __first, _ForwardIterator __last, _Size __count, const } // copy - -template -struct __libcpp_is_trivial_iterator -{ - static const bool value = is_pointer<_Iter>::value; -}; - -template -struct __libcpp_is_trivial_iterator > -{ - static const bool value = is_pointer<_Iter>::value; -}; - -template -struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> > -{ - static const bool value = is_pointer<_Iter>::value; -}; - template inline _LIBCPP_INLINE_VISIBILITY _Iter diff --git a/include/iterator b/include/iterator index 8dd6bd59c1a8..8d9b31101bdf 100644 --- a/include/iterator +++ b/include/iterator @@ -437,6 +437,12 @@ struct __is_bidirectional_iterator : public __has_iterator_category_convertible_ template struct __is_random_access_iterator : public __has_iterator_category_convertible_to<_Tp, random_access_iterator_tag> {}; +template +struct __is_exactly_input_iterator + : public integral_constant::value && + !__has_iterator_category_convertible_to<_Tp, forward_iterator_tag>::value> {}; + template struct _LIBCPP_TYPE_VIS_ONLY iterator @@ -1404,6 +1410,23 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } +template +struct __libcpp_is_trivial_iterator + : public _LIBCPP_BOOL_CONSTANT(is_pointer<_Iter>::value) {}; + +template +struct __libcpp_is_trivial_iterator > + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; + +template +struct __libcpp_is_trivial_iterator > + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; + +template +struct __libcpp_is_trivial_iterator<__wrap_iter<_Iter> > + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value) {}; + + template inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp* diff --git a/include/string b/include/string index ee5db1aab63b..91502441e0c0 100644 --- a/include/string +++ b/include/string @@ -1201,6 +1201,30 @@ _LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common) #pragma warning( pop ) #endif // _LIBCPP_MSVC +#ifdef _LIBCPP_NO_EXCEPTIONS +template +struct __libcpp_string_gets_noexcept_iterator_impl : public true_type {}; +#elif defined(_LIBCPP_HAS_NO_NOEXCEPT) +template +struct __libcpp_string_gets_noexcept_iterator_impl : public false_type {}; +#else +template ::value> +struct __libcpp_string_gets_noexcept_iterator_impl : public _LIBCPP_BOOL_CONSTANT(( + noexcept(++(declval<_Iter&>())) && + is_nothrow_assignable<_Iter&, _Iter>::value && + noexcept(declval<_Iter>() == declval<_Iter>()) && + noexcept(*declval<_Iter>()) +)) {}; + +template +struct __libcpp_string_gets_noexcept_iterator_impl<_Iter, false> : public false_type {}; +#endif + + +template +struct __libcpp_string_gets_noexcept_iterator + : public _LIBCPP_BOOL_CONSTANT(__libcpp_is_trivial_iterator<_Iter>::value || __libcpp_string_gets_noexcept_iterator_impl<_Iter>::value) {}; + #ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT template @@ -1495,15 +1519,16 @@ public: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type append(_InputIterator __first, _InputIterator __last); template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string& >::type append(_ForwardIterator __first, _ForwardIterator __last); @@ -1535,15 +1560,16 @@ public: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string& >::type assign(_InputIterator __first, _InputIterator __last); template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string& >::type assign(_ForwardIterator __first, _ForwardIterator __last); @@ -1564,15 +1590,16 @@ public: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, iterator >::type insert(const_iterator __pos, _InputIterator __first, _InputIterator __last); template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, iterator >::type insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last); @@ -1817,8 +1844,7 @@ private: template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value, void >::type __init(_InputIterator __first, _InputIterator __last); @@ -2195,8 +2221,7 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value, void >::type basic_string<_CharT, _Traits, _Allocator>::__init(_InputIterator __first, _InputIterator __last) @@ -2494,15 +2519,14 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator <_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::assign(_InputIterator __first, _InputIterator __last) { - clear(); - for (; __first != __last; ++__first) - push_back(*__first); + basic_string __temp(__first, __last, __alloc()); + assign(__temp.data(), __temp.size()); return *this; } @@ -2510,7 +2534,8 @@ template template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _ForwardIterator __last) @@ -2643,14 +2668,14 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::append(_InputIterator __first, _InputIterator __last) { - for (; __first != __last; ++__first) - push_back(*__first); + basic_string __temp (__first, __last, __alloc()); + append(__temp.data(), __temp.size()); return *this; } @@ -2658,7 +2683,8 @@ template template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, basic_string<_CharT, _Traits, _Allocator>& >::type basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _ForwardIterator __last) @@ -2774,9 +2800,9 @@ template template typename enable_if < - __is_input_iterator <_InputIterator>::value && - !__is_forward_iterator<_InputIterator>::value, - typename basic_string<_CharT, _Traits, _Allocator>::iterator + __is_exactly_input_iterator<_InputIterator>::value + || !__libcpp_string_gets_noexcept_iterator<_InputIterator>::value, + typename basic_string<_CharT, _Traits, _Allocator>::iterator >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { @@ -2785,24 +2811,16 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIt "string::insert(iterator, range) called with an iterator not" " referring to this string"); #endif - size_type __old_sz = size(); - difference_type __ip = __pos - begin(); - for (; __first != __last; ++__first) - push_back(*__first); - pointer __p = __get_pointer(); - _VSTD::rotate(__p + __ip, __p + __old_sz, __p + size()); -#if _LIBCPP_DEBUG_LEVEL >= 2 - return iterator(this, __p + __ip); -#else - return iterator(__p + __ip); -#endif + basic_string __temp(__first, __last, __alloc()); + return insert(__pos, __temp.data(), __temp.data() + __temp.size()); } template template typename enable_if < - __is_forward_iterator<_ForwardIterator>::value, + __is_forward_iterator<_ForwardIterator>::value + && __libcpp_string_gets_noexcept_iterator<_ForwardIterator>::value, typename basic_string<_CharT, _Traits, _Allocator>::iterator >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) @@ -3005,22 +3023,8 @@ typename enable_if basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, _InputIterator __j1, _InputIterator __j2) { - for (; true; ++__i1, ++__j1) - { - if (__i1 == __i2) - { - if (__j1 != __j2) - insert(__i1, __j1, __j2); - break; - } - if (__j1 == __j2) - { - erase(__i1, __i2); - break; - } - traits_type::assign(const_cast(*__i1), *__j1); - } - return *this; + basic_string __temp(__j1, __j2, __alloc()); + return this->replace(__i1, __i2, __temp); } template diff --git a/test/libcxx/iterators/trivial_iterators.pass.cpp b/test/libcxx/iterators/trivial_iterators.pass.cpp new file mode 100644 index 000000000000..0b7a47316d65 --- /dev/null +++ b/test/libcxx/iterators/trivial_iterators.pass.cpp @@ -0,0 +1,187 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +// + +// __libcpp_is_trivial_iterator + +// __libcpp_is_trivial_iterator determines if an iterator is a "trivial" one, +// that can be used w/o worrying about its operations throwing exceptions. +// Pointers are trivial iterators. Libc++ has three "iterator wrappers": +// reverse_iterator, move_iterator, and __wrap_iter. If the underlying iterator +// is trivial, then those are as well. +// + +#include +#include +#include +#include +#include + +#include "test_iterators.h" + +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define DELETE_FUNCTION = delete +#else +#define DELETE_FUNCTION +#endif + +class T; // incomplete + +class my_input_iterator_tag : public std::input_iterator_tag {}; + +template +class my_input_iterator +{ + It it_; + + template friend class input_iterator; +public: + typedef my_input_iterator_tag iterator_category; + typedef typename std::iterator_traits::value_type value_type; + typedef typename std::iterator_traits::difference_type difference_type; + typedef It pointer; + typedef typename std::iterator_traits::reference reference; + + It base() const {return it_;} + + my_input_iterator() : it_() {} + explicit my_input_iterator(It it) : it_(it) {} + template + my_input_iterator(const input_iterator& u) :it_(u.it_) {} + + reference operator*() const {return *it_;} + pointer operator->() const {return it_;} + + my_input_iterator& operator++() {++it_; return *this;} + my_input_iterator operator++(int) + {my_input_iterator tmp(*this); ++(*this); return tmp;} + + friend bool operator==(const my_input_iterator& x, const my_input_iterator& y) + {return x.it_ == y.it_;} + friend bool operator!=(const my_input_iterator& x, const my_input_iterator& y) + {return !(x == y);} + + template + void operator,(T const &) DELETE_FUNCTION; +}; + +template +inline +bool +operator==(const my_input_iterator& x, const my_input_iterator& y) +{ + return x.base() == y.base(); +} + +template +inline +bool +operator!=(const my_input_iterator& x, const my_input_iterator& y) +{ + return !(x == y); +} + + +int main() +{ +// basic tests + static_assert(( std::__libcpp_is_trivial_iterator::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::value), ""); + + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator >::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator >::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator >::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator > ::value), ""); + + static_assert(( std::__libcpp_is_trivial_iterator > > ::value), ""); + +// iterators in the libc++ test suite + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + static_assert((!std::__libcpp_is_trivial_iterator >::value), ""); + + +// Iterator classification + static_assert(( std::__is_input_iterator ::value), "" ); + static_assert(( std::__is_forward_iterator ::value), "" ); + static_assert(( std::__is_bidirectional_iterator::value), "" ); + static_assert(( std::__is_random_access_iterator::value), "" ); + static_assert((!std::__is_exactly_input_iterator::value), "" ); + + static_assert(( std::__is_input_iterator >::value), "" ); + static_assert((!std::__is_forward_iterator >::value), "" ); + static_assert((!std::__is_bidirectional_iterator >::value), "" ); + static_assert((!std::__is_random_access_iterator >::value), "" ); + static_assert(( std::__is_exactly_input_iterator >::value), "" ); + + static_assert(( std::__is_input_iterator >::value), "" ); + static_assert(( std::__is_forward_iterator >::value), "" ); + static_assert((!std::__is_bidirectional_iterator >::value), "" ); + static_assert((!std::__is_random_access_iterator >::value), "" ); + static_assert((!std::__is_exactly_input_iterator >::value), "" ); + + static_assert(( std::__is_input_iterator >::value), "" ); + static_assert(( std::__is_forward_iterator >::value), "" ); + static_assert(( std::__is_bidirectional_iterator >::value), "" ); + static_assert((!std::__is_random_access_iterator >::value), "" ); + static_assert((!std::__is_exactly_input_iterator >::value), "" ); + + static_assert(( std::__is_input_iterator >::value), "" ); + static_assert(( std::__is_forward_iterator >::value), "" ); + static_assert(( std::__is_bidirectional_iterator >::value), "" ); + static_assert(( std::__is_random_access_iterator >::value), "" ); + static_assert((!std::__is_exactly_input_iterator >::value), "" ); + + static_assert(( std::__is_input_iterator >::value), "" ); + static_assert((!std::__is_forward_iterator >::value), "" ); + static_assert((!std::__is_bidirectional_iterator >::value), "" ); + static_assert((!std::__is_random_access_iterator >::value), "" ); + static_assert(( std::__is_exactly_input_iterator >::value), "" ); + +// +// iterators from libc++'s containers +// + +// string + static_assert(( std::__libcpp_is_trivial_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::const_iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::reverse_iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::const_reverse_iterator>::value), ""); + +// vector + static_assert(( std::__libcpp_is_trivial_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::const_iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::reverse_iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::const_reverse_iterator>::value), ""); + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +// Initializer list (which has no reverse iterators) + static_assert(( std::__libcpp_is_trivial_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_is_trivial_iterator::const_iterator> ::value), ""); +#endif + +} diff --git a/test/libcxx/strings/iterators.exceptions.pass.cpp b/test/libcxx/strings/iterators.exceptions.pass.cpp new file mode 100644 index 000000000000..591782b5dd4a --- /dev/null +++ b/test/libcxx/strings/iterators.exceptions.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +// + +// __libcpp_is_trivial_iterator + +// __libcpp_string_gets_noexcept_iterator determines if an iterator can be used +// w/o worrying about whether or not certain operations can throw. +// This gives us a "fast path for string operations" +// + +#include +#include +#include +#include +#include + +#include "test_iterators.h" + +int main() +{ +// basic tests + static_assert(( std::__libcpp_string_gets_noexcept_iterator::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator > > ::value), ""); + +// iterators in the libc++ test suite + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); + +#if __has_feature(cxx_noexcept) + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); +#else + static_assert((!std::__libcpp_string_gets_noexcept_iterator >::value), ""); +#endif + +// +// iterators from libc++'s containers +// + +// string + static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::reverse_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_reverse_iterator>::value), ""); + +// vector + static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::reverse_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_reverse_iterator>::value), ""); + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +// Initializer list (which has no reverse iterators) + static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); +#endif +} diff --git a/test/libcxx/strings/iterators.noexcept.pass.cpp b/test/libcxx/strings/iterators.noexcept.pass.cpp new file mode 100644 index 000000000000..f39a4deac735 --- /dev/null +++ b/test/libcxx/strings/iterators.noexcept.pass.cpp @@ -0,0 +1,79 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// + +// + +// __libcpp_is_trivial_iterator + +// __libcpp_string_gets_noexcept_iterator determines if an iterator can be used +// w/o worrying about whether or not certain operations can throw. +// This gives us a "fast path for string operations". +// +// When exceptions are disabled, all iterators should get this "fast path" +// + +#define _LIBCPP_NO_EXCEPTIONS + +#include +#include +#include +#include +#include + +#include "test_iterators.h" + +int main() +{ +// basic tests + static_assert(( std::__libcpp_string_gets_noexcept_iterator::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator > ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator > > ::value), ""); + +// iterators in the libc++ test suite + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + + static_assert(( std::__libcpp_string_gets_noexcept_iterator >::value), ""); + +// +// iterators from libc++'s containers +// + +// string + static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::reverse_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_reverse_iterator>::value), ""); + +// vector + static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::reverse_iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_reverse_iterator>::value), ""); + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +// Initializer list (which has no reverse iterators) + static_assert(( std::__libcpp_string_gets_noexcept_iterator::iterator> ::value), ""); + static_assert(( std::__libcpp_string_gets_noexcept_iterator::const_iterator> ::value), ""); +#endif +} diff --git a/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp index fb28e498c321..2abfbf0a172b 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/initializer_list.pass.cpp @@ -24,7 +24,7 @@ int main() s.append({'a', 'b', 'c'}); assert(s == "123abc"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S s("123"); diff --git a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp index 3bf2afa25521..82e6fb5895e7 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/iterator.pass.cpp @@ -15,7 +15,7 @@ #include #include -#include "../../input_iterator.h" +#include "test_iterators.h" #include "min_allocator.h" template @@ -27,6 +27,20 @@ test(S s, It first, It last, S expected) assert(s == expected); } +template +void +test_exceptions(S s, It first, It last) +{ + S aCopy = s; + try { + s.append(first, last); + assert(false); + } + catch (...) {} + assert(s.__invariants()); + assert(s == aCopy); +} + int main() { { @@ -87,7 +101,7 @@ int main() test(S("12345678901234567890"), input_iterator(s), input_iterator(s+52), S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -147,4 +161,17 @@ int main() S("12345678901234567890""ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); } #endif + { // test iterator operations that throw + typedef std::string S; + typedef ThrowingIterator TIter; + typedef input_iterator IIter; + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test_exceptions(S(), IIter(TIter(s, s+10, 4, TIter::TAIncrement)), IIter()); + test_exceptions(S(), IIter(TIter(s, s+10, 5, TIter::TADereference)), IIter()); + test_exceptions(S(), IIter(TIter(s, s+10, 6, TIter::TAComparison)), IIter()); + + test_exceptions(S(), TIter(s, s+10, 4, TIter::TAIncrement), TIter()); + test_exceptions(S(), TIter(s, s+10, 5, TIter::TADereference), TIter()); + test_exceptions(S(), TIter(s, s+10, 6, TIter::TAComparison), TIter()); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp index 5ae15f0a0a4a..c0413d607e8f 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/pointer.pass.cpp @@ -43,7 +43,7 @@ int main() test(S("12345678901234567890"), "12345678901234567890", S("1234567890123456789012345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), "", S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp index 5a9e8e2b814b..f3ea3b0a89d7 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/pointer_size.pass.cpp @@ -48,7 +48,7 @@ int main() test(S("12345678901234567890"), "12345678901234567890", 20, S("1234567890123456789012345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), "", 0, S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp index b0a2eb5e5cbd..d6116d3f4823 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp @@ -33,7 +33,7 @@ int main() test(S("12345"), 'a', S("12345a")); test(S("12345678901234567890"), 'a', S("12345678901234567890a")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), 'a', S(1, 'a')); diff --git a/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp index 00e6ae375cce..a049e6112a8a 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/size_char.pass.cpp @@ -43,7 +43,7 @@ int main() test(S("12345678901234567890"), 1, 'a', S("12345678901234567890a")); test(S("12345678901234567890"), 10, 'a', S("12345678901234567890aaaaaaaaaa")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), 0, 'a', S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp index 31f174b4f305..e25627fa6a24 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/string.pass.cpp @@ -51,7 +51,7 @@ int main() test(S("12345678901234567890"), S("12345678901234567890"), S("1234567890123456789012345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), S(), S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp index 1d409b0932da..d67b0304b41a 100644 --- a/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_append/string_size_size.pass.cpp @@ -80,7 +80,7 @@ int main() test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, S("123456789012345678906789012345")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), S(), 0, 0, S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp index 2dae10745965..003af0eef827 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/initializer_list.pass.cpp @@ -24,7 +24,7 @@ int main() s.assign({'a', 'b', 'c'}); assert(s == "abc"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S s("123"); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp index 83b5dd14b3f6..690aebd4c2a6 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp @@ -15,7 +15,7 @@ #include #include -#include "../../input_iterator.h" +#include "test_iterators.h" #include "min_allocator.h" template @@ -27,6 +27,20 @@ test(S s, It first, It last, S expected) assert(s == expected); } +template +void +test_exceptions(S s, It first, It last) +{ + S aCopy = s; + try { + s.assign(first, last); + assert(false); + } + catch (...) {} + assert(s.__invariants()); + assert(s == aCopy); +} + int main() { { @@ -147,4 +161,17 @@ int main() S("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); } #endif + { // test iterator operations that throw + typedef std::string S; + typedef ThrowingIterator TIter; + typedef input_iterator IIter; + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test_exceptions(S(), IIter(TIter(s, s+10, 4, TIter::TAIncrement)), IIter()); + test_exceptions(S(), IIter(TIter(s, s+10, 5, TIter::TADereference)), IIter()); + test_exceptions(S(), IIter(TIter(s, s+10, 6, TIter::TAComparison)), IIter()); + + test_exceptions(S(), TIter(s, s+10, 4, TIter::TAIncrement), TIter()); + test_exceptions(S(), TIter(s, s+10, 5, TIter::TADereference), TIter()); + test_exceptions(S(), TIter(s, s+10, 6, TIter::TAComparison), TIter()); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp index adf24ac49877..07dbcea704dc 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/pointer.pass.cpp @@ -43,7 +43,7 @@ int main() test(S("12345678901234567890"), "12345678901234567890", S("12345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), "", S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp index 476fe963de73..a9c71cec882b 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/pointer_size.pass.cpp @@ -48,7 +48,7 @@ int main() test(S("12345678901234567890"), "12345678901234567890", 20, S("12345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), "", 0, S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp index 4273860f41ad..b3d225a8d04a 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/rv_string.pass.cpp @@ -52,7 +52,7 @@ int main() test(S("12345678901234567890"), S("12345678901234567890"), S("12345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), S(), S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp index a8f747091c6d..9dd19d877c90 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/size_char.pass.cpp @@ -43,7 +43,7 @@ int main() test(S("12345678901234567890"), 1, 'a', S(1, 'a')); test(S("12345678901234567890"), 10, 'a', S(10, 'a')); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), 0, 'a', S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp index 99b53155d37e..2bc5dd223e62 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/string.pass.cpp @@ -51,7 +51,7 @@ int main() test(S("12345678901234567890"), S("12345678901234567890"), S("12345678901234567890")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), S(), S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp index db9e9a3271c6..275d249d304c 100644 --- a/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_assign/string_size_size.pass.cpp @@ -80,7 +80,7 @@ int main() test(S("12345678901234567890"), S("12345678901234567890"), 5, 10, S("6789012345")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(), S(), 0, 0, S()); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp index b9e5fa8bc064..6b0a3aa006ee 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_char.pass.cpp @@ -56,7 +56,7 @@ int main() test(s, s.begin()+5, 'B', S("a567AB1432dcb")); test(s, s.begin()+6, 'C', S("a567ABC1432dcb")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S s; diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp index e091662eae06..2adf846c1e36 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_initializer_list.pass.cpp @@ -29,7 +29,7 @@ int main() assert(i - s.begin() == 3); assert(s == "123abc456"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S s("123456"); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp index 38353dd2f4e4..4c29ab4ed093 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_iter_iter.pass.cpp @@ -19,7 +19,7 @@ #include #include -#include "../../input_iterator.h" +#include "test_iterators.h" #include "min_allocator.h" template @@ -33,6 +33,21 @@ test(S s, typename S::difference_type pos, It first, It last, S expected) assert(s == expected); } +template +void +test_exceptions(S s, typename S::difference_type pos, It first, It last) +{ + typename S::const_iterator p = s.cbegin() + pos; + S aCopy = s; + try { + s.insert(p, first, last); + assert(false); + } + catch (...) {} + assert(s.__invariants()); + assert(s == aCopy); +} + int main() { { @@ -80,7 +95,7 @@ int main() test(S("12345678901234567890"), 20, input_iterator(s), input_iterator(s+52), S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; @@ -127,6 +142,19 @@ int main() S("12345678901234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")); } #endif + { // test iterator operations that throw + typedef std::string S; + typedef ThrowingIterator TIter; + typedef input_iterator IIter; + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test_exceptions(S(), 0, IIter(TIter(s, s+10, 4, TIter::TAIncrement)), IIter()); + test_exceptions(S(), 0, IIter(TIter(s, s+10, 5, TIter::TADereference)), IIter()); + test_exceptions(S(), 0, IIter(TIter(s, s+10, 6, TIter::TAComparison)), IIter()); + + test_exceptions(S(), 0, TIter(s, s+10, 4, TIter::TAIncrement), TIter()); + test_exceptions(S(), 0, TIter(s, s+10, 5, TIter::TADereference), TIter()); + test_exceptions(S(), 0, TIter(s, s+10, 6, TIter::TAComparison), TIter()); + } #if _LIBCPP_DEBUG >= 1 { std::string v; diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp index 739c89404c1d..e6d1db6fc0df 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/iter_size_char.pass.cpp @@ -101,7 +101,7 @@ int main() test(S("abcdefghijklmnopqrst"), 20, 10, '1', S("abcdefghijklmnopqrst1111111111")); test(S("abcdefghijklmnopqrst"), 20, 20, '1', S("abcdefghijklmnopqrst11111111111111111111")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(""), 0, 0, '1', S("")); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp index 8277f88d99cd..247b3308f96e 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer.pass.cpp @@ -124,7 +124,7 @@ int main() test(S("abcdefghijklmnopqrst"), 21, "1234567890", S("can't happen")); test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", S("can't happen")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(""), 0, "", S("")); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp index 4df5a14cbc0e..41b81231075e 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_pointer_size.pass.cpp @@ -365,7 +365,7 @@ int main() test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 19, S("can't happen")); test(S("abcdefghijklmnopqrst"), 21, "12345678901234567890", 20, S("can't happen")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(""), 0, "", 0, S("")); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp index 20e030273962..945ec48012ba 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_size_char.pass.cpp @@ -125,7 +125,7 @@ int main() test(S("abcdefghijklmnopqrst"), 21, 10, '1', S("can't happen")); test(S("abcdefghijklmnopqrst"), 21, 20, '1', S("can't happen")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(""), 0, 0, '1', S("")); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp index 016dcaf396fe..04b47ec78988 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string.pass.cpp @@ -124,7 +124,7 @@ int main() test(S("abcdefghijklmnopqrst"), 21, S("1234567890"), S("can't happen")); test(S("abcdefghijklmnopqrst"), 21, S("12345678901234567890"), S("can't happen")); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test(S(""), 0, S(""), S("")); diff --git a/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp index 3c4c818e0396..c3745c3749db 100644 --- a/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_insert/size_string_size_size.pass.cpp @@ -1746,7 +1746,7 @@ int main() test29(); test30(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp index 20455b258c0a..b60a58c55e0e 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_initializer_list.pass.cpp @@ -24,7 +24,7 @@ int main() s.replace(s.cbegin() + 3, s.cbegin() + 6, {'a', 'b', 'c'}); assert(s == "123abc456"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; S s("123def456"); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp index 9295c5bde9fa..057964112aa1 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_iter_iter.pass.cpp @@ -18,6 +18,7 @@ #include #include "min_allocator.h" +#include "test_iterators.h" template void @@ -34,6 +35,22 @@ test(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l, S ex assert(s.size() == old_size - xlen + rlen); } +template +void +test_exceptions(S s, typename S::size_type pos1, typename S::size_type n1, It f, It l) +{ + typename S::const_iterator first = s.begin() + pos1; + typename S::const_iterator last = s.begin() + pos1 + n1; + S aCopy = s; + try { + s.replace(first, last, f, l); + assert(false); + } + catch (...) {} + assert(s.__invariants()); + assert(s == aCopy); +} + const char* str = "12345678901234567890"; template @@ -959,7 +976,7 @@ int main() test7(); test8(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); @@ -973,4 +990,17 @@ int main() test8(); } #endif + { // test iterator operations that throw + typedef std::string S; + typedef ThrowingIterator TIter; + typedef input_iterator IIter; + const char* s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; + test_exceptions(S("abcdefghijklmnopqrst"), 10, 5, IIter(TIter(s, s+10, 4, TIter::TAIncrement)), IIter()); + test_exceptions(S("abcdefghijklmnopqrst"), 10, 5, IIter(TIter(s, s+10, 5, TIter::TADereference)), IIter()); + test_exceptions(S("abcdefghijklmnopqrst"), 10, 5, IIter(TIter(s, s+10, 6, TIter::TAComparison)), IIter()); + + test_exceptions(S("abcdefghijklmnopqrst"), 10, 5, TIter(s, s+10, 4, TIter::TAIncrement), TIter()); + test_exceptions(S("abcdefghijklmnopqrst"), 10, 5, TIter(s, s+10, 5, TIter::TADereference), TIter()); + test_exceptions(S("abcdefghijklmnopqrst"), 10, 5, TIter(s, s+10, 6, TIter::TAComparison), TIter()); + } } diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp index cb4ce61d0942..c7551b928ec1 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer.pass.cpp @@ -274,7 +274,7 @@ int main() test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp index b1d6ab1ba579..087df7824ac2 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_pointer_size.pass.cpp @@ -959,7 +959,7 @@ int main() test7(); test8(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp index b0e2234a7e53..8be8b5298237 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_size_char.pass.cpp @@ -275,7 +275,7 @@ int main() test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp index 0f95492fdb1a..b85a1063ebe1 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/iter_iter_string.pass.cpp @@ -274,7 +274,7 @@ int main() test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp index 18f32bfe222a..eb0e982ef16e 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer.pass.cpp @@ -365,7 +365,7 @@ int main() test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp index fc7ee98f9e34..898ab2a144c1 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_pointer_size.pass.cpp @@ -1308,7 +1308,7 @@ int main() test10(); test11(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp index cda4112257b0..e616ecc04261 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_size_char.pass.cpp @@ -364,7 +364,7 @@ int main() test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp index 59e4d5c28096..ea311dd1564f 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string.pass.cpp @@ -362,7 +362,7 @@ int main() test1(); test2(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp index f5ac2e8b6023..01f4a1f6ccef 100644 --- a/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp +++ b/test/std/strings/basic.string/string.modifiers/string_replace/size_size_string_size_size.pass.cpp @@ -5903,7 +5903,7 @@ int main() test54(); test55(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::basic_string, min_allocator> S; test0(); diff --git a/test/support/test_iterators.h b/test/support/test_iterators.h index e09fd834d215..d814879fa272 100644 --- a/test/support/test_iterators.h +++ b/test/support/test_iterators.h @@ -11,8 +11,11 @@ #define ITERATORS_H #include +#include #include +#include "test_macros.h" + #ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS #define DELETE_FUNCTION = delete #else @@ -324,6 +327,202 @@ inline Iter base(random_access_iterator i) { return i.base(); } template // everything else inline Iter base(Iter i) { return i; } +template +struct ThrowingIterator { + typedef std::bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef const T value_type; + typedef const T * pointer; + typedef const T & reference; + + enum ThrowingAction { TAIncrement, TADecrement, TADereference, TAAssignment, TAComparison }; + +// Constructors + ThrowingIterator () + : begin_(nullptr), end_(nullptr), current_(nullptr), action_(TADereference), index_(0) {} + ThrowingIterator (const T *first, const T *last, size_t index = 0, ThrowingAction action = TADereference) + : begin_(first), end_(last), current_(first), action_(action), index_(index) {} + ThrowingIterator (const ThrowingIterator &rhs) + : begin_(rhs.begin_), end_(rhs.end_), current_(rhs.current_), action_(rhs.action_), index_(rhs.index_) {} + ThrowingIterator & operator= (const ThrowingIterator &rhs) + { + if (action_ == TAAssignment) + { + if (index_ == 0) + throw std::runtime_error ("throw from iterator assignment"); + else + --index_; + } + begin_ = rhs.begin_; + end_ = rhs.end_; + current_ = rhs.current_; + action_ = rhs.action_; + index_ = rhs.index_; + return *this; + } + +// iterator operations + reference operator*() const + { + if (action_ == TADereference) + { + if (index_ == 0) + throw std::runtime_error ("throw from iterator dereference"); + else + --index_; + } + return *current_; + } + + ThrowingIterator & operator++() + { + if (action_ == TAIncrement) + { + if (index_ == 0) + throw std::runtime_error ("throw from iterator increment"); + else + --index_; + } + ++current_; + return *this; + } + + ThrowingIterator operator++(int) + { + ThrowingIterator temp = *this; + ++(*this); + return temp; + } + + ThrowingIterator & operator--() + { + if (action_ == TADecrement) + { + if (index_ == 0) + throw std::runtime_error ("throw from iterator decrement"); + else + --index_; + } + --current_; + return *this; + } + + ThrowingIterator operator--(int) { + ThrowingIterator temp = *this; + --(*this); + return temp; + } + + bool operator== (const ThrowingIterator &rhs) const + { + if (action_ == TAComparison) + { + if (index_ == 0) + throw std::runtime_error ("throw from iterator comparison"); + else + --index_; + } + bool atEndL = current_ == end_; + bool atEndR = rhs.current_ == rhs.end_; + if (atEndL != atEndR) return false; // one is at the end (or empty), the other is not. + if (atEndL) return true; // both are at the end (or empty) + return current_ == rhs.current_; + } + +private: + const T* begin_; + const T* end_; + const T* current_; + ThrowingAction action_; + mutable size_t index_; +}; + +template +bool operator== (const ThrowingIterator& a, const ThrowingIterator& b) +{ return a.operator==(b); } + +template +bool operator!= (const ThrowingIterator& a, const ThrowingIterator& b) +{ return !a.operator==(b); } + +template +struct NonThrowingIterator { + typedef std::bidirectional_iterator_tag iterator_category; + typedef ptrdiff_t difference_type; + typedef const T value_type; + typedef const T * pointer; + typedef const T & reference; + +// Constructors + NonThrowingIterator () + : begin_(nullptr), end_(nullptr), current_(nullptr) {} + NonThrowingIterator (const T *first, const T* last) + : begin_(first), end_(last), current_(first) {} + NonThrowingIterator (const NonThrowingIterator &rhs) + : begin_(rhs.begin_), end_(rhs.end_), current_(rhs.current_) {} + NonThrowingIterator & operator= (const NonThrowingIterator &rhs) TEST_NOEXCEPT + { + begin_ = rhs.begin_; + end_ = rhs.end_; + current_ = rhs.current_; + return *this; + } + +// iterator operations + reference operator*() const TEST_NOEXCEPT + { + return *current_; + } + + NonThrowingIterator & operator++() TEST_NOEXCEPT + { + ++current_; + return *this; + } + + NonThrowingIterator operator++(int) TEST_NOEXCEPT + { + NonThrowingIterator temp = *this; + ++(*this); + return temp; + } + + NonThrowingIterator & operator--() TEST_NOEXCEPT + { + --current_; + return *this; + } + + NonThrowingIterator operator--(int) TEST_NOEXCEPT + { + NonThrowingIterator temp = *this; + --(*this); + return temp; + } + + bool operator== (const NonThrowingIterator &rhs) const TEST_NOEXCEPT + { + bool atEndL = current_ == end_; + bool atEndR = rhs.current_ == rhs.end_; + if (atEndL != atEndR) return false; // one is at the end (or empty), the other is not. + if (atEndL) return true; // both are at the end (or empty) + return current_ == rhs.current_; + } + +private: + const T* begin_; + const T* end_; + const T* current_; +}; + +template +bool operator== (const NonThrowingIterator& a, const NonThrowingIterator& b) TEST_NOEXCEPT +{ return a.operator==(b); } + +template +bool operator!= (const NonThrowingIterator& a, const NonThrowingIterator& b) TEST_NOEXCEPT +{ return !a.operator==(b); } + #undef DELETE_FUNCTION #endif // ITERATORS_H From e0b666adaf915eaff59507f0fdcc4a120f68ce40 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Fri, 22 Jan 2016 21:18:04 +0000 Subject: [PATCH 5/8] Vendor import of libc++ release_38 branch r258549: https://llvm.org/svn/llvm-project/libcxx/branches/release_38@258549 --- src/include/atomic_support.h | 9 +++++++++ test/libcxx/compiler.py | 9 +++++++++ test/libcxx/test/config.py | 11 ++++++++++- test/libcxx/test/executor.py | 9 +++++++++ test/libcxx/test/format.py | 9 +++++++++ test/libcxx/test/target_info.py | 9 +++++++++ test/libcxx/test/tracing.py | 9 +++++++++ test/libcxx/util.py | 9 +++++++++ .../atomics.types.operations.req/atomic_helpers.h | 9 +++++++++ .../function.objects/func.require/invoke_helpers.h | 9 +++++++++ .../func.wrap/func.wrap.func/function_types.h | 9 +++++++++ test/support/any_helpers.h | 8 ++++++++ test/support/cmpxchg_loop.h | 9 +++++++++ test/support/count_new.hpp | 9 +++++++++ test/support/disable_missing_braces_warning.h | 8 ++++++++ test/support/nasty_macros.hpp | 8 ++++++++ test/support/tracked_value.h | 8 ++++++++ test/support/user_defined_integral.hpp | 8 ++++++++ utils/gen_link_script/gen_link_script.py | 9 +++++++++ utils/not/not.py | 9 +++++++++ utils/sym_check/sym_check/__init__.py | 9 +++++++++ utils/sym_check/sym_check/diff.py | 8 ++++++++ utils/sym_check/sym_check/extract.py | 8 ++++++++ utils/sym_check/sym_check/match.py | 8 ++++++++ utils/sym_check/sym_check/util.py | 9 +++++++++ utils/sym_check/sym_diff.py | 9 +++++++++ utils/sym_check/sym_extract.py | 8 ++++++++ utils/sym_check/sym_match.py | 9 +++++++++ 28 files changed, 244 insertions(+), 1 deletion(-) diff --git a/src/include/atomic_support.h b/src/include/atomic_support.h index dbf3b9c81ea4..8b719c5f2214 100644 --- a/src/include/atomic_support.h +++ b/src/include/atomic_support.h @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===//// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===//// + #ifndef ATOMIC_SUPPORT_H #define ATOMIC_SUPPORT_H diff --git a/test/libcxx/compiler.py b/test/libcxx/compiler.py index 4962038cbbed..7dfb13abbd41 100644 --- a/test/libcxx/compiler.py +++ b/test/libcxx/compiler.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import os import lit.util import libcxx.util diff --git a/test/libcxx/test/config.py b/test/libcxx/test/config.py index 5ab7fcb37401..f8096ad15f8a 100644 --- a/test/libcxx/test/config.py +++ b/test/libcxx/test/config.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import locale import os import platform @@ -606,7 +615,7 @@ def configure_substitutions(self): for k, v in self.env.items(): exec_env_str += ' %s=%s' % (k, v) # Configure run env substitution. - exec_str = '' + exec_str = exec_env_str if self.lit_config.useValgrind: exec_str = ' '.join(self.lit_config.valgrindArgs) + exec_env_str sub.append(('%exec', exec_str)) diff --git a/test/libcxx/test/executor.py b/test/libcxx/test/executor.py index f0356ceca784..ee4288fb0083 100644 --- a/test/libcxx/test/executor.py +++ b/test/libcxx/test/executor.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import os from libcxx.test import tracing diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py index 19c9fc742a49..ca934a4b395f 100644 --- a/test/libcxx/test/format.py +++ b/test/libcxx/test/format.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import errno import os import time diff --git a/test/libcxx/test/target_info.py b/test/libcxx/test/target_info.py index df216fcb21fa..7ca08bea193a 100644 --- a/test/libcxx/test/target_info.py +++ b/test/libcxx/test/target_info.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===// +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===// + import importlib import lit.util # pylint: disable=import-error,no-name-in-module import locale diff --git a/test/libcxx/test/tracing.py b/test/libcxx/test/tracing.py index 766fc192f9f5..c590ba3efd01 100644 --- a/test/libcxx/test/tracing.py +++ b/test/libcxx/test/tracing.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import os import inspect diff --git a/test/libcxx/util.py b/test/libcxx/util.py index 28f2619d69cb..8899ffaa4b26 100644 --- a/test/libcxx/util.py +++ b/test/libcxx/util.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + from contextlib import contextmanager import os import tempfile diff --git a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h index e31420b156c6..6cbc0c35c0f5 100644 --- a/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h +++ b/test/std/atomics/atomics.types.operations/atomics.types.operations.req/atomic_helpers.h @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #ifndef ATOMIC_HELPERS_H #define ATOMIC_HELPERS_H diff --git a/test/std/utilities/function.objects/func.require/invoke_helpers.h b/test/std/utilities/function.objects/func.require/invoke_helpers.h index 0583b624da31..a85b39f37175 100644 --- a/test/std/utilities/function.objects/func.require/invoke_helpers.h +++ b/test/std/utilities/function.objects/func.require/invoke_helpers.h @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #ifndef INVOKE_HELPERS_H #define INVOKE_HELPERS_H diff --git a/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h b/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h index 55eb80f43ffe..f1526544bcfe 100644 --- a/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h +++ b/test/std/utilities/function.objects/func.wrap/func.wrap.func/function_types.h @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #ifndef FUNCTION_TYPES_H #define FUNCTION_TYPES_H diff --git a/test/support/any_helpers.h b/test/support/any_helpers.h index 76b1922fb1f1..bb1ad175c1f2 100644 --- a/test/support/any_helpers.h +++ b/test/support/any_helpers.h @@ -1,3 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef ANY_HELPERS_H #define ANY_HELPERS_H diff --git a/test/support/cmpxchg_loop.h b/test/support/cmpxchg_loop.h index c39e3fb12f67..5bec51b63321 100644 --- a/test/support/cmpxchg_loop.h +++ b/test/support/cmpxchg_loop.h @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #include template diff --git a/test/support/count_new.hpp b/test/support/count_new.hpp index 57aca7def335..e8968a93de98 100644 --- a/test/support/count_new.hpp +++ b/test/support/count_new.hpp @@ -1,3 +1,12 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + #ifndef COUNT_NEW_HPP #define COUNT_NEW_HPP diff --git a/test/support/disable_missing_braces_warning.h b/test/support/disable_missing_braces_warning.h index 967a87ab3a2e..97fd8a89a51a 100644 --- a/test/support/disable_missing_braces_warning.h +++ b/test/support/disable_missing_braces_warning.h @@ -1,3 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef SUPPORT_DISABLE_MISSING_BRACES_WARNING_H #define SUPPORT_DISABLE_MISSING_BRACES_WARNING_H diff --git a/test/support/nasty_macros.hpp b/test/support/nasty_macros.hpp index 2738e47eac9f..074853ea0b8a 100644 --- a/test/support/nasty_macros.hpp +++ b/test/support/nasty_macros.hpp @@ -1,3 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef SUPPORT_NASTY_MACROS_HPP #define SUPPORT_NASTY_MACROS_HPP diff --git a/test/support/tracked_value.h b/test/support/tracked_value.h index b0869b23bdcb..14d96b88368e 100644 --- a/test/support/tracked_value.h +++ b/test/support/tracked_value.h @@ -1,3 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef SUPPORT_TRACKED_VALUE_H #define SUPPORT_TRACKED_VALUE_H diff --git a/test/support/user_defined_integral.hpp b/test/support/user_defined_integral.hpp index 3b0f7a19fcf4..383b65f72e3f 100644 --- a/test/support/user_defined_integral.hpp +++ b/test/support/user_defined_integral.hpp @@ -1,3 +1,11 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #ifndef SUPPORT_USER_DEFINED_INTEGRAL_HPP #define SUPPORT_USER_DEFINED_INTEGRAL_HPP diff --git a/utils/gen_link_script/gen_link_script.py b/utils/gen_link_script/gen_link_script.py index 5de18f9129c6..9f1f0b771fc1 100755 --- a/utils/gen_link_script/gen_link_script.py +++ b/utils/gen_link_script/gen_link_script.py @@ -1,4 +1,13 @@ #!/usr/bin/env python +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import os import sys diff --git a/utils/not/not.py b/utils/not/not.py index 96e4ea7eee18..d9ceb8515d03 100644 --- a/utils/not/not.py +++ b/utils/not/not.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + """not.py is a utility for inverting the return code of commands. It acts similar to llvm/utils/not. ex: python /path/to/not.py ' echo hello diff --git a/utils/sym_check/sym_check/__init__.py b/utils/sym_check/sym_check/__init__.py index 3c668036e47c..1aa2b450c12f 100644 --- a/utils/sym_check/sym_check/__init__.py +++ b/utils/sym_check/sym_check/__init__.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + """libcxx abi symbol checker""" __author__ = 'Eric Fiselier' diff --git a/utils/sym_check/sym_check/diff.py b/utils/sym_check/sym_check/diff.py index a16e54d34e01..6502a4819a47 100644 --- a/utils/sym_check/sym_check/diff.py +++ b/utils/sym_check/sym_check/diff.py @@ -1,4 +1,12 @@ # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## """ diff - A set of functions for diff-ing two symbol lists. """ diff --git a/utils/sym_check/sym_check/extract.py b/utils/sym_check/sym_check/extract.py index b4f4cee2dc55..7bafd8ec4c54 100644 --- a/utils/sym_check/sym_check/extract.py +++ b/utils/sym_check/sym_check/extract.py @@ -1,4 +1,12 @@ # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## """ extract - A set of function that extract symbol lists from shared libraries. """ diff --git a/utils/sym_check/sym_check/match.py b/utils/sym_check/sym_check/match.py index 9f496427e372..fae400e4e77e 100644 --- a/utils/sym_check/sym_check/match.py +++ b/utils/sym_check/sym_check/match.py @@ -1,4 +1,12 @@ # -*- Python -*- vim: set syntax=python tabstop=4 expandtab cc=80: +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## """ match - A set of functions for matching symbols in a list to a list of regexs """ diff --git a/utils/sym_check/sym_check/util.py b/utils/sym_check/sym_check/util.py index 1d3b424f6f30..6ae71b01080a 100644 --- a/utils/sym_check/sym_check/util.py +++ b/utils/sym_check/sym_check/util.py @@ -1,3 +1,12 @@ +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + import ast import distutils.spawn import signal diff --git a/utils/sym_check/sym_diff.py b/utils/sym_check/sym_diff.py index 054c6c18e3e3..69c340028c6b 100755 --- a/utils/sym_check/sym_diff.py +++ b/utils/sym_check/sym_diff.py @@ -1,7 +1,16 @@ #!/usr/bin/env python +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## """ sym_diff - Compare two symbol lists and output the differences. """ + from argparse import ArgumentParser import sys from sym_check import diff, util diff --git a/utils/sym_check/sym_extract.py b/utils/sym_check/sym_extract.py index 5d8953986b28..a0fbb3e6341a 100755 --- a/utils/sym_check/sym_extract.py +++ b/utils/sym_check/sym_extract.py @@ -1,4 +1,12 @@ #!/usr/bin/env python +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## """ sym_extract - Extract and output a list of symbols from a shared library. """ diff --git a/utils/sym_check/sym_match.py b/utils/sym_check/sym_match.py index c60b24629353..231bdc8b367a 100755 --- a/utils/sym_check/sym_match.py +++ b/utils/sym_check/sym_match.py @@ -1,4 +1,13 @@ #!/usr/bin/env python +#===----------------------------------------------------------------------===## +# +# The LLVM Compiler Infrastructure +# +# This file is dual licensed under the MIT and the University of Illinois Open +# Source Licenses. See LICENSE.TXT for details. +# +#===----------------------------------------------------------------------===## + """ sym_match - Match all symbols in a list against a list of regexes. """ From 2e583f3370eba07a025e17447f2fe5401ef7cd49 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Wed, 27 Jan 2016 21:10:55 +0000 Subject: [PATCH 6/8] Vendor import of libc++ release_38 branch r258968: https://llvm.org/svn/llvm-project/libcxx/branches/release_38@258968 --- .../file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp | 2 ++ .../file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp | 2 ++ .../input.output/iostream.format/ext.manip/get_time.pass.cpp | 2 ++ .../input.output/iostream.format/ext.manip/put_time.pass.cpp | 2 ++ .../ios.base/ios.base.callback/register_callback.pass.cpp | 2 ++ .../iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp | 2 ++ .../iostreams.base/ios/basic.ios.members/imbue.pass.cpp | 2 ++ .../stream.buffers/streambuf/streambuf.cons/copy.pass.cpp | 2 ++ .../stream.buffers/streambuf/streambuf.cons/default.pass.cpp | 2 ++ .../streambuf.protected/streambuf.assign/assign.pass.cpp | 2 ++ .../streambuf.protected/streambuf.assign/swap.pass.cpp | 2 ++ .../category.collate/locale.collate.byname/hash.pass.cpp | 2 ++ .../category.collate/locale.collate.byname/types.pass.cpp | 2 ++ .../category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/types.pass.cpp | 2 ++ .../localization/locales/locale/locale.cons/default.pass.cpp | 2 ++ .../locales/locale/locale.cons/locale_string_cat.pass.cpp | 3 ++- .../localization/locales/locale/locale.members/name.pass.cpp | 2 ++ .../localization/locales/locale/locale.operators/eq.pass.cpp | 2 ++ .../localization/locales/locale/locale.statics/global.pass.cpp | 2 ++ test/std/re/re.regex/re.regex.locale/imbue.pass.cpp | 2 ++ test/std/re/re.traits/default.pass.cpp | 2 ++ test/std/re/re.traits/getloc.pass.cpp | 2 ++ test/std/re/re.traits/imbue.pass.cpp | 2 ++ 24 files changed, 48 insertions(+), 1 deletion(-) diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp index 1da385698210..042fe03d416a 100644 --- a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp +++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/overflow.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // int_type overflow(int_type c = traits::eof()); diff --git a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp index e34bc844bd28..9ada23b45468 100644 --- a/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp +++ b/test/std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // int_type underflow(); diff --git a/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp b/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp index 17ff642dc46d..a8b82a62bb6b 100644 --- a/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp +++ b/test/std/input.output/iostream.format/ext.manip/get_time.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template T9 get_time(struct tm* tmb, const charT* fmt); diff --git a/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp b/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp index 52a98a1b5688..f4e3ded1745c 100644 --- a/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp +++ b/test/std/input.output/iostream.format/ext.manip/put_time.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template T10 put_time(const struct tm* tmb, const charT* fmt); diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp index c0ed3150457c..f4d541e2f527 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.base.callback/register_callback.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // class ios_base diff --git a/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp b/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp index 4e34c08ab083..1cad020b0ec0 100644 --- a/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp +++ b/test/std/input.output/iostreams.base/ios.base/ios.base.locales/imbue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // class ios_base diff --git a/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp b/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp index 6d4ce5f577f4..1c1c8be9542a 100644 --- a/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp +++ b/test/std/input.output/iostreams.base/ios/basic.ios.members/imbue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class basic_ios diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp index c1e18392b6ce..7ca8f37fae0e 100644 --- a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/copy.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template > diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp index d8ca8aebc62b..0572a9bbe290 100644 --- a/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.cons/default.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template > diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp index 803198938f6e..fc1a18fe31ec 100644 --- a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/assign.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template > diff --git a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp index 7a23206b42de..4ede8a514f96 100644 --- a/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp +++ b/test/std/input.output/stream.buffers/streambuf/streambuf.protected/streambuf.assign/swap.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template > diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp index f8641cb1eb6c..df67f432e329 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/hash.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class collate_byname diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp index 04974b244e4e..7c07c71d102c 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/types.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template diff --git a/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp index bc55f009e0a8..adaf4e8fb136 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.codecvt.byname/ctor_wchar_t.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template <> class codecvt_byname diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp index 03e8dfcef97f..fdfab5769043 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template diff --git a/test/std/localization/locales/locale/locale.cons/default.pass.cpp b/test/std/localization/locales/locale/locale.cons/default.pass.cpp index 1efc939f3c27..2bb3c9a8000c 100644 --- a/test/std/localization/locales/locale/locale.cons/default.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/default.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // locale() throw(); diff --git a/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp index d48a572a2afe..59fbc59b90da 100644 --- a/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp @@ -6,7 +6,8 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// - + +// REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 // UNSUPPORTED: sanitizer-new-delete diff --git a/test/std/localization/locales/locale/locale.members/name.pass.cpp b/test/std/localization/locales/locale/locale.members/name.pass.cpp index 9d9b1423f334..13ae27285b78 100644 --- a/test/std/localization/locales/locale/locale.members/name.pass.cpp +++ b/test/std/localization/locales/locale/locale.members/name.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // basic_string name() const; diff --git a/test/std/localization/locales/locale/locale.operators/eq.pass.cpp b/test/std/localization/locales/locale/locale.operators/eq.pass.cpp index ec118e07ff27..c809f49d2cd8 100644 --- a/test/std/localization/locales/locale/locale.operators/eq.pass.cpp +++ b/test/std/localization/locales/locale/locale.operators/eq.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // basic_string name() const; diff --git a/test/std/localization/locales/locale/locale.statics/global.pass.cpp b/test/std/localization/locales/locale/locale.statics/global.pass.cpp index 59a6bc6dd383..d4b115514fb7 100644 --- a/test/std/localization/locales/locale/locale.statics/global.pass.cpp +++ b/test/std/localization/locales/locale/locale.statics/global.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // static const locale& classic(); diff --git a/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp b/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp index be0b26dc5c2c..c7ad39414c65 100644 --- a/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp +++ b/test/std/re/re.regex/re.regex.locale/imbue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template > class basic_regex; diff --git a/test/std/re/re.traits/default.pass.cpp b/test/std/re/re.traits/default.pass.cpp index c9a97e025ac5..defadd95378b 100644 --- a/test/std/re/re.traits/default.pass.cpp +++ b/test/std/re/re.traits/default.pass.cpp @@ -8,6 +8,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template struct regex_traits; diff --git a/test/std/re/re.traits/getloc.pass.cpp b/test/std/re/re.traits/getloc.pass.cpp index 27ab6cd86545..0b7810a2099d 100644 --- a/test/std/re/re.traits/getloc.pass.cpp +++ b/test/std/re/re.traits/getloc.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template struct regex_traits; diff --git a/test/std/re/re.traits/imbue.pass.cpp b/test/std/re/re.traits/imbue.pass.cpp index 11eca41de37a..6988058a832c 100644 --- a/test/std/re/re.traits/imbue.pass.cpp +++ b/test/std/re/re.traits/imbue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template struct regex_traits; From 09a81ed06676bfa727cafe139f24ab2c076ecd04 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 13 Feb 2016 15:00:49 +0000 Subject: [PATCH 7/8] Vendor import of libc++ release_38 branch r260756: https://llvm.org/svn/llvm-project/libcxx/branches/release_38@260756 --- test/libcxx/test/format.py | 2 +- .../category.collate/locale.collate.byname/compare.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/tolower_1.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/tolower_many.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/toupper_1.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/toupper_many.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/widen_1.pass.cpp | 2 ++ .../category.ctype/locale.ctype.byname/widen_many.pass.cpp | 2 ++ 8 files changed, 15 insertions(+), 1 deletion(-) diff --git a/test/libcxx/test/format.py b/test/libcxx/test/format.py index ca934a4b395f..aaa9a1845ae4 100644 --- a/test/libcxx/test/format.py +++ b/test/libcxx/test/format.py @@ -161,7 +161,7 @@ def _evaluate_fail_test(self, test): 'expected-error', 'expected-no-diagnostics'] use_verify = self.use_verify_for_fail and \ any([tag in contents for tag in verify_tags]) - extra_flags = [] + extra_flags = ['-fsyntax-only'] if use_verify: extra_flags += ['-Xclang', '-verify', '-Xclang', '-verify-ignore-unexpected=note'] diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp index 69af9ac1b7bf..09009ceaaae2 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class collate_byname diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp index c2eeea820ba0..741f47f4380c 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_1.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class ctype_byname; diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp index b2577e323a2d..bf1cb64b22c0 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/tolower_many.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class ctype_byname; diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp index 8611293b84aa..3044ba1897fc 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_1.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class ctype_byname; diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp index d23a29273e2b..be6ba4c3e908 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/toupper_many.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class ctype_byname; diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp index 320e08db26e0..e5c49defa11f 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_1.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class ctype_byname; diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp index b46ae32237b7..c16974a2414a 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/widen_many.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// REQUIRES: locale.en_US.UTF-8 + // // template class ctype_byname; From bb5e33f003797b67974a8893f7f2930fc51b8210 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sun, 21 Feb 2016 13:53:59 +0000 Subject: [PATCH 8/8] Vendor import of libc++ release_38 branch r261369: https://llvm.org/svn/llvm-project/libcxx/branches/release_38@261369 --- include/regex | 16 ++++-- .../re.regex.construct/bad_escape.pass.cpp | 1 + .../re.results/re.results.form/form1.pass.cpp | 52 +++++++++++++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/include/regex b/include/regex index b9dac4765cdf..1139d8fb2a90 100644 --- a/include/regex +++ b/include/regex @@ -976,7 +976,12 @@ public: typedef locale locale_type; typedef ctype_base::mask char_class_type; +#if defined(__mips__) && defined(__GLIBC__) + static const char_class_type __regex_word = static_cast(_ISbit(15)); +#else static const char_class_type __regex_word = 0x80; +#endif + private: locale __loc_; const ctype* __ct_; @@ -4265,6 +4270,9 @@ basic_regex<_CharT, _Traits>::__parse_atom_escape(_ForwardIterator __first, if (__first != __last && *__first == '\\') { _ForwardIterator __t1 = _VSTD::next(__first); + if (__t1 == __last) + __throw_regex_error(); + _ForwardIterator __t2 = __parse_decimal_escape(__t1, __last); if (__t2 != __t1) __first = __t2; @@ -5384,8 +5392,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, if ('0' <= *__fmt_first && *__fmt_first <= '9') { size_t __i = *__fmt_first - '0'; - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { @@ -5436,8 +5444,8 @@ match_results<_BidirectionalIterator, _Allocator>::format(_OutputIter __out, ++__fmt_first; __i = 10 * __i + *__fmt_first - '0'; } - __out = _VSTD::copy(__matches_[__i].first, - __matches_[__i].second, __out); + __out = _VSTD::copy((*this)[__i].first, + (*this)[__i].second, __out); } else { diff --git a/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp b/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp index 4da4d957a88a..9459cd74ccff 100644 --- a/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp +++ b/test/std/re/re.regex/re.regex.construct/bad_escape.pass.cpp @@ -33,6 +33,7 @@ int main() { assert(error_escape_thrown("[\\a]")); assert(error_escape_thrown("\\a")); + assert(error_escape_thrown("\\")); assert(error_escape_thrown("[\\e]")); assert(error_escape_thrown("\\e")); diff --git a/test/std/re/re.results/re.results.form/form1.pass.cpp b/test/std/re/re.results/re.results.form/form1.pass.cpp index 9701c60ba77c..5b04c684fef1 100644 --- a/test/std/re/re.results/re.results.form/form1.pass.cpp +++ b/test/std/re/re.results/re.results.form/form1.pass.cpp @@ -35,6 +35,31 @@ int main() assert(r == out + 58); assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: efg, m[2]: e"); } + { + std::match_results m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cd((e)fg)hi", + std::regex_constants::nosubs))); + + char out[100] = {0}; + const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2"; + char* r = m.format(output_iterator(out), + fmt, fmt + std::char_traits::length(fmt)).base(); + assert(r == out + 54); + assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: , m[2]: "); + } + { + std::match_results m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cdefghi"))); + + char out[100] = {0}; + const char fmt[] = "prefix: $`, match: $&, suffix: $', m[1]: $1, m[2]: $2"; + char* r = m.format(output_iterator(out), + fmt, fmt + std::char_traits::length(fmt)).base(); + assert(r == out + 54); + assert(std::string(out) == "prefix: ab, match: cdefghi, suffix: jk, m[1]: , m[2]: "); + } { std::match_results m; const char s[] = "abcdefghijk"; @@ -61,6 +86,33 @@ int main() assert(r == out + 34); assert(std::string(out) == "match: cdefghi, m[1]: efg, m[2]: e"); } + { + std::match_results m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cd((e)fg)hi", + std::regex_constants::nosubs))); + + char out[100] = {0}; + const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2"; + char* r = m.format(output_iterator(out), + fmt, fmt + std::char_traits::length(fmt), + std::regex_constants::format_sed).base(); + assert(r == out + 30); + assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: "); + } + { + std::match_results m; + const char s[] = "abcdefghijk"; + assert(std::regex_search(s, m, std::regex("cdefghi"))); + + char out[100] = {0}; + const char fmt[] = "match: &, m[1]: \\1, m[2]: \\2"; + char* r = m.format(output_iterator(out), + fmt, fmt + std::char_traits::length(fmt), + std::regex_constants::format_sed).base(); + assert(r == out + 30); + assert(std::string(out) == "match: cdefghi, m[1]: , m[2]: "); + } { std::match_results m;